@@ -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:: {
@@ -1133,7 +1133,7 @@ impl Step for Rustc {
11331133 cargo. env ( "RUSTC_BOLT_LINK_FLAGS" , "1" ) ;
11341134 }
11351135
1136- let _guard = builder. msg_sysroot_tool (
1136+ let _guard = builder. msg_rustc_tool (
11371137 Kind :: Build ,
11381138 build_compiler. stage ,
11391139 format_args ! ( "compiler artifacts{}" , crate_description( & self . crates) ) ,
@@ -1546,9 +1546,8 @@ impl Step for RustcLink {
15461546
15471547#[ derive( Debug , Clone , PartialEq , Eq , Hash ) ]
15481548pub struct CodegenBackend {
1549- pub target : TargetSelection ,
1550- pub compiler : Compiler ,
1551- pub backend : String ,
1549+ compilers : RustcPrivateCompilers ,
1550+ backend : String ,
15521551}
15531552
15541553fn needs_codegen_config ( run : & RunConfig < ' _ > ) -> bool {
@@ -1612,8 +1611,11 @@ impl Step for CodegenBackend {
16121611 }
16131612
16141613 run. builder . ensure ( CodegenBackend {
1615- target : run. target ,
1616- compiler : run. builder . compiler ( run. builder . top_stage , run. build_triple ( ) ) ,
1614+ compilers : RustcPrivateCompilers :: new (
1615+ run. builder ,
1616+ run. builder . top_stage ,
1617+ run. target ,
1618+ ) ,
16171619 backend : backend. clone ( ) ,
16181620 } ) ;
16191621 }
@@ -1626,21 +1628,17 @@ impl Step for CodegenBackend {
16261628 name = "CodegenBackend::run" ,
16271629 skip_all,
16281630 fields(
1629- compiler = ?self . compiler,
1630- target = ?self . target,
1631- backend = ?self . target,
1631+ compilers = ?self . compilers,
1632+ backend = ?self . backend,
16321633 ) ,
16331634 ) ,
16341635 ) ]
16351636 fn run ( self , builder : & Builder < ' _ > ) {
1636- let compiler = self . compiler ;
1637- let target = self . target ;
16381637 let backend = self . backend ;
1638+ let target = self . compilers . target ( ) ;
1639+ let build_compiler = self . compilers . build_compiler ( ) ;
16391640
1640- // FIXME: migrate to RustcPrivateCompilers
1641- builder. ensure ( Rustc :: new ( compiler, target) ) ;
1642-
1643- if builder. config . keep_stage . contains ( & compiler. stage ) {
1641+ if builder. config . keep_stage . contains ( & build_compiler. stage ) {
16441642 trace ! ( "`keep-stage` requested" ) ;
16451643 builder. info (
16461644 "WARNING: Using a potentially old codegen backend. \
@@ -1651,17 +1649,11 @@ impl Step for CodegenBackend {
16511649 return ;
16521650 }
16531651
1654- let compiler_to_use = builder. compiler_for ( compiler. stage , compiler. host , target) ;
1655- if compiler_to_use != compiler {
1656- builder. ensure ( CodegenBackend { compiler : compiler_to_use, target, backend } ) ;
1657- return ;
1658- }
1659-
1660- let out_dir = builder. cargo_out ( compiler, Mode :: Codegen , target) ;
1652+ let out_dir = builder. cargo_out ( build_compiler, Mode :: Codegen , target) ;
16611653
16621654 let mut cargo = builder:: Cargo :: new (
16631655 builder,
1664- compiler ,
1656+ build_compiler ,
16651657 Mode :: Codegen ,
16661658 SourceType :: InTree ,
16671659 target,
@@ -1682,7 +1674,13 @@ impl Step for CodegenBackend {
16821674
16831675 let tmp_stamp = BuildStamp :: new ( & out_dir) . with_prefix ( "tmp" ) ;
16841676
1685- let _guard = builder. msg_build ( compiler, format_args ! ( "codegen backend {backend}" ) , target) ;
1677+ let _guard = builder. msg_rustc_tool (
1678+ Kind :: Build ,
1679+ build_compiler. stage ,
1680+ format_args ! ( "codegen backend {backend}" ) ,
1681+ build_compiler. host ,
1682+ target,
1683+ ) ;
16861684 let files = run_cargo ( builder, cargo, vec ! [ ] , & tmp_stamp, vec ! [ ] , false , false ) ;
16871685 if builder. config . dry_run ( ) {
16881686 return ;
@@ -1702,15 +1700,18 @@ impl Step for CodegenBackend {
17021700 f. display( )
17031701 ) ;
17041702 }
1705- let stamp = build_stamp:: codegen_backend_stamp ( builder, compiler , target, & backend) ;
1703+ let stamp = build_stamp:: codegen_backend_stamp ( builder, build_compiler , target, & backend) ;
17061704 let codegen_backend = codegen_backend. to_str ( ) . unwrap ( ) ;
17071705 t ! ( stamp. add_stamp( codegen_backend) . write( ) ) ;
17081706 }
17091707
17101708 fn metadata ( & self ) -> Option < StepMetadata > {
17111709 Some (
1712- StepMetadata :: build ( & format ! ( "rustc_codegen_{}" , self . backend) , self . target )
1713- . built_by ( self . compiler ) ,
1710+ StepMetadata :: build (
1711+ & format ! ( "rustc_codegen_{}" , self . backend) ,
1712+ self . compilers . target ( ) ,
1713+ )
1714+ . built_by ( self . compilers . build_compiler ( ) ) ,
17141715 )
17151716 }
17161717}
@@ -2199,8 +2200,10 @@ impl Step for Assemble {
21992200 continue ;
22002201 }
22012202 builder. ensure ( CodegenBackend {
2202- compiler : build_compiler,
2203- target : target_compiler. host ,
2203+ compilers : RustcPrivateCompilers :: from_build_and_link_compiler (
2204+ build_compiler,
2205+ target_compiler,
2206+ ) ,
22042207 backend : backend. clone ( ) ,
22052208 } ) ;
22062209 }
0 commit comments