diff options
author | Alex Lorenz <arphaman@gmail.com> | 2017-06-19 10:57:27 +0000 |
---|---|---|
committer | Alex Lorenz <arphaman@gmail.com> | 2017-06-19 10:57:27 +0000 |
commit | dad1e1a3b50b035eecfc5e225b736796a232b09c (patch) | |
tree | 357f6d18ffdc87f93840d402bb0e64a5a58e3b64 /clang/lib/Driver/ToolChains/Darwin.cpp | |
parent | ee1b096f8a15f4a3dfb1a32f8e534d89bf24bea1 (diff) | |
download | bcm5719-llvm-dad1e1a3b50b035eecfc5e225b736796a232b09c.tar.gz bcm5719-llvm-dad1e1a3b50b035eecfc5e225b736796a232b09c.zip |
[driver][macOS] Pick the system version for the deployment target
if the SDK is newer than the system
This commit improves the driver by making sure that it picks the system version
for the deployment target when the version of the macOS SDK is newer than the
system version.
rdar://29449467
Differential Revision: https://reviews.llvm.org/D34175
llvm-svn: 305678
Diffstat (limited to 'clang/lib/Driver/ToolChains/Darwin.cpp')
-rw-r--r-- | clang/lib/Driver/ToolChains/Darwin.cpp | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/clang/lib/Driver/ToolChains/Darwin.cpp b/clang/lib/Driver/ToolChains/Darwin.cpp index e41b50c40b2..32925fde5ef 100644 --- a/clang/lib/Driver/ToolChains/Darwin.cpp +++ b/clang/lib/Driver/ToolChains/Darwin.cpp @@ -1118,6 +1118,25 @@ void DarwinClang::AddLinkRuntimeLibArgs(const ArgList &Args, } } +/// Returns the most appropriate macOS target version for the current process. +/// +/// If the macOS SDK version is the same or earlier than the system version, +/// then the SDK version is returned. Otherwise the system version is returned. +static std::string getSystemOrSDKMacOSVersion(StringRef MacOSSDKVersion) { + unsigned Major, Minor, Micro; + llvm::Triple(llvm::sys::getProcessTriple()) + .getMacOSXVersion(Major, Minor, Micro); + VersionTuple SystemVersion(Major, Minor, Micro); + bool HadExtra; + if (!Driver::GetReleaseVersion(MacOSSDKVersion, Major, Minor, Micro, + HadExtra)) + return MacOSSDKVersion; + VersionTuple SDKVersion(Major, Minor, Micro); + if (SDKVersion > SystemVersion) + return SystemVersion.getAsString(); + return MacOSSDKVersion; +} + void Darwin::AddDeploymentTarget(DerivedArgList &Args) const { const OptTable &Opts = getDriver().getOpts(); @@ -1210,7 +1229,7 @@ void Darwin::AddDeploymentTarget(DerivedArgList &Args) const { SDK.startswith("iPhoneSimulator")) iOSTarget = Version; else if (SDK.startswith("MacOSX")) - OSXTarget = Version; + OSXTarget = getSystemOrSDKMacOSVersion(Version); else if (SDK.startswith("WatchOS") || SDK.startswith("WatchSimulator")) WatchOSTarget = Version; |