[clang+lld] Pass -platform_version args to ld64.lld

Fix regression where we aren't passing `-platform_version` to new ld64.lld after {D95204}.

Most of the changes were originally in D95204, but I backed them out due to
test failures on builds which have `CLANG_DEFAULT_LINKER=lld`. The tests are
properly updated in this diff.

Reviewed By: #lld-macho, thakis

Differential Revision: https://reviews.llvm.org/D97741
This commit is contained in:
Jez Ng 2021-03-02 12:50:51 -05:00
parent 563ea45052
commit 18fa1d380d
11 changed files with 45 additions and 44 deletions

View file

@ -620,11 +620,11 @@ std::string ToolChain::GetLinkerPath(bool *LinkerIsLLD,
std::string LinkerPath(GetProgramPath(LinkerName.c_str()));
if (llvm::sys::fs::can_execute(LinkerPath)) {
// FIXME: Remove lld.darwinnew here once it's the only MachO lld.
// FIXME: Remove LinkerIsLLDDarwinNew once there's only one MachO lld.
if (LinkerIsLLD)
*LinkerIsLLD = UseLinker == "lld" || UseLinker == "lld.darwinnew";
*LinkerIsLLD = UseLinker == "lld" || UseLinker == "lld.darwinold";
if (LinkerIsLLDDarwinNew)
*LinkerIsLLDDarwinNew = UseLinker == "lld.darwinnew";
*LinkerIsLLDDarwinNew = UseLinker == "lld";
return LinkerPath;
}
}

View file

@ -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 -mlinker-version=400 -### 2>&1 \
// RUN: env SDKROOT=%t/SDKs/iPhoneOS8.0.0.sdk %clang -fuse-ld= %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 -mlinker-version=400 -### 2>&1 \
// RUN: env SDKROOT=%t/SDKs/iPhoneOS8.0.0.sdk IPHONEOS_DEPLOYMENT_TARGET=8.0 %clang -fuse-ld= %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 -arch x86_64 %s -mlinker-version=400 -### 2>&1 \
// RUN: env SDKROOT=%t/SDKs/iPhoneSimulator8.0.sdk %clang -fuse-ld= -arch x86_64 %s -mlinker-version=400 -### 2>&1 \
// RUN: | FileCheck --check-prefix=CHECK-SIMULATOR %s
//
// CHECK-SIMULATOR: clang
@ -29,7 +29,7 @@
//
// RUN: rm -rf %t/SDKs/iPhoneSimulator14.0.sdk
// RUN: mkdir -p %t/SDKs/iPhoneSimulator14.0.sdk
// RUN: env SDKROOT=%t/SDKs/iPhoneSimulator14.0.sdk %clang -arch arm64 %s -mlinker-version=400 -### 2>&1 \
// RUN: env SDKROOT=%t/SDKs/iPhoneSimulator14.0.sdk %clang -fuse-ld= -arch arm64 %s -mlinker-version=400 -### 2>&1 \
// RUN: | FileCheck --check-prefix=CHECK-SIMULATOR-ARM64 %s
//
// CHECK-SIMULATOR-ARM64: clang
@ -41,9 +41,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 -mlinker-version=400 -### 2>&1 \
// RUN: env SDKROOT=%t/SDKs/WatchOS3.0.sdk %clang %s -fuse-ld= -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 -mlinker-version=400 -### 2>&1 \
// RUN: env WATCHOS_DEPLOYMENT_TARGET=3.0 %clang %s -fuse-ld= -isysroot %t/SDKs/WatchOS3.0.sdk -mlinker-version=400 -### 2>&1 \
// RUN: | FileCheck --check-prefix=CHECK-WATCH %s
//
// CHECK-WATCH: clang
@ -55,7 +55,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 -arch x86_64 %s -mlinker-version=400 -### 2>&1 \
// RUN: env SDKROOT=%t/SDKs/WatchSimulator3.0.sdk %clang -fuse-ld= -arch x86_64 %s -mlinker-version=400 -### 2>&1 \
// RUN: | FileCheck --check-prefix=CHECK-WATCH-SIMULATOR %s
//
// CHECK-WATCH-SIMULATOR: clang
@ -67,7 +67,7 @@
//
// RUN: rm -rf %t/SDKs/WatchSimulator7.0.sdk
// RUN: mkdir -p %t/SDKs/WatchSimulator7.0.sdk
// RUN: env SDKROOT=%t/SDKs/WatchSimulator7.0.sdk %clang -arch arm64 %s -mlinker-version=400 -### 2>&1 \
// RUN: env SDKROOT=%t/SDKs/WatchSimulator7.0.sdk %clang -fuse-ld= -arch arm64 %s -mlinker-version=400 -### 2>&1 \
// RUN: | FileCheck --check-prefix=CHECK-WATCH-SIMULATOR-ARM64 %s
//
// CHECK-WATCH-SIMULATOR-ARM64: clang
@ -79,7 +79,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 -mlinker-version=400 -### 2>&1 \
// RUN: env SDKROOT=%t/SDKs/AppleTVOS10.0.sdk %clang %s -fuse-ld= -mlinker-version=400 -### 2>&1 \
// RUN: | FileCheck --check-prefix=CHECK-TV %s
//
// CHECK-TV: clang
@ -91,7 +91,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 -arch x86_64 %s -mlinker-version=400 -### 2>&1 \
// RUN: env SDKROOT=%t/SDKs/AppleTVSimulator10.0.sdk %clang -fuse-ld= -arch x86_64 %s -mlinker-version=400 -### 2>&1 \
// RUN: | FileCheck --check-prefix=CHECK-TV-SIMULATOR %s
//
// CHECK-TV-SIMULATOR: clang
@ -103,7 +103,7 @@
//
// RUN: rm -rf %t/SDKs/AppleTVSimulator14.0.sdk
// RUN: mkdir -p %t/SDKs/AppleTVSimulator14.0.sdk
// RUN: env SDKROOT=%t/SDKs/AppleTVSimulator14.0.sdk %clang -arch arm64 %s -mlinker-version=400 -### 2>&1 \
// RUN: env SDKROOT=%t/SDKs/AppleTVSimulator14.0.sdk %clang -fuse-ld= -arch arm64 %s -mlinker-version=400 -### 2>&1 \
// RUN: | FileCheck --check-prefix=CHECK-TV-SIMULATOR-ARM64 %s
//
// CHECK-TV-SIMULATOR-ARM64: clang

View file

@ -1,12 +1,13 @@
// With -fuse-ld=lld, -demangle is always passed to the linker on Darwin.
// REQUIRES: shell
// FIXME: Remove this test case when we remove the lld.darwinold backend.
// RUN: %clang --target=x86_64-apple-darwin -### \
// RUN: -fuse-ld=lld.darwinold -B%S/Inputs/lld -mlinker-version=0 %s 2>&1 \
// RUN: | FileCheck %s
// RUN: %clang --target=x86_64-apple-darwin -### \
// RUN: -fuse-ld=lld -B%S/Inputs/lld -mlinker-version=0 %s 2>&1 \
// RUN: | FileCheck %s
// FIXME: Remove ld.darwinnew once it's the default (and only) mach-o lld.
// RUN: %clang --target=x86_64-apple-darwin -### \
// RUN: -fuse-ld=lld.darwinnew -B%S/Inputs/lld -mlinker-version=0 %s 2>&1 \
// RUN: | FileCheck %s
// CHECK: "-demangle"

View file

@ -5,7 +5,7 @@
// RUN: mkdir -p %t/bin
// RUN: mkdir -p %t/lib
// RUN: touch %t/lib/libLTO.dylib
// RUN: %clang -target x86_64-apple-darwin10 -### %s \
// RUN: %clang -fuse-ld= -target x86_64-apple-darwin10 -### %s \
// RUN: -ccc-install-dir %t/bin -mlinker-version=133 2> %t.log
// RUN: FileCheck -check-prefix=LINK_LTOLIB_PATH %s -input-file %t.log
//
@ -14,7 +14,7 @@
// Also pass -lto_library even if the file doesn't exist; if it's needed at
// link time, ld will complain instead.
// RUN: %clang -target x86_64-apple-darwin10 -### %s \
// RUN: %clang -fuse-ld= -target x86_64-apple-darwin10 -### %s \
// RUN: -ccc-install-dir %S/dummytestdir -mlinker-version=133 2> %t.log
// RUN: FileCheck -check-prefix=LINK_LTOLIB_PATH %s -input-file %t.log

View file

@ -1,6 +1,6 @@
// RUN: touch %t.o
// RUN: %clang -target arm64-apple-ios12.3 -fuse-ld= \
// RUN: %clang -target arm64-apple-ios12.3 -fuse-ld=lld.darwinold \
// RUN: -isysroot %S/Inputs/iPhoneOS13.0.sdk -mlinker-version=0 \
// RUN: -### %t.o 2>&1 \
// RUN: | FileCheck --check-prefix=LINKER-OLD %s
@ -12,7 +12,7 @@
// RUN: -isysroot %S/Inputs/iPhoneOS13.0.sdk -mlinker-version=520 \
// RUN: -### %t.o 2>&1 \
// RUN: | FileCheck --check-prefix=LINKER-NEW %s
// RUN: %clang -target arm64-apple-ios12.3 -fuse-ld=lld.darwinnew \
// RUN: %clang -target arm64-apple-ios12.3 -fuse-ld=lld \
// RUN: -isysroot %S/Inputs/iPhoneOS13.0.sdk -mlinker-version=0 \
// RUN: -### %t.o -B%S/Inputs/lld 2>&1 \
// RUN: | FileCheck --check-prefix=LINKER-NEW %s
@ -20,7 +20,7 @@
// RUN: -isysroot %S/Inputs/iPhoneOS13.0.sdk -mlinker-version=520 \
// RUN: -### %t.o 2>&1 \
// RUN: | FileCheck --check-prefix=SIMUL %s
// RUN: %clang -target x86_64-apple-ios13-simulator -fuse-ld=lld.darwinnew \
// RUN: %clang -target x86_64-apple-ios13-simulator -fuse-ld=lld \
// RUN: -isysroot %S/Inputs/iPhoneOS13.0.sdk -mlinker-version=0 \
// RUN: -### %t.o -B%S/Inputs/lld 2>&1 \
// RUN: | FileCheck --check-prefix=SIMUL %s

View file

@ -1,10 +1,10 @@
// RUN: touch %t.o
// RUN: %clang -target x86_64-apple-macos10.13 -fuse-ld= \
// RUN: %clang -target x86_64-apple-macos10.13 -fuse-ld=lld.darwinold \
// RUN: -isysroot %S/Inputs/MacOSX10.14.sdk -mlinker-version=0 \
// RUN: -### %t.o 2>&1 \
// RUN: | FileCheck --check-prefix=LINKER-OLD %s
// RUN: %clang -target x86_64-apple-macos10.13 -fuse-ld=lld.darwinnew \
// RUN: %clang -target x86_64-apple-macos10.13 -fuse-ld=lld \
// RUN: -isysroot %S/Inputs/MacOSX10.14.sdk -mlinker-version=0 \
// RUN: -### %t.o -B%S/Inputs/lld 2>&1 \
// RUN: | FileCheck --check-prefix=LINKER-NEW %s
@ -21,7 +21,7 @@
// RUN: -isysroot %S/Inputs/MacOSX10.14.sdk -mlinker-version=400 \
// RUN: -### %t.o 2>&1 \
// RUN: | FileCheck --check-prefix=ARM64_OLD %s
// RUN: %clang -target arm64-apple-macos10.13 -fuse-ld=lld.darwinnew \
// RUN: %clang -target arm64-apple-macos10.13 -fuse-ld=lld \
// RUN: -isysroot %S/Inputs/MacOSX10.14.sdk -mlinker-version=400 \
// RUN: -### %t.o -B%S/Inputs/lld 2>&1 \
// RUN: | FileCheck --check-prefix=ARM64_NEW %s

View file

@ -1,6 +1,6 @@
// RUN: touch %t.o
// RUN: %clang -target arm64-apple-tvos12.3 -fuse-ld= \
// RUN: %clang -target arm64-apple-tvos12.3 -fuse-ld=lld.darwinold \
// RUN: -isysroot %S/Inputs/iPhoneOS13.0.sdk -mlinker-version=0 \
// RUN: -### %t.o 2>&1 \
// RUN: | FileCheck --check-prefix=LINKER-OLD %s
@ -8,7 +8,7 @@
// RUN: -isysroot %S/Inputs/iPhoneOS13.0.sdk -mlinker-version=400 \
// RUN: -### %t.o 2>&1 \
// RUN: | FileCheck --check-prefix=LINKER-OLD %s
// RUN: %clang -target arm64-apple-tvos12.3 -fuse-ld=lld.darwinnew \
// RUN: %clang -target arm64-apple-tvos12.3 -fuse-ld=lld \
// RUN: -isysroot %S/Inputs/iPhoneOS13.0.sdk -mlinker-version=0 \
// RUN: -### %t.o -B%S/Inputs/lld 2>&1 \
// RUN: | FileCheck --check-prefix=LINKER-NEW %s

View file

@ -1,6 +1,6 @@
// RUN: touch %t.o
// RUN: %clang -target arm64_32-apple-watchos5.2 -fuse-ld= \
// RUN: %clang -target arm64_32-apple-watchos5.2 -fuse-ld=lld.darwinold \
// RUN: -isysroot %S/Inputs/WatchOS6.0.sdk -mlinker-version=0 \
// RUN: -### %t.o 2>&1 \
// RUN: | FileCheck --check-prefix=LINKER-OLD %s
@ -8,7 +8,7 @@
// RUN: -isysroot %S/Inputs/WatchOS6.0.sdk -mlinker-version=400 \
// RUN: -### %t.o 2>&1 \
// RUN: | FileCheck --check-prefix=LINKER-OLD %s
// RUN: %clang -target arm64_32-apple-watchos5.2 -fuse-ld=lld.darwinnew \
// RUN: %clang -target arm64_32-apple-watchos5.2 -fuse-ld=lld \
// RUN: -isysroot %S/Inputs/WatchOS6.0.sdk -mlinker-version=0 \
// RUN: -### %t.o -B%S/Inputs/lld 2>&1 \
// RUN: | FileCheck --check-prefix=LINKER-NEW %s

View file

@ -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 -mlinker-version=400 --sysroot="" %s -### 2>&1 \
// RUN: env SDKROOT=%t/SDKs/iPhoneOS8.0.0.sdk %clang -fuse-ld= -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 -mlinker-version=400 --sysroot="" %s -### 2>&1 \
// RUN: env SDKROOT=%t/SDKs/iPhoneSimulator8.0.sdk %clang -fuse-ld= -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 -mlinker-version=400 --sysroot="" %s -### 2>&1 \
// RUN: env SDKROOT=%t/SDKs/MacOSX10.10.0.sdk %clang -fuse-ld= -target x86_64-apple-darwin -mlinker-version=400 --sysroot="" %s -### 2>&1 \
// RUN: | FileCheck --check-prefix=CHECK-MACOSX %s
//
// CHECK-MACOSX: clang

View file

@ -1,16 +1,16 @@
// RUN: touch %t.o
// 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 -fuse-ld= -target x86_64-apple-macosx10.4 -mlinker-version=400 -### %t.o 2> %t.log
// RUN: %clang -fuse-ld= -target x86_64-apple-darwin9 -mlinker-version=400 -### %t.o 2>> %t.log
// RUN: %clang -fuse-ld= -target x86_64-apple-macosx10.7 -mlinker-version=400 -### %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: %clang -target arm64e-apple-ios13.0 -mlinker-version=400 -### %t.o 2>> %t.log
// RUN: %clang -target arm64e-apple-ios14.1 -mlinker-version=400 -### %t.o 2>> %t.log
// RUN: %clang -fuse-ld= -target armv7-apple-ios -mlinker-version=400 -### %t.o 2>> %t.log
// RUN: %clang -fuse-ld= -target armv7-apple-ios0.0 -mlinker-version=400 -### %t.o 2>> %t.log
// RUN: %clang -fuse-ld= -target armv7-apple-ios1.2.3 -mlinker-version=400 -### %t.o 2>> %t.log
// RUN: %clang -fuse-ld= -target armv7-apple-ios5.0 -mlinker-version=400 -### %t.o 2>> %t.log
// RUN: %clang -fuse-ld= -target armv7-apple-ios7.0 -mlinker-version=400 -### %t.o 2>> %t.log
// RUN: %clang -fuse-ld= -target arm64-apple-ios -mlinker-version=400 -### %t.o 2>> %t.log
// RUN: %clang -fuse-ld= -target arm64e-apple-ios13.0 -mlinker-version=400 -### %t.o 2>> %t.log
// RUN: %clang -fuse-ld= -target arm64e-apple-ios14.1 -mlinker-version=400 -### %t.o 2>> %t.log
//
// RUN: FileCheck %s < %t.log