Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/llvm/llvm-project.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/lld
diff options
context:
space:
mode:
authorNico Weber <thakis@chromium.org>2022-04-20 19:36:16 +0300
committerNico Weber <thakis@chromium.org>2022-04-21 19:05:56 +0300
commit889847922dc6b9247f7f9189cf06e46fa5591049 (patch)
tree247c4deaf7aaf08b84612eed107d90142337a4d1 /lld
parentad46aaede6e4d5a6951fc9827da994d3fbe1af44 (diff)
[lld/mac] Warn that writing zippered outputs isn't implemented
A "zippered" dylib contains several LC_BUILD_VERSION load commands, usually one each for "normal" macOS and one for macCatalyst. These are usually created by passing something like -shared -target arm64-apple-macos -darwin-target-variant arm64-apple-ios13.1-macabi to clang, which turns it into -platform_version macos 12.0.0 12.3 -platform_version "mac catalyst" 14.0.0 15.4 for the linker. ld64.lld can read these files fine, but it can't write them. Before this change, it would just silently use the last -platform_version flag and ignore the rest. This change adds a warning that writing zippered dylibs isn't implemented yet instead. Sadly, parts of ld64.lld's test suite relied on the previous "silently use last flag" semantics for its test suite: `%lld` always expanded to `ld64.lld -platform_version macos 10.15 11.0` and tests that wanted a different value passed a 2nd `-platform_version` flag later on. But this now produces a warning if the platform passed to `-platform_version` is not `macos`. There weren't very many cases of this, so move these to use `%no-arg-lld` and manually pass `-arch`. Differential Revision: https://reviews.llvm.org/D124106
Diffstat (limited to 'lld')
-rw-r--r--lld/MachO/Driver.cpp65
-rw-r--r--lld/MachO/InputFiles.cpp1
-rw-r--r--lld/test/MachO/invalid/incompatible-arch.s14
-rw-r--r--lld/test/MachO/invalid/incompatible-target-tapi.test2
-rw-r--r--lld/test/MachO/lc-build-version.s24
-rw-r--r--lld/test/MachO/objc-uses-custom-personality.s4
-rw-r--r--lld/test/MachO/platform-version.s47
-rw-r--r--lld/test/MachO/tapi-link-by-arch.s6
-rw-r--r--lld/test/MachO/zippered.yaml4
9 files changed, 109 insertions, 58 deletions
diff --git a/lld/MachO/Driver.cpp b/lld/MachO/Driver.cpp
index ae974a5e34d7..879fd25eb1b2 100644
--- a/lld/MachO/Driver.cpp
+++ b/lld/MachO/Driver.cpp
@@ -578,20 +578,22 @@ static std::string lowerDash(StringRef s) {
map_iterator(s.end(), toLowerDash));
}
-// Has the side-effect of setting Config::platformInfo.
-static PlatformType parsePlatformVersion(const ArgList &args) {
- const Arg *arg = args.getLastArg(OPT_platform_version);
- if (!arg) {
- error("must specify -platform_version");
- return PLATFORM_UNKNOWN;
- }
-
+struct PlatformVersion {
+ PlatformType platform = PLATFORM_UNKNOWN;
+ llvm::VersionTuple minimum;
+ llvm::VersionTuple sdk;
+};
+
+static PlatformVersion parsePlatformVersion(const Arg *arg) {
+ assert(arg->getOption().getID() == OPT_platform_version);
StringRef platformStr = arg->getValue(0);
StringRef minVersionStr = arg->getValue(1);
StringRef sdkVersionStr = arg->getValue(2);
+ PlatformVersion platformVersion;
+
// TODO(compnerd) see if we can generate this case list via XMACROS
- PlatformType platform =
+ platformVersion.platform =
StringSwitch<PlatformType>(lowerDash(platformStr))
.Cases("macos", "1", PLATFORM_MACOS)
.Cases("ios", "2", PLATFORM_IOS)
@@ -604,17 +606,52 @@ static PlatformType parsePlatformVersion(const ArgList &args) {
.Cases("watchos-simulator", "9", PLATFORM_WATCHOSSIMULATOR)
.Cases("driverkit", "10", PLATFORM_DRIVERKIT)
.Default(PLATFORM_UNKNOWN);
- if (platform == PLATFORM_UNKNOWN)
+ if (platformVersion.platform == PLATFORM_UNKNOWN)
error(Twine("malformed platform: ") + platformStr);
// TODO: check validity of version strings, which varies by platform
// NOTE: ld64 accepts version strings with 5 components
// llvm::VersionTuple accepts no more than 4 components
// Has Apple ever published version strings with 5 components?
- if (config->platformInfo.minimum.tryParse(minVersionStr))
+ if (platformVersion.minimum.tryParse(minVersionStr))
error(Twine("malformed minimum version: ") + minVersionStr);
- if (config->platformInfo.sdk.tryParse(sdkVersionStr))
+ if (platformVersion.sdk.tryParse(sdkVersionStr))
error(Twine("malformed sdk version: ") + sdkVersionStr);
- return platform;
+ return platformVersion;
+}
+
+// Has the side-effect of setting Config::platformInfo.
+static PlatformType parsePlatformVersions(const ArgList &args) {
+ std::map<PlatformType, PlatformVersion> platformVersions;
+ const PlatformVersion *lastVersionInfo = nullptr;
+ for (const Arg *arg : args.filtered(OPT_platform_version)) {
+ PlatformVersion version = parsePlatformVersion(arg);
+
+ // For each platform, the last flag wins:
+ // `-platform_version macos 2 3 -platform_version macos 4 5` has the same
+ // effect as just passing `-platform_version macos 4 5`.
+ // FIXME: ld64 warns on multiple flags for one platform. Should we?
+ platformVersions[version.platform] = version;
+ lastVersionInfo = &platformVersions[version.platform];
+ }
+
+ if (platformVersions.empty()) {
+ error("must specify -platform_version");
+ return PLATFORM_UNKNOWN;
+ }
+ if (platformVersions.size() > 2) {
+ error("must specify -platform_version at most twice");
+ return PLATFORM_UNKNOWN;
+ }
+ if (platformVersions.size() == 2) {
+ // FIXME: If you implement support for this, add a diagnostic if
+ // outputType is not dylib or bundle -- linkers shouldn't be able to
+ // write zippered executables.
+ warn("writing zippered outputs not yet implemented, "
+ "ignoring all but last -platform_version flag");
+ }
+ config->platformInfo.minimum = lastVersionInfo->minimum;
+ config->platformInfo.sdk = lastVersionInfo->sdk;
+ return lastVersionInfo->platform;
}
// Has the side-effect of setting Config::target.
@@ -625,7 +662,7 @@ static TargetInfo *createTargetInfo(InputArgList &args) {
return nullptr;
}
- PlatformType platform = parsePlatformVersion(args);
+ PlatformType platform = parsePlatformVersions(args);
config->platformInfo.target =
MachO::Target(getArchitectureFromName(archName), platform);
diff --git a/lld/MachO/InputFiles.cpp b/lld/MachO/InputFiles.cpp
index 4e37bad92361..3a7025795be6 100644
--- a/lld/MachO/InputFiles.cpp
+++ b/lld/MachO/InputFiles.cpp
@@ -116,6 +116,7 @@ static std::vector<PlatformInfo> getPlatformInfos(const InputFile *input) {
const char *hdr = input->mb.getBufferStart();
+ // "Zippered" object files can have multiple LC_BUILD_VERSION load commands.
std::vector<PlatformInfo> platformInfos;
for (auto *cmd : findCommands<build_version_command>(hdr, LC_BUILD_VERSION)) {
PlatformInfo info;
diff --git a/lld/test/MachO/invalid/incompatible-arch.s b/lld/test/MachO/invalid/incompatible-arch.s
index 9aae5baec107..d5cb403a5102 100644
--- a/lld/test/MachO/invalid/incompatible-arch.s
+++ b/lld/test/MachO/invalid/incompatible-arch.s
@@ -12,8 +12,8 @@
# RUN: %lld -dylib -arch arm64 -platform_version macOS 10.14 10.15 -o %t/out.dylib %t/test.o
-# RUN: not %lld -dylib -arch arm64 -platform_version iOS 9.0 11.0 %t/out.dylib \
-# RUN: -o /dev/null 2>&1 | FileCheck %s --check-prefix=DYLIB-PLAT
+# RUN: not %no-arg-lld -dylib -arch arm64 -platform_version iOS 9.0 11.0 \
+# RUN: %t/out.dylib -o /dev/null 2>&1 | FileCheck %s --check-prefix=DYLIB-PLAT
# DYLIB-PLAT: {{.*}}out.dylib has platform macOS, which is different from target platform iOS
# RUN: %lld -lSystem -dylib -arch arm64 -platform_version macOS 10.14.0 10.15.0 %t/out.dylib -o /dev/null
@@ -24,7 +24,7 @@
# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-macos10.15.0 %s -o %t/test_x86.o
-# RUN: not %lld %t/test_x86.o -lSystem -arch x86_64 -platform_version iOS 10.0 15.0 \
+# RUN: not %no-arg-lld %t/test_x86.o -lSystem -arch x86_64 -platform_version iOS 10.0 15.0 \
# RUN: -o /dev/null 2>&1 | FileCheck %s --check-prefix=OBJ-PLAT
# OBJ-PLAT: {{.*}}test_x86.o has platform macOS, which is different from target platform iOS
@@ -38,13 +38,13 @@
# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-ios14.0 %s -o %t/test_x86_ios.o
# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-ios14.0-simulator %s -o %t/test_x86_ios_sim.o
-# RUN: %lld -dylib -platform_version ios-simulator 14.0.0 14.0.0 %t/test_x86_ios.o -o /dev/null
-# RUN: %lld -dylib -platform_version ios 14.0.0 14.0.0 %t/test_x86_ios_sim.o -o /dev/null
+# RUN: %no-arg-lld -dylib -arch x86_64 -platform_version ios-simulator 14.0.0 14.0.0 %t/test_x86_ios.o -o /dev/null
+# RUN: %no-arg-lld -dylib -arch x86_64 -platform_version ios 14.0.0 14.0.0 %t/test_x86_ios_sim.o -o /dev/null
-# RUN: not %lld -dylib -platform_version watchos-simulator 14.0.0 14.0.0 %t/test_x86_ios.o \
+# RUN: not %no-arg-lld -dylib -arch x86_64 -platform_version watchos-simulator 14.0.0 14.0.0 %t/test_x86_ios.o \
# RUN: -o /dev/null 2>&1 | FileCheck %s --check-prefix=CROSS-SIM
# CROSS-SIM: {{.*}}test_x86_ios.o has platform iOS, which is different from target platform watchOS Simulator
-# RUN: not %lld -dylib -platform_version watchos-simulator 14.0.0 14.0.0 %t/test_x86_ios_sim.o \
+# RUN: not %no-arg-lld -dylib -arch x86_64 -platform_version watchos-simulator 14.0.0 14.0.0 %t/test_x86_ios_sim.o \
# RUN: -o /dev/null 2>&1 | FileCheck %s --check-prefix=CROSS-SIM2
# CROSS-SIM2: {{.*}}test_x86_ios_sim.o has platform iOS Simulator, which is different from target platform watchOS Simulator
diff --git a/lld/test/MachO/invalid/incompatible-target-tapi.test b/lld/test/MachO/invalid/incompatible-target-tapi.test
index f99f63c67e78..052e854d91e5 100644
--- a/lld/test/MachO/invalid/incompatible-target-tapi.test
+++ b/lld/test/MachO/invalid/incompatible-target-tapi.test
@@ -4,7 +4,7 @@ RUN: echo "" | llvm-mc -filetype=obj -triple=x86_64-apple-macosx -o %t/x86_64-te
RUN: echo "" | llvm-mc -filetype=obj -triple=arm64-apple-iossimulator -o %t/arm64-test.o
RUN: not %lld -dylib -arch x86_64 %S/Inputs/libincompatible.tbd %t/x86_64-test.o \
RUN: -o /dev/null 2>&1 | FileCheck %s --check-prefix=ARCH
-RUN: not %lld -dylib -arch arm64 -platform_version ios-simulator 14.0 15.0 %t/arm64-test.o \
+RUN: not %no-arg-lld -dylib -arch arm64 -platform_version ios-simulator 14.0 15.0 %t/arm64-test.o \
RUN: %S/Inputs/libincompatible.tbd -o /dev/null 2>&1 | FileCheck %s --check-prefix=PLATFORM
ARCH: error: {{.*}}libincompatible.tbd(/usr/lib/libincompatible.dylib) is incompatible with x86_64 (macOS)
PLATFORM: error: {{.*}}libincompatible.tbd(/usr/lib/libincompatible.dylib) is incompatible with arm64 (iOS Simulator)
diff --git a/lld/test/MachO/lc-build-version.s b/lld/test/MachO/lc-build-version.s
index d7bd8be26f4b..3fc9ba24b311 100644
--- a/lld/test/MachO/lc-build-version.s
+++ b/lld/test/MachO/lc-build-version.s
@@ -22,44 +22,44 @@
# MACOS_10_13-NEXT: version 10.13
# MACOS_10_13-NEXT: sdk 10.15
-# RUN: %lld -platform_version ios 12.0 10.15 -o %t.ios_12_0 %t.o
+# RUN: %no-arg-lld -arch x86_64 -platform_version ios 12.0 10.15 -o %t.ios_12_0 %t.o
# RUN: llvm-objdump --macho --all-headers %t.ios_12_0 | FileCheck %s --check-prefix=IOS_12_0
-# RUN: %lld -platform_version ios-simulator 13.0 10.15 -o %t.ios_sim_13_0 %t.o
+# RUN: %no-arg-lld -arch x86_64 -platform_version ios-simulator 13.0 10.15 -o %t.ios_sim_13_0 %t.o
# RUN: llvm-objdump --macho --all-headers %t.ios_sim_13_0 | FileCheck %s --check-prefix=IOS_12_0
# IOS_12_0: cmd LC_BUILD_VERSION
-# RUN: %lld -platform_version ios 11.0 10.15 -o %t.ios_11_0 %t.o
+# RUN: %no-arg-lld -arch x86_64 -platform_version ios 11.0 10.15 -o %t.ios_11_0 %t.o
# RUN: llvm-objdump --macho --all-headers %t.ios_11_0 | FileCheck %s --check-prefix=IOS_11_0
-# RUN: %lld -platform_version ios-simulator 12.0 10.15 -o %t.ios_sim_12_0 %t.o
+# RUN: %no-arg-lld -arch x86_64 -platform_version ios-simulator 12.0 10.15 -o %t.ios_sim_12_0 %t.o
# RUN: llvm-objdump --macho --all-headers %t.ios_sim_12_0 | FileCheck %s --check-prefix=IOS_11_0
# IOS_11_0: cmd LC_VERSION_MIN_IPHONEOS
-# RUN: %lld -platform_version tvos 12.0 10.15 -o %t.tvos_12_0 %t.o
+# RUN: %no-arg-lld -arch x86_64 -platform_version tvos 12.0 10.15 -o %t.tvos_12_0 %t.o
# RUN: llvm-objdump --macho --all-headers %t.tvos_12_0 | FileCheck %s --check-prefix=TVOS_12_0
-# RUN: %lld -platform_version tvos-simulator 13.0 10.15 -o %t.tvos_sim_13_0 %t.o
+# RUN: %no-arg-lld -arch x86_64 -platform_version tvos-simulator 13.0 10.15 -o %t.tvos_sim_13_0 %t.o
# RUN: llvm-objdump --macho --all-headers %t.tvos_sim_13_0 | FileCheck %s --check-prefix=TVOS_12_0
# TVOS_12_0: cmd LC_BUILD_VERSION
-# RUN: %lld -platform_version tvos 11.0 10.15 -o %t.tvos_11_0 %t.o
+# RUN: %no-arg-lld -arch x86_64 -platform_version tvos 11.0 10.15 -o %t.tvos_11_0 %t.o
# RUN: llvm-objdump --macho --all-headers %t.tvos_11_0 | FileCheck %s --check-prefix=TVOS_11_0
-# RUN: %lld -platform_version tvos-simulator 12.0 10.15 -o %t.tvos_sim_12_0 %t.o
+# RUN: %no-arg-lld -arch x86_64 -platform_version tvos-simulator 12.0 10.15 -o %t.tvos_sim_12_0 %t.o
# RUN: llvm-objdump --macho --all-headers %t.tvos_sim_12_0 | FileCheck %s --check-prefix=TVOS_11_0
# TVOS_11_0: cmd LC_VERSION_MIN_TVOS
-# RUN: %lld -platform_version watchos 5.0 10.15 -o %t.watchos_5_0 %t.o
+# RUN: %no-arg-lld -arch x86_64 -platform_version watchos 5.0 10.15 -o %t.watchos_5_0 %t.o
# RUN: llvm-objdump --macho --all-headers %t.watchos_5_0 | FileCheck %s --check-prefix=WATCHOS_5_0
-# RUN: %lld -platform_version watchos-simulator 6.0 10.15 -o %t.watchos_sim_6_0 %t.o
+# RUN: %no-arg-lld -arch x86_64 -platform_version watchos-simulator 6.0 10.15 -o %t.watchos_sim_6_0 %t.o
# RUN: llvm-objdump --macho --all-headers %t.watchos_sim_6_0 | FileCheck %s --check-prefix=WATCHOS_5_0
# WATCHOS_5_0: cmd LC_BUILD_VERSION
-# RUN: %lld -platform_version watchos 4.0 10.15 -o %t.watchos_4_0 %t.o
+# RUN: %no-arg-lld -arch x86_64 -platform_version watchos 4.0 10.15 -o %t.watchos_4_0 %t.o
# RUN: llvm-objdump --macho --all-headers %t.watchos_4_0 | FileCheck %s --check-prefix=WATCHOS_4_0
-# RUN: %lld -platform_version watchos-simulator 5.0 10.15 -o %t.watchos_sim_5_0 %t.o
+# RUN: %no-arg-lld -arch x86_64 -platform_version watchos-simulator 5.0 10.15 -o %t.watchos_sim_5_0 %t.o
# RUN: llvm-objdump --macho --all-headers %t.watchos_sim_5_0 | FileCheck %s --check-prefix=WATCHOS_4_0
# WATCHOS_4_0: cmd LC_VERSION_MIN_WATCHOS
diff --git a/lld/test/MachO/objc-uses-custom-personality.s b/lld/test/MachO/objc-uses-custom-personality.s
index 403c9004179b..b3d57d14ad73 100644
--- a/lld/test/MachO/objc-uses-custom-personality.s
+++ b/lld/test/MachO/objc-uses-custom-personality.s
@@ -5,9 +5,9 @@
# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-iossimulator %t/defined.s -o %t/defined.o
# RUN: yaml2obj %t/combined.yaml > %t/combined.o
# RUN: llvm-ar r %t/pack.a %t/defined.o %t/combined.o
-# RUN: %lld -dylib -arch x86_64 -platform_version ios-simulator 12.0.0 15.0 -ObjC %t/pack.a -o %t/a.dylib
+# RUN: %no-arg-lld -dylib -arch x86_64 -platform_version ios-simulator 12.0.0 15.0 -ObjC %t/pack.a -o %t/a.dylib
# RUN: llvm-objdump --macho --syms %t/a.dylib | FileCheck %s
-# RUN: %lld -dylib -arch x86_64 -platform_version ios-simulator 12.0.0 15.0 -ObjC --start-lib %t/defined.o %t/combined.o --end-lib -o %t/a.dylib
+# RUN: %no-arg-lld -dylib -arch x86_64 -platform_version ios-simulator 12.0.0 15.0 -ObjC --start-lib %t/defined.o %t/combined.o --end-lib -o %t/a.dylib
# RUN: llvm-objdump --macho --syms %t/a.dylib | FileCheck %s
# CHECK: SYMBOL TABLE:
diff --git a/lld/test/MachO/platform-version.s b/lld/test/MachO/platform-version.s
index 0bfc46930c5b..56b566140ad6 100644
--- a/lld/test/MachO/platform-version.s
+++ b/lld/test/MachO/platform-version.s
@@ -5,61 +5,74 @@
### with bad version strings, so we use *-NOT patterns to ensure that
### no "malformed platform" diagnostic appears in those cases.
-# RUN: not %lld -o %t %t.o 2>&1 \
+# RUN: not %no-arg-lld -arch x86_64 -o %t %t.o 2>&1 \
# RUN: -platform_version \
# RUN: | FileCheck --check-prefix=FAIL-MISSING %s
-# RUN: not %lld -o %t %t.o 2>&1 \
+# RUN: not %no-arg-lld -arch x86_64 -o %t %t.o 2>&1 \
# RUN: -platform_version wtf \
# RUN: | FileCheck --check-prefix=FAIL-MISSING %s
-# RUN: not %lld -o %t %t.o 2>&1 \
+# RUN: not %no-arg-lld -arch x86_64 -o %t %t.o 2>&1 \
# RUN: -platform_version lolz 1.2.3.4.5 \
# RUN: | FileCheck --check-prefix=FAIL-MISSING %s
# FAIL-MISSING: -platform_version: missing argument
# FAIL-MISSING-NOT: malformed platform: {{.*}}
# FAIL-MISSING-NOT: malformed {{minimum|sdk}} version: {{.*}}
-# RUN: not %lld -o %t %t.o 2>&1 \
+# RUN: not %no-arg-lld -arch x86_64 -o %t %t.o 2>&1 \
# RUN: -platform_version macOS -lfoo 2 \
# RUN: | FileCheck --check-prefix=FAIL-MALFORM %s
-# RUN: not %lld -o %t %t.o 2>&1 \
+# RUN: not %no-arg-lld -arch x86_64 -o %t %t.o 2>&1 \
# RUN: -platform_version iOS 1 2.a \
# RUN: | FileCheck --check-prefix=FAIL-MALFORM %s
-# RUN: not %lld -o %t %t.o 2>&1 \
+# RUN: not %no-arg-lld -arch x86_64 -o %t %t.o 2>&1 \
# RUN: -platform_version tvOS 1.2.3.4.5 10 \
# RUN: | FileCheck --check-prefix=FAIL-MALFORM %s
-# RUN: not %lld -o %t %t.o 2>&1 \
+# RUN: not %no-arg-lld -arch x86_64 -o %t %t.o 2>&1 \
# RUN: -platform_version watchOS 10 1.2.3.4.5 \
# RUN: | FileCheck --check-prefix=FAIL-MALFORM %s
# FAIL-MALFORM-NOT: malformed platform: {{.*}}
# FAIL-MALFORM: malformed {{minimum|sdk}} version: {{.*}}
-# RUN: %lld -o %t %t.o 2>&1 \
+# RUN: %no-arg-lld -arch x86_64 -o %t %t.o 2>&1 \
# RUN: -platform_version bridgeOS 1 5
-# RUN: %lld -o %t %t.o 2>&1 \
+# RUN: %no-arg-lld -arch x86_64 -o %t %t.o 2>&1 \
# RUN: -platform_version "Mac Catalyst" 1.2 5.6
-# RUN: %lld -o %t %t.o 2>&1 \
+# RUN: %no-arg-lld -arch x86_64 -o %t %t.o 2>&1 \
# RUN: -platform_version "iOS Simulator" 1.2.3 5.6.7
-# RUN: %lld -o %t %t.o 2>&1 \
+# RUN: %no-arg-lld -arch x86_64 -o %t %t.o 2>&1 \
# RUN: -platform_version tvOS-Simulator 1.2.3.4 5.6.7.8
-# RUN: %lld -o %t %t.o 2>&1 \
+# RUN: %no-arg-lld -arch x86_64 -o %t %t.o 2>&1 \
# RUN: -platform_version watchOS-Simulator 1 5
-# RUN: %lld -o %t %t.o 2>&1 \
+# RUN: %no-arg-lld -arch x86_64 -o %t %t.o 2>&1 \
# RUN: -platform_version 1 1 5
-# RUN: %lld -o %t %t.o 2>&1 \
+# RUN: %no-arg-lld -arch x86_64 -o %t %t.o 2>&1 \
# RUN: -platform_version 9 1 5
-# RUN: not %lld -o %t %t.o 2>&1 \
+# RUN: not %no-arg-lld -arch x86_64 -o %t %t.o 2>&1 \
# RUN: -platform_version wtf 1 5 \
# RUN: | FileCheck --check-prefix=FAIL-PLATFORM %s
-# RUN: not %lld -o %t %t.o 2>&1 \
+# RUN: not %no-arg-lld -arch x86_64 -o %t %t.o 2>&1 \
# RUN: -platform_version 0 1 5 \
# RUN: | FileCheck --check-prefix=FAIL-PLATFORM %s
-# RUN: not %lld -o %t %t.o 2>&1 \
+# RUN: not %no-arg-lld -arch x86_64 -o %t %t.o 2>&1 \
# RUN: -platform_version 11 1 5 \
# RUN: | FileCheck --check-prefix=FAIL-PLATFORM %s
# FAIL-PLATFORM: malformed platform: {{.*}}
# FAIL-PLATFORM-NOT: malformed {{minimum|sdk}} version: {{.*}}
+# RUN: not %no-arg-lld -arch x86_64 -o %t %t.o -fatal_warnings 2>&1 \
+# RUN: -platform_version 'mac catalyst' 14.0 15.0 \
+# RUN: -platform_version macos 12.0 12.0 \
+# RUN: | FileCheck --check-prefix=FAIL-TODO %s
+# FAIL-TODO: writing zippered outputs not yet implemented, ignoring all but last -platform_version flag
+
+# RUN: not %no-arg-lld -arch x86_64 -o %t %t.o 2>&1 \
+# RUN: -platform_version bridgeOS 1 5 \
+# RUN: -platform_version 'mac catalyst' 14.0 15.0 \
+# RUN: -platform_version macos 12.0 12.0 \
+# RUN: | FileCheck --check-prefix=FAIL-TOOMANY %s
+# FAIL-TOOMANY: must specify -platform_version at most twice
+
.text
.global _main
_main:
diff --git a/lld/test/MachO/tapi-link-by-arch.s b/lld/test/MachO/tapi-link-by-arch.s
index 61e397a621d8..d78b2ea83c1e 100644
--- a/lld/test/MachO/tapi-link-by-arch.s
+++ b/lld/test/MachO/tapi-link-by-arch.s
@@ -2,15 +2,15 @@
# RUN: mkdir -p %t
# RUN: llvm-mc -filetype obj -triple arm64-apple-ios14.4 %s -o %t/arm64-ios.o
-# RUN: not %lld -dylib -arch arm64 -platform_version ios 14.4 15.0 -o /dev/null \
+# RUN: not %no-arg-lld -dylib -arch arm64 -platform_version ios 14.4 15.0 -o /dev/null \
# RUN: -lSystem %S/Inputs/libStubLink.tbd %t/arm64-ios.o 2>&1 | FileCheck %s
# RUN: llvm-mc -filetype obj -triple x86_64-apple-iossimulator14.4 %s -o %t/x86_64-sim.o
-# RUN: not %lld -dylib -arch x86_64 -platform_version ios-simulator 14.4 15.0 -o /dev/null \
+# RUN: not %no-arg-lld -dylib -arch x86_64 -platform_version ios-simulator 14.4 15.0 -o /dev/null \
# RUN: -lSystem %S/Inputs/libStubLink.tbd %t/x86_64-sim.o 2>&1 | FileCheck %s
# RUN: llvm-mc -filetype obj -triple arm64-apple-iossimulator14.4 %s -o %t/arm64-sim.o
-# RUN: %lld -dylib -arch arm64 -platform_version ios-simulator 14.4 15.0 -o \
+# RUN: %no-arg-lld -dylib -arch arm64 -platform_version ios-simulator 14.4 15.0 -o \
# RUN: /dev/null %S/Inputs/libStubLink.tbd %t/arm64-sim.o
# CHECK: error: undefined symbol: _arm64_sim_only
diff --git a/lld/test/MachO/zippered.yaml b/lld/test/MachO/zippered.yaml
index 0b7c520b6b2e..bc289669e8d0 100644
--- a/lld/test/MachO/zippered.yaml
+++ b/lld/test/MachO/zippered.yaml
@@ -6,9 +6,9 @@
# RUN: echo "" | llvm-mc -filetype=obj -triple=x86_64-apple-ios13.15.0 -o %t/test_ios.o
# RUN: %lld -lSystem -dylib %t/test.dylib %t/test_macos.o -o /dev/null
-# RUN: %lld -lSystem -dylib -platform_version mac-catalyst 13.15.0 14.0 %t/test.dylib %t/test_maccatalyst.o -o /dev/null
+# RUN: %no-arg-lld -syslibroot %S/Inputs/MacOSX.sdk -lSystem -dylib -arch x86_64 -platform_version mac-catalyst 13.15.0 14.0 %t/test.dylib %t/test_maccatalyst.o -o /dev/null
-# RUN: not %lld -lSystem -dylib -platform_version ios 13.15.0 14.0 %t/test.dylib %t/test_ios.o -o /dev/null 2>&1 | FileCheck %s
+# RUN: not %no-arg-lld -syslibroot %S/Inputs/MacOSX.sdk -lSystem -dylib -arch x86_64 -platform_version ios 13.15.0 14.0 %t/test.dylib %t/test_ios.o -o /dev/null 2>&1 | FileCheck %s
# CHECK: test.dylib has platform macOS/macCatalyst, which is different from target platform iOS
--- !mach-o