@@ -3124,9 +3124,7 @@ fn add_apple_link_args(cmd: &mut dyn Linker, sess: &Session, flavor: LinkerFlavo
31243124}
31253125
31263126fn add_apple_sdk ( cmd : & mut dyn Linker , sess : & Session , flavor : LinkerFlavor ) -> Option < PathBuf > {
3127- let arch = & sess. target . arch ;
31283127 let os = & sess. target . os ;
3129- let llvm_target = & sess. target . llvm_target ;
31303128 if sess. target . vendor != "apple"
31313129 || !matches ! ( os. as_ref( ) , "ios" | "tvos" | "watchos" | "visionos" | "macos" )
31323130 || !matches ! ( flavor, LinkerFlavor :: Darwin ( ..) )
@@ -3138,30 +3136,8 @@ fn add_apple_sdk(cmd: &mut dyn Linker, sess: &Session, flavor: LinkerFlavor) ->
31383136 return None ;
31393137 }
31403138
3141- let sdk_name = match ( arch. as_ref ( ) , os. as_ref ( ) ) {
3142- ( "aarch64" , "tvos" ) if llvm_target. ends_with ( "-simulator" ) => "appletvsimulator" ,
3143- ( "aarch64" , "tvos" ) => "appletvos" ,
3144- ( "x86_64" , "tvos" ) => "appletvsimulator" ,
3145- ( "arm" , "ios" ) => "iphoneos" ,
3146- ( "aarch64" , "ios" ) if llvm_target. contains ( "macabi" ) => "macosx" ,
3147- ( "aarch64" , "ios" ) if llvm_target. ends_with ( "-simulator" ) => "iphonesimulator" ,
3148- ( "aarch64" , "ios" ) => "iphoneos" ,
3149- ( "x86" , "ios" ) => "iphonesimulator" ,
3150- ( "x86_64" , "ios" ) if llvm_target. contains ( "macabi" ) => "macosx" ,
3151- ( "x86_64" , "ios" ) => "iphonesimulator" ,
3152- ( "x86_64" , "watchos" ) => "watchsimulator" ,
3153- ( "arm64_32" , "watchos" ) => "watchos" ,
3154- ( "aarch64" , "watchos" ) if llvm_target. ends_with ( "-simulator" ) => "watchsimulator" ,
3155- ( "aarch64" , "watchos" ) => "watchos" ,
3156- ( "aarch64" , "visionos" ) if llvm_target. ends_with ( "-simulator" ) => "xrsimulator" ,
3157- ( "aarch64" , "visionos" ) => "xros" ,
3158- ( "arm" , "watchos" ) => "watchos" ,
3159- ( _, "macos" ) => "macosx" ,
3160- _ => {
3161- sess. dcx ( ) . emit_err ( errors:: UnsupportedArch { arch, os } ) ;
3162- return None ;
3163- }
3164- } ;
3139+ let sdk_name = apple:: sdk_name ( & sess. target ) ;
3140+
31653141 let sdk_root = match get_apple_sdk_root ( sdk_name) {
31663142 Ok ( s) => s,
31673143 Err ( e) => {
@@ -3198,7 +3174,7 @@ fn get_apple_sdk_root(sdk_name: &str) -> Result<String, errors::AppleSdkRootErro
31983174 // can fall back to checking for xcrun on PATH.)
31993175 if let Ok ( sdkroot) = env:: var ( "SDKROOT" ) {
32003176 let p = Path :: new ( & sdkroot) ;
3201- match sdk_name {
3177+ match & * sdk_name. to_lowercase ( ) {
32023178 // Ignore `SDKROOT` if it's clearly set for the wrong platform.
32033179 "appletvos"
32043180 if sdkroot. contains ( "TVSimulator.platform" )
@@ -3229,18 +3205,21 @@ fn get_apple_sdk_root(sdk_name: &str) -> Result<String, errors::AppleSdkRootErro
32293205 _ => return Ok ( sdkroot) ,
32303206 }
32313207 }
3232- let res =
3233- Command :: new ( "xcrun" ) . arg ( "--show-sdk-path" ) . arg ( "-sdk" ) . arg ( sdk_name) . output ( ) . and_then (
3234- |output| {
3235- if output. status . success ( ) {
3236- Ok ( String :: from_utf8 ( output. stdout ) . unwrap ( ) )
3237- } else {
3238- let error = String :: from_utf8 ( output. stderr ) ;
3239- let error = format ! ( "process exit with error: {}" , error. unwrap( ) ) ;
3240- Err ( io:: Error :: new ( io:: ErrorKind :: Other , & error[ ..] ) )
3241- }
3242- } ,
3243- ) ;
3208+
3209+ let res = Command :: new ( "xcrun" )
3210+ . arg ( "--show-sdk-path" )
3211+ . arg ( "-sdk" )
3212+ . arg ( sdk_name. to_lowercase ( ) )
3213+ . output ( )
3214+ . and_then ( |output| {
3215+ if output. status . success ( ) {
3216+ Ok ( String :: from_utf8 ( output. stdout ) . unwrap ( ) )
3217+ } else {
3218+ let error = String :: from_utf8 ( output. stderr ) ;
3219+ let error = format ! ( "process exit with error: {}" , error. unwrap( ) ) ;
3220+ Err ( io:: Error :: new ( io:: ErrorKind :: Other , & error[ ..] ) )
3221+ }
3222+ } ) ;
32443223
32453224 match res {
32463225 Ok ( output) => Ok ( output. trim ( ) . to_string ( ) ) ,
0 commit comments