@@ -33,7 +33,10 @@ use crate::utils::exec::command;
33
33
use crate :: utils:: helpers:: {
34
34
exe, get_clang_cl_resource_dir, is_debug_info, is_dylib, symlink_dir, t, up_to_date,
35
35
} ;
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
+ } ;
37
40
38
41
/// Build a standard library for the given `target` using the given `compiler`.
39
42
#[ derive( Debug , Clone , PartialEq , Eq , PartialOrd , Ord , Hash ) ]
@@ -1330,7 +1333,7 @@ pub fn rustc_cargo_env(builder: &Builder<'_>, cargo: &mut Cargo, target: TargetS
1330
1333
}
1331
1334
1332
1335
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 ( ) ) ;
1334
1337
}
1335
1338
1336
1339
let libdir_relative = builder. config . libdir_relative ( ) . unwrap_or_else ( || Path :: new ( "lib" ) ) ;
@@ -1543,7 +1546,7 @@ impl Step for RustcLink {
1543
1546
pub struct CodegenBackend {
1544
1547
pub target : TargetSelection ,
1545
1548
pub compiler : Compiler ,
1546
- pub backend : String ,
1549
+ pub backend : CodegenBackendKind ,
1547
1550
}
1548
1551
1549
1552
fn needs_codegen_config ( run : & RunConfig < ' _ > ) -> bool {
@@ -1568,7 +1571,7 @@ fn is_codegen_cfg_needed(path: &TaskPath, run: &RunConfig<'_>) -> bool {
1568
1571
if path. contains ( CODEGEN_BACKEND_PREFIX ) {
1569
1572
let mut needs_codegen_backend_config = true ;
1570
1573
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 ( ) ) ) {
1572
1575
needs_codegen_backend_config = false ;
1573
1576
}
1574
1577
}
@@ -1602,7 +1605,7 @@ impl Step for CodegenBackend {
1602
1605
}
1603
1606
1604
1607
for backend in run. builder . config . codegen_backends ( run. target ) {
1605
- if backend == "llvm" {
1608
+ if backend. is_llvm ( ) {
1606
1609
continue ; // Already built as part of rustc
1607
1610
}
1608
1611
@@ -1663,20 +1666,21 @@ impl Step for CodegenBackend {
1663
1666
) ;
1664
1667
cargo
1665
1668
. 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 ( ) ) ) ) ;
1667
1670
rustc_cargo_env ( builder, & mut cargo, target) ;
1668
1671
1669
1672
// Ideally, we'd have a separate step for the individual codegen backends,
1670
1673
// like we have in tests (test::CodegenGCC) but that would require a lot of restructuring.
1671
1674
// If the logic gets more complicated, it should probably be done.
1672
- if backend == "gcc" {
1675
+ if backend. is_gcc ( ) {
1673
1676
let gcc = builder. ensure ( Gcc { target } ) ;
1674
1677
add_cg_gcc_cargo_flags ( & mut cargo, & gcc) ;
1675
1678
}
1676
1679
1677
1680
let tmp_stamp = BuildStamp :: new ( & out_dir) . with_prefix ( "tmp" ) ;
1678
1681
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) ;
1680
1684
let files = run_cargo ( builder, cargo, vec ! [ ] , & tmp_stamp, vec ! [ ] , false , false ) ;
1681
1685
if builder. config . dry_run ( ) {
1682
1686
return ;
@@ -1731,7 +1735,7 @@ fn copy_codegen_backends_to_sysroot(
1731
1735
}
1732
1736
1733
1737
for backend in builder. config . codegen_backends ( target) {
1734
- if backend == "llvm" {
1738
+ if backend. is_llvm ( ) {
1735
1739
continue ; // Already built as part of rustc
1736
1740
}
1737
1741
@@ -2161,7 +2165,7 @@ impl Step for Assemble {
2161
2165
let _codegen_backend_span =
2162
2166
span ! ( tracing:: Level :: DEBUG , "building requested codegen backends" ) . entered ( ) ;
2163
2167
for backend in builder. config . codegen_backends ( target_compiler. host ) {
2164
- if backend == "llvm" {
2168
+ if backend. is_llvm ( ) {
2165
2169
debug ! ( "llvm codegen backend is already built as part of rustc" ) ;
2166
2170
continue ; // Already built as part of rustc
2167
2171
}
0 commit comments