@@ -487,17 +487,6 @@ impl Config {
487
487
& get_toml,
488
488
) ;
489
489
490
- if cfg ! ( test) {
491
- // When configuring bootstrap for tests, make sure to set the rustc and Cargo to the
492
- // same ones used to call the tests (if custom ones are not defined in the toml). If we
493
- // don't do that, bootstrap will use its own detection logic to find a suitable rustc
494
- // and Cargo, which doesn't work when the caller is specìfying a custom local rustc or
495
- // Cargo in their bootstrap.toml.
496
- let build = toml. build . get_or_insert_with ( Default :: default) ;
497
- build. rustc = build. rustc . take ( ) . or ( std:: env:: var_os ( "RUSTC" ) . map ( |p| p. into ( ) ) ) ;
498
- build. cargo = build. cargo . take ( ) . or ( std:: env:: var_os ( "CARGO" ) . map ( |p| p. into ( ) ) ) ;
499
- }
500
-
501
490
// Now override TOML values with flags, to make sure that we won't later override flags with
502
491
// TOML values by accident instead, because flags have higher priority.
503
492
let Build {
@@ -507,7 +496,7 @@ impl Config {
507
496
target : build_target_toml,
508
497
build_dir : build_build_dir_toml,
509
498
cargo : build_cargo_toml,
510
- rustc : build_rustc_toml,
499
+ rustc : mut build_rustc_toml,
511
500
rustfmt : build_rustfmt_toml,
512
501
cargo_clippy : build_cargo_clippy_toml,
513
502
docs : build_docs_toml,
@@ -556,8 +545,20 @@ impl Config {
556
545
ccache : build_ccache_toml,
557
546
exclude : build_exclude_toml,
558
547
} = toml. build . unwrap_or_default ( ) ;
548
+
549
+ if cfg ! ( test) {
550
+ // When configuring bootstrap for tests, make sure to set the rustc and Cargo to the
551
+ // same ones used to call the tests (if custom ones are not defined in the toml). If we
552
+ // don't do that, bootstrap will use its own detection logic to find a suitable rustc
553
+ // and Cargo, which doesn't work when the caller is specìfying a custom local rustc or
554
+ // Cargo in their bootstrap.toml.
555
+ build_rustc_toml = build_rustc_toml. take ( ) . or ( std:: env:: var_os ( "RUSTC" ) . map ( |p| p. into ( ) ) ) ;
556
+ build_build_toml = build_build_toml. take ( ) . or ( std:: env:: var_os ( "CARGO" ) . map ( |p| p. into_string ( ) . unwrap ( ) ) ) ;
557
+ }
558
+
559
559
build_jobs_toml = flags_jobs. or ( build_jobs_toml) ;
560
560
build_build_toml = flags_build. or ( build_build_toml) ;
561
+
561
562
let build_dir = flags_build_dir. or ( build_build_dir_toml. map ( PathBuf :: from) ) ;
562
563
let host = if let Some ( TargetSelectionList ( hosts) ) = flags_host {
563
564
Some ( hosts)
0 commit comments