[PATCH] D101855: [lld-macho] Check simulator platforms to avoid issuing false positive errors.
Vy Nguyen via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue May 4 15:06:59 PDT 2021
oontvoo updated this revision to Diff 342878.
oontvoo added a comment.
added some tests
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D101855/new/
https://reviews.llvm.org/D101855
Files:
lld/MachO/InputFiles.cpp
lld/test/MachO/invalid/incompatible-arch.s
Index: lld/test/MachO/invalid/incompatible-arch.s
===================================================================
--- lld/test/MachO/invalid/incompatible-arch.s
+++ lld/test/MachO/invalid/incompatible-arch.s
@@ -30,6 +30,15 @@
# RUN: -o /dev/null 2>&1 | FileCheck %s --check-prefix=OBJ-VERSION
# OBJ-VERSION: {{.*}}test_x86.o has version 10.15.0, which is newer than target minimum of 10.14.0
+## Test that simulators platforms are compat with their simulatees.
+# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-ios10.15.0 %s -o %t/test_x86_ios.o
+
+# RUN: %lld -dylib -platform_version ios-simulator 10.15.0 10.15.0 %t/test_x86_ios.o
+# RUN: not %lld -dylib -platform_version watchos-simulator 10.15.0 10.15.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
+
+
.globl _main
_main:
ret
Index: lld/MachO/InputFiles.cpp
===================================================================
--- lld/MachO/InputFiles.cpp
+++ lld/MachO/InputFiles.cpp
@@ -139,12 +139,35 @@
return None;
}
+static bool checkSimulatedPlatform(PlatformKind lhs, PlatformKind rhs) {
+ // Mapping of platform to simulator and vice-versa.
+ static std::map<PlatformKind, PlatformKind> *platformMap = []() {
+ auto *ret = new std::map<PlatformKind, PlatformKind>();
+
+ ret->insert({PlatformKind::iOS, PlatformKind::iOSSimulator});
+ ret->insert({PlatformKind::iOSSimulator, PlatformKind::iOS});
+
+ ret->insert({PlatformKind::tvOS, PlatformKind::tvOSSimulator});
+ ret->insert({PlatformKind::tvOSSimulator, PlatformKind::tvOS});
+
+ ret->insert({PlatformKind::watchOS, PlatformKind::watchOSSimulator});
+ ret->insert({PlatformKind::watchOSSimulator, PlatformKind::watchOS});
+
+ return ret;
+ }();
+
+ auto iter = platformMap->find(lhs);
+ return iter != platformMap->end() && iter->second == rhs;
+}
+
static bool checkCompatibility(const InputFile *input) {
Optional<PlatformInfo> platformInfo = getPlatformInfo(input);
if (!platformInfo)
return true;
// TODO: Correctly detect simulator platforms or relax this check.
- if (config->platform() != platformInfo->target.Platform) {
+ if (config->platform() != platformInfo->target.Platform &&
+ !checkSimulatedPlatform(config->platform(),
+ platformInfo->target.Platform)) {
error(toString(input) + " has platform " +
getPlatformName(platformInfo->target.Platform) +
Twine(", which is different from target platform ") +
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D101855.342878.patch
Type: text/x-patch
Size: 2624 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210504/b83a323f/attachment.bin>
More information about the llvm-commits
mailing list