[PATCH] D157716: [lld-macho] Postprocess LC Linker Option

Jez Ng via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Aug 12 21:09:47 PDT 2023


int3 added a comment.

Another way to simplify/shorten the tests is to use `%lld` instead of `%no-arg-lld`. This defaults us to linking against x86_64 + macos, but for most tests the arch doesn't actually matter



================
Comment at: lld/test/MachO/lc-linker-option-lto.ll:17-18
+; RUN: %no-arg-lld -dylib -arch arm64 -o %t/nolto-nolto.out -platform_version ios 7.0.0 7.0.0 -L%t %t/f.nolto.o %t/b.nolto.o
+; RUN: llvm-objdump --no-print-imm-hex --no-leading-addr --no-show-raw-insn -d %t/nolto-nolto.out --disassemble-symbols=_weak1 | FileCheck %s --check-prefix=WEAK1
+; RUN: llvm-objdump --no-print-imm-hex --no-leading-addr --no-show-raw-insn -d %t/nolto-nolto.out --disassemble-symbols=_weak2 | FileCheck %s --check-prefix=WEAK2
+
----------------
I think this should work given the changes suggested below on line 54

FileCheck does substring matching by default, so the leading address and other info can be ignored


================
Comment at: lld/test/MachO/lc-linker-option-lto.ll:18
+; RUN: llvm-objdump --no-print-imm-hex --no-leading-addr --no-show-raw-insn -d %t/nolto-nolto.out --disassemble-symbols=_weak1 | FileCheck %s --check-prefix=WEAK1
+; RUN: llvm-objdump --no-print-imm-hex --no-leading-addr --no-show-raw-insn -d %t/nolto-nolto.out --disassemble-symbols=_weak2 | FileCheck %s --check-prefix=WEAK2
+
----------------
there is also the option of putting weak1/weak2 into different sections per input file. Then you could just run FileCheck on the output of `llvm-objdump --syms`. This would be my preferred approach


================
Comment at: lld/test/MachO/lc-linker-option-lto.ll:54-57
+; WEAK1-LABEL: <_weak1>:
+; WEAK1:         bl
+; WEAK2-LABEL: <_weak2>:
+; WEAK2:         mov w0, #4
----------------



Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D157716/new/

https://reviews.llvm.org/D157716



More information about the llvm-commits mailing list