[PATCH] D97979: [lld-macho] Check platform and version while constructing ObjFile and DylibFile
Jez Ng via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Mar 5 12:15:40 PST 2021
int3 added inline comments.
================
Comment at: lld/MachO/InputFiles.h:179
+template <class CommandType = llvm::MachO::load_command>
+const CommandType *findCommand(const llvm::MachO::mach_header_64 *hdr,
+ uint32_t type) {
----------------
oontvoo wrote:
> int3 wrote:
> > nice, I like the convenient casting. But I don't think there's a need to move this function into the header
> It's a templated function, so you can't put it in the cpp file.
>
> If we put it in the cpp file, then it can only be a static local function.
Oh, I didn't realize this was being used in ObjC.cpp
================
Comment at: lld/test/MachO/invalid/incompatible-arch.s:12-13
+
+# RUN: not %lld -dylib -arch arm64 -platform_version iOS 9.0 11.0 -o %t/new.dylib %t/out.dylib \
+# RUN: -o /dev/null 2>&1 | FileCheck %s --check-prefix=PLAT
+# PLAT: {{.*}}out.dylib has platform macOS, which is different from target platform iOS
----------------
doesn't seem like the `-o %t/new.dylib` is necessary given that we have `-o /dev/null` later
================
Comment at: lld/test/MachO/invalid/incompatible-arch.s:17
+# RUN: not %lld -dylib -arch arm64 -platform_version macOS 14.0 15.0 -o %t/new.dylib %t/out.dylib \
+# RUN: -o /dev/null 2>&1 | FileCheck %s --check-prefix=DYLIB_VERSION
+# DYLIB_VERSION: {{.*}}out.dylib has version 9.0.0, which is incompatible with target version of 14.0
----------------
nit: use hyphens for uniformity with things like `CHECK-NEXT`
================
Comment at: lld/test/MachO/invalid/incompatible-arch.s:20-23
+# RUN: llvm-as %t/foo.ll -o %t/foo.o
+# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-macos -o %t/main_x86.o %t/main2.s
+# RUN: not %lld %t/main_x86.o %t/foo.o -arch x86_64 -platform_version macOS 14.0 15.0 -lSystem \
+# RUN: -o /dev/null 2>&1 | FileCheck %s --check-prefix=OBJ_VERSION
----------------
I'm guessing you created a bitcode file in order to specify the platform? You can actually specify it by compiling a regular assembly file via llvm-mc:
llvm-mc -filetype=obj -triple=x86_64-apple-macos14.0
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D97979/new/
https://reviews.llvm.org/D97979
More information about the llvm-commits
mailing list