@@ -46,9 +46,9 @@ use rustc_session::{Session, filesearch};
4646use rustc_span:: Symbol ;
4747use rustc_target:: spec:: crt_objects:: CrtObjects ;
4848use rustc_target:: spec:: {
49- BinaryFormat , Cc , LinkOutputKind , LinkSelfContainedComponents , LinkSelfContainedDefault ,
50- LinkerFeatures , LinkerFlavor , LinkerFlavorCli , Lld , RelocModel , RelroLevel , SanitizerSet ,
51- SplitDebuginfo ,
49+ Abi , BinaryFormat , Cc , Env , LinkOutputKind , LinkSelfContainedComponents ,
50+ LinkSelfContainedDefault , LinkerFeatures , LinkerFlavor , LinkerFlavorCli , Lld , Os , RelocModel ,
51+ RelroLevel , SanitizerSet , SplitDebuginfo ,
5252} ;
5353use tracing:: { debug, info, warn} ;
5454
@@ -1407,11 +1407,9 @@ pub fn linker_and_flavor(sess: &Session) -> (PathBuf, LinkerFlavor) {
14071407 Some ( LinkerFlavorCli :: Llbc ) => Some ( LinkerFlavor :: Llbc ) ,
14081408 Some ( LinkerFlavorCli :: Ptx ) => Some ( LinkerFlavor :: Ptx ) ,
14091409 // The linker flavors that corresponds to targets needs logic that keeps the base LinkerFlavor
1410- _ => sess
1411- . opts
1412- . cg
1413- . linker_flavor
1414- . map ( |flavor| sess. target . linker_flavor . with_cli_hints ( flavor) ) ,
1410+ linker_flavor => {
1411+ linker_flavor. map ( |flavor| sess. target . linker_flavor . with_cli_hints ( flavor) )
1412+ }
14151413 } ;
14161414 if let Some ( ret) = infer_from ( sess, sess. opts . cg . linker . clone ( ) , linker_flavor, features) {
14171415 return ret;
@@ -1819,7 +1817,7 @@ fn self_contained_components(
18191817 LinkSelfContainedDefault :: InferredForMusl => sess. crt_static ( Some ( crate_type) ) ,
18201818 LinkSelfContainedDefault :: InferredForMingw => {
18211819 sess. host == sess. target
1822- && sess. target . abi != "uwp"
1820+ && sess. target . abi != Abi :: Uwp
18231821 && detect_self_contained_mingw ( sess, linker)
18241822 }
18251823 }
@@ -1845,7 +1843,7 @@ fn add_pre_link_objects(
18451843 let empty = Default :: default ( ) ;
18461844 let objects = if self_contained {
18471845 & opts. pre_link_objects_self_contained
1848- } else if !( sess. target . os == "fuchsia" && matches ! ( flavor, LinkerFlavor :: Gnu ( Cc :: Yes , _) ) ) {
1846+ } else if !( sess. target . os == Os :: Fuchsia && matches ! ( flavor, LinkerFlavor :: Gnu ( Cc :: Yes , _) ) ) {
18491847 & opts. pre_link_objects
18501848 } else {
18511849 & empty
@@ -2496,7 +2494,7 @@ fn add_order_independent_options(
24962494
24972495 let apple_sdk_root = add_apple_sdk ( cmd, sess, flavor) ;
24982496
2499- if sess. target . os == "fuchsia"
2497+ if sess. target . os == Os :: Fuchsia
25002498 && crate_type == CrateType :: Executable
25012499 && !matches ! ( flavor, LinkerFlavor :: Gnu ( Cc :: Yes , _) )
25022500 {
@@ -2515,7 +2513,7 @@ fn add_order_independent_options(
25152513 cmd. no_crt_objects ( ) ;
25162514 }
25172515
2518- if sess. target . os == "emscripten" {
2516+ if sess. target . os == Os :: Emscripten {
25192517 cmd. cc_arg ( if sess. opts . unstable_opts . emscripten_wasm_eh {
25202518 "-fwasm-exceptions"
25212519 } else if sess. panic_strategy ( ) . unwinds ( ) {
@@ -3070,8 +3068,8 @@ fn add_apple_link_args(cmd: &mut dyn Linker, sess: &Session, flavor: LinkerFlavo
30703068
30713069 // `sess.target.arch` (`target_arch`) is not detailed enough.
30723070 let llvm_arch = sess. target . llvm_target . split_once ( '-' ) . expect ( "LLVM target must have arch" ) . 0 ;
3073- let target_os = & * sess. target . os ;
3074- let target_env = & * sess. target . env ;
3071+ let target_os = & sess. target . os ;
3072+ let target_env = & sess. target . env ;
30753073
30763074 // The architecture name to forward to the linker.
30773075 //
@@ -3123,12 +3121,12 @@ fn add_apple_link_args(cmd: &mut dyn Linker, sess: &Session, flavor: LinkerFlavo
31233121 // > - xros-simulator
31243122 // > - driverkit
31253123 let platform_name = match ( target_os, target_env) {
3126- ( os, "" ) => os,
3127- ( "ios" , "macabi" ) => "mac-catalyst" ,
3128- ( "ios" , "sim" ) => "ios-simulator" ,
3129- ( "tvos" , "sim" ) => "tvos-simulator" ,
3130- ( "watchos" , "sim" ) => "watchos-simulator" ,
3131- ( "visionos" , "sim" ) => "visionos-simulator" ,
3124+ ( os, Env :: Unspecified ) => os. desc ( ) ,
3125+ ( Os :: IOs , Env :: MacAbi ) => "mac-catalyst" ,
3126+ ( Os :: IOs , Env :: Sim ) => "ios-simulator" ,
3127+ ( Os :: TvOs , Env :: Sim ) => "tvos-simulator" ,
3128+ ( Os :: WatchOs , Env :: Sim ) => "watchos-simulator" ,
3129+ ( Os :: VisionOs , Env :: Sim ) => "visionos-simulator" ,
31323130 _ => bug ! ( "invalid OS/env combination for Apple target: {target_os}, {target_env}" ) ,
31333131 } ;
31343132
@@ -3192,7 +3190,7 @@ fn add_apple_link_args(cmd: &mut dyn Linker, sess: &Session, flavor: LinkerFlavo
31923190 // fairly safely use `-target`. See also the following, where it is
31933191 // made explicit that the recommendation by LLVM developers is to use
31943192 // `-target`: <https://github.com/llvm/llvm-project/issues/88271>
3195- if target_os == "macos" {
3193+ if * target_os == Os :: MacOs {
31963194 // `-arch` communicates the architecture.
31973195 //
31983196 // CC forwards the `-arch` to the linker, so we use the same value
0 commit comments