@@ -1541,6 +1541,8 @@ impl Step for RustcLink {
15411541 }
15421542}
15431543
1544+ pub const RUSTC_CODEGEN_GCC : & str = "rustc_codegen_gcc" ;
1545+
15441546#[ derive( Debug , Clone , PartialEq , Eq , Hash ) ]
15451547pub struct GccCodegenBackend {
15461548 compilers : RustcPrivateCompilers ,
@@ -1551,7 +1553,7 @@ impl Step for GccCodegenBackend {
15511553 const ONLY_HOSTS : bool = true ;
15521554
15531555 fn should_run ( run : ShouldRun < ' _ > ) -> ShouldRun < ' _ > {
1554- run. alias ( "rustc_codegen_gcc" ) . alias ( "cg_gcc" )
1556+ run. alias ( RUSTC_CODEGEN_GCC ) . alias ( "cg_gcc" )
15551557 }
15561558
15571559 fn make_run ( run : RunConfig < ' _ > ) {
@@ -1610,7 +1612,7 @@ impl Step for GccCodegenBackend {
16101612 let _guard = builder. msg_rustc_tool (
16111613 Kind :: Build ,
16121614 build_compiler. stage ,
1613- format_args ! ( "codegen backend gcc" ) ,
1615+ "codegen backend gcc" ,
16141616 build_compiler. host ,
16151617 target,
16161618 ) ;
@@ -1620,12 +1622,14 @@ impl Step for GccCodegenBackend {
16201622
16211623 fn metadata ( & self ) -> Option < StepMetadata > {
16221624 Some (
1623- StepMetadata :: build ( "rustc_codegen_gcc" , self . compilers . target ( ) )
1625+ StepMetadata :: build ( RUSTC_CODEGEN_GCC , self . compilers . target ( ) )
16241626 . built_by ( self . compilers . build_compiler ( ) ) ,
16251627 )
16261628 }
16271629}
16281630
1631+ pub const RUSTC_CODEGEN_CRANELIFT : & str = "rustc_codegen_cranelift" ;
1632+
16291633#[ derive( Debug , Clone , PartialEq , Eq , Hash ) ]
16301634pub struct CraneliftCodegenBackend {
16311635 pub compilers : RustcPrivateCompilers ,
@@ -1636,7 +1640,7 @@ impl Step for CraneliftCodegenBackend {
16361640 const ONLY_HOSTS : bool = true ;
16371641
16381642 fn should_run ( run : ShouldRun < ' _ > ) -> ShouldRun < ' _ > {
1639- run. alias ( "rustc_codegen_cranelift" ) . alias ( "cg_clif" )
1643+ run. alias ( RUSTC_CODEGEN_CRANELIFT ) . alias ( "cg_clif" )
16401644 }
16411645
16421646 fn make_run ( run : RunConfig < ' _ > ) {
@@ -1688,13 +1692,13 @@ impl Step for CraneliftCodegenBackend {
16881692 ) ;
16891693 cargo
16901694 . arg ( "--manifest-path" )
1691- . arg ( builder. src . join ( "compiler/rustc_codegen_cranelift /Cargo.toml" ) ) ;
1695+ . arg ( builder. src . join ( format ! ( "compiler/{RUSTC_CODEGEN_CRANELIFT} /Cargo.toml" ) ) ) ;
16921696 rustc_cargo_env ( builder, & mut cargo, target) ;
16931697
16941698 let _guard = builder. msg_rustc_tool (
16951699 Kind :: Build ,
16961700 build_compiler. stage ,
1697- format_args ! ( "codegen backend cranelift" ) ,
1701+ "codegen backend cranelift" ,
16981702 build_compiler. host ,
16991703 target,
17001704 ) ;
@@ -1704,7 +1708,7 @@ impl Step for CraneliftCodegenBackend {
17041708
17051709 fn metadata ( & self ) -> Option < StepMetadata > {
17061710 Some (
1707- StepMetadata :: build ( "rustc_codegen_cranelift" , self . compilers . target ( ) )
1711+ StepMetadata :: build ( RUSTC_CODEGEN_CRANELIFT , self . compilers . target ( ) )
17081712 . built_by ( self . compilers . build_compiler ( ) ) ,
17091713 )
17101714 }
@@ -1716,32 +1720,28 @@ fn write_codegen_backend_stamp(
17161720 files : Vec < PathBuf > ,
17171721 dry_run : bool ,
17181722) -> BuildStamp {
1719- if !dry_run {
1720- let mut files = files. into_iter ( ) . filter ( |f| {
1721- let filename = f. file_name ( ) . unwrap ( ) . to_str ( ) . unwrap ( ) ;
1722- is_dylib ( f) && filename. contains ( "rustc_codegen_" )
1723- } ) ;
1724- let codegen_backend = match files. next ( ) {
1725- Some ( f) => f,
1726- None => panic ! ( "no dylibs built for codegen backend?" ) ,
1727- } ;
1728- if let Some ( f) = files. next ( ) {
1729- panic ! (
1730- "codegen backend built two dylibs:\n {}\n {}" ,
1731- codegen_backend. display( ) ,
1732- f. display( )
1733- ) ;
1734- }
1723+ if dry_run {
1724+ return stamp;
1725+ }
17351726
1736- let codegen_backend = codegen_backend. to_str ( ) . unwrap ( ) ;
1737- stamp = stamp. add_stamp ( codegen_backend) ;
1738- t ! ( stamp. write( ) ) ;
1727+ let mut files = files. into_iter ( ) . filter ( |f| {
1728+ let filename = f. file_name ( ) . unwrap ( ) . to_str ( ) . unwrap ( ) ;
1729+ is_dylib ( f) && filename. contains ( "rustc_codegen_" )
1730+ } ) ;
1731+ let codegen_backend = match files. next ( ) {
1732+ Some ( f) => f,
1733+ None => panic ! ( "no dylibs built for codegen backend?" ) ,
1734+ } ;
1735+ if let Some ( f) = files. next ( ) {
1736+ panic ! ( "codegen backend built two dylibs:\n {}\n {}" , codegen_backend. display( ) , f. display( ) ) ;
17391737 }
1738+
1739+ let codegen_backend = codegen_backend. to_str ( ) . unwrap ( ) ;
1740+ stamp = stamp. add_stamp ( codegen_backend) ;
1741+ t ! ( stamp. write( ) ) ;
17401742 stamp
17411743}
17421744
1743- pub ( crate ) const CODEGEN_BACKEND_PREFIX : & str = "rustc_codegen_" ;
1744-
17451745/// Creates the `codegen-backends` folder for a compiler that's about to be
17461746/// assembled as a complete compiler.
17471747///
0 commit comments