summaryrefslogtreecommitdiffstats
path: root/clang/lib/Driver/ToolChains.cpp
diff options
context:
space:
mode:
authorSteven Wu <stevenwu@apple.com>2015-06-25 01:59:35 +0000
committerSteven Wu <stevenwu@apple.com>2015-06-25 01:59:35 +0000
commit7a1372ce34b8dd44ffa52dd1fbc613863eb26771 (patch)
tree83e358952ec1a48c07fda46dbb0ad5a57a10b161 /clang/lib/Driver/ToolChains.cpp
parent1d4cff2cdc8cd0abf3d5dda8875e4b5bfcfde56b (diff)
downloadbcm5719-llvm-7a1372ce34b8dd44ffa52dd1fbc613863eb26771.tar.gz
bcm5719-llvm-7a1372ce34b8dd44ffa52dd1fbc613863eb26771.zip
Update darwin SDK version parsing to support OSX and simulator
This re-commits r226005 with a tweak. The origin attempt failed because Darwin bot sets up SDKROOT and clang can deduce SDK version from them after this patch. That broke many driver tests due to the change of deployment target version. Now the tests should not complain after r240574. llvm-svn: 240619
Diffstat (limited to 'clang/lib/Driver/ToolChains.cpp')
-rw-r--r--clang/lib/Driver/ToolChains.cpp31
1 files changed, 23 insertions, 8 deletions
diff --git a/clang/lib/Driver/ToolChains.cpp b/clang/lib/Driver/ToolChains.cpp
index e107126d98b..4c69716dc14 100644
--- a/clang/lib/Driver/ToolChains.cpp
+++ b/clang/lib/Driver/ToolChains.cpp
@@ -463,16 +463,31 @@ void Darwin::AddDeploymentTarget(DerivedArgList &Args) const {
if (char *env = ::getenv("IPHONEOS_DEPLOYMENT_TARGET"))
iOSTarget = 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 there is no command-line argument to specify the Target version and
+ // no environment variable defined, see if we can set the default based
+ // on -isysroot.
+ if (iOSTarget.empty() && OSXTarget.empty() &&
+ Args.hasArg(options::OPT_isysroot)) {
if (const Arg *A = Args.getLastArg(options::OPT_isysroot)) {
- StringRef first, second;
StringRef isysroot = A->getValue();
- std::tie(first, second) = isysroot.split(StringRef("SDKs/iPhoneOS"));
- if (second != "")
- iOSTarget = second.substr(0,3);
+ // Assume SDK has path: SOME_PATH/SDKs/PlatformXX.YY.sdk
+ size_t BeginSDK = isysroot.rfind("SDKs/");
+ size_t EndSDK = isysroot.rfind(".sdk");
+ if (BeginSDK != StringRef::npos && EndSDK != StringRef::npos) {
+ StringRef SDK = isysroot.slice(BeginSDK + 5, EndSDK);
+ // Slice the version number out.
+ // Version number is between the first and the last number.
+ size_t StartVer = SDK.find_first_of("0123456789");
+ size_t EndVer = SDK.find_last_of("0123456789");
+ if (StartVer != StringRef::npos && EndVer > StartVer) {
+ StringRef Version = SDK.slice(StartVer, EndVer + 1);
+ if (SDK.startswith("iPhoneOS") ||
+ SDK.startswith("iPhoneSimulator"))
+ iOSTarget = Version;
+ else if (SDK.startswith("MacOSX"))
+ OSXTarget = Version;
+ }
+ }
}
}
OpenPOWER on IntegriCloud