diff options
Diffstat (limited to 'clang/lib/Driver')
| -rw-r--r-- | clang/lib/Driver/ToolChains.cpp | 44 | ||||
| -rw-r--r-- | clang/lib/Driver/ToolChains.h | 6 |
2 files changed, 35 insertions, 15 deletions
diff --git a/clang/lib/Driver/ToolChains.cpp b/clang/lib/Driver/ToolChains.cpp index a9c6a68ceb8..355dbe4052d 100644 --- a/clang/lib/Driver/ToolChains.cpp +++ b/clang/lib/Driver/ToolChains.cpp @@ -403,22 +403,38 @@ DerivedArgList *Darwin::TranslateArgs(InputArgList &Args, << OSXVersion->getAsString(Args) << iPhoneVersion->getAsString(Args); } else if (!OSXVersion && !iPhoneVersion) { - // Chose the default version based on the arch. - // - // FIXME: Are there iPhone overrides for this? - - if (!isIPhoneOS()) { - // Look for MACOSX_DEPLOYMENT_TARGET, otherwise use the version - // from the host. - const char *Version = ::getenv("MACOSX_DEPLOYMENT_TARGET"); - if (!Version) - Version = MacosxVersionMin.c_str(); + // If neither OS X nor iPhoneOS targets were specified, check for + // environment defines. + const char *OSXTarget = ::getenv("MACOSX_DEPLOYMENT_TARGET"); + const char *iPhoneOSTarget = ::getenv("IPHONEOS_DEPLOYMENT_TARGET"); + + // Ignore empty strings. + if (OSXTarget && OSXTarget[0] == '\0') + OSXTarget = 0; + if (iPhoneOSTarget && iPhoneOSTarget[0] == '\0') + iPhoneOSTarget = 0; + + if (OSXTarget && iPhoneOSTarget) { + getDriver().Diag(clang::diag::err_drv_conflicting_deployment_targets) + << OSXTarget << iPhoneOSTarget; + } else if (OSXTarget) { const Option *O = Opts.getOption(options::OPT_mmacosx_version_min_EQ); - DAL->append(DAL->MakeJoinedArg(0, O, Version)); - } else { - const char *Version = IPhoneOSVersionMin.c_str(); + DAL->append(DAL->MakeJoinedArg(0, O, OSXTarget)); + } else if (iPhoneOSTarget) { const Option *O = Opts.getOption(options::OPT_miphoneos_version_min_EQ); - DAL->append(DAL->MakeJoinedArg(0, O, Version)); + DAL->append(DAL->MakeJoinedArg(0, O, iPhoneOSTarget)); + } else { + // Otherwise, choose the default version based on the toolchain. + + // FIXME: This is confusing it should be more explicit what the default + // target is. + if (isIPhoneOS()) { + const Option *O = Opts.getOption(options::OPT_miphoneos_version_min_EQ); + DAL->append(DAL->MakeJoinedArg(0, O, IPhoneOSVersionMin)); + } else { + const Option *O = Opts.getOption(options::OPT_mmacosx_version_min_EQ); + DAL->append(DAL->MakeJoinedArg(0, O, MacosxVersionMin)); + } } } diff --git a/clang/lib/Driver/ToolChains.h b/clang/lib/Driver/ToolChains.h index 3ca6ad88972..89478d5f157 100644 --- a/clang/lib/Driver/ToolChains.h +++ b/clang/lib/Driver/ToolChains.h @@ -54,11 +54,15 @@ class VISIBILITY_HIDDEN Darwin : public ToolChain { // // FIXME: This should go away, such differences should be completely // determined by the target triple. + // + // FIXME: It is also broken, we need to distinguish the "default target" from + // the actual target. The -m...-version-min strings and deployment targets can + // change this. bool IsIPhoneOS; /// The default macosx-version-min of this tool chain; empty until /// initialized. - mutable std::string MacosxVersionMin; + std::string MacosxVersionMin; /// The default iphoneos-version-min of this tool chain. std::string IPhoneOSVersionMin; |

