]> granicus.if.org Git - clang/commitdiff
Revert "More robust deployment target parsing on darwin"
authorSteven Wu <stevenwu@apple.com>
Wed, 14 Jan 2015 18:22:29 +0000 (18:22 +0000)
committerSteven Wu <stevenwu@apple.com>
Wed, 14 Jan 2015 18:22:29 +0000 (18:22 +0000)
This breaks green-dragon. Revert it and investigate.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@226011 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Driver/ToolChains.cpp
test/Driver/darwin-sdkroot.c

index 5677e6205f5b438f02e09d01b97e87b046a0d188..4d97ab3bf485dfcac751e001f178d1fb045b6d07 100644 (file)
@@ -494,28 +494,16 @@ void Darwin::AddDeploymentTarget(DerivedArgList &Args) const {
     if (char *env = ::getenv("IPHONEOS_DEPLOYMENT_TARGET"))
       iOSTarget = env;
 
-    // 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 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();
-        // 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);
-          size_t StartVer = SDK.find_first_of("123456789");
-          if (StartVer != StringRef::npos) {
-            StringRef Version = SDK.substr(StartVer);
-            if (SDK.startswith("iPhoneOS") ||
-                SDK.startswith("iPhoneSimulator"))
-              iOSTarget = Version;
-            else if (SDK.startswith("MacOSX"))
-              OSXTarget = Version;
-          }
-        }
+        std::tie(first, second) = isysroot.split(StringRef("SDKs/iPhoneOS"));
+        if (second != "")
+          iOSTarget = second.substr(0,3);
       }
     }
 
index b7971a0c87b4b05c2db6b365e68cab04622dbe19..58bc683320ff836b8070c730be344448d88e7157 100644 (file)
 //   env SDKROOT=/ cmd //c echo %SDKROOT%
 //
 // This test passes using env.exe from GnuWin32.
-
-// Check if clang set the correct deployment target from -sysroot
-//
-// RUN: rm -rf %t/SDKs/iPhoneOS8.0.0.sdk
-// RUN: mkdir -p %t/SDKs/iPhoneOS8.0.0.sdk
-// RUN: env SDKROOT=%t/SDKs/iPhoneOS8.0.0.sdk %clang -target arm64-apple-darwin %s -### 2>&1 \
-// RUN:   | FileCheck --check-prefix=CHECK-IPHONE %s
-//
-// CHECK-IPHONE: clang
-// CHECK-IPHONE: "-cc1"
-// CHECK-IPHONE: "-triple" "arm64-apple-ios8.0.0"
-// CHECK-IPHONE: ld
-// CHECK-IPHONE: "-iphoneos_version_min" "8.0.0"
-//
-// RUN: rm -rf %t/SDKs/iPhoneSimulator8.0.0.sdk
-// RUN: mkdir -p %t/SDKs/iPhoneSimulator8.0.0.sdk
-// RUN: env SDKROOT=%t/SDKs/iPhoneSimulator8.0.0.sdk %clang -target x86_64-apple-darwin %s -### 2>&1 \
-// RUN:   | FileCheck --check-prefix=CHECK-SIMULATOR %s
-//
-// CHECK-SIMULATOR: clang
-// CHECK-SIMULATOR: "-cc1"
-// CHECK-SIMULATOR: "-triple" "x86_64-apple-ios8.0.0"
-// CHECK-SIMULATOR: ld
-// CHECK-SIMULATOR: "-ios_simulator_version_min" "8.0.0"
-//
-// RUN: rm -rf %t/SDKs/MacOSX10.10.0.sdk
-// RUN: mkdir -p %t/SDKs/MacOSX10.10.0.sdk
-// RUN: env SDKROOT=%t/SDKs/MacOSX10.10.0.sdk %clang -target x86_64-apple-darwin %s -### 2>&1 \
-// RUN:   | FileCheck --check-prefix=CHECK-MACOSX %s
-//
-// CHECK-MACOSX: clang
-// CHECK-MACOSX: "-cc1"
-// CHECK-MACOSX: "-triple" "x86_64-apple-macosx10.10.0"
-// CHECK-MACOSX: ld
-// CHECK-MACOSX: "-macosx_version_min" "10.10.0"