@@ -21,6 +21,7 @@ use crate::core::config::flags::{Color, Subcommand};
2121use crate :: core:: config:: { DryRun , SplitDebuginfo , TargetSelection } ;
2222use crate :: prepare_behaviour_dump_dir;
2323use crate :: utils:: cache:: Cache ;
24+ use crate :: utils:: exec:: BootstrapCommand ;
2425use crate :: utils:: helpers:: { self , add_dylib_path, add_link_lib_path, exe, linker_args} ;
2526use crate :: utils:: helpers:: { check_cfg_arg, libdir, linker_flags, output, t, LldThreads } ;
2627use crate :: EXTRA_CHECK_CFGS ;
@@ -2152,7 +2153,7 @@ impl<'a> Builder<'a> {
21522153 } ) ;
21532154
21542155 Cargo {
2155- command : cargo,
2156+ bootstrap_command : cargo. into ( ) ,
21562157 compiler,
21572158 target,
21582159 rustflags,
@@ -2382,7 +2383,7 @@ impl HostFlags {
23822383
23832384#[ derive( Debug ) ]
23842385pub struct Cargo {
2385- command : Command ,
2386+ bootstrap_command : BootstrapCommand ,
23862387 compiler : Compiler ,
23872388 target : TargetSelection ,
23882389 rustflags : Rustflags ,
@@ -2429,7 +2430,7 @@ impl Cargo {
24292430 }
24302431
24312432 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 ( ) ) ;
24332434 self
24342435 }
24352436
@@ -2448,16 +2449,16 @@ impl Cargo {
24482449 // These are managed through rustflag/rustdocflag interfaces.
24492450 assert_ne ! ( key. as_ref( ) , "RUSTFLAGS" ) ;
24502451 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 ( ) ) ;
24522453 self
24532454 }
24542455
24552456 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 ) ;
24572458 }
24582459
24592460 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) ;
24612462 self
24622463 }
24632464
@@ -2530,7 +2531,9 @@ impl Cargo {
25302531
25312532 if let Some ( target_linker) = builder. linker ( target) {
25322533 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) ;
25342537 }
25352538 // We want to set -Clinker using Cargo, therefore we only call `linker_flags` and not
25362539 // `linker_args` here.
@@ -2560,7 +2563,7 @@ impl Cargo {
25602563 // https://github.com/llvm/llvm-project/pull/81849. This is
25612564 // fixed in LLVM 19, but can't be backported.
25622565 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) ;
25642567 }
25652568 }
25662569 } else {
@@ -2582,22 +2585,26 @@ impl Cargo {
25822585 } ;
25832586 let triple_underscored = target. triple . replace ( '-' , "_" ) ;
25842587 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) ;
25862589
25872590 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) ;
25892594
25902595 if let Some ( ar) = builder. ar ( target) {
25912596 let ranlib = format ! ( "{} s" , ar. display( ) ) ;
2592- self . command
2597+ self . bootstrap_command
2598+ . inner_command
25932599 . env ( format ! ( "AR_{triple_underscored}" ) , ar)
25942600 . env ( format ! ( "RANLIB_{triple_underscored}" ) , ranlib) ;
25952601 }
25962602
25972603 if let Ok ( cxx) = builder. cxx ( target) {
25982604 let cxx = ccacheify ( & cxx) ;
25992605 let cxxflags = builder. cflags ( target, GitRepo :: Rustc , CLang :: Cxx ) . join ( " " ) ;
2600- self . command
2606+ self . bootstrap_command
2607+ . inner_command
26012608 . env ( format ! ( "CXX_{triple_underscored}" ) , & cxx)
26022609 . env ( format ! ( "CXXFLAGS_{triple_underscored}" ) , cxxflags) ;
26032610 }
@@ -2611,23 +2618,23 @@ impl From<Cargo> for Command {
26112618 fn from ( mut cargo : Cargo ) -> Command {
26122619 let rustflags = & cargo. rustflags . 0 ;
26132620 if !rustflags. is_empty ( ) {
2614- cargo. command . env ( "RUSTFLAGS" , rustflags) ;
2621+ cargo. bootstrap_command . inner_command . env ( "RUSTFLAGS" , rustflags) ;
26152622 }
26162623
26172624 let rustdocflags = & cargo. rustdocflags . 0 ;
26182625 if !rustdocflags. is_empty ( ) {
2619- cargo. command . env ( "RUSTDOCFLAGS" , rustdocflags) ;
2626+ cargo. bootstrap_command . inner_command . env ( "RUSTDOCFLAGS" , rustdocflags) ;
26202627 }
26212628
26222629 let encoded_hostflags = cargo. hostflags . encode ( ) ;
26232630 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) ;
26252632 }
26262633
26272634 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 ) ;
26292636 }
26302637
2631- cargo. command
2638+ cargo. bootstrap_command . inner_command
26322639 }
26332640}
0 commit comments