@@ -3124,9 +3124,7 @@ fn add_apple_link_args(cmd: &mut dyn Linker, sess: &Session, flavor: LinkerFlavo
3124
3124
}
3125
3125
3126
3126
fn add_apple_sdk ( cmd : & mut dyn Linker , sess : & Session , flavor : LinkerFlavor ) -> Option < PathBuf > {
3127
- let arch = & sess. target . arch ;
3128
3127
let os = & sess. target . os ;
3129
- let llvm_target = & sess. target . llvm_target ;
3130
3128
if sess. target . vendor != "apple"
3131
3129
|| !matches ! ( os. as_ref( ) , "ios" | "tvos" | "watchos" | "visionos" | "macos" )
3132
3130
|| !matches ! ( flavor, LinkerFlavor :: Darwin ( ..) )
@@ -3138,30 +3136,8 @@ fn add_apple_sdk(cmd: &mut dyn Linker, sess: &Session, flavor: LinkerFlavor) ->
3138
3136
return None ;
3139
3137
}
3140
3138
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
+
3165
3141
let sdk_root = match get_apple_sdk_root ( sdk_name) {
3166
3142
Ok ( s) => s,
3167
3143
Err ( e) => {
@@ -3198,7 +3174,7 @@ fn get_apple_sdk_root(sdk_name: &str) -> Result<String, errors::AppleSdkRootErro
3198
3174
// can fall back to checking for xcrun on PATH.)
3199
3175
if let Ok ( sdkroot) = env:: var ( "SDKROOT" ) {
3200
3176
let p = Path :: new ( & sdkroot) ;
3201
- match sdk_name {
3177
+ match & * sdk_name. to_lowercase ( ) {
3202
3178
// Ignore `SDKROOT` if it's clearly set for the wrong platform.
3203
3179
"appletvos"
3204
3180
if sdkroot. contains ( "TVSimulator.platform" )
@@ -3229,18 +3205,21 @@ fn get_apple_sdk_root(sdk_name: &str) -> Result<String, errors::AppleSdkRootErro
3229
3205
_ => return Ok ( sdkroot) ,
3230
3206
}
3231
3207
}
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
+ } ) ;
3244
3223
3245
3224
match res {
3246
3225
Ok ( output) => Ok ( output. trim ( ) . to_string ( ) ) ,
0 commit comments