[PATCH] D132258: clang/apple: Infer simulator env from -mios-simulator-version-min flag
Nico Weber via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Aug 22 09:20:49 PDT 2022
This revision was automatically updated to reflect the committed changes.
Closed by commit rG3affbae5300d: clang/apple: Infer simulator env from -mios-simulator-version-min= flag (authored by thakis).
Herald added a project: clang.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D132258/new/
https://reviews.llvm.org/D132258
Files:
clang/lib/Driver/ToolChains/Darwin.cpp
clang/test/Driver/darwin-ld.c
clang/test/Driver/darwin-version.c
Index: clang/test/Driver/darwin-version.c
===================================================================
--- clang/test/Driver/darwin-version.c
+++ clang/test/Driver/darwin-version.c
@@ -48,6 +48,10 @@
// RUN: FileCheck --check-prefix=CHECK-VERSION-IOS10 %s
// CHECK-VERSION-IOS10: x86_64-apple-ios11.0.0-simulator
+// RUN: %clang -target arm64-apple-darwin -mios-simulator-version-min=11.0 -c -### %s 2>&1 | \
+// RUN: FileCheck --check-prefix=CHECK-VERSION-IOS10-ARM64 %s
+// CHECK-VERSION-IOS10-ARM64: arm64-apple-ios11.0.0-simulator
+
// RUN: %clang -target arm64-apple-ios11.1 -c -### %s 2>&1 | \
// RUN: FileCheck --check-prefix=CHECK-VERSION-IOS11 %s
// CHECK-VERSION-IOS11: arm64-apple-ios11.1.0
Index: clang/test/Driver/darwin-ld.c
===================================================================
--- clang/test/Driver/darwin-ld.c
+++ clang/test/Driver/darwin-ld.c
@@ -67,6 +67,10 @@
// LINK_IOSSIM_3_0-NOT: -lbundle1.o
// LINK_IOSSIM_3_0: -lSystem
+// RUN: %clang -target arm64-apple-darwin -fuse-ld= -mlinker-version=700 -### -arch arm64 -mios-simulator-version-min=15.0 %t.o 2>&1 | FileCheck -check-prefix=LINK_IOSSIM_ARM64 %s
+
+// LINK_IOSSIM_ARM64: "-platform_version" "ios-simulator" "15.0.0" "15.0.0"
+
// RUN: %clang -target i386-apple-darwin9 -### -fpie %t.o 2> %t.log
// RUN: FileCheck -check-prefix=LINK_EXPLICIT_PIE %s < %t.log
//
Index: clang/lib/Driver/ToolChains/Darwin.cpp
===================================================================
--- clang/lib/Driver/ToolChains/Darwin.cpp
+++ clang/lib/Driver/ToolChains/Darwin.cpp
@@ -1655,9 +1655,12 @@
Result.setEnvironment(Environment, OSVersion, SDKInfo);
return Result;
}
- static DarwinPlatform createOSVersionArg(DarwinPlatformKind Platform,
- Arg *A) {
- return DarwinPlatform(OSVersionArg, Platform, A);
+ static DarwinPlatform createOSVersionArg(DarwinPlatformKind Platform, Arg *A,
+ bool IsSimulator) {
+ DarwinPlatform Result{OSVersionArg, Platform, A};
+ if (IsSimulator)
+ Result.Environment = DarwinEnvironmentKind::Simulator;
+ return Result;
}
static DarwinPlatform createDeploymentTargetEnv(DarwinPlatformKind Platform,
StringRef EnvVarName,
@@ -1752,23 +1755,33 @@
: TvOSVersion ? TvOSVersion : WatchOSVersion)
->getAsString(Args);
}
- return DarwinPlatform::createOSVersionArg(Darwin::MacOS, macOSVersion);
+ return DarwinPlatform::createOSVersionArg(Darwin::MacOS, macOSVersion,
+ /*IsImulator=*/false);
} else if (iOSVersion) {
if (TvOSVersion || WatchOSVersion) {
TheDriver.Diag(diag::err_drv_argument_not_allowed_with)
<< iOSVersion->getAsString(Args)
<< (TvOSVersion ? TvOSVersion : WatchOSVersion)->getAsString(Args);
}
- return DarwinPlatform::createOSVersionArg(Darwin::IPhoneOS, iOSVersion);
+ return DarwinPlatform::createOSVersionArg(
+ Darwin::IPhoneOS, iOSVersion,
+ iOSVersion->getOption().getID() ==
+ options::OPT_mios_simulator_version_min_EQ);
} else if (TvOSVersion) {
if (WatchOSVersion) {
TheDriver.Diag(diag::err_drv_argument_not_allowed_with)
<< TvOSVersion->getAsString(Args)
<< WatchOSVersion->getAsString(Args);
}
- return DarwinPlatform::createOSVersionArg(Darwin::TvOS, TvOSVersion);
+ return DarwinPlatform::createOSVersionArg(
+ Darwin::TvOS, TvOSVersion,
+ TvOSVersion->getOption().getID() ==
+ options::OPT_mtvos_simulator_version_min_EQ);
} else if (WatchOSVersion)
- return DarwinPlatform::createOSVersionArg(Darwin::WatchOS, WatchOSVersion);
+ return DarwinPlatform::createOSVersionArg(
+ Darwin::WatchOS, WatchOSVersion,
+ WatchOSVersion->getOption().getID() ==
+ options::OPT_mwatchos_simulator_version_min_EQ);
return None;
}
@@ -2228,6 +2241,7 @@
DarwinEnvironmentKind Environment = OSTarget->getEnvironment();
// Recognize iOS targets with an x86 architecture as the iOS simulator.
+ // FIXME: Remove this.
if (Environment == NativeEnvironment && Platform != MacOS &&
Platform != DriverKit && OSTarget->canInferSimulatorFromArch() &&
getTriple().isX86())
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D132258.454538.patch
Type: text/x-patch
Size: 4395 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220822/0ec85764/attachment.bin>
More information about the cfe-commits
mailing list