@@ -21,6 +21,7 @@ use crate::core::config::flags::{Color, Subcommand};
21
21
use crate :: core:: config:: { DryRun , SplitDebuginfo , TargetSelection } ;
22
22
use crate :: prepare_behaviour_dump_dir;
23
23
use crate :: utils:: cache:: Cache ;
24
+ use crate :: utils:: exec:: BootstrapCommand ;
24
25
use crate :: utils:: helpers:: { self , add_dylib_path, add_link_lib_path, exe, linker_args} ;
25
26
use crate :: utils:: helpers:: { check_cfg_arg, libdir, linker_flags, output, t, LldThreads } ;
26
27
use crate :: EXTRA_CHECK_CFGS ;
@@ -2152,7 +2153,7 @@ impl<'a> Builder<'a> {
2152
2153
} ) ;
2153
2154
2154
2155
Cargo {
2155
- command : cargo,
2156
+ bootstrap_command : cargo. into ( ) ,
2156
2157
compiler,
2157
2158
target,
2158
2159
rustflags,
@@ -2382,7 +2383,7 @@ impl HostFlags {
2382
2383
2383
2384
#[ derive( Debug ) ]
2384
2385
pub struct Cargo {
2385
- command : Command ,
2386
+ bootstrap_command : BootstrapCommand ,
2386
2387
compiler : Compiler ,
2387
2388
target : TargetSelection ,
2388
2389
rustflags : Rustflags ,
@@ -2429,7 +2430,7 @@ impl Cargo {
2429
2430
}
2430
2431
2431
2432
pub fn arg ( & mut self , arg : impl AsRef < OsStr > ) -> & mut Cargo {
2432
- self . command . arg ( arg. as_ref ( ) ) ;
2433
+ self . bootstrap_command . inner_command . arg ( arg. as_ref ( ) ) ;
2433
2434
self
2434
2435
}
2435
2436
@@ -2448,16 +2449,16 @@ impl Cargo {
2448
2449
// These are managed through rustflag/rustdocflag interfaces.
2449
2450
assert_ne ! ( key. as_ref( ) , "RUSTFLAGS" ) ;
2450
2451
assert_ne ! ( key. as_ref( ) , "RUSTDOCFLAGS" ) ;
2451
- self . command . env ( key. as_ref ( ) , value. as_ref ( ) ) ;
2452
+ self . bootstrap_command . inner_command . env ( key. as_ref ( ) , value. as_ref ( ) ) ;
2452
2453
self
2453
2454
}
2454
2455
2455
2456
pub fn add_rustc_lib_path ( & mut self , builder : & Builder < ' _ > ) {
2456
- builder. add_rustc_lib_path ( self . compiler , & mut self . command ) ;
2457
+ builder. add_rustc_lib_path ( self . compiler , & mut self . bootstrap_command . inner_command ) ;
2457
2458
}
2458
2459
2459
2460
pub fn current_dir ( & mut self , dir : & Path ) -> & mut Cargo {
2460
- self . command . current_dir ( dir) ;
2461
+ self . bootstrap_command . inner_command . current_dir ( dir) ;
2461
2462
self
2462
2463
}
2463
2464
@@ -2530,7 +2531,9 @@ impl Cargo {
2530
2531
2531
2532
if let Some ( target_linker) = builder. linker ( target) {
2532
2533
let target = crate :: envify ( & target. triple ) ;
2533
- self . command . env ( & format ! ( "CARGO_TARGET_{target}_LINKER" ) , target_linker) ;
2534
+ self . bootstrap_command
2535
+ . inner_command
2536
+ . env ( & format ! ( "CARGO_TARGET_{target}_LINKER" ) , target_linker) ;
2534
2537
}
2535
2538
// We want to set -Clinker using Cargo, therefore we only call `linker_flags` and not
2536
2539
// `linker_args` here.
@@ -2560,7 +2563,7 @@ impl Cargo {
2560
2563
// https://github.com/llvm/llvm-project/pull/81849. This is
2561
2564
// fixed in LLVM 19, but can't be backported.
2562
2565
if !target. starts_with ( "aarch64" ) && !target. starts_with ( "arm64ec" ) {
2563
- self . command . env ( "CC" , cl) . env ( "CXX" , cl) ;
2566
+ self . bootstrap_command . inner_command . env ( "CC" , cl) . env ( "CXX" , cl) ;
2564
2567
}
2565
2568
}
2566
2569
} else {
@@ -2582,22 +2585,26 @@ impl Cargo {
2582
2585
} ;
2583
2586
let triple_underscored = target. triple . replace ( '-' , "_" ) ;
2584
2587
let cc = ccacheify ( & builder. cc ( target) ) ;
2585
- self . command . env ( format ! ( "CC_{triple_underscored}" ) , & cc) ;
2588
+ self . bootstrap_command . inner_command . env ( format ! ( "CC_{triple_underscored}" ) , & cc) ;
2586
2589
2587
2590
let cflags = builder. cflags ( target, GitRepo :: Rustc , CLang :: C ) . join ( " " ) ;
2588
- self . command . env ( format ! ( "CFLAGS_{triple_underscored}" ) , & cflags) ;
2591
+ self . bootstrap_command
2592
+ . inner_command
2593
+ . env ( format ! ( "CFLAGS_{triple_underscored}" ) , & cflags) ;
2589
2594
2590
2595
if let Some ( ar) = builder. ar ( target) {
2591
2596
let ranlib = format ! ( "{} s" , ar. display( ) ) ;
2592
- self . command
2597
+ self . bootstrap_command
2598
+ . inner_command
2593
2599
. env ( format ! ( "AR_{triple_underscored}" ) , ar)
2594
2600
. env ( format ! ( "RANLIB_{triple_underscored}" ) , ranlib) ;
2595
2601
}
2596
2602
2597
2603
if let Ok ( cxx) = builder. cxx ( target) {
2598
2604
let cxx = ccacheify ( & cxx) ;
2599
2605
let cxxflags = builder. cflags ( target, GitRepo :: Rustc , CLang :: Cxx ) . join ( " " ) ;
2600
- self . command
2606
+ self . bootstrap_command
2607
+ . inner_command
2601
2608
. env ( format ! ( "CXX_{triple_underscored}" ) , & cxx)
2602
2609
. env ( format ! ( "CXXFLAGS_{triple_underscored}" ) , cxxflags) ;
2603
2610
}
@@ -2611,23 +2618,23 @@ impl From<Cargo> for Command {
2611
2618
fn from ( mut cargo : Cargo ) -> Command {
2612
2619
let rustflags = & cargo. rustflags . 0 ;
2613
2620
if !rustflags. is_empty ( ) {
2614
- cargo. command . env ( "RUSTFLAGS" , rustflags) ;
2621
+ cargo. bootstrap_command . inner_command . env ( "RUSTFLAGS" , rustflags) ;
2615
2622
}
2616
2623
2617
2624
let rustdocflags = & cargo. rustdocflags . 0 ;
2618
2625
if !rustdocflags. is_empty ( ) {
2619
- cargo. command . env ( "RUSTDOCFLAGS" , rustdocflags) ;
2626
+ cargo. bootstrap_command . inner_command . env ( "RUSTDOCFLAGS" , rustdocflags) ;
2620
2627
}
2621
2628
2622
2629
let encoded_hostflags = cargo. hostflags . encode ( ) ;
2623
2630
if !encoded_hostflags. is_empty ( ) {
2624
- cargo. command . env ( "RUSTC_HOST_FLAGS" , encoded_hostflags) ;
2631
+ cargo. bootstrap_command . inner_command . env ( "RUSTC_HOST_FLAGS" , encoded_hostflags) ;
2625
2632
}
2626
2633
2627
2634
if !cargo. allow_features . is_empty ( ) {
2628
- cargo. command . env ( "RUSTC_ALLOW_FEATURES" , cargo. allow_features ) ;
2635
+ cargo. bootstrap_command . inner_command . env ( "RUSTC_ALLOW_FEATURES" , cargo. allow_features ) ;
2629
2636
}
2630
2637
2631
- cargo. command
2638
+ cargo. bootstrap_command . inner_command
2632
2639
}
2633
2640
}
0 commit comments