Skip to content

Commit 2263ce7

Browse files
committed
[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 (cherry picked from commit 25ce33a)
1 parent e1ad4d1 commit 2263ce7

File tree

13 files changed

+141
-44
lines changed

13 files changed

+141
-44
lines changed

clang/lib/Driver/ToolChains/Darwin.cpp

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,10 @@ void darwin::Linker::AddLinkArgs(Compilation &C, const ArgList &Args,
335335
Args.AddAllArgs(CmdArgs, options::OPT_init);
336336

337337
// Add the deployment target.
338-
MachOTC.addMinVersionArgs(Args, CmdArgs);
338+
if (!Version[0] || Version[0] >= 520)
339+
MachOTC.addPlatformVersionArgs(Args, CmdArgs);
340+
else
341+
MachOTC.addMinVersionArgs(Args, CmdArgs);
339342

340343
Args.AddLastArg(CmdArgs, options::OPT_nomultidefs);
341344
Args.AddLastArg(CmdArgs, options::OPT_multi__module);
@@ -2520,6 +2523,45 @@ void Darwin::addMinVersionArgs(const ArgList &Args,
25202523
CmdArgs.push_back(Args.MakeArgString(TargetVersion.getAsString()));
25212524
}
25222525

2526+
static const char *getPlatformName(Darwin::DarwinPlatformKind Platform,
2527+
Darwin::DarwinEnvironmentKind Environment) {
2528+
switch (Platform) {
2529+
case Darwin::MacOS:
2530+
return "macos";
2531+
case Darwin::IPhoneOS:
2532+
if (Environment == Darwin::NativeEnvironment ||
2533+
Environment == Darwin::Simulator)
2534+
return "ios";
2535+
// FIXME: Add macCatalyst support here ("\"mac catalyst\"").
2536+
llvm_unreachable("macCatalyst isn't yet supported");
2537+
case Darwin::TvOS:
2538+
return "tvos";
2539+
case Darwin::WatchOS:
2540+
return "watchos";
2541+
}
2542+
llvm_unreachable("invalid platform");
2543+
}
2544+
2545+
void Darwin::addPlatformVersionArgs(const llvm::opt::ArgList &Args,
2546+
llvm::opt::ArgStringList &CmdArgs) const {
2547+
// -platform_version <platform> <target_version> <sdk_version>
2548+
// Both the target and SDK version support only up to 3 components.
2549+
CmdArgs.push_back("-platform_version");
2550+
std::string PlatformName = getPlatformName(TargetPlatform, TargetEnvironment);
2551+
if (TargetEnvironment == Darwin::Simulator)
2552+
PlatformName += "-simulator";
2553+
CmdArgs.push_back(Args.MakeArgString(PlatformName));
2554+
VersionTuple TargetVersion = getTargetVersion().withoutBuild();
2555+
CmdArgs.push_back(Args.MakeArgString(TargetVersion.getAsString()));
2556+
if (SDKInfo) {
2557+
VersionTuple SDKVersion = SDKInfo->getVersion().withoutBuild();
2558+
CmdArgs.push_back(Args.MakeArgString(SDKVersion.getAsString()));
2559+
} else {
2560+
// Use a blank SDK version if it's not present.
2561+
CmdArgs.push_back("0.0.0");
2562+
}
2563+
}
2564+
25232565
void Darwin::addStartObjectFileArgs(const ArgList &Args,
25242566
ArgStringList &CmdArgs) const {
25252567
// Derived from startfile spec.

clang/lib/Driver/ToolChains/Darwin.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,10 @@ class LLVM_LIBRARY_VISIBILITY MachO : public ToolChain {
167167
virtual void addMinVersionArgs(const llvm::opt::ArgList &Args,
168168
llvm::opt::ArgStringList &CmdArgs) const {}
169169

170+
virtual void addPlatformVersionArgs(const llvm::opt::ArgList &Args,
171+
llvm::opt::ArgStringList &CmdArgs) const {
172+
}
173+
170174
/// On some iOS platforms, kernel and kernel modules were built statically. Is
171175
/// this such a target?
172176
virtual bool isKernelStatic() const { return false; }
@@ -311,6 +315,9 @@ class LLVM_LIBRARY_VISIBILITY Darwin : public MachO {
311315
void addMinVersionArgs(const llvm::opt::ArgList &Args,
312316
llvm::opt::ArgStringList &CmdArgs) const override;
313317

318+
void addPlatformVersionArgs(const llvm::opt::ArgList &Args,
319+
llvm::opt::ArgStringList &CmdArgs) const override;
320+
314321
void addStartObjectFileArgs(const llvm::opt::ArgList &Args,
315322
llvm::opt::ArgStringList &CmdArgs) const override;
316323

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"Version":"6.0.0"}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"Version":"13.0"}

clang/test/Driver/darwin-infer-simulator-sdkroot.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@
44
//
55
// RUN: rm -rf %t/SDKs/iPhoneOS8.0.0.sdk
66
// RUN: mkdir -p %t/SDKs/iPhoneOS8.0.0.sdk
7-
// RUN: env SDKROOT=%t/SDKs/iPhoneOS8.0.0.sdk %clang %s -### 2>&1 \
7+
// RUN: env SDKROOT=%t/SDKs/iPhoneOS8.0.0.sdk %clang %s -mlinker-version=400 -### 2>&1 \
88
// RUN: | FileCheck --check-prefix=CHECK-IPHONE %s
9-
// RUN: env SDKROOT=%t/SDKs/iPhoneOS8.0.0.sdk IPHONEOS_DEPLOYMENT_TARGET=8.0 %clang %s -### 2>&1 \
9+
// RUN: env SDKROOT=%t/SDKs/iPhoneOS8.0.0.sdk IPHONEOS_DEPLOYMENT_TARGET=8.0 %clang %s -mlinker-version=400 -### 2>&1 \
1010
// RUN: | FileCheck --check-prefix=CHECK-IPHONE %s
1111
// CHECK-IPHONE: clang
1212
// CHECK-IPHONE: "-cc1"
@@ -17,7 +17,7 @@
1717
//
1818
// RUN: rm -rf %t/SDKs/iPhoneSimulator8.0.sdk
1919
// RUN: mkdir -p %t/SDKs/iPhoneSimulator8.0.sdk
20-
// RUN: env SDKROOT=%t/SDKs/iPhoneSimulator8.0.sdk %clang %s -### 2>&1 \
20+
// RUN: env SDKROOT=%t/SDKs/iPhoneSimulator8.0.sdk %clang %s -mlinker-version=400 -### 2>&1 \
2121
// RUN: | FileCheck --check-prefix=CHECK-SIMULATOR %s
2222
//
2323
// CHECK-SIMULATOR: clang
@@ -29,9 +29,9 @@
2929
//
3030
// RUN: rm -rf %t/SDKs/WatchOS3.0.sdk
3131
// RUN: mkdir -p %t/SDKs/WatchOS3.0.sdk
32-
// RUN: env SDKROOT=%t/SDKs/WatchOS3.0.sdk %clang %s -### 2>&1 \
32+
// RUN: env SDKROOT=%t/SDKs/WatchOS3.0.sdk %clang %s -mlinker-version=400 -### 2>&1 \
3333
// RUN: | FileCheck --check-prefix=CHECK-WATCH %s
34-
// RUN: env WATCHOS_DEPLOYMENT_TARGET=3.0 %clang %s -isysroot %t/SDKs/WatchOS3.0.sdk -### 2>&1 \
34+
// RUN: env WATCHOS_DEPLOYMENT_TARGET=3.0 %clang %s -isysroot %t/SDKs/WatchOS3.0.sdk -mlinker-version=400 -### 2>&1 \
3535
// RUN: | FileCheck --check-prefix=CHECK-WATCH %s
3636
//
3737
// CHECK-WATCH: clang
@@ -43,7 +43,7 @@
4343
//
4444
// RUN: rm -rf %t/SDKs/WatchSimulator3.0.sdk
4545
// RUN: mkdir -p %t/SDKs/WatchSimulator3.0.sdk
46-
// RUN: env SDKROOT=%t/SDKs/WatchSimulator3.0.sdk %clang %s -### 2>&1 \
46+
// RUN: env SDKROOT=%t/SDKs/WatchSimulator3.0.sdk %clang %s -mlinker-version=400 -### 2>&1 \
4747
// RUN: | FileCheck --check-prefix=CHECK-WATCH-SIMULATOR %s
4848
//
4949
// CHECK-WATCH-SIMULATOR: clang
@@ -55,7 +55,7 @@
5555
//
5656
// RUN: rm -rf %t/SDKs/AppleTVOS10.0.sdk
5757
// RUN: mkdir -p %t/SDKs/AppleTVOS10.0.sdk
58-
// RUN: env SDKROOT=%t/SDKs/AppleTVOS10.0.sdk %clang %s -### 2>&1 \
58+
// RUN: env SDKROOT=%t/SDKs/AppleTVOS10.0.sdk %clang %s -mlinker-version=400 -### 2>&1 \
5959
// RUN: | FileCheck --check-prefix=CHECK-TV %s
6060
//
6161
// CHECK-TV: clang
@@ -67,7 +67,7 @@
6767
//
6868
// RUN: rm -rf %t/SDKs/AppleTVSimulator10.0.sdk
6969
// RUN: mkdir -p %t/SDKs/AppleTVSimulator10.0.sdk
70-
// RUN: env SDKROOT=%t/SDKs/AppleTVSimulator10.0.sdk %clang %s -### 2>&1 \
70+
// RUN: env SDKROOT=%t/SDKs/AppleTVSimulator10.0.sdk %clang %s -mlinker-version=400 -### 2>&1 \
7171
// RUN: | FileCheck --check-prefix=CHECK-TV-SIMULATOR %s
7272
//
7373
// CHECK-TV-SIMULATOR: clang
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// RUN: touch %t.o
2+
3+
// RUN: %clang -target arm64-apple-ios12.3 -isysroot %S/Inputs/iPhoneOS13.0.sdk -### %t.o 2>&1 \
4+
// RUN: | FileCheck %s
5+
// RUN: %clang -target x86_64-apple-ios13-simulator -isysroot %S/Inputs/iPhoneOS13.0.sdk -### %t.o 2>&1 \
6+
// RUN: | FileCheck --check-prefix=SIMUL %s
7+
8+
// CHECK: "-platform_version" "ios" "12.3.0" "13.0"
9+
// SIMUL: "-platform_version" "ios-simulator" "13.0.0" "13.0"
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// RUN: touch %t.o
2+
3+
// RUN: %clang -target x86_64-apple-macos10.13 -isysroot %S/Inputs/MacOSX10.14.sdk -### %t.o 2>&1 \
4+
// RUN: | FileCheck %s
5+
// RUN: env SDKROOT=%S/Inputs/MacOSX10.14.sdk %clang -target x86_64-apple-macos10.13.0.1 -mlinker-version=520 -### %t.o 2>&1 \
6+
// RUN: | FileCheck %s
7+
8+
// CHECK: "-platform_version" "macos" "10.13.0" "10.14"
9+
10+
// RUN: %clang -target x86_64-apple-macos10.13 -### %t.o 2>&1 \
11+
// RUN: | FileCheck --check-prefix=NOSDK %s
12+
// NOSDK: "-platform_version" "macos" "10.13.0" "0.0.0"
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// RUN: touch %t.o
2+
3+
// RUN: %clang -target arm64-apple-tvos12.3 -isysroot %S/Inputs/iPhoneOS13.0.sdk -### %t.o 2>&1 \
4+
// RUN: | FileCheck %s
5+
// RUN: %clang -target x86_64-apple-tvos13-simulator -isysroot %S/Inputs/iPhoneOS13.0.sdk -### %t.o 2>&1 \
6+
// RUN: | FileCheck --check-prefix=SIMUL %s
7+
8+
// CHECK: "-platform_version" "tvos" "12.3.0" "13.0"
9+
// SIMUL: "-platform_version" "tvos-simulator" "13.0.0" "13.0"
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
// RUN: touch %t.o
2+
3+
// RUN: %clang -target arm64_32-apple-watchos5.2 -isysroot %S/Inputs/WatchOS6.0.sdk -### %t.o 2>&1 \
4+
// RUN: | FileCheck %s
5+
// RUN: %clang -target x86_64-apple-watchos6-simulator -isysroot %S/Inputs/WatchOS6.0.sdk -### %t.o 2>&1 \
6+
// RUN: | FileCheck --check-prefix=SIMUL %s
7+
8+
// CHECK: "-platform_version" "watchos" "5.2.0" "6.0.0"
9+
// SIMUL: "-platform_version" "watchos-simulator" "6.0.0" "6.0.0"

clang/test/Driver/darwin-ld.c

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@
1111

1212
// Check linker changes that came with new linkedit format.
1313
// RUN: touch %t.o
14-
// RUN: %clang -target i386-apple-darwin9 -### -arch armv6 -miphoneos-version-min=3.0 %t.o 2> %t.log
15-
// RUN: %clang -target i386-apple-darwin9 -### -arch armv6 -miphoneos-version-min=3.0 -dynamiclib %t.o 2>> %t.log
16-
// RUN: %clang -target i386-apple-darwin9 -### -arch armv6 -miphoneos-version-min=3.0 -bundle %t.o 2>> %t.log
14+
// RUN: %clang -target i386-apple-darwin9 -mlinker-version=400 -### -arch armv6 -miphoneos-version-min=3.0 %t.o 2> %t.log
15+
// RUN: %clang -target i386-apple-darwin9 -mlinker-version=400 -### -arch armv6 -miphoneos-version-min=3.0 -dynamiclib %t.o 2>> %t.log
16+
// RUN: %clang -target i386-apple-darwin9 -mlinker-version=400 -### -arch armv6 -miphoneos-version-min=3.0 -bundle %t.o 2>> %t.log
1717
// RUN: FileCheck -check-prefix=LINK_IPHONE_3_0 %s < %t.log
1818

1919
// LINK_IPHONE_3_0: {{ld(.exe)?"}}
@@ -30,9 +30,9 @@
3030
// LINK_IPHONE_3_0: -lbundle1.o
3131
// LINK_IPHONE_3_0: -lSystem
3232

33-
// RUN: %clang -target i386-apple-darwin9 -### -arch armv7 -miphoneos-version-min=3.1 %t.o 2> %t.log
34-
// RUN: %clang -target i386-apple-darwin9 -### -arch armv7 -miphoneos-version-min=3.1 -dynamiclib %t.o 2>> %t.log
35-
// RUN: %clang -target i386-apple-darwin9 -### -arch armv7 -miphoneos-version-min=3.1 -bundle %t.o 2>> %t.log
33+
// RUN: %clang -target i386-apple-darwin9 -mlinker-version=400 -### -arch armv7 -miphoneos-version-min=3.1 %t.o 2> %t.log
34+
// RUN: %clang -target i386-apple-darwin9 -mlinker-version=400 -### -arch armv7 -miphoneos-version-min=3.1 -dynamiclib %t.o 2>> %t.log
35+
// RUN: %clang -target i386-apple-darwin9 -mlinker-version=400 -### -arch armv7 -miphoneos-version-min=3.1 -bundle %t.o 2>> %t.log
3636
// RUN: FileCheck -check-prefix=LINK_IPHONE_3_1 %s < %t.log
3737

3838
// LINK_IPHONE_3_1: {{ld(.exe)?"}}
@@ -49,9 +49,9 @@
4949
// LINK_IPHONE_3_1-NOT: -lbundle1.o
5050
// LINK_IPHONE_3_1: -lSystem
5151

52-
// RUN: %clang -target i386-apple-darwin9 -### -arch i386 -mios-simulator-version-min=3.0 %t.o 2> %t.log
53-
// RUN: %clang -target i386-apple-darwin9 -### -arch i386 -mios-simulator-version-min=3.0 -dynamiclib %t.o 2>> %t.log
54-
// RUN: %clang -target i386-apple-darwin9 -### -arch i386 -mios-simulator-version-min=3.0 -bundle %t.o 2>> %t.log
52+
// RUN: %clang -target i386-apple-darwin9 -mlinker-version=400 -### -arch i386 -mios-simulator-version-min=3.0 %t.o 2> %t.log
53+
// RUN: %clang -target i386-apple-darwin9 -mlinker-version=400 -### -arch i386 -mios-simulator-version-min=3.0 -dynamiclib %t.o 2>> %t.log
54+
// RUN: %clang -target i386-apple-darwin9 -mlinker-version=400 -### -arch i386 -mios-simulator-version-min=3.0 -bundle %t.o 2>> %t.log
5555
// RUN: FileCheck -check-prefix=LINK_IOSSIM_3_0 %s < %t.log
5656

5757
// LINK_IOSSIM_3_0: {{ld(.exe)?"}}
@@ -132,8 +132,8 @@
132132
// LINK_LAZY_LIBRARY: {{ld(.exe)?"}}
133133
// LINK_LAZY_LIBRARY: "-lazy_library" "Library"
134134

135-
// RUN: %clang -target x86_64-apple-darwin10 -### %t.o 2> %t.log
136-
// RUN: %clang -target x86_64-apple-macosx10.7 -### %t.o 2>> %t.log
135+
// RUN: %clang -target x86_64-apple-darwin10 -mlinker-version=400 -### %t.o 2> %t.log
136+
// RUN: %clang -target x86_64-apple-macosx10.7 -mlinker-version=400 -### %t.o 2>> %t.log
137137
// RUN: FileCheck -check-prefix=LINK_VERSION_MIN %s < %t.log
138138
// LINK_VERSION_MIN: {{ld(.exe)?"}}
139139
// LINK_VERSION_MIN: "-macosx_version_min" "10.6.0"
@@ -158,41 +158,41 @@
158158
// LINK_IOSSIM_PROFILE: libclang_rt.profile_iossim.a
159159
// LINK_IOSSIM_PROFILE: libclang_rt.ios.a
160160

161-
// RUN: %clang -target arm64-apple-tvos8.3 -mtvos-version-min=8.3 -resource-dir=%S/Inputs/resource_dir -### %t.o 2> %t.log
161+
// 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
162162
// RUN: FileCheck -check-prefix=LINK_TVOS_ARM64 %s < %t.log
163163
// LINK_TVOS_ARM64: {{ld(.exe)?"}}
164164
// LINK_TVOS_ARM64: -tvos_version_min
165165
// LINK_TVOS_ARM64-NOT: crt
166166
// LINK_TVOS_ARM64-NOT: lgcc_s.1
167167
// LINK_TVOS_ARM64: libclang_rt.tvos.a
168168

169-
// 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
169+
// 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
170170
// RUN: FileCheck -check-prefix=LINK_TVOS_PROFILE %s < %t.log
171171
// LINK_TVOS_PROFILE: {{ld(.exe)?"}}
172172
// LINK_TVOS_PROFILE: libclang_rt.profile_tvos.a
173173
// LINK_TVOS_PROFILE: libclang_rt.tvos.a
174174

175-
// 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
175+
// 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
176176
// RUN: FileCheck -check-prefix=LINK_TVOS_KEXT %s < %t.log
177177
// LINK_TVOS_KEXT: {{ld(.exe)?"}}
178178
// LINK_TVOS_KEXT: libclang_rt.cc_kext_tvos.a
179179
// LINK_TVOS_KEXT: libclang_rt.tvos.a
180180

181-
// RUN: %clang -target armv7k-apple-watchos2.0 -mwatchos-version-min=2.0 -resource-dir=%S/Inputs/resource_dir -### %t.o 2> %t.log
181+
// 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
182182
// RUN: FileCheck -check-prefix=LINK_WATCHOS_ARM %s < %t.log
183183
// LINK_WATCHOS_ARM: {{ld(.exe)?"}}
184184
// LINK_WATCHOS_ARM: -watchos_version_min
185185
// LINK_WATCHOS_ARM-NOT: crt
186186
// LINK_WATCHOS_ARM-NOT: lgcc_s.1
187187
// LINK_WATCHOS_ARM: libclang_rt.watchos.a
188188

189-
// 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
189+
// 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
190190
// RUN: FileCheck -check-prefix=LINK_WATCHOS_PROFILE %s < %t.log
191191
// LINK_WATCHOS_PROFILE: {{ld(.exe)?"}}
192192
// LINK_WATCHOS_PROFILE: libclang_rt.profile_watchos.a
193193
// LINK_WATCHOS_PROFILE: libclang_rt.watchos.a
194194

195-
// 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
195+
// 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
196196
// RUN: FileCheck -check-prefix=LINK_WATCHOS_KEXT %s < %t.log
197197
// LINK_WATCHOS_KEXT: {{ld(.exe)?"}}
198198
// LINK_WATCHOS_KEXT: libclang_rt.cc_kext_watchos.a
@@ -251,30 +251,30 @@
251251
// IPHONEOS_DEPLOYMENT_TARGET variable is used instead of the command-line
252252
// deployment target options.
253253
// RUN: env IPHONEOS_DEPLOYMENT_TARGET=7.0 \
254-
// RUN: %clang -target arm64-apple-darwin -### %t.o 2> %t.log
254+
// RUN: %clang -target arm64-apple-darwin -mlinker-version=400 -### %t.o 2> %t.log
255255
// RUN: FileCheck -check-prefix=LINK_IPHONEOS_VERSION_MIN %s < %t.log
256256
// RUN: env IPHONEOS_DEPLOYMENT_TARGET=7.0 \
257-
// RUN: %clang -target i386-apple-darwin -### %t.o 2> %t.log
257+
// RUN: %clang -target i386-apple-darwin -mlinker-version=400 -### %t.o 2> %t.log
258258
// RUN: FileCheck -check-prefix=LINK_IOS_SIMULATOR_VERSION_MIN %s < %t.log
259259
// LINK_IPHONEOS_VERSION_MIN: -iphoneos_version_min
260260
// LINK_IOS_SIMULATOR_VERSION_MIN: -ios_simulator_version_min
261261

262262
// Ditto for tvOS....
263263
// RUN: env TVOS_DEPLOYMENT_TARGET=7.0 \
264-
// RUN: %clang -target armv7-apple-darwin -### %t.o 2> %t.log
264+
// RUN: %clang -target armv7-apple-darwin -mlinker-version=400 -### %t.o 2> %t.log
265265
// RUN: FileCheck -check-prefix=LINK_TVOS_VERSION_MIN %s < %t.log
266266
// RUN: env TVOS_DEPLOYMENT_TARGET=7.0 \
267-
// RUN: %clang -target x86_64-apple-darwin -### %t.o 2> %t.log
267+
// RUN: %clang -target x86_64-apple-darwin -mlinker-version=400 -### %t.o 2> %t.log
268268
// RUN: FileCheck -check-prefix=LINK_TVOS_SIMULATOR_VERSION_MIN %s < %t.log
269269
// LINK_TVOS_VERSION_MIN: -tvos_version_min
270270
// LINK_TVOS_SIMULATOR_VERSION_MIN: -tvos_simulator_version_min
271271

272272
// ...and for watchOS.
273273
// RUN: env WATCHOS_DEPLOYMENT_TARGET=2.0 \
274-
// RUN: %clang -target armv7k-apple-darwin -### %t.o 2> %t.log
274+
// RUN: %clang -target armv7k-apple-darwin -mlinker-version=400 -### %t.o 2> %t.log
275275
// RUN: FileCheck -check-prefix=LINK_WATCHOS_VERSION_MIN %s < %t.log
276276
// RUN: env WATCHOS_DEPLOYMENT_TARGET=2.0 \
277-
// RUN: %clang -target i386-apple-darwin -### %t.o 2> %t.log
277+
// RUN: %clang -target i386-apple-darwin -mlinker-version=400 -### %t.o 2> %t.log
278278
// RUN: FileCheck -check-prefix=LINK_WATCHOS_SIMULATOR_VERSION_MIN %s < %t.log
279279
// LINK_WATCHOS_VERSION_MIN: -watchos_version_min
280280
// LINK_WATCHOS_SIMULATOR_VERSION_MIN: -watchos_simulator_version_min

clang/test/Driver/darwin-sdkroot.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
//
4444
// RUN: rm -rf %t/SDKs/iPhoneOS8.0.0.sdk
4545
// RUN: mkdir -p %t/SDKs/iPhoneOS8.0.0.sdk
46-
// RUN: env SDKROOT=%t/SDKs/iPhoneOS8.0.0.sdk %clang -target arm64-apple-darwin %s -### 2>&1 \
46+
// RUN: env SDKROOT=%t/SDKs/iPhoneOS8.0.0.sdk %clang -target arm64-apple-darwin -mlinker-version=400 %s -### 2>&1 \
4747
// RUN: | FileCheck --check-prefix=CHECK-IPHONE %s
4848
//
4949
// CHECK-IPHONE: clang
@@ -55,7 +55,7 @@
5555
//
5656
// RUN: rm -rf %t/SDKs/iPhoneSimulator8.0.sdk
5757
// RUN: mkdir -p %t/SDKs/iPhoneSimulator8.0.sdk
58-
// RUN: env SDKROOT=%t/SDKs/iPhoneSimulator8.0.sdk %clang -target x86_64-apple-darwin %s -### 2>&1 \
58+
// RUN: env SDKROOT=%t/SDKs/iPhoneSimulator8.0.sdk %clang -target x86_64-apple-darwin -mlinker-version=400 %s -### 2>&1 \
5959
// RUN: | FileCheck --check-prefix=CHECK-SIMULATOR %s
6060
//
6161
// CHECK-SIMULATOR: clang
@@ -66,7 +66,7 @@
6666
//
6767
// RUN: rm -rf %t/SDKs/MacOSX10.10.0.sdk
6868
// RUN: mkdir -p %t/SDKs/MacOSX10.10.0.sdk
69-
// RUN: env SDKROOT=%t/SDKs/MacOSX10.10.0.sdk %clang -target x86_64-apple-darwin %s -### 2>&1 \
69+
// RUN: env SDKROOT=%t/SDKs/MacOSX10.10.0.sdk %clang -target x86_64-apple-darwin -mlinker-version=400 %s -### 2>&1 \
7070
// RUN: | FileCheck --check-prefix=CHECK-MACOSX %s
7171
//
7272
// CHECK-MACOSX: clang

clang/test/Driver/target-triple-deployment.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
// RUN: touch %t.o
2-
// RUN: %clang -target x86_64-apple-macosx10.4 -### %t.o 2> %t.log
3-
// RUN: %clang -target x86_64-apple-darwin9 -### %t.o 2>> %t.log
4-
// RUN: %clang -target x86_64-apple-macosx10.7 -### %t.o 2>> %t.log
2+
// RUN: %clang -target x86_64-apple-macosx10.4 -mlinker-version=400 -### %t.o 2> %t.log
3+
// RUN: %clang -target x86_64-apple-darwin9 -mlinker-version=400 -### %t.o 2>> %t.log
4+
// RUN: %clang -target x86_64-apple-macosx10.7 -mlinker-version=400 -### %t.o 2>> %t.log
55
//
6-
// RUN: %clang -target armv7-apple-ios -### %t.o 2>> %t.log
7-
// RUN: %clang -target armv7-apple-ios0.0 -### %t.o 2>> %t.log
8-
// RUN: %clang -target armv7-apple-ios1.2.3 -### %t.o 2>> %t.log
9-
// RUN: %clang -target armv7-apple-ios5.0 -### %t.o 2>> %t.log
10-
// RUN: %clang -target armv7-apple-ios7.0 -### %t.o 2>> %t.log
11-
// RUN: %clang -target arm64-apple-ios -### %t.o 2>> %t.log
6+
// RUN: %clang -target armv7-apple-ios -mlinker-version=400 -### %t.o 2>> %t.log
7+
// RUN: %clang -target armv7-apple-ios0.0 -mlinker-version=400 -### %t.o 2>> %t.log
8+
// RUN: %clang -target armv7-apple-ios1.2.3 -mlinker-version=400 -### %t.o 2>> %t.log
9+
// RUN: %clang -target armv7-apple-ios5.0 -mlinker-version=400 -### %t.o 2>> %t.log
10+
// RUN: %clang -target armv7-apple-ios7.0 -mlinker-version=400 -### %t.o 2>> %t.log
11+
// RUN: %clang -target arm64-apple-ios -mlinker-version=400 -### %t.o 2>> %t.log
1212
//
1313
// RUN: FileCheck %s < %t.log
1414

llvm/include/llvm/Support/VersionTuple.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,13 @@ class VersionTuple {
9191
return Build;
9292
}
9393

94+
/// Return a version tuple that contains only the first 3 version components.
95+
VersionTuple withoutBuild() const {
96+
if (HasBuild)
97+
return VersionTuple(Major, Minor, Subminor);
98+
return *this;
99+
}
100+
94101
/// Determine if two version numbers are equivalent. If not
95102
/// provided, minor and subminor version numbers are considered to be zero.
96103
friend bool operator==(const VersionTuple &X, const VersionTuple &Y) {

0 commit comments

Comments
 (0)