@@ -2188,17 +2188,14 @@ impl Build {
21882188 }
21892189 }
21902190
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 ( ) ) ;
22022199 }
22032200 }
22042201 ToolFamily :: Msvc { clang_cl } => {
@@ -2214,8 +2211,7 @@ impl Build {
22142211 cmd. push_cc_arg ( "-m32" . into ( ) ) ;
22152212 cmd. push_cc_arg ( "-arch:IA32" . into ( ) ) ;
22162213 } 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 ( ) ) ;
22192215 }
22202216 } else if target. full_arch == "i586" {
22212217 cmd. push_cc_arg ( "-arch:IA32" . into ( ) ) ;
@@ -2645,23 +2641,13 @@ impl Build {
26452641 fn apple_flags ( & self , cmd : & mut Tool ) -> Result < ( ) , Error > {
26462642 let target = self . get_target ( ) ?;
26472643
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.
26552645 //
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 ( ) ) ;
26652651
26662652 // AppleClang sometimes requires sysroot even on macOS
26672653 if cmd. is_xctoolchain_clang ( ) || target. os != "macos" {
0 commit comments