Skip to content

Commit 38ee10d

Browse files
committed
[driver][darwin] Don't use -platform_version flag by default (PR44813)
The code in llvmorg-10-init-12188-g25ce33a6e4f is a breaking change for users of older linkers who don't pass a version parameter, which prevents a drop-in clang upgrade. Old tools can't know about what future tools will do, so as a general principle the burden should be new tools to be compatible by default. Also, for comparison, none of the other tests of Version within AddLinkArgs add any new behaviors unless the version is explicitly specified. Therefore, this patch changes the -platform_version behavior from opt-out to opt-in. Patch by David Major! Differential revision: https://reviews.llvm.org/D74784 (cherry picked from commit 5122e82)
1 parent b2b41bc commit 38ee10d

File tree

5 files changed

+28
-10
lines changed

5 files changed

+28
-10
lines changed

clang/lib/Driver/ToolChains/Darwin.cpp

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

337337
// Add the deployment target.
338-
if (!Version[0] || Version[0] >= 520)
338+
if (Version[0] >= 520)
339339
MachOTC.addPlatformVersionArgs(Args, CmdArgs);
340340
else
341341
MachOTC.addMinVersionArgs(Args, CmdArgs);
Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
// RUN: touch %t.o
22

3+
// RUN: %clang -target arm64-apple-ios12.3 -isysroot %S/Inputs/iPhoneOS13.0.sdk -mlinker-version=0 -### %t.o 2>&1 \
4+
// RUN: | FileCheck --check-prefix=LINKER-OLD %s
5+
// RUN: %clang -target arm64-apple-ios12.3 -isysroot %S/Inputs/iPhoneOS13.0.sdk -mlinker-version=400 -### %t.o 2>&1 \
6+
// RUN: | FileCheck --check-prefix=LINKER-OLD %s
37
// RUN: %clang -target arm64-apple-ios12.3 -isysroot %S/Inputs/iPhoneOS13.0.sdk -mlinker-version=520 -### %t.o 2>&1 \
4-
// RUN: | FileCheck %s
8+
// RUN: | FileCheck --check-prefix=LINKER-NEW %s
59
// RUN: %clang -target x86_64-apple-ios13-simulator -isysroot %S/Inputs/iPhoneOS13.0.sdk -mlinker-version=520 -### %t.o 2>&1 \
610
// RUN: | FileCheck --check-prefix=SIMUL %s
711

8-
// CHECK: "-platform_version" "ios" "12.3.0" "13.0"
12+
// LINKER-OLD: "-iphoneos_version_min" "12.3.0"
13+
// LINKER-NEW: "-platform_version" "ios" "12.3.0" "13.0"
914
// SIMUL: "-platform_version" "ios-simulator" "13.0.0" "13.0"

clang/test/Driver/darwin-ld-platform-version-macos.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,14 @@
11
// RUN: touch %t.o
22

33
// RUN: %clang -target x86_64-apple-macos10.13 -isysroot %S/Inputs/MacOSX10.14.sdk -mlinker-version=0 -### %t.o 2>&1 \
4-
// RUN: | FileCheck %s
4+
// RUN: | FileCheck --check-prefix=LINKER-OLD %s
5+
// RUN: %clang -target x86_64-apple-macos10.13 -isysroot %S/Inputs/MacOSX10.14.sdk -mlinker-version=400 -### %t.o 2>&1 \
6+
// RUN: | FileCheck --check-prefix=LINKER-OLD %s
57
// 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
8+
// RUN: | FileCheck --check-prefix=LINKER-NEW %s
79

8-
// CHECK: "-platform_version" "macos" "10.13.0" "10.14"
10+
// LINKER-OLD: "-macosx_version_min" "10.13.0"
11+
// LINKER-NEW: "-platform_version" "macos" "10.13.0" "10.14"
912

1013
// RUN: %clang -target x86_64-apple-macos10.13 -mlinker-version=520 -### %t.o 2>&1 \
1114
// RUN: | FileCheck --check-prefix=NOSDK %s
Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
// RUN: touch %t.o
22

3+
// RUN: %clang -target arm64-apple-tvos12.3 -isysroot %S/Inputs/iPhoneOS13.0.sdk -mlinker-version=0 -### %t.o 2>&1 \
4+
// RUN: | FileCheck --check-prefix=LINKER-OLD %s
5+
// RUN: %clang -target arm64-apple-tvos12.3 -isysroot %S/Inputs/iPhoneOS13.0.sdk -mlinker-version=400 -### %t.o 2>&1 \
6+
// RUN: | FileCheck --check-prefix=LINKER-OLD %s
37
// RUN: %clang -target arm64-apple-tvos12.3 -isysroot %S/Inputs/iPhoneOS13.0.sdk -mlinker-version=520 -### %t.o 2>&1 \
4-
// RUN: | FileCheck %s
8+
// RUN: | FileCheck --check-prefix=LINKER-NEW %s
59
// RUN: %clang -target x86_64-apple-tvos13-simulator -isysroot %S/Inputs/iPhoneOS13.0.sdk -mlinker-version=520 -### %t.o 2>&1 \
610
// RUN: | FileCheck --check-prefix=SIMUL %s
711

8-
// CHECK: "-platform_version" "tvos" "12.3.0" "13.0"
12+
// LINKER-OLD: "-tvos_version_min" "12.3.0"
13+
// LINKER-NEW: "-platform_version" "tvos" "12.3.0" "13.0"
914
// SIMUL: "-platform_version" "tvos-simulator" "13.0.0" "13.0"
Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
// RUN: touch %t.o
22

3+
// RUN: %clang -target arm64_32-apple-watchos5.2 -isysroot %S/Inputs/WatchOS6.0.sdk -mlinker-version=0 -### %t.o 2>&1 \
4+
// RUN: | FileCheck --check-prefix=LINKER-OLD %s
5+
// RUN: %clang -target arm64_32-apple-watchos5.2 -isysroot %S/Inputs/WatchOS6.0.sdk -mlinker-version=400 -### %t.o 2>&1 \
6+
// RUN: | FileCheck --check-prefix=LINKER-OLD %s
37
// RUN: %clang -target arm64_32-apple-watchos5.2 -isysroot %S/Inputs/WatchOS6.0.sdk -mlinker-version=520 -### %t.o 2>&1 \
4-
// RUN: | FileCheck %s
8+
// RUN: | FileCheck --check-prefix=LINKER-NEW %s
59
// RUN: %clang -target x86_64-apple-watchos6-simulator -isysroot %S/Inputs/WatchOS6.0.sdk -mlinker-version=520 -### %t.o 2>&1 \
610
// RUN: | FileCheck --check-prefix=SIMUL %s
711

8-
// CHECK: "-platform_version" "watchos" "5.2.0" "6.0.0"
12+
// LINKER-OLD: "-watchos_version_min" "5.2.0"
13+
// LINKER-NEW: "-platform_version" "watchos" "5.2.0" "6.0.0"
914
// SIMUL: "-platform_version" "watchos-simulator" "6.0.0" "6.0.0"

0 commit comments

Comments
 (0)