[clang] 25ce33a - [driver][darwin] Pass -platform_version flag to the linker instead of the -<platform>_version_min flag
Alex Lorenz via cfe-commits
cfe-commits at lists.llvm.org
Tue Dec 17 10:28:20 PST 2019
Author: Alex Lorenz
Date: 2019-12-17T10:26:32-08:00
New Revision: 25ce33a6e4f3b13732c0f851e68390dc2acb9123
URL: https://github.com/llvm/llvm-project/commit/25ce33a6e4f3b13732c0f851e68390dc2acb9123
DIFF: https://github.com/llvm/llvm-project/commit/25ce33a6e4f3b13732c0f851e68390dc2acb9123.diff
LOG: [driver][darwin] Pass -platform_version flag to the linker instead of the -<platform>_version_min flag
In Xcode 11, ld added a new flag called -platform_version that can be used instead of the old -<platform>_version_min flags.
The new flag allows Clang to pass the SDK version from the driver to the linker.
This patch adopts the new -platform_version flag in Clang, and starts using it by default,
unless a linker version < 520 is passed to the driver.
Differential Revision: https://reviews.llvm.org/D71579
Added:
clang/test/Driver/Inputs/WatchOS6.0.sdk/SDKSettings.json
clang/test/Driver/Inputs/iPhoneOS13.0.sdk/SDKSettings.json
clang/test/Driver/darwin-ld-platform-version-ios.c
clang/test/Driver/darwin-ld-platform-version-macos.c
clang/test/Driver/darwin-ld-platform-version-tvos.c
clang/test/Driver/darwin-ld-platform-version-watchos.c
Modified:
clang/lib/Driver/ToolChains/Darwin.cpp
clang/lib/Driver/ToolChains/Darwin.h
clang/test/Driver/darwin-infer-simulator-sdkroot.c
clang/test/Driver/darwin-ld.c
clang/test/Driver/darwin-sdkroot.c
clang/test/Driver/target-triple-deployment.c
llvm/include/llvm/Support/VersionTuple.h
Removed:
################################################################################
diff --git a/clang/lib/Driver/ToolChains/Darwin.cpp b/clang/lib/Driver/ToolChains/Darwin.cpp
index 75a47d2c3a23..5725a326ca5f 100644
--- a/clang/lib/Driver/ToolChains/Darwin.cpp
+++ b/clang/lib/Driver/ToolChains/Darwin.cpp
@@ -336,7 +336,10 @@ void darwin::Linker::AddLinkArgs(Compilation &C, const ArgList &Args,
Args.AddAllArgs(CmdArgs, options::OPT_init);
// Add the deployment target.
- MachOTC.addMinVersionArgs(Args, CmdArgs);
+ if (!Version[0] || Version[0] >= 520)
+ MachOTC.addPlatformVersionArgs(Args, CmdArgs);
+ else
+ MachOTC.addMinVersionArgs(Args, CmdArgs);
Args.AddLastArg(CmdArgs, options::OPT_nomultidefs);
Args.AddLastArg(CmdArgs, options::OPT_multi__module);
@@ -2515,6 +2518,45 @@ void Darwin::addMinVersionArgs(const ArgList &Args,
CmdArgs.push_back(Args.MakeArgString(TargetVersion.getAsString()));
}
+static const char *getPlatformName(Darwin::DarwinPlatformKind Platform,
+ Darwin::DarwinEnvironmentKind Environment) {
+ switch (Platform) {
+ case Darwin::MacOS:
+ return "macos";
+ case Darwin::IPhoneOS:
+ if (Environment == Darwin::NativeEnvironment ||
+ Environment == Darwin::Simulator)
+ return "ios";
+ // FIXME: Add macCatalyst support here ("\"mac catalyst\"").
+ llvm_unreachable("macCatalyst isn't yet supported");
+ case Darwin::TvOS:
+ return "tvos";
+ case Darwin::WatchOS:
+ return "watchos";
+ }
+ llvm_unreachable("invalid platform");
+}
+
+void Darwin::addPlatformVersionArgs(const llvm::opt::ArgList &Args,
+ llvm::opt::ArgStringList &CmdArgs) const {
+ // -platform_version <platform> <target_version> <sdk_version>
+ // Both the target and SDK version support only up to 3 components.
+ CmdArgs.push_back("-platform_version");
+ std::string PlatformName = getPlatformName(TargetPlatform, TargetEnvironment);
+ if (TargetEnvironment == Darwin::Simulator)
+ PlatformName += "-simulator";
+ CmdArgs.push_back(Args.MakeArgString(PlatformName));
+ VersionTuple TargetVersion = getTargetVersion().withoutBuild();
+ CmdArgs.push_back(Args.MakeArgString(TargetVersion.getAsString()));
+ if (SDKInfo) {
+ VersionTuple SDKVersion = SDKInfo->getVersion().withoutBuild();
+ CmdArgs.push_back(Args.MakeArgString(SDKVersion.getAsString()));
+ } else {
+ // Use a blank SDK version if it's not present.
+ CmdArgs.push_back("0.0.0");
+ }
+}
+
void Darwin::addStartObjectFileArgs(const ArgList &Args,
ArgStringList &CmdArgs) const {
// Derived from startfile spec.
diff --git a/clang/lib/Driver/ToolChains/Darwin.h b/clang/lib/Driver/ToolChains/Darwin.h
index 1b1c358c40a4..1b193a4c4eb9 100644
--- a/clang/lib/Driver/ToolChains/Darwin.h
+++ b/clang/lib/Driver/ToolChains/Darwin.h
@@ -167,6 +167,10 @@ class LLVM_LIBRARY_VISIBILITY MachO : public ToolChain {
virtual void addMinVersionArgs(const llvm::opt::ArgList &Args,
llvm::opt::ArgStringList &CmdArgs) const {}
+ virtual void addPlatformVersionArgs(const llvm::opt::ArgList &Args,
+ llvm::opt::ArgStringList &CmdArgs) const {
+ }
+
/// On some iOS platforms, kernel and kernel modules were built statically. Is
/// this such a target?
virtual bool isKernelStatic() const { return false; }
@@ -314,6 +318,9 @@ class LLVM_LIBRARY_VISIBILITY Darwin : public MachO {
void addMinVersionArgs(const llvm::opt::ArgList &Args,
llvm::opt::ArgStringList &CmdArgs) const override;
+ void addPlatformVersionArgs(const llvm::opt::ArgList &Args,
+ llvm::opt::ArgStringList &CmdArgs) const override;
+
void addStartObjectFileArgs(const llvm::opt::ArgList &Args,
llvm::opt::ArgStringList &CmdArgs) const override;
diff --git a/clang/test/Driver/Inputs/WatchOS6.0.sdk/SDKSettings.json b/clang/test/Driver/Inputs/WatchOS6.0.sdk/SDKSettings.json
new file mode 100644
index 000000000000..b78b8c1ca56d
--- /dev/null
+++ b/clang/test/Driver/Inputs/WatchOS6.0.sdk/SDKSettings.json
@@ -0,0 +1 @@
+{"Version":"6.0.0"}
diff --git a/clang/test/Driver/Inputs/iPhoneOS13.0.sdk/SDKSettings.json b/clang/test/Driver/Inputs/iPhoneOS13.0.sdk/SDKSettings.json
new file mode 100644
index 000000000000..04cb1644cd70
--- /dev/null
+++ b/clang/test/Driver/Inputs/iPhoneOS13.0.sdk/SDKSettings.json
@@ -0,0 +1 @@
+{"Version":"13.0"}
diff --git a/clang/test/Driver/darwin-infer-simulator-sdkroot.c b/clang/test/Driver/darwin-infer-simulator-sdkroot.c
index 3fda5998addb..a084bf6346b6 100644
--- a/clang/test/Driver/darwin-infer-simulator-sdkroot.c
+++ b/clang/test/Driver/darwin-infer-simulator-sdkroot.c
@@ -4,9 +4,9 @@
//
// 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 %s -### 2>&1 \
+// RUN: env SDKROOT=%t/SDKs/iPhoneOS8.0.0.sdk %clang %s -mlinker-version=400 -### 2>&1 \
// RUN: | FileCheck --check-prefix=CHECK-IPHONE %s
-// RUN: env SDKROOT=%t/SDKs/iPhoneOS8.0.0.sdk IPHONEOS_DEPLOYMENT_TARGET=8.0 %clang %s -### 2>&1 \
+// RUN: env SDKROOT=%t/SDKs/iPhoneOS8.0.0.sdk IPHONEOS_DEPLOYMENT_TARGET=8.0 %clang %s -mlinker-version=400 -### 2>&1 \
// RUN: | FileCheck --check-prefix=CHECK-IPHONE %s
// CHECK-IPHONE: clang
// CHECK-IPHONE: "-cc1"
@@ -17,7 +17,7 @@
//
// 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 %s -### 2>&1 \
+// RUN: env SDKROOT=%t/SDKs/iPhoneSimulator8.0.sdk %clang %s -mlinker-version=400 -### 2>&1 \
// RUN: | FileCheck --check-prefix=CHECK-SIMULATOR %s
//
// CHECK-SIMULATOR: clang
@@ -29,9 +29,9 @@
//
// 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: env SDKROOT=%t/SDKs/WatchOS3.0.sdk %clang %s -mlinker-version=400 -### 2>&1 \
// RUN: | FileCheck --check-prefix=CHECK-WATCH %s
-// RUN: env WATCHOS_DEPLOYMENT_TARGET=3.0 %clang %s -isysroot %t/SDKs/WatchOS3.0.sdk -### 2>&1 \
+// RUN: env WATCHOS_DEPLOYMENT_TARGET=3.0 %clang %s -isysroot %t/SDKs/WatchOS3.0.sdk -mlinker-version=400 -### 2>&1 \
// RUN: | FileCheck --check-prefix=CHECK-WATCH %s
//
// CHECK-WATCH: clang
@@ -43,7 +43,7 @@
//
// 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: env SDKROOT=%t/SDKs/WatchSimulator3.0.sdk %clang %s -mlinker-version=400 -### 2>&1 \
// RUN: | FileCheck --check-prefix=CHECK-WATCH-SIMULATOR %s
//
// CHECK-WATCH-SIMULATOR: clang
@@ -55,7 +55,7 @@
//
// 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: env SDKROOT=%t/SDKs/AppleTVOS10.0.sdk %clang %s -mlinker-version=400 -### 2>&1 \
// RUN: | FileCheck --check-prefix=CHECK-TV %s
//
// CHECK-TV: clang
@@ -67,7 +67,7 @@
//
// 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: env SDKROOT=%t/SDKs/AppleTVSimulator10.0.sdk %clang %s -mlinker-version=400 -### 2>&1 \
// RUN: | FileCheck --check-prefix=CHECK-TV-SIMULATOR %s
//
// CHECK-TV-SIMULATOR: clang
diff --git a/clang/test/Driver/darwin-ld-platform-version-ios.c b/clang/test/Driver/darwin-ld-platform-version-ios.c
new file mode 100644
index 000000000000..157aa18bc32f
--- /dev/null
+++ b/clang/test/Driver/darwin-ld-platform-version-ios.c
@@ -0,0 +1,9 @@
+// RUN: touch %t.o
+
+// RUN: %clang -target arm64-apple-ios12.3 -isysroot %S/Inputs/iPhoneOS13.0.sdk -### %t.o 2>&1 \
+// RUN: | FileCheck %s
+// RUN: %clang -target x86_64-apple-ios13-simulator -isysroot %S/Inputs/iPhoneOS13.0.sdk -### %t.o 2>&1 \
+// RUN: | FileCheck --check-prefix=SIMUL %s
+
+// CHECK: "-platform_version" "ios" "12.3.0" "13.0"
+// SIMUL: "-platform_version" "ios-simulator" "13.0.0" "13.0"
diff --git a/clang/test/Driver/darwin-ld-platform-version-macos.c b/clang/test/Driver/darwin-ld-platform-version-macos.c
new file mode 100644
index 000000000000..1e86a28b05b6
--- /dev/null
+++ b/clang/test/Driver/darwin-ld-platform-version-macos.c
@@ -0,0 +1,12 @@
+// RUN: touch %t.o
+
+// RUN: %clang -target x86_64-apple-macos10.13 -isysroot %S/Inputs/MacOSX10.14.sdk -### %t.o 2>&1 \
+// RUN: | FileCheck %s
+// RUN: env SDKROOT=%S/Inputs/MacOSX10.14.sdk %clang -target x86_64-apple-macos10.13.0.1 -mlinker-version=520 -### %t.o 2>&1 \
+// RUN: | FileCheck %s
+
+// CHECK: "-platform_version" "macos" "10.13.0" "10.14"
+
+// RUN: %clang -target x86_64-apple-macos10.13 -### %t.o 2>&1 \
+// RUN: | FileCheck --check-prefix=NOSDK %s
+// NOSDK: "-platform_version" "macos" "10.13.0" "0.0.0"
diff --git a/clang/test/Driver/darwin-ld-platform-version-tvos.c b/clang/test/Driver/darwin-ld-platform-version-tvos.c
new file mode 100644
index 000000000000..cb32f7096f5c
--- /dev/null
+++ b/clang/test/Driver/darwin-ld-platform-version-tvos.c
@@ -0,0 +1,9 @@
+// RUN: touch %t.o
+
+// RUN: %clang -target arm64-apple-tvos12.3 -isysroot %S/Inputs/iPhoneOS13.0.sdk -### %t.o 2>&1 \
+// RUN: | FileCheck %s
+// RUN: %clang -target x86_64-apple-tvos13-simulator -isysroot %S/Inputs/iPhoneOS13.0.sdk -### %t.o 2>&1 \
+// RUN: | FileCheck --check-prefix=SIMUL %s
+
+// CHECK: "-platform_version" "tvos" "12.3.0" "13.0"
+// SIMUL: "-platform_version" "tvos-simulator" "13.0.0" "13.0"
diff --git a/clang/test/Driver/darwin-ld-platform-version-watchos.c b/clang/test/Driver/darwin-ld-platform-version-watchos.c
new file mode 100644
index 000000000000..f2666b014f0e
--- /dev/null
+++ b/clang/test/Driver/darwin-ld-platform-version-watchos.c
@@ -0,0 +1,9 @@
+// RUN: touch %t.o
+
+// RUN: %clang -target arm64_32-apple-watchos5.2 -isysroot %S/Inputs/WatchOS6.0.sdk -### %t.o 2>&1 \
+// RUN: | FileCheck %s
+// RUN: %clang -target x86_64-apple-watchos6-simulator -isysroot %S/Inputs/WatchOS6.0.sdk -### %t.o 2>&1 \
+// RUN: | FileCheck --check-prefix=SIMUL %s
+
+// CHECK: "-platform_version" "watchos" "5.2.0" "6.0.0"
+// SIMUL: "-platform_version" "watchos-simulator" "6.0.0" "6.0.0"
diff --git a/clang/test/Driver/darwin-ld.c b/clang/test/Driver/darwin-ld.c
index 420dda357f8b..001ed871efe6 100644
--- a/clang/test/Driver/darwin-ld.c
+++ b/clang/test/Driver/darwin-ld.c
@@ -11,9 +11,9 @@
// Check linker changes that came with new linkedit format.
// RUN: touch %t.o
-// RUN: %clang -target i386-apple-darwin9 -### -arch armv6 -miphoneos-version-min=3.0 %t.o 2> %t.log
-// RUN: %clang -target i386-apple-darwin9 -### -arch armv6 -miphoneos-version-min=3.0 -dynamiclib %t.o 2>> %t.log
-// RUN: %clang -target i386-apple-darwin9 -### -arch armv6 -miphoneos-version-min=3.0 -bundle %t.o 2>> %t.log
+// RUN: %clang -target i386-apple-darwin9 -mlinker-version=400 -### -arch armv6 -miphoneos-version-min=3.0 %t.o 2> %t.log
+// RUN: %clang -target i386-apple-darwin9 -mlinker-version=400 -### -arch armv6 -miphoneos-version-min=3.0 -dynamiclib %t.o 2>> %t.log
+// RUN: %clang -target i386-apple-darwin9 -mlinker-version=400 -### -arch armv6 -miphoneos-version-min=3.0 -bundle %t.o 2>> %t.log
// RUN: FileCheck -check-prefix=LINK_IPHONE_3_0 %s < %t.log
// LINK_IPHONE_3_0: {{ld(.exe)?"}}
@@ -30,9 +30,9 @@
// LINK_IPHONE_3_0: -lbundle1.o
// LINK_IPHONE_3_0: -lSystem
-// RUN: %clang -target i386-apple-darwin9 -### -arch armv7 -miphoneos-version-min=3.1 %t.o 2> %t.log
-// RUN: %clang -target i386-apple-darwin9 -### -arch armv7 -miphoneos-version-min=3.1 -dynamiclib %t.o 2>> %t.log
-// RUN: %clang -target i386-apple-darwin9 -### -arch armv7 -miphoneos-version-min=3.1 -bundle %t.o 2>> %t.log
+// RUN: %clang -target i386-apple-darwin9 -mlinker-version=400 -### -arch armv7 -miphoneos-version-min=3.1 %t.o 2> %t.log
+// RUN: %clang -target i386-apple-darwin9 -mlinker-version=400 -### -arch armv7 -miphoneos-version-min=3.1 -dynamiclib %t.o 2>> %t.log
+// RUN: %clang -target i386-apple-darwin9 -mlinker-version=400 -### -arch armv7 -miphoneos-version-min=3.1 -bundle %t.o 2>> %t.log
// RUN: FileCheck -check-prefix=LINK_IPHONE_3_1 %s < %t.log
// LINK_IPHONE_3_1: {{ld(.exe)?"}}
@@ -49,9 +49,9 @@
// LINK_IPHONE_3_1-NOT: -lbundle1.o
// LINK_IPHONE_3_1: -lSystem
-// RUN: %clang -target i386-apple-darwin9 -### -arch i386 -mios-simulator-version-min=3.0 %t.o 2> %t.log
-// RUN: %clang -target i386-apple-darwin9 -### -arch i386 -mios-simulator-version-min=3.0 -dynamiclib %t.o 2>> %t.log
-// RUN: %clang -target i386-apple-darwin9 -### -arch i386 -mios-simulator-version-min=3.0 -bundle %t.o 2>> %t.log
+// RUN: %clang -target i386-apple-darwin9 -mlinker-version=400 -### -arch i386 -mios-simulator-version-min=3.0 %t.o 2> %t.log
+// RUN: %clang -target i386-apple-darwin9 -mlinker-version=400 -### -arch i386 -mios-simulator-version-min=3.0 -dynamiclib %t.o 2>> %t.log
+// RUN: %clang -target i386-apple-darwin9 -mlinker-version=400 -### -arch i386 -mios-simulator-version-min=3.0 -bundle %t.o 2>> %t.log
// RUN: FileCheck -check-prefix=LINK_IOSSIM_3_0 %s < %t.log
// LINK_IOSSIM_3_0: {{ld(.exe)?"}}
@@ -132,8 +132,8 @@
// LINK_LAZY_LIBRARY: {{ld(.exe)?"}}
// LINK_LAZY_LIBRARY: "-lazy_library" "Library"
-// RUN: %clang -target x86_64-apple-darwin10 -### %t.o 2> %t.log
-// RUN: %clang -target x86_64-apple-macosx10.7 -### %t.o 2>> %t.log
+// RUN: %clang -target x86_64-apple-darwin10 -mlinker-version=400 -### %t.o 2> %t.log
+// RUN: %clang -target x86_64-apple-macosx10.7 -mlinker-version=400 -### %t.o 2>> %t.log
// RUN: FileCheck -check-prefix=LINK_VERSION_MIN %s < %t.log
// LINK_VERSION_MIN: {{ld(.exe)?"}}
// LINK_VERSION_MIN: "-macosx_version_min" "10.6.0"
@@ -158,7 +158,7 @@
// LINK_IOSSIM_PROFILE: libclang_rt.profile_iossim.a
// LINK_IOSSIM_PROFILE: libclang_rt.ios.a
-// RUN: %clang -target arm64-apple-tvos8.3 -mtvos-version-min=8.3 -resource-dir=%S/Inputs/resource_dir -### %t.o 2> %t.log
+// RUN: %clang -target arm64-apple-tvos8.3 -mlinker-version=400 -mtvos-version-min=8.3 -resource-dir=%S/Inputs/resource_dir -### %t.o 2> %t.log
// RUN: FileCheck -check-prefix=LINK_TVOS_ARM64 %s < %t.log
// LINK_TVOS_ARM64: {{ld(.exe)?"}}
// LINK_TVOS_ARM64: -tvos_version_min
@@ -166,19 +166,19 @@
// LINK_TVOS_ARM64-NOT: lgcc_s.1
// LINK_TVOS_ARM64: libclang_rt.tvos.a
-// RUN: %clang -target arm64-apple-tvos8.3 -mtvos-version-min=8.3 -fprofile-instr-generate -resource-dir=%S/Inputs/resource_dir -### %t.o 2> %t.log
+// RUN: %clang -target arm64-apple-tvos8.3 -mlinker-version=400 -mtvos-version-min=8.3 -fprofile-instr-generate -resource-dir=%S/Inputs/resource_dir -### %t.o 2> %t.log
// RUN: FileCheck -check-prefix=LINK_TVOS_PROFILE %s < %t.log
// LINK_TVOS_PROFILE: {{ld(.exe)?"}}
// LINK_TVOS_PROFILE: libclang_rt.profile_tvos.a
// LINK_TVOS_PROFILE: libclang_rt.tvos.a
-// RUN: %clang -target arm64-apple-tvos8.3 -mtvos-version-min=8.3 -resource-dir=%S/Inputs/resource_dir -### %t.o -lcc_kext 2> %t.log
+// RUN: %clang -target arm64-apple-tvos8.3 -mlinker-version=400 -mtvos-version-min=8.3 -resource-dir=%S/Inputs/resource_dir -### %t.o -lcc_kext 2> %t.log
// RUN: FileCheck -check-prefix=LINK_TVOS_KEXT %s < %t.log
// LINK_TVOS_KEXT: {{ld(.exe)?"}}
// LINK_TVOS_KEXT: libclang_rt.cc_kext_tvos.a
// LINK_TVOS_KEXT: libclang_rt.tvos.a
-// RUN: %clang -target armv7k-apple-watchos2.0 -mwatchos-version-min=2.0 -resource-dir=%S/Inputs/resource_dir -### %t.o 2> %t.log
+// RUN: %clang -target armv7k-apple-watchos2.0 -mlinker-version=400 -mwatchos-version-min=2.0 -resource-dir=%S/Inputs/resource_dir -### %t.o 2> %t.log
// RUN: FileCheck -check-prefix=LINK_WATCHOS_ARM %s < %t.log
// LINK_WATCHOS_ARM: {{ld(.exe)?"}}
// LINK_WATCHOS_ARM: -watchos_version_min
@@ -186,13 +186,13 @@
// LINK_WATCHOS_ARM-NOT: lgcc_s.1
// LINK_WATCHOS_ARM: libclang_rt.watchos.a
-// RUN: %clang -target armv7k-apple-watchos2.0 -mwatchos-version-min=2.0 -resource-dir=%S/Inputs/resource_dir -fprofile-instr-generate -### %t.o 2> %t.log
+// RUN: %clang -target armv7k-apple-watchos2.0 -mlinker-version=400 -mwatchos-version-min=2.0 -resource-dir=%S/Inputs/resource_dir -fprofile-instr-generate -### %t.o 2> %t.log
// RUN: FileCheck -check-prefix=LINK_WATCHOS_PROFILE %s < %t.log
// LINK_WATCHOS_PROFILE: {{ld(.exe)?"}}
// LINK_WATCHOS_PROFILE: libclang_rt.profile_watchos.a
// LINK_WATCHOS_PROFILE: libclang_rt.watchos.a
-// RUN: %clang -target armv7k-apple-watchos2.0 -mwatchos-version-min=2.0 -resource-dir=%S/Inputs/resource_dir -### %t.o -lcc_kext 2> %t.log
+// RUN: %clang -target armv7k-apple-watchos2.0 -mlinker-version=400 -mwatchos-version-min=2.0 -resource-dir=%S/Inputs/resource_dir -### %t.o -lcc_kext 2> %t.log
// RUN: FileCheck -check-prefix=LINK_WATCHOS_KEXT %s < %t.log
// LINK_WATCHOS_KEXT: {{ld(.exe)?"}}
// LINK_WATCHOS_KEXT: libclang_rt.cc_kext_watchos.a
@@ -251,30 +251,30 @@
// IPHONEOS_DEPLOYMENT_TARGET variable is used instead of the command-line
// deployment target options.
// RUN: env IPHONEOS_DEPLOYMENT_TARGET=7.0 \
-// RUN: %clang -target arm64-apple-darwin -### %t.o 2> %t.log
+// RUN: %clang -target arm64-apple-darwin -mlinker-version=400 -### %t.o 2> %t.log
// RUN: FileCheck -check-prefix=LINK_IPHONEOS_VERSION_MIN %s < %t.log
// RUN: env IPHONEOS_DEPLOYMENT_TARGET=7.0 \
-// RUN: %clang -target i386-apple-darwin -### %t.o 2> %t.log
+// RUN: %clang -target i386-apple-darwin -mlinker-version=400 -### %t.o 2> %t.log
// RUN: FileCheck -check-prefix=LINK_IOS_SIMULATOR_VERSION_MIN %s < %t.log
// LINK_IPHONEOS_VERSION_MIN: -iphoneos_version_min
// LINK_IOS_SIMULATOR_VERSION_MIN: -ios_simulator_version_min
// Ditto for tvOS....
// RUN: env TVOS_DEPLOYMENT_TARGET=7.0 \
-// RUN: %clang -target armv7-apple-darwin -### %t.o 2> %t.log
+// RUN: %clang -target armv7-apple-darwin -mlinker-version=400 -### %t.o 2> %t.log
// RUN: FileCheck -check-prefix=LINK_TVOS_VERSION_MIN %s < %t.log
// RUN: env TVOS_DEPLOYMENT_TARGET=7.0 \
-// RUN: %clang -target x86_64-apple-darwin -### %t.o 2> %t.log
+// RUN: %clang -target x86_64-apple-darwin -mlinker-version=400 -### %t.o 2> %t.log
// RUN: FileCheck -check-prefix=LINK_TVOS_SIMULATOR_VERSION_MIN %s < %t.log
// LINK_TVOS_VERSION_MIN: -tvos_version_min
// LINK_TVOS_SIMULATOR_VERSION_MIN: -tvos_simulator_version_min
// ...and for watchOS.
// RUN: env WATCHOS_DEPLOYMENT_TARGET=2.0 \
-// RUN: %clang -target armv7k-apple-darwin -### %t.o 2> %t.log
+// RUN: %clang -target armv7k-apple-darwin -mlinker-version=400 -### %t.o 2> %t.log
// RUN: FileCheck -check-prefix=LINK_WATCHOS_VERSION_MIN %s < %t.log
// RUN: env WATCHOS_DEPLOYMENT_TARGET=2.0 \
-// RUN: %clang -target i386-apple-darwin -### %t.o 2> %t.log
+// RUN: %clang -target i386-apple-darwin -mlinker-version=400 -### %t.o 2> %t.log
// RUN: FileCheck -check-prefix=LINK_WATCHOS_SIMULATOR_VERSION_MIN %s < %t.log
// LINK_WATCHOS_VERSION_MIN: -watchos_version_min
// LINK_WATCHOS_SIMULATOR_VERSION_MIN: -watchos_simulator_version_min
diff --git a/clang/test/Driver/darwin-sdkroot.c b/clang/test/Driver/darwin-sdkroot.c
index 700993fa96a6..fae0d440959c 100644
--- a/clang/test/Driver/darwin-sdkroot.c
+++ b/clang/test/Driver/darwin-sdkroot.c
@@ -43,7 +43,7 @@
//
// 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 --sysroot="" %s -### 2>&1 \
+// RUN: env SDKROOT=%t/SDKs/iPhoneOS8.0.0.sdk %clang -target arm64-apple-darwin -mlinker-version=400 --sysroot="" %s -### 2>&1 \
// RUN: | FileCheck --check-prefix=CHECK-IPHONE %s
//
// CHECK-IPHONE: clang
@@ -55,7 +55,7 @@
//
// 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 --sysroot="" %s -### 2>&1 \
+// RUN: env SDKROOT=%t/SDKs/iPhoneSimulator8.0.sdk %clang -target x86_64-apple-darwin -mlinker-version=400 --sysroot="" %s -### 2>&1 \
// RUN: | FileCheck --check-prefix=CHECK-SIMULATOR %s
//
// CHECK-SIMULATOR: clang
@@ -66,7 +66,7 @@
//
// 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 --sysroot="" %s -### 2>&1 \
+// RUN: env SDKROOT=%t/SDKs/MacOSX10.10.0.sdk %clang -target x86_64-apple-darwin -mlinker-version=400 --sysroot="" %s -### 2>&1 \
// RUN: | FileCheck --check-prefix=CHECK-MACOSX %s
//
// CHECK-MACOSX: clang
diff --git a/clang/test/Driver/target-triple-deployment.c b/clang/test/Driver/target-triple-deployment.c
index b59f81a0106f..351f2ac2cdca 100644
--- a/clang/test/Driver/target-triple-deployment.c
+++ b/clang/test/Driver/target-triple-deployment.c
@@ -1,14 +1,14 @@
// RUN: touch %t.o
-// RUN: %clang -target x86_64-apple-macosx10.4 -### %t.o 2> %t.log
-// RUN: %clang -target x86_64-apple-darwin9 -### %t.o 2>> %t.log
-// RUN: %clang -target x86_64-apple-macosx10.7 -### %t.o 2>> %t.log
+// RUN: %clang -target x86_64-apple-macosx10.4 -mlinker-version=400 -### %t.o 2> %t.log
+// RUN: %clang -target x86_64-apple-darwin9 -mlinker-version=400 -### %t.o 2>> %t.log
+// RUN: %clang -target x86_64-apple-macosx10.7 -mlinker-version=400 -### %t.o 2>> %t.log
//
-// RUN: %clang -target armv7-apple-ios -### %t.o 2>> %t.log
-// RUN: %clang -target armv7-apple-ios0.0 -### %t.o 2>> %t.log
-// RUN: %clang -target armv7-apple-ios1.2.3 -### %t.o 2>> %t.log
-// RUN: %clang -target armv7-apple-ios5.0 -### %t.o 2>> %t.log
-// RUN: %clang -target armv7-apple-ios7.0 -### %t.o 2>> %t.log
-// RUN: %clang -target arm64-apple-ios -### %t.o 2>> %t.log
+// RUN: %clang -target armv7-apple-ios -mlinker-version=400 -### %t.o 2>> %t.log
+// RUN: %clang -target armv7-apple-ios0.0 -mlinker-version=400 -### %t.o 2>> %t.log
+// RUN: %clang -target armv7-apple-ios1.2.3 -mlinker-version=400 -### %t.o 2>> %t.log
+// RUN: %clang -target armv7-apple-ios5.0 -mlinker-version=400 -### %t.o 2>> %t.log
+// RUN: %clang -target armv7-apple-ios7.0 -mlinker-version=400 -### %t.o 2>> %t.log
+// RUN: %clang -target arm64-apple-ios -mlinker-version=400 -### %t.o 2>> %t.log
//
// RUN: FileCheck %s < %t.log
diff --git a/llvm/include/llvm/Support/VersionTuple.h b/llvm/include/llvm/Support/VersionTuple.h
index 14736d6b28f0..f3eeea2f7b44 100644
--- a/llvm/include/llvm/Support/VersionTuple.h
+++ b/llvm/include/llvm/Support/VersionTuple.h
@@ -87,6 +87,13 @@ class VersionTuple {
return Build;
}
+ /// Return a version tuple that contains only the first 3 version components.
+ VersionTuple withoutBuild() const {
+ if (HasBuild)
+ return VersionTuple(Major, Minor, Subminor);
+ return *this;
+ }
+
/// Determine if two version numbers are equivalent. If not
/// provided, minor and subminor version numbers are considered to be zero.
friend bool operator==(const VersionTuple &X, const VersionTuple &Y) {
More information about the cfe-commits
mailing list