@@ -45,6 +45,7 @@ use rustc_target::spec::{
45
45
use tempfile:: Builder as TempFileBuilder ;
46
46
use tracing:: { debug, info, warn} ;
47
47
48
+ use super :: apple;
48
49
use super :: archive:: { ArchiveBuilder , ArchiveBuilderBuilder } ;
49
50
use super :: command:: Command ;
50
51
use super :: linker:: { self , Linker } ;
@@ -3125,9 +3126,7 @@ fn add_apple_link_args(cmd: &mut dyn Linker, sess: &Session, flavor: LinkerFlavo
3125
3126
}
3126
3127
3127
3128
fn add_apple_sdk ( cmd : & mut dyn Linker , sess : & Session , flavor : LinkerFlavor ) -> Option < PathBuf > {
3128
- let arch = & sess. target . arch ;
3129
3129
let os = & sess. target . os ;
3130
- let llvm_target = & sess. target . llvm_target ;
3131
3130
if sess. target . vendor != "apple"
3132
3131
|| !matches ! ( os. as_ref( ) , "ios" | "tvos" | "watchos" | "visionos" | "macos" )
3133
3132
|| !matches ! ( flavor, LinkerFlavor :: Darwin ( ..) )
@@ -3139,30 +3138,8 @@ fn add_apple_sdk(cmd: &mut dyn Linker, sess: &Session, flavor: LinkerFlavor) ->
3139
3138
return None ;
3140
3139
}
3141
3140
3142
- let sdk_name = match ( arch. as_ref ( ) , os. as_ref ( ) ) {
3143
- ( "aarch64" , "tvos" ) if llvm_target. ends_with ( "-simulator" ) => "appletvsimulator" ,
3144
- ( "aarch64" , "tvos" ) => "appletvos" ,
3145
- ( "x86_64" , "tvos" ) => "appletvsimulator" ,
3146
- ( "arm" , "ios" ) => "iphoneos" ,
3147
- ( "aarch64" , "ios" ) if llvm_target. contains ( "macabi" ) => "macosx" ,
3148
- ( "aarch64" , "ios" ) if llvm_target. ends_with ( "-simulator" ) => "iphonesimulator" ,
3149
- ( "aarch64" , "ios" ) => "iphoneos" ,
3150
- ( "x86" , "ios" ) => "iphonesimulator" ,
3151
- ( "x86_64" , "ios" ) if llvm_target. contains ( "macabi" ) => "macosx" ,
3152
- ( "x86_64" , "ios" ) => "iphonesimulator" ,
3153
- ( "x86_64" , "watchos" ) => "watchsimulator" ,
3154
- ( "arm64_32" , "watchos" ) => "watchos" ,
3155
- ( "aarch64" , "watchos" ) if llvm_target. ends_with ( "-simulator" ) => "watchsimulator" ,
3156
- ( "aarch64" , "watchos" ) => "watchos" ,
3157
- ( "aarch64" , "visionos" ) if llvm_target. ends_with ( "-simulator" ) => "xrsimulator" ,
3158
- ( "aarch64" , "visionos" ) => "xros" ,
3159
- ( "arm" , "watchos" ) => "watchos" ,
3160
- ( _, "macos" ) => "macosx" ,
3161
- _ => {
3162
- sess. dcx ( ) . emit_err ( errors:: UnsupportedArch { arch, os } ) ;
3163
- return None ;
3164
- }
3165
- } ;
3141
+ let sdk_name = apple:: sdk_name ( & sess. target ) ;
3142
+
3166
3143
let sdk_root = match get_apple_sdk_root ( sdk_name) {
3167
3144
Ok ( s) => s,
3168
3145
Err ( e) => {
@@ -3199,7 +3176,7 @@ fn get_apple_sdk_root(sdk_name: &str) -> Result<String, errors::AppleSdkRootErro
3199
3176
// can fall back to checking for xcrun on PATH.)
3200
3177
if let Ok ( sdkroot) = env:: var ( "SDKROOT" ) {
3201
3178
let p = Path :: new ( & sdkroot) ;
3202
- match sdk_name {
3179
+ match & * sdk_name. to_lowercase ( ) {
3203
3180
// Ignore `SDKROOT` if it's clearly set for the wrong platform.
3204
3181
"appletvos"
3205
3182
if sdkroot. contains ( "TVSimulator.platform" )
@@ -3230,18 +3207,21 @@ fn get_apple_sdk_root(sdk_name: &str) -> Result<String, errors::AppleSdkRootErro
3230
3207
_ => return Ok ( sdkroot) ,
3231
3208
}
3232
3209
}
3233
- let res =
3234
- Command :: new ( "xcrun" ) . arg ( "--show-sdk-path" ) . arg ( "-sdk" ) . arg ( sdk_name) . output ( ) . and_then (
3235
- |output| {
3236
- if output. status . success ( ) {
3237
- Ok ( String :: from_utf8 ( output. stdout ) . unwrap ( ) )
3238
- } else {
3239
- let error = String :: from_utf8 ( output. stderr ) ;
3240
- let error = format ! ( "process exit with error: {}" , error. unwrap( ) ) ;
3241
- Err ( io:: Error :: new ( io:: ErrorKind :: Other , & error[ ..] ) )
3242
- }
3243
- } ,
3244
- ) ;
3210
+
3211
+ let res = Command :: new ( "xcrun" )
3212
+ . arg ( "--show-sdk-path" )
3213
+ . arg ( "-sdk" )
3214
+ . arg ( sdk_name. to_lowercase ( ) )
3215
+ . output ( )
3216
+ . and_then ( |output| {
3217
+ if output. status . success ( ) {
3218
+ Ok ( String :: from_utf8 ( output. stdout ) . unwrap ( ) )
3219
+ } else {
3220
+ let error = String :: from_utf8 ( output. stderr ) ;
3221
+ let error = format ! ( "process exit with error: {}" , error. unwrap( ) ) ;
3222
+ Err ( io:: Error :: new ( io:: ErrorKind :: Other , & error[ ..] ) )
3223
+ }
3224
+ } ) ;
3245
3225
3246
3226
match res {
3247
3227
Ok ( output) => Ok ( output. trim ( ) . to_string ( ) ) ,
0 commit comments