[PATCH] D103324: [lld/mac] Implement -dead_strip
Nico Weber via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri May 28 08:46:33 PDT 2021
thakis created this revision.
thakis added a reviewer: lld-macho.
Herald added subscribers: dang, mgorny.
Herald added a reviewer: int3.
Herald added a reviewer: gkm.
Herald added a project: lld-macho.
thakis requested review of this revision.
Herald added a project: LLVM.
Also adds support for live_support sections, no_dead_strip sections,
.no_dead_strip symbols.
Chromium Framework 345MB unstripped -> 250MB stripped
(vs 290MB unstripped -> 236M stripped with ld64).
Doing dead stripping is a bit faster than not, because so much less
data needs to be processed:
% ministat lld_*
x lld_nostrip.txt
+ lld_strip.txt
N Min Max Median Avg Stddev
x 10 3.929414 4.07692 4.0269079 4.0089678 0.044214794
+ 10 3.8129408 3.9025559 3.8670411 3.8642573 0.024779651
Difference at 95.0% confidence
-0.144711 +/- 0.0336749
-3.60967% +/- 0.839989%
(Student's t, pooled s = 0.0358398)
This interacts with many parts of the linker. I tried to add test coverage
for all added `isLive()` checks, so that some test will fail if any of them
is removed. (It's possible there's interaction with some feature I didn't
think of though.) Interacts with:
- debug info
- export tries
- import opcodes
- flags like -exported_symbol(s_list)
- -U / dynamic_lookup
- mod_init_funcs, mod_term_funcs
- weak symbol handling
- unwind info
- stubs
- map files
- -sectcreate
I also did some manual testing:
- check-llvm check-clang check-lld work with lld with this patch as host linker and -dead_strip enabled
- Chromium still starts
- Chromium's base_unittests still pass, including unwind tests
Implemenation-wise, this is InputSection-based, so it'll work for
object files with .subsections_via_symbols (which includes all
object files generated by clang). I first based this on the COFF
implementation, but later realized that things are more similar to ELF.
I think it'd be good to refactor MarkLive.cpp to look more like the ELF
part at some point, but I'd like to get a working state checked in first.
Mechanical parts:
- Rename canOmitFromOutput to wasCoalesced (no behavior change) since it really is for weak coalesced symbols
- Add noDeadStrip to Defined, corresponding to N_NO_DEAD_STRIP (`.no_dead_strip` in asm)
https://reviews.llvm.org/D103324
Files:
lld/MachO/CMakeLists.txt
lld/MachO/ConcatOutputSection.cpp
lld/MachO/Config.h
lld/MachO/Driver.cpp
lld/MachO/InputFiles.cpp
lld/MachO/InputSection.h
lld/MachO/MapFile.cpp
lld/MachO/MarkLive.cpp
lld/MachO/MarkLive.h
lld/MachO/Options.td
lld/MachO/SymbolTable.cpp
lld/MachO/SymbolTable.h
lld/MachO/Symbols.cpp
lld/MachO/Symbols.h
lld/MachO/SyntheticSections.cpp
lld/MachO/SyntheticSections.h
lld/MachO/UnwindInfoSection.cpp
lld/MachO/Writer.cpp
lld/test/MachO/Inputs/MacOSX.sdk/usr/lib/libc++abi.tbd
lld/test/MachO/dead-strip.s
lld/test/MachO/mh-header-link.s
lld/test/MachO/sectcreate.s
llvm/utils/gn/secondary/lld/MachO/BUILD.gn
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D103324.348542.patch
Type: text/x-patch
Size: 55334 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210528/5d5a70cc/attachment.bin>
More information about the llvm-commits
mailing list