@@ -3194,39 +3194,34 @@ fn add_apple_link_args(cmd: &mut dyn Linker, sess: &Session, flavor: LinkerFlavo
3194
3194
}
3195
3195
3196
3196
fn add_apple_sdk ( cmd : & mut dyn Linker , sess : & Session , flavor : LinkerFlavor ) -> Option < PathBuf > {
3197
- let os = & sess. target . os ;
3198
- if sess. target . vendor != "apple"
3199
- || !matches ! ( os. as_ref( ) , "ios" | "tvos" | "watchos" | "visionos" | "macos" )
3200
- || !matches ! ( flavor, LinkerFlavor :: Darwin ( ..) )
3201
- {
3197
+ if !sess. target . is_like_darwin {
3202
3198
return None ;
3203
3199
}
3204
-
3205
- if os == "macos" && !matches ! ( flavor, LinkerFlavor :: Darwin ( Cc :: No , _) ) {
3200
+ let LinkerFlavor :: Darwin ( cc, _) = flavor else {
3201
+ return None ;
3202
+ } ;
3203
+ if os == "macos" && cc != Cc :: No {
3204
+ // FIXME(madsmtm): Remove this branch.
3206
3205
return None ;
3207
3206
}
3208
3207
3209
- let sdk_root = sess. time ( "get_apple_sdk_root" , || get_apple_sdk_root ( sess) ) ?;
3208
+ let sdkroot = sess. time ( "get_apple_sdk_root" , || get_apple_sdk_root ( sess) ) ?;
3210
3209
3211
- match flavor {
3212
- LinkerFlavor :: Darwin ( Cc :: Yes , _) => {
3213
- // Use `-isysroot` instead of `--sysroot`, as only the former
3214
- // makes Clang treat it as a platform SDK.
3215
- //
3216
- // This is admittedly a bit strange, as on most targets
3217
- // `-isysroot` only applies to include header files, but on Apple
3218
- // targets this also applies to libraries and frameworks.
3219
- cmd. cc_arg ( "-isysroot" ) ;
3220
- cmd. cc_arg ( & sdk_root) ;
3221
- }
3222
- LinkerFlavor :: Darwin ( Cc :: No , _) => {
3223
- cmd. link_arg ( "-syslibroot" ) ;
3224
- cmd. link_arg ( & sdk_root) ;
3225
- }
3226
- _ => unreachable ! ( ) ,
3210
+ if cc == Cc :: Yes {
3211
+ // Use `-isysroot` instead of `--sysroot`, as only the former
3212
+ // makes Clang treat it as a platform SDK.
3213
+ //
3214
+ // This is admittedly a bit strange, as on most targets
3215
+ // `-isysroot` only applies to include header files, but on Apple
3216
+ // targets this also applies to libraries and frameworks.
3217
+ cmd. cc_arg ( "-isysroot" ) ;
3218
+ cmd. cc_arg ( & sdk_root) ;
3219
+ } else {
3220
+ cmd. link_arg ( "-syslibroot" ) ;
3221
+ cmd. link_arg ( & sdkroot) ;
3227
3222
}
3228
3223
3229
- Some ( sdk_root )
3224
+ Some ( sdkroot )
3230
3225
}
3231
3226
3232
3227
fn get_apple_sdk_root ( sess : & Session ) -> Option < PathBuf > {
0 commit comments