@@ -33,7 +33,10 @@ use crate::utils::exec::command;
3333use crate :: utils:: helpers:: {
3434 exe, get_clang_cl_resource_dir, is_debug_info, is_dylib, symlink_dir, t, up_to_date,
3535} ;
36- use crate :: { CLang , Compiler , DependencyType , FileType , GitRepo , LLVM_TOOLS , Mode , debug, trace} ;
36+ use crate :: {
37+ CLang , CodegenBackendKind , Compiler , DependencyType , FileType , GitRepo , LLVM_TOOLS , Mode ,
38+ debug, trace,
39+ } ;
3740
3841/// Build a standard library for the given `target` using the given `compiler`.
3942#[ derive( Debug , Clone , PartialEq , Eq , PartialOrd , Ord , Hash ) ]
@@ -1330,7 +1333,7 @@ pub fn rustc_cargo_env(builder: &Builder<'_>, cargo: &mut Cargo, target: TargetS
13301333 }
13311334
13321335 if let Some ( backend) = builder. config . default_codegen_backend ( target) {
1333- cargo. env ( "CFG_DEFAULT_CODEGEN_BACKEND" , backend) ;
1336+ cargo. env ( "CFG_DEFAULT_CODEGEN_BACKEND" , backend. name ( ) ) ;
13341337 }
13351338
13361339 let libdir_relative = builder. config . libdir_relative ( ) . unwrap_or_else ( || Path :: new ( "lib" ) ) ;
@@ -1543,7 +1546,7 @@ impl Step for RustcLink {
15431546pub struct CodegenBackend {
15441547 pub target : TargetSelection ,
15451548 pub compiler : Compiler ,
1546- pub backend : String ,
1549+ pub backend : CodegenBackendKind ,
15471550}
15481551
15491552fn needs_codegen_config ( run : & RunConfig < ' _ > ) -> bool {
@@ -1568,7 +1571,7 @@ fn is_codegen_cfg_needed(path: &TaskPath, run: &RunConfig<'_>) -> bool {
15681571 if path. contains ( CODEGEN_BACKEND_PREFIX ) {
15691572 let mut needs_codegen_backend_config = true ;
15701573 for backend in run. builder . config . codegen_backends ( run. target ) {
1571- if path. ends_with ( & ( CODEGEN_BACKEND_PREFIX . to_owned ( ) + backend) ) {
1574+ if path. ends_with ( & ( CODEGEN_BACKEND_PREFIX . to_owned ( ) + backend. name ( ) ) ) {
15721575 needs_codegen_backend_config = false ;
15731576 }
15741577 }
@@ -1602,7 +1605,7 @@ impl Step for CodegenBackend {
16021605 }
16031606
16041607 for backend in run. builder . config . codegen_backends ( run. target ) {
1605- if backend == "llvm" {
1608+ if backend. is_llvm ( ) {
16061609 continue ; // Already built as part of rustc
16071610 }
16081611
@@ -1663,20 +1666,21 @@ impl Step for CodegenBackend {
16631666 ) ;
16641667 cargo
16651668 . arg ( "--manifest-path" )
1666- . arg ( builder. src . join ( format ! ( "compiler/rustc_codegen_{backend }/Cargo.toml" ) ) ) ;
1669+ . arg ( builder. src . join ( format ! ( "compiler/{ }/Cargo.toml" , backend . crate_name ( ) ) ) ) ;
16671670 rustc_cargo_env ( builder, & mut cargo, target) ;
16681671
16691672 // Ideally, we'd have a separate step for the individual codegen backends,
16701673 // like we have in tests (test::CodegenGCC) but that would require a lot of restructuring.
16711674 // If the logic gets more complicated, it should probably be done.
1672- if backend == "gcc" {
1675+ if backend. is_gcc ( ) {
16731676 let gcc = builder. ensure ( Gcc { target } ) ;
16741677 add_cg_gcc_cargo_flags ( & mut cargo, & gcc) ;
16751678 }
16761679
16771680 let tmp_stamp = BuildStamp :: new ( & out_dir) . with_prefix ( "tmp" ) ;
16781681
1679- let _guard = builder. msg_build ( compiler, format_args ! ( "codegen backend {backend}" ) , target) ;
1682+ let _guard =
1683+ builder. msg_build ( compiler, format_args ! ( "codegen backend {}" , backend. name( ) ) , target) ;
16801684 let files = run_cargo ( builder, cargo, vec ! [ ] , & tmp_stamp, vec ! [ ] , false , false ) ;
16811685 if builder. config . dry_run ( ) {
16821686 return ;
@@ -1731,7 +1735,7 @@ fn copy_codegen_backends_to_sysroot(
17311735 }
17321736
17331737 for backend in builder. config . codegen_backends ( target) {
1734- if backend == "llvm" {
1738+ if backend. is_llvm ( ) {
17351739 continue ; // Already built as part of rustc
17361740 }
17371741
@@ -2161,7 +2165,7 @@ impl Step for Assemble {
21612165 let _codegen_backend_span =
21622166 span ! ( tracing:: Level :: DEBUG , "building requested codegen backends" ) . entered ( ) ;
21632167 for backend in builder. config . codegen_backends ( target_compiler. host ) {
2164- if backend == "llvm" {
2168+ if backend. is_llvm ( ) {
21652169 debug ! ( "llvm codegen backend is already built as part of rustc" ) ;
21662170 continue ; // Already built as part of rustc
21672171 }
0 commit comments