[lld-macho] Add --start-lib --end-lib
authorFangrui Song <i@maskray.me>
Wed, 19 Jan 2022 18:14:49 +0000 (10:14 -0800)
committerFangrui Song <i@maskray.me>
Wed, 19 Jan 2022 18:14:49 +0000 (10:14 -0800)
commit0aae2bf37318eff2ac4abeb570383d9d603be552
treeb833c2a2927aa4c06fb610d6526a28b470b3f631
parent4f61749e16f63b0c9ebd9bdd1f8bf4f570a31692
[lld-macho] Add --start-lib --end-lib

In ld.lld, when an ObjFile/BitcodeFile is read in --start-lib state, the file is
given archive semantics. --end-lib closes the previous --start-lib. A build
system can use this feature as an alternative to archives. This patch ports
the feature to lld-macho.

--start-lib and --end-lib are positional, unlike usual ld64 options.
I think the slight drawback does not matter as (a) reusing option names
make build systems convenient (b) `--start-lib a.o b.o --end-lib` conveys more
information than an alternative design: `-objlib a.o -objlib b.o` because
--start-lib makes it clear which objects are in the same conceptual archive.
This provides flexibility (c) `-objlib`/`-filelist` interaction may be weird.

Close https://github.com/llvm/llvm-project/issues/52931

Reviewed By: #lld-macho, Jez Ng, oontvoo

Differential Revision: https://reviews.llvm.org/D116913
12 files changed:
lld/MachO/Driver.cpp
lld/MachO/InputFiles.cpp
lld/MachO/InputFiles.h
lld/MachO/Options.td
lld/MachO/SymbolTable.cpp
lld/MachO/SymbolTable.h
lld/MachO/Symbols.h
lld/MachO/UnwindInfoSection.cpp
lld/test/MachO/objc-uses-custom-personality.s
lld/test/MachO/objc.s
lld/test/MachO/start-lib.s [new file with mode: 0644]
lld/test/MachO/weak-definition-direct-fetch.s