[PATCH] D78342: [lld] Add archive file support to Mach-O backend

Fangrui Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun May 3 17:02:02 PDT 2020


MaskRay added inline comments.


================
Comment at: lld/test/MachO/archive.s:3
+# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %s -o %t
+# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %S/Inputs/archive.s -o %t.main
+# RUN: llvm-mc -filetype=obj -triple=x86_64-apple-darwin %S/Inputs/archive2.s -o %t2
----------------
Ktwu wrote:
> int3 wrote:
> > Nits: I don't think having a separate `Inputs/archive.s` is necessary; could just include its contents below and reference it  via `%s`.
> > 
> > Also, I was looking at some of the lld-ELF tests (e.g. `archive-fetch.s`), and it seems that we can create object files / archives with symbols but no corresponding code. So we could define those files inline too via `echo '.globl _boo | llvm-mc ...`
> I'll definitely get rid of archive.s (this was back when I didn't know how Filecheck worked).
> 
> I like having explicit test files (although knowing about passing stuff straight to llvm-mc is a neat trick), so I'd prefer to keep the archive#.s if that's OK.
For a definition, just write:

`echo '.globl _bar; _bar:' | llvm-mc -filetype=obj -triple=x86_64-apple-darwin - -o %t2.o`

For a reference:

`echo '.globl _bar' | llvm-mc -filetype=obj -triple=x86_64-apple-darwin - -o %t3.o`

Use applicable file extensions.


================
Comment at: lld/test/MachO/archive.s:11
+# RUN: lld -flavor darwinnew %t %t.a -o %t.out
+# RUN: llvm-nm %t.out | FileCheck %s
+
----------------
`llvm-nm -p` may be better than plain `llvm-nm`. We can additionally check the symbol order.



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78342





More information about the llvm-commits mailing list