r329110 - [driver][darwin] Do not infer -simulator environment for non-simulator SDKs
Alex Lorenz via cfe-commits
cfe-commits at lists.llvm.org
Tue Apr 3 13:50:06 PDT 2018
Author: arphaman
Date: Tue Apr 3 13:50:05 2018
New Revision: 329110
URL: http://llvm.org/viewvc/llvm-project?rev=329110&view=rev
Log:
[driver][darwin] Do not infer -simulator environment for non-simulator SDKs
rdar://36369832
Modified:
cfe/trunk/lib/Driver/ToolChains/Darwin.cpp
cfe/trunk/test/Driver/darwin-sdkroot.c
Modified: cfe/trunk/lib/Driver/ToolChains/Darwin.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Driver/ToolChains/Darwin.cpp?rev=329110&r1=329109&r2=329110&view=diff
==============================================================================
--- cfe/trunk/lib/Driver/ToolChains/Darwin.cpp (original)
+++ cfe/trunk/lib/Driver/ToolChains/Darwin.cpp Tue Apr 3 13:50:05 2018
@@ -1211,6 +1211,9 @@ struct DarwinPlatform {
/// Returns true if the target OS was explicitly specified.
bool isExplicitlySpecified() const { return Kind <= DeploymentTargetEnv; }
+ /// Returns true if the simulator environment can be inferred from the arch.
+ bool canInferSimulatorFromArch() const { return Kind != InferredFromSDK; }
+
/// Adds the -m<os>-version-min argument to the compiler invocation.
void addOSVersionMinArgument(DerivedArgList &Args, const OptTable &Opts) {
if (Argument)
@@ -1280,8 +1283,12 @@ struct DarwinPlatform {
return Result;
}
static DarwinPlatform createFromSDK(DarwinPlatformKind Platform,
- StringRef Value) {
- return DarwinPlatform(InferredFromSDK, Platform, Value);
+ StringRef Value,
+ bool IsSimulator = false) {
+ DarwinPlatform Result(InferredFromSDK, Platform, Value);
+ if (IsSimulator)
+ Result.Environment = DarwinEnvironmentKind::Simulator;
+ return Result;
}
static DarwinPlatform createFromArch(llvm::Triple::OSType OS,
StringRef Value) {
@@ -1437,14 +1444,20 @@ Optional<DarwinPlatform> inferDeployment
if (StartVer != StringRef::npos && EndVer > StartVer) {
StringRef Version = SDK.slice(StartVer, EndVer + 1);
if (SDK.startswith("iPhoneOS") || SDK.startswith("iPhoneSimulator"))
- return DarwinPlatform::createFromSDK(Darwin::IPhoneOS, Version);
+ return DarwinPlatform::createFromSDK(
+ Darwin::IPhoneOS, Version,
+ /*IsSimulator=*/SDK.startswith("iPhoneSimulator"));
else if (SDK.startswith("MacOSX"))
return DarwinPlatform::createFromSDK(Darwin::MacOS,
getSystemOrSDKMacOSVersion(Version));
else if (SDK.startswith("WatchOS") || SDK.startswith("WatchSimulator"))
- return DarwinPlatform::createFromSDK(Darwin::WatchOS, Version);
+ return DarwinPlatform::createFromSDK(
+ Darwin::WatchOS, Version,
+ /*IsSimulator=*/SDK.startswith("WatchSimulator"));
else if (SDK.startswith("AppleTVOS") || SDK.startswith("AppleTVSimulator"))
- return DarwinPlatform::createFromSDK(Darwin::TvOS, Version);
+ return DarwinPlatform::createFromSDK(
+ Darwin::TvOS, Version,
+ /*IsSimulator=*/SDK.startswith("AppleTVSimulator"));
}
return None;
}
@@ -1645,6 +1658,7 @@ void Darwin::AddDeploymentTarget(Derived
DarwinEnvironmentKind Environment = OSTarget->getEnvironment();
// Recognize iOS targets with an x86 architecture as the iOS simulator.
if (Environment == NativeEnvironment && Platform != MacOS &&
+ OSTarget->canInferSimulatorFromArch() &&
(getTriple().getArch() == llvm::Triple::x86 ||
getTriple().getArch() == llvm::Triple::x86_64))
Environment = Simulator;
Modified: cfe/trunk/test/Driver/darwin-sdkroot.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Driver/darwin-sdkroot.c?rev=329110&r1=329109&r2=329110&view=diff
==============================================================================
--- cfe/trunk/test/Driver/darwin-sdkroot.c (original)
+++ cfe/trunk/test/Driver/darwin-sdkroot.c Tue Apr 3 13:50:05 2018
@@ -51,12 +51,21 @@
// CHECK-IPHONE: "-triple" "arm64-apple-ios8.0.0"
// CHECK-IPHONE: ld
// CHECK-IPHONE: "-iphoneos_version_min" "8.0.0"
+// RUN: env SDKROOT=%t/SDKs/iPhoneOS8.0.0.sdk %clang %s -### 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-IPHONE-X86 %s
+// CHECK-IPHONE-X86: clang
+// CHECK-IPHONE-X86: "-cc1"
+// CHECK-IPHONE-X86: -apple-ios8.0.0"
+// CHECK-IPHONE-X86: ld
+// CHECK-IPHONE-X86: "-iphoneos_version_min" "8.0.0"
//
//
// RUN: rm -rf %t/SDKs/iPhoneSimulator8.0.sdk
// RUN: mkdir -p %t/SDKs/iPhoneSimulator8.0.sdk
// RUN: env SDKROOT=%t/SDKs/iPhoneSimulator8.0.sdk %clang -target x86_64-apple-darwin %s -### 2>&1 \
// RUN: | FileCheck --check-prefix=CHECK-SIMULATOR %s
+// RUN: env SDKROOT=%t/SDKs/iPhoneSimulator8.0.sdk %clang -arch x86_64 %s -### 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-SIMULATOR %s
//
// CHECK-SIMULATOR: clang
// CHECK-SIMULATOR: "-cc1"
@@ -74,3 +83,49 @@
// CHECK-MACOSX: "-triple" "x86_64-apple-macosx10.10.0"
// CHECK-MACOSX: ld
// CHECK-MACOSX: "-macosx_version_min" "10.10.0"
+
+// RUN: rm -rf %t/SDKs/WatchOS3.0.sdk
+// RUN: mkdir -p %t/SDKs/WatchOS3.0.sdk
+// RUN: env SDKROOT=%t/SDKs/WatchOS3.0.sdk %clang %s -### 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-WATCH %s
+//
+// CHECK-WATCH: clang
+// CHECK-WATCH: "-cc1"
+// CHECK-WATCH: -apple-watchos3.0.0"
+// CHECK-WATCH: ld
+// CHECK-WATCH: "-watchos_version_min" "3.0.0"
+//
+//
+// RUN: rm -rf %t/SDKs/WatchSimulator3.0.sdk
+// RUN: mkdir -p %t/SDKs/WatchSimulator3.0.sdk
+// RUN: env SDKROOT=%t/SDKs/WatchSimulator3.0.sdk %clang %s -### 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-WATCH-SIMULATOR %s
+//
+// CHECK-WATCH-SIMULATOR: clang
+// CHECK-WATCH-SIMULATOR: "-cc1"
+// CHECK-WATCH-SIMULATOR: -apple-watchos3.0.0-simulator"
+// CHECK-WATCH-SIMULATOR: ld
+// CHECK-WATCH-SIMULATOR: "-watchos_simulator_version_min" "3.0.0"
+
+// RUN: rm -rf %t/SDKs/AppleTVOS10.0.sdk
+// RUN: mkdir -p %t/SDKs/AppleTVOS10.0.sdk
+// RUN: env SDKROOT=%t/SDKs/AppleTVOS10.0.sdk %clang %s -### 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-TV %s
+//
+// CHECK-TV: clang
+// CHECK-TV: "-cc1"
+// CHECK-TV: -apple-tvos10.0.0"
+// CHECK-TV: ld
+// CHECK-TV: "-tvos_version_min" "10.0.0"
+//
+//
+// RUN: rm -rf %t/SDKs/AppleTVSimulator10.0.sdk
+// RUN: mkdir -p %t/SDKs/AppleTVSimulator10.0.sdk
+// RUN: env SDKROOT=%t/SDKs/AppleTVSimulator10.0.sdk %clang %s -### 2>&1 \
+// RUN: | FileCheck --check-prefix=CHECK-TV-SIMULATOR %s
+//
+// CHECK-TV-SIMULATOR: clang
+// CHECK-TV-SIMULATOR: "-cc1"
+// CHECK-TV-SIMULATOR: -apple-tvos10.0.0-simulator"
+// CHECK-TV-SIMULATOR: ld
+// CHECK-TV-SIMULATOR: "-tvos_simulator_version_min" "10.0.0"
More information about the cfe-commits
mailing list