@@ -19,7 +19,7 @@ use serde_derive::Deserialize;
1919use tracing:: { instrument, span} ;
2020
2121use crate :: core:: build_steps:: gcc:: { Gcc , add_cg_gcc_cargo_flags} ;
22- use crate :: core:: build_steps:: tool:: { SourceType , copy_lld_artifacts} ;
22+ use crate :: core:: build_steps:: tool:: { RustcPrivateCompilers , SourceType , copy_lld_artifacts} ;
2323use crate :: core:: build_steps:: { dist, llvm} ;
2424use crate :: core:: builder;
2525use crate :: core:: builder:: {
@@ -1131,7 +1131,7 @@ impl Step for Rustc {
11311131 cargo. env ( "RUSTC_BOLT_LINK_FLAGS" , "1" ) ;
11321132 }
11331133
1134- let _guard = builder. msg_sysroot_tool (
1134+ let _guard = builder. msg_rustc_tool (
11351135 Kind :: Build ,
11361136 build_compiler. stage ,
11371137 format_args ! ( "compiler artifacts{}" , crate_description( & self . crates) ) ,
@@ -1544,9 +1544,8 @@ impl Step for RustcLink {
15441544
15451545#[ derive( Debug , Clone , PartialEq , Eq , Hash ) ]
15461546pub struct CodegenBackend {
1547- pub target : TargetSelection ,
1548- pub compiler : Compiler ,
1549- pub backend : CodegenBackendKind ,
1547+ compilers : RustcPrivateCompilers ,
1548+ backend : CodegenBackendKind ,
15501549}
15511550
15521551fn needs_codegen_config ( run : & RunConfig < ' _ > ) -> bool {
@@ -1610,8 +1609,11 @@ impl Step for CodegenBackend {
16101609 }
16111610
16121611 run. builder . ensure ( CodegenBackend {
1613- target : run. target ,
1614- compiler : run. builder . compiler ( run. builder . top_stage , run. build_triple ( ) ) ,
1612+ compilers : RustcPrivateCompilers :: new (
1613+ run. builder ,
1614+ run. builder . top_stage ,
1615+ run. target ,
1616+ ) ,
16151617 backend : backend. clone ( ) ,
16161618 } ) ;
16171619 }
@@ -1624,21 +1626,17 @@ impl Step for CodegenBackend {
16241626 name = "CodegenBackend::run" ,
16251627 skip_all,
16261628 fields(
1627- compiler = ?self . compiler,
1628- target = ?self . target,
1629- backend = ?self . target,
1629+ compilers = ?self . compilers,
1630+ backend = ?self . backend,
16301631 ) ,
16311632 ) ,
16321633 ) ]
16331634 fn run ( self , builder : & Builder < ' _ > ) {
1634- let compiler = self . compiler ;
1635- let target = self . target ;
16361635 let backend = self . backend ;
1636+ let target = self . compilers . target ( ) ;
1637+ let build_compiler = self . compilers . build_compiler ( ) ;
16371638
1638- // FIXME: migrate to RustcPrivateCompilers
1639- builder. ensure ( Rustc :: new ( compiler, target) ) ;
1640-
1641- if builder. config . keep_stage . contains ( & compiler. stage ) {
1639+ if builder. config . keep_stage . contains ( & build_compiler. stage ) {
16421640 trace ! ( "`keep-stage` requested" ) ;
16431641 builder. info (
16441642 "WARNING: Using a potentially old codegen backend. \
@@ -1649,17 +1647,11 @@ impl Step for CodegenBackend {
16491647 return ;
16501648 }
16511649
1652- let compiler_to_use = builder. compiler_for ( compiler. stage , compiler. host , target) ;
1653- if compiler_to_use != compiler {
1654- builder. ensure ( CodegenBackend { compiler : compiler_to_use, target, backend } ) ;
1655- return ;
1656- }
1657-
1658- let out_dir = builder. cargo_out ( compiler, Mode :: Codegen , target) ;
1650+ let out_dir = builder. cargo_out ( build_compiler, Mode :: Codegen , target) ;
16591651
16601652 let mut cargo = builder:: Cargo :: new (
16611653 builder,
1662- compiler ,
1654+ build_compiler ,
16631655 Mode :: Codegen ,
16641656 SourceType :: InTree ,
16651657 target,
@@ -1680,8 +1672,13 @@ impl Step for CodegenBackend {
16801672
16811673 let tmp_stamp = BuildStamp :: new ( & out_dir) . with_prefix ( "tmp" ) ;
16821674
1683- let _guard =
1684- builder. msg_build ( compiler, format_args ! ( "codegen backend {}" , backend. name( ) ) , target) ;
1675+ let _guard = builder. msg_rustc_tool (
1676+ Kind :: Build ,
1677+ build_compiler. stage ,
1678+ format_args ! ( "codegen backend {}" , backend. name( ) ) ,
1679+ build_compiler. host ,
1680+ target,
1681+ ) ;
16851682 let files = run_cargo ( builder, cargo, vec ! [ ] , & tmp_stamp, vec ! [ ] , false , false ) ;
16861683 if builder. config . dry_run ( ) {
16871684 return ;
@@ -1701,15 +1698,15 @@ impl Step for CodegenBackend {
17011698 f. display( )
17021699 ) ;
17031700 }
1704- let stamp = build_stamp:: codegen_backend_stamp ( builder, compiler , target, & backend) ;
1701+ let stamp = build_stamp:: codegen_backend_stamp ( builder, build_compiler , target, & backend) ;
17051702 let codegen_backend = codegen_backend. to_str ( ) . unwrap ( ) ;
17061703 t ! ( stamp. add_stamp( codegen_backend) . write( ) ) ;
17071704 }
17081705
17091706 fn metadata ( & self ) -> Option < StepMetadata > {
17101707 Some (
1711- StepMetadata :: build ( & format ! ( "rustc_codegen_{}" , self . backend) , self . target )
1712- . built_by ( self . compiler ) ,
1708+ StepMetadata :: build ( & self . backend . crate_name ( ) , self . compilers . target ( ) )
1709+ . built_by ( self . compilers . build_compiler ( ) ) ,
17131710 )
17141711 }
17151712}
@@ -2198,8 +2195,10 @@ impl Step for Assemble {
21982195 continue ;
21992196 }
22002197 builder. ensure ( CodegenBackend {
2201- compiler : build_compiler,
2202- target : target_compiler. host ,
2198+ compilers : RustcPrivateCompilers :: from_build_and_link_compiler (
2199+ build_compiler,
2200+ target_compiler,
2201+ ) ,
22032202 backend : backend. clone ( ) ,
22042203 } ) ;
22052204 }
0 commit comments