diff options
-rw-r--r-- | lib/Driver/ToolChains.cpp | 66 |
1 files changed, 31 insertions, 35 deletions
diff --git a/lib/Driver/ToolChains.cpp b/lib/Driver/ToolChains.cpp index 81ff10b7d0..d5b132c725 100644 --- a/lib/Driver/ToolChains.cpp +++ b/lib/Driver/ToolChains.cpp @@ -493,21 +493,6 @@ void Darwin::AddDeploymentTarget(DerivedArgList &Args) const { Arg *iOSSimVersion = Args.getLastArg( options::OPT_mios_simulator_version_min_EQ); - // If no '-miphoneos-version-min' specified, see if we can set the default - // based on isysroot. - if (!iOSVersion) { - if (const Arg *A = Args.getLastArg(options::OPT_isysroot)) { - StringRef first, second; - StringRef isysroot = A->getValue(Args); - llvm::tie(first, second) = isysroot.split(StringRef("SDKs/iPhoneOS")); - if (second != "") { - const Option *O = Opts.getOption(options::OPT_miphoneos_version_min_EQ); - iOSVersion = Args.MakeJoinedArg(0, O, second.substr(0,3)); - Args.append(iOSVersion); - } - } - } - // FIXME: HACK! When compiling for the simulator we don't get a // '-miphoneos-version-min' to help us know whether there is an ARC runtime // or not; try to parse a __IPHONE_OS_VERSION_MIN_REQUIRED @@ -539,51 +524,62 @@ void Darwin::AddDeploymentTarget(DerivedArgList &Args) const { << iOSSimVersion->getAsString(Args); iOSSimVersion = 0; } else if (!OSXVersion && !iOSVersion && !iOSSimVersion) { - // If not deployment target was specified on the command line, check for + // If no deployment target was specified on the command line, check for // environment defines. - const char *OSXTarget = ::getenv("MACOSX_DEPLOYMENT_TARGET"); - const char *iOSTarget = ::getenv("IPHONEOS_DEPLOYMENT_TARGET"); - const char *iOSSimTarget = ::getenv("IOS_SIMULATOR_DEPLOYMENT_TARGET"); - - // Ignore empty strings. - if (OSXTarget && OSXTarget[0] == '\0') - OSXTarget = 0; - if (iOSTarget && iOSTarget[0] == '\0') - iOSTarget = 0; - if (iOSSimTarget && iOSSimTarget[0] == '\0') - iOSSimTarget = 0; + StringRef OSXTarget; + StringRef iOSTarget; + StringRef iOSSimTarget; + if (char *env = ::getenv("MACOSX_DEPLOYMENT_TARGET")) + OSXTarget = env; + if (char *env = ::getenv("IPHONEOS_DEPLOYMENT_TARGET")) + iOSTarget = env; + if (char *env = ::getenv("IOS_SIMULATOR_DEPLOYMENT_TARGET")) + iOSSimTarget = env; + + // If no '-miphoneos-version-min' specified on the command line and + // IPHONEOS_DEPLOYMENT_TARGET is not defined, see if we can set the default + // based on isysroot. + if (iOSTarget.empty()) { + if (const Arg *A = Args.getLastArg(options::OPT_isysroot)) { + StringRef first, second; + StringRef isysroot = A->getValue(Args); + llvm::tie(first, second) = isysroot.split(StringRef("SDKs/iPhoneOS")); + if (second != "") + iOSTarget = second.substr(0,3); + } + } // Handle conflicting deployment targets // // FIXME: Don't hardcode default here. // Do not allow conflicts with the iOS simulator target. - if (iOSSimTarget && (OSXTarget || iOSTarget)) { + if (!iOSSimTarget.empty() && (!OSXTarget.empty() || !iOSTarget.empty())) { getDriver().Diag(diag::err_drv_conflicting_deployment_targets) << "IOS_SIMULATOR_DEPLOYMENT_TARGET" - << (OSXTarget ? "MACOSX_DEPLOYMENT_TARGET" : + << (!OSXTarget.empty() ? "MACOSX_DEPLOYMENT_TARGET" : "IPHONEOS_DEPLOYMENT_TARGET"); } // Allow conflicts among OSX and iOS for historical reasons, but choose the // default platform. - if (OSXTarget && iOSTarget) { + if (!OSXTarget.empty() && !iOSTarget.empty()) { if (getTriple().getArch() == llvm::Triple::arm || getTriple().getArch() == llvm::Triple::thumb) - OSXTarget = 0; + OSXTarget = ""; else - iOSTarget = 0; + iOSTarget = ""; } - if (OSXTarget) { + if (!OSXTarget.empty()) { const Option *O = Opts.getOption(options::OPT_mmacosx_version_min_EQ); OSXVersion = Args.MakeJoinedArg(0, O, OSXTarget); Args.append(OSXVersion); - } else if (iOSTarget) { + } else if (!iOSTarget.empty()) { const Option *O = Opts.getOption(options::OPT_miphoneos_version_min_EQ); iOSVersion = Args.MakeJoinedArg(0, O, iOSTarget); Args.append(iOSVersion); - } else if (iOSSimTarget) { + } else if (!iOSSimTarget.empty()) { const Option *O = Opts.getOption( options::OPT_mios_simulator_version_min_EQ); iOSSimVersion = Args.MakeJoinedArg(0, O, iOSSimTarget); |