Skip to content

Commit

Permalink
[Driver] Make sure the deployment target is earlier than iOS 11 when
Browse files Browse the repository at this point in the history
it is inferred from -isysroot.

This fixes a change that was inadvertently introduced in r309607.

rdar://problem/32230613

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@309633 91177308-0d34-0410-b5e6-96231b3b80d8
(cherry picked from commit d00f966)

Conflicts:
lib/Driver/ToolChains/Darwin.cpp
  • Loading branch information
ahatanaka committed Jul 31, 2017
1 parent e8adf5b commit 13991a0
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 19 deletions.
40 changes: 21 additions & 19 deletions lib/Driver/ToolChains.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -596,13 +596,12 @@ void Darwin::AddDeploymentTarget(DerivedArgList &Args) const {
unsigned Major, Minor, Micro;
bool HadExtra;

// iOS 10 is the maximum deployment target for 32-bit targets.
if (iOSVersion && getTriple().isArch32Bit() &&
Driver::GetReleaseVersion(iOSVersion->getValue(), Major, Minor, Micro,
HadExtra) &&
Major > 10)
getDriver().Diag(diag::warn_invalid_ios_deployment_target)
<< iOSVersion->getAsString(Args);
// The iOS deployment target that is explicitly specified via a command line
// option or an environment variable.
std::string ExplicitIOSDeploymentTargetStr;

if (iOSVersion)
ExplicitIOSDeploymentTargetStr = iOSVersion->getAsString(Args);

// Add a macro to differentiate between m(iphone|tv|watch)os-version-min=X.Y and
// -m(iphone|tv|watch)simulator-version-min=X.Y.
Expand Down Expand Up @@ -645,13 +644,9 @@ void Darwin::AddDeploymentTarget(DerivedArgList &Args) const {
if (char *env = ::getenv("WATCHOS_DEPLOYMENT_TARGET"))
WatchOSTarget = env;

// iOS 10 is the maximum deployment target for 32-bit targets.
if (!iOSTarget.empty() && getTriple().isArch32Bit() &&
Driver::GetReleaseVersion(iOSTarget.c_str(), Major, Minor, Micro,
HadExtra) &&
Major > 10)
getDriver().Diag(diag::warn_invalid_ios_deployment_target)
<< std::string("IPHONEOS_DEPLOYMENT_TARGET=") + iOSTarget;
if (!iOSTarget.empty())
ExplicitIOSDeploymentTargetStr =
std::string("IPHONEOS_DEPLOYMENT_TARGET=") + iOSTarget;

// If there is no command-line argument to specify the Target version and
// no environment variable defined, see if we can set the default based
Expand Down Expand Up @@ -785,12 +780,19 @@ void Darwin::AddDeploymentTarget(DerivedArgList &Args) const {
HadExtra || Major >= 100 || Minor >= 100 || Micro >= 100)
getDriver().Diag(diag::err_drv_invalid_version_number)
<< iOSVersion->getAsString(Args);
// iOS 10 is the maximum deployment target for 32-bit targets. If the
// inferred deployment target is iOS 11 or later, set it to 10.99.
// For 32-bit targets, the deployment target for iOS has to be earlier than
// iOS 11.
if (getTriple().isArch32Bit() && Major >= 11) {
Major = 10;
Minor = 99;
Micro = 99;
// If the deployment target is explicitly specified, print a diagnostic.
if (!ExplicitIOSDeploymentTargetStr.empty()) {
getDriver().Diag(diag::warn_invalid_ios_deployment_target)
<< ExplicitIOSDeploymentTargetStr;
// Otherwise, set it to 10.99.99.
} else {
Major = 10;
Minor = 99;
Micro = 99;
}
}
} else if (Platform == TvOS) {
if (!Driver::GetReleaseVersion(TvOSVersion->getValue(), Major, Minor,
Expand Down
2 changes: 2 additions & 0 deletions test/Driver/darwin-version.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@

// RUN: %clang -target armv7-apple-ios11.1 -c -### %s 2>&1 | \
// RUN: FileCheck --check-prefix=CHECK-VERSION-IOS7 %s
// RUN: %clang -arch armv7 -isysroot SDKs/iPhoneOS11.0.sdk -c -### %s 2>&1 | \
// RUN: FileCheck --check-prefix=CHECK-VERSION-IOS7 %s
// CHECK-VERSION-IOS7: thumbv7-apple-ios10.99.99

// RUN: env IPHONEOS_DEPLOYMENT_TARGET=11.0 \
Expand Down

0 comments on commit 13991a0

Please sign in to comment.