@@ -2188,17 +2188,14 @@ impl Build {
2188
2188
}
2189
2189
}
2190
2190
2191
- // Add version information to the target.
2192
- let llvm_target = if target. vendor == "apple" {
2193
- let deployment_target = self . apple_deployment_target ( target) ;
2194
- target. versioned_llvm_target ( Some ( & deployment_target) )
2195
- } else {
2196
- target. versioned_llvm_target ( None )
2197
- } ;
2198
-
2199
- // Pass `--target` with the LLVM target to properly
2200
- // configure Clang even when cross-compiling.
2201
- cmd. push_cc_arg ( format ! ( "--target={llvm_target}" ) . into ( ) ) ;
2191
+ // Pass `--target` with the LLVM target to properly configure Clang even when
2192
+ // cross-compiling.
2193
+ //
2194
+ // We intentionally don't put the deployment version in here on Apple targets,
2195
+ // and instead pass that via `-mmacosx-version-min=` and similar flags, for
2196
+ // better compatibility with older versions of Clang that has poor support for
2197
+ // versioned target names (especially when it comes to configuration files).
2198
+ cmd. push_cc_arg ( format ! ( "--target={}" , target. llvm_target) . into ( ) ) ;
2202
2199
}
2203
2200
}
2204
2201
ToolFamily :: Msvc { clang_cl } => {
@@ -2214,8 +2211,7 @@ impl Build {
2214
2211
cmd. push_cc_arg ( "-m32" . into ( ) ) ;
2215
2212
cmd. push_cc_arg ( "-arch:IA32" . into ( ) ) ;
2216
2213
} else {
2217
- let llvm_target = target. versioned_llvm_target ( None ) ;
2218
- cmd. push_cc_arg ( format ! ( "--target={llvm_target}" ) . into ( ) ) ;
2214
+ cmd. push_cc_arg ( format ! ( "--target={}" , target. llvm_target) . into ( ) ) ;
2219
2215
}
2220
2216
} else if target. full_arch == "i586" {
2221
2217
cmd. push_cc_arg ( "-arch:IA32" . into ( ) ) ;
@@ -2645,23 +2641,13 @@ impl Build {
2645
2641
fn apple_flags ( & self , cmd : & mut Tool ) -> Result < ( ) , Error > {
2646
2642
let target = self . get_target ( ) ?;
2647
2643
2648
- // If the compiler is Clang, then we've already specifed the target
2649
- // information (including the deployment target) with the `--target`
2650
- // option, so we don't need to do anything further here.
2651
- //
2652
- // If the compiler is GCC, then we need to specify
2653
- // `-mmacosx-version-min` to set the deployment target, as well
2654
- // as to say that the target OS is macOS.
2644
+ // Pass the deployment target via `-mmacosx-version-min=`, `-mtargetos=` and similar.
2655
2645
//
2656
- // NOTE: GCC does not support `-miphoneos-version-min=` etc. (because
2657
- // it does not support iOS in general), but we specify them anyhow in
2658
- // case we actually have a Clang-like compiler disguised as a GNU-like
2659
- // compiler, or in case GCC adds support for these in the future.
2660
- if !cmd. is_like_clang ( ) {
2661
- let min_version = self . apple_deployment_target ( & target) ;
2662
- cmd. args
2663
- . push ( target. apple_version_flag ( & min_version) . into ( ) ) ;
2664
- }
2646
+ // It is also necessary on GCC, as it forces a compilation error if the compiler is not
2647
+ // configured for Darwin: https://gcc.gnu.org/onlinedocs/gcc/Darwin-Options.html
2648
+ let min_version = self . apple_deployment_target ( & target) ;
2649
+ cmd. args
2650
+ . push ( target. apple_version_flag ( & min_version) . into ( ) ) ;
2665
2651
2666
2652
// AppleClang sometimes requires sysroot even on macOS
2667
2653
if cmd. is_xctoolchain_clang ( ) || target. os != "macos" {
0 commit comments