@@ -2527,22 +2527,22 @@ impl Build {
25272527 fn apple_flags ( & self , cmd : & mut Tool ) -> Result < ( ) , Error > {
25282528 let target = self . get_target ( ) ?;
25292529
2530- let min_version = self . apple_deployment_target ( & target) ;
2531- let version_flag = match ( & * target . os , & * target. abi ) {
2532- ( "macos" , "" ) => Some ( "-mmacosx-version-min" ) ,
2533- ( "ios" , "" ) => Some ( "-miphoneos-version-min" ) ,
2534- ( "ios" , "sim" ) => Some ( "-mios-simulator-version-min" ) ,
2535- ( "tvos" , "" ) => Some ( "-mappletvos -version-min" ) ,
2536- ( "tvos" , "sim" ) => Some ( "-mappletvsimulator-version-min" ) ,
2537- ( "watchos" , "" ) => Some ( "-mwatchos-version-min" ) ,
2538- ( "watchos" , "sim" ) => Some ( "-mwatchsimulator -version-min" ) ,
2539- // `-mxros-version-min` does not exist
2540- // https://github.com/llvm/llvm-project/issues/88271
2541- _ => None ,
2542- } ;
2543- if let Some ( version_flag ) = version_flag {
2530+ // If the compiler is Clang, then we've already specifed the target
2531+ // information (including the deployment target) with the `--target`
2532+ // option, so we don't need to do anything further here.
2533+ //
2534+ // If the compiler is GCC, then we need to specify
2535+ // `-mmacosx -version-min` to set the deployment target, as well
2536+ // as to say that the target OS is macOS.
2537+ //
2538+ // NOTE: GCC does not support `-miphoneos -version-min=` etc. (because
2539+ // it does not support iOS in general), but we specify them anyhow in
2540+ // case we actually have a Clang-like compiler disguised as a GNU-like
2541+ // compiler, or in case GCC adds support for these in the future.
2542+ if !cmd . is_like_clang ( ) {
2543+ let min_version = self . apple_deployment_target ( & target ) ;
25442544 cmd. args
2545- . push ( format ! ( "{}={}" , version_flag , min_version) . into ( ) ) ;
2545+ . push ( target . apple_version_flag ( & min_version) . into ( ) ) ;
25462546 }
25472547
25482548 // AppleClang sometimes requires sysroot even on macOS
0 commit comments