llvm-project/lld/test/MachO
Nico Weber d5a70db193 [lld/mac] Write every weak symbol only once in the output
Before this, if an inline function was defined in several input files,
lld would write each copy of the inline function the output. With this
patch, it only writes one copy.

Reduces the size of Chromium Framework from 378MB to 345MB (compared
to 290MB linked with ld64, which also does dead-stripping, which we
don't do yet), and makes linking it faster:

        N           Min           Max        Median           Avg        Stddev
    x  10     3.9957051     4.3496981     4.1411121      4.156837    0.10092097
    +  10      3.908154      4.169318     3.9712729     3.9846753   0.075773012
    Difference at 95.0% confidence
            -0.172162 +/- 0.083847
            -4.14165% +/- 2.01709%
            (Student's t, pooled s = 0.0892373)

Implementation-wise, when merging two weak symbols, this sets a
"canOmitFromOutput" on the InputSection belonging to the weak symbol not put in
the symbol table. We then don't write InputSections that have this set, as long
as they are not referenced from other symbols. (This happens e.g. for object
files that don't set .subsections_via_symbols or that use .alt_entry.)

Some restrictions:
- not yet done for bitcode inputs
- no "comdat" handling (`kindNoneGroupSubordinate*` in ld64) --
  Frame Descriptor Entries (FDEs), Language Specific Data Areas (LSDAs)
  (that is, catch block unwind information) and Personality Routines
  associated with weak functions still not stripped. This is wasteful,
  but harmless.
- However, this does strip weaks from __unwind_info (which is needed for
  correctness and not just for size)
- This nopes out on InputSections that are referenced form more than
  one symbol (eg from .alt_entry) for now

Things that work based on symbols Just Work:
- map files (change in MapFile.cpp is no-op and not needed; I just
  found it a bit more explicit)
- exports

Things that work with inputSections need to explicitly check if
an inputSection is written (e.g. unwind info).

This patch is useful in itself, but it's also likely also a useful foundation
for dead_strip.

I used to have a "canoncialRepresentative" pointer on InputSection instead of
just the bool, which would be handy for ICF too. But I ended up not needing it
for this patch, so I removed that again for now.

Differential Revision: https://reviews.llvm.org/D102076
2021-05-07 17:11:40 -04:00
..
Inputs [lld-macho] Support loading of zippered dylibs 2021-05-06 11:19:40 -04:00
invalid [lld-macho] Check simulator platforms to avoid issuing false positive errors. 2021-05-05 18:07:58 -04:00
tools [lld-macho] Emit personalities in compact unwind 2021-02-08 13:47:59 -05:00
U-dynamic-lookup.s [lld/mac] Add some support for dynamic lookup symbols, and implement -U 2021-02-26 16:50:53 -05:00
abs-symbols.s [lld-macho][nfc] Extend abs-symbol.s to test for local absolute symbols 2021-04-08 12:21:01 -04:00
add-ast-path.s [lld-macho] Support -add_ast_path 2021-04-08 14:12:55 -04:00
adhoc-codesign.s [lld-macho] Only codesign by default on arm64 macOS 2021-03-12 17:26:27 -05:00
arch.s [lld-macho] Always include custom syslibroot when running tests 2020-09-25 11:28:36 -07:00
archive.s [lld-macho][nfc] Clean up tests 2020-12-21 14:44:08 -05:00
arm-branch-relocs.s [lld-macho] Preliminary support for ARM_RELOC_BR24 2021-05-05 14:41:01 -04:00
arm64-32-reloc-got-load.s [llvm-objdump] Improve newline consistency between different pieces of information 2021-05-04 09:56:07 -07:00
arm64-32-stubs.s [lld-macho] Add support for arm64_32 2021-04-15 21:16:33 -04:00
arm64-reloc-got-load.s [llvm-objdump] Improve newline consistency between different pieces of information 2021-05-04 09:56:07 -07:00
arm64-reloc-pointer-to-got.s [lld-macho][nfc] Convert tabs to spaces 2021-04-11 23:25:23 -04:00
arm64-reloc-tlv-load.s [llvm-objdump] Improve newline consistency between different pieces of information 2021-05-04 09:56:07 -07:00
arm64-relocs.s [lld-macho][nfc] Convert tabs to spaces 2021-04-11 23:25:23 -04:00
arm64-stubs.s [lld-macho][nfc] Add test for ARM64 stubs 2021-04-07 12:08:12 -04:00
bitcode-bundle.ll [lld-macho] Ensure segments are laid out contiguously 2021-04-20 16:58:57 -04:00
bitcode-nodatalayout.ll [lld-macho] Support parsing of bitcode within archives 2020-12-08 10:34:32 -08:00
bss.s [lld-macho] Ensure segments are laid out contiguously 2021-04-20 16:58:57 -04:00
builtin-rename.s [lld-macho] Implement builtin section renaming 2021-05-03 21:26:51 -07:00
bundle-loader.s Reland [lld-macho]Implement bundle_loader 2021-02-22 14:05:12 -05:00
codemodel.ll [lld-macho] Add support for -mcpu, -mattr, -code-model in LTO 2020-12-10 15:57:51 -08:00
color-diagnostics.test [lld/mac] Implement basic typo correction for flags 2020-11-24 11:33:39 -05:00
common-symbol-coalescing.s [lld-macho] Always include custom syslibroot when running tests 2020-09-25 11:28:36 -07:00
common-symbol-resolution.s [lld-macho][nfc] Clean up tests 2020-12-21 14:44:08 -05:00
compact-unwind-generated.test [lld-macho] Have tests default to targeting macos 10.15 2021-04-23 09:25:08 -04:00
compact-unwind.s [lld-macho] Have tests default to targeting macos 10.15 2021-04-23 09:25:08 -04:00
cpu-string.ll [lld-macho] Add support for -mcpu, -mattr, -code-model in LTO 2020-12-10 15:57:51 -08:00
demangle.s [lld-macho] Implement option: -undefined TREATMENT 2020-12-17 17:40:50 -08:00
dependency-info.s [lld-macho] Re-root absolute input file paths if -syslibroot is specified 2021-04-15 21:16:33 -04:00
driver.test [lld][test] Relax test assertion of cmake defaults appearing in --version output. 2020-12-23 14:33:04 -08:00
dso-handle.s [lld-macho][nfc] Give every SyntheticSection a fake InputSection 2021-03-12 17:26:27 -05:00
dylib-stub.yaml [lld-macho] Fix alignment & layout to match ld64 and satisfy kernel & codesign 2021-02-05 17:22:03 -07:00
dylib-version.s [mac/lld] simplify code using PackedVersion instead of VersionTuple 2020-12-15 19:23:07 -05:00
dylib.s [lld-macho] Always include custom syslibroot when running tests 2020-09-25 11:28:36 -07:00
dylink.s [lld/mac] fill in current and compatibility version for LC_LOAD_(WEAK_)DYLIB 2020-12-15 19:34:59 -05:00
encryption-info.s [lld/mac] add aarch64 to requirements of encryption-info.s test 2021-04-21 14:21:42 -04:00
entry-symbol.s [lld-macho] Fix alignment & layout to match ld64 and satisfy kernel & codesign 2021-02-05 17:22:03 -07:00
error-limit.test [lld-macho] Add option --error-limit=N 2021-04-26 07:10:12 -07:00
export-options.s [lld/mac] Don't assert when using -exported_symbol with private symbol 2021-04-24 10:21:51 -04:00
export-trie.s [lld-macho] Have tests default to targeting macos 10.15 2021-04-23 09:25:08 -04:00
fat-arch.s [lld-macho] Always include custom syslibroot when running tests 2020-09-25 11:28:36 -07:00
fatal-warnings.s [mac/lld] Run tests with -fatal_warnings by default 2020-12-03 21:23:47 -05:00
filelist.s [lld-macho][nfc] Clean up tests 2020-12-21 14:44:08 -05:00
flat-namespace.s [lld/mac] Add support for -flat_namespace 2021-03-01 15:25:10 -05:00
force-load.s [lld-macho][nfc] Clean up tests 2020-12-21 14:44:08 -05:00
framework.s [lld-macho][nfc] Clean up tests 2020-12-21 14:44:08 -05:00
function-starts.s [lld-macho] Support -no_function_starts 2021-03-26 18:14:10 -04:00
header.s [lld-macho] Initial scaffolding for ARM32 support 2021-04-30 16:17:25 -04:00
headerpad.s [lld][MachO] Add support for LC_FUNCTION_STARTS 2021-03-08 22:08:36 -08:00
implicit-dylibs.s [lld-macho] Bind re-exported symbols directly to implicitly-linked umbrellas 2021-03-04 14:36:44 -05:00
indirect-symtab.s [lld-macho][nfc] Convert tabs to spaces 2021-04-11 23:25:23 -04:00
install-name.s [lld/mac] warn on -install_name without -dylib 2021-03-10 09:05:44 -05:00
internalize.ll [lld-macho] Have tests default to targeting macos 10.15 2021-04-23 09:25:08 -04:00
lc-build-version.s [lld][MachO] Add support for LC_VERSION_MIN_* load commands 2021-04-21 05:41:14 -07:00
lc-linker-option.ll [lld-macho] Have tests default to targeting macos 10.15 2021-04-23 09:25:08 -04:00
link-search-order.s [lld/mac] Use libSystem.dylib instead of libSystem.B.dylib in tests 2021-03-01 15:23:28 -05:00
linkedit-contiguity.s [lld-macho] Ensure segments are laid out contiguously 2021-04-20 16:58:57 -04:00
linkonce.ll [lld-macho] Have tests default to targeting macos 10.15 2021-04-23 09:25:08 -04:00
lit.local.cfg [lld-macho] Have tests default to targeting macos 10.15 2021-04-23 09:25:08 -04:00
load-command-sequence.s [lld-macho] Implement builtin section renaming 2021-05-03 21:26:51 -07:00
load-commands.s [mac/lld] Run tests with -fatal_warnings by default 2020-12-03 21:23:47 -05:00
local-got.s [lld-macho] Implement builtin section renaming 2021-05-03 21:26:51 -07:00
lto-archive.ll [lld-macho] Have tests default to targeting macos 10.15 2021-04-23 09:25:08 -04:00
lto-object-path.ll [lld-macho] Have tests default to targeting macos 10.15 2021-04-23 09:25:08 -04:00
lto-save-temps.ll [lld-macho] Have tests default to targeting macos 10.15 2021-04-23 09:25:08 -04:00
map-file.s [lld-macho] Have tests default to targeting macos 10.15 2021-04-23 09:25:08 -04:00
mark-dead-strippable-dylib.s [lld/mac] Implement support for -mark_dead_strippable_dylib 2021-03-10 08:57:46 -05:00
mattrs.ll [lld-macho][nfc] Convert tabs to spaces 2021-04-11 23:25:23 -04:00
mh-execute-header.s [lld-macho] Define __mh_*_header synthetic symbols. 2021-03-19 14:14:40 -04:00
mh-header-link.s [lld-macho] Have tests default to targeting macos 10.15 2021-04-23 09:25:08 -04:00
module-asm.ll [lld-macho] Have tests default to targeting macos 10.15 2021-04-23 09:25:08 -04:00
no-exports-dylib.s [lld-macho] Always include custom syslibroot when running tests 2020-09-25 11:28:36 -07:00
no-unneeded-dyld-info.s [lld-macho] Always include custom syslibroot when running tests 2020-09-25 11:28:36 -07:00
nonweak-definition-override.s [lld-macho] Always include custom syslibroot when running tests 2020-09-25 11:28:36 -07:00
objc-arc-contract.ll [lld-macho] Run ObjCContractPass during LTO 2021-01-20 14:21:32 -05:00
objc.s [lld-macho] Add ARM requirement to objc.s 2021-05-03 18:47:30 -04:00
order-file.s [lld-macho][nfc] Clean up tests 2020-12-21 14:44:08 -05:00
platform-version.s [lld-macho] Simulator & DriverKit executables should always be PIE 2020-12-23 11:24:12 -05:00
private-extern.s [lld-macho]][nfc] Fix some typos + rephrase a comment 2021-04-23 18:05:48 -04:00
reexport-stub.s [lld-macho] Implement `-no_implicit_dylibs` 2020-12-10 15:57:52 -08:00
reloc-subtractor.s [lld-macho] Support subtractor relocations that reference sections 2021-04-20 16:58:57 -04:00
rename.s [lld-macho] Rework length check when opening input files 2021-03-02 13:00:57 -08:00
reproduce-thin-archives.s [mac/lld] Make --reproduce work with thin archives 2020-12-02 09:48:31 -05:00
reproduce.s Require shell for lld/test/MachO/reproduce.s 2021-04-30 14:23:35 +02:00
reroot-path.s [lld-macho] Have --reproduce account for path rerooting 2021-05-05 14:41:01 -04:00
resolution.s [lld-macho][nfc] Clean up tests 2020-12-21 14:44:08 -05:00
responsefile.test [mac/lld] Add support for response files 2020-11-30 08:23:58 -05:00
rpath.s [lld-macho] Always include custom syslibroot when running tests 2020-09-25 11:28:36 -07:00
search-paths-darwin.test [lld-macho] Switch default to new Darwin backend 2021-03-01 12:30:10 -05:00
search-paths.test [lld/mac on non-mac] fix test/MachO/search-paths.test after ab45289d2e 2021-03-01 15:21:24 -05:00
sectcreate.s [lld-macho][nfc] Remove HelpHidden from aliases to implemented flags 2021-04-06 15:10:00 -04:00
section-headers.s [lld-macho] Ensure segments are laid out contiguously 2021-04-20 16:58:57 -04:00
section-merge.s [lld-macho][nfc] Clean up tests 2020-12-21 14:44:08 -05:00
segments.s [lld-macho] Ensure segments are laid out contiguously 2021-04-20 16:58:57 -04:00
segprot.s [lld-macho] Implement -segprot 2021-03-29 14:08:12 -04:00
silent-ignore.test [lld/mac] Make -v print version and search paths in additon to linking, not instead of linking 2021-03-01 15:09:46 -05:00
skip-platform-checks.s [lld-macho] Skip platform checks for a few libSystem re-exports 2021-04-20 19:54:53 -04:00
stabs.s [lld-macho] Sibling N_SO symbols must have the empty string 2021-04-07 12:08:14 -04:00
static-link.s [lld-macho] Always include custom syslibroot when running tests 2020-09-25 11:28:36 -07:00
sub-library.s [lld-macho] Support -sub_umbrella 2020-12-15 15:58:26 -05:00
subsections-section-relocs.s [lld-macho][nfc] Clean up tests 2020-12-21 14:44:08 -05:00
subsections-symbol-relocs.s [lld-macho][nfc] Clean up tests 2020-12-21 14:44:08 -05:00
symbol-order.s [lld-macho][nfc] Clean up tests 2020-12-21 14:44:08 -05:00
symtab.s [llvm-readobj] Recognize N_THUMB_DEF as a symbol flag 2021-04-30 17:39:56 -04:00
syslibroot.test [lld-macho] Require -arch and -platform_version to always be specified 2021-03-03 15:52:10 -05:00
t.s [lld-macho] Have tests default to targeting macos 10.15 2021-04-23 09:25:08 -04:00
tapi-framework.s [lld-macho][nfc] Rename some tests 2021-04-06 15:10:00 -04:00
tapi-link-by-arch.s [re-land][lld-macho] Fix min version check 2021-04-22 19:35:32 -04:00
tapi-link.s [lld-macho][nfc] Rename some tests 2021-04-06 15:10:00 -04:00
thin-archive.s [mac/lld] fix typo in 07ab597bb0 that broke test on Windows 2020-12-01 20:36:49 -05:00
thinlto-jobs.ll [lld-macho] Support --thinlto-jobs 2021-04-08 12:21:01 -04:00
thinlto-time-trace.ll [lld-macho] Add time tracing for LTO 2021-03-26 18:14:10 -04:00
threads.s [lld-macho] Add support for --threads 2021-03-25 14:51:31 -04:00
time-trace.s [lld-macho] Make time-trace* options more permissive. 2021-04-07 16:00:20 -04:00
tlv-dylib.s [lld-macho][nfc] Convert tabs to spaces 2021-04-11 23:25:23 -04:00
tlv.s [lld-macho][nfc] Convert tabs to spaces 2021-04-11 23:25:23 -04:00
treat-undef-sym.s [lld/mac] Implement the missing bits of -undefined 2021-03-01 15:30:53 -05:00
u.s [lld-macho] Have toString() emit full path to archive files 2021-04-13 10:43:28 -04:00
weak-binding.s [lld-macho][nfc] Convert tabs to spaces 2021-04-11 23:25:23 -04:00
weak-def-can-be-hidden.s [lld/mac] Implement support for .weak_def_can_be_hidden 2021-04-22 22:51:34 -04:00
weak-def-thumb-conflict.s [lld-macho] Parse & emit the N_ARM_THUMB_DEF symbol flag 2021-04-30 16:17:26 -04:00
weak-definition-direct-fetch.s [lld/mac] Remove unused -L%t flags from tests 2021-04-30 09:37:02 -04:00
weak-definition-gc.s [lld/mac] Write every weak symbol only once in the output 2021-05-07 17:11:40 -04:00
weak-definition-indirect-fetch.s [lld/mac] Remove unused -L%t flags from tests 2021-04-30 09:37:02 -04:00
weak-definition-order.s [lld/mac] Remove unused -L%t flags from tests 2021-04-30 09:37:02 -04:00
weak-definition-over-dysym.s [lld-macho][nfc] Clean up tests 2020-12-21 14:44:08 -05:00
weak-header-flags.s [lld-macho] Always include custom syslibroot when running tests 2020-09-25 11:28:36 -07:00
weak-import.s [lld/mac] Use libSystem.dylib instead of libSystem.B.dylib in tests 2021-03-01 15:23:28 -05:00
weak-private-extern.s [lld/mac] slightly improve weak-private-extern.s test 2021-04-22 22:42:48 -04:00
weak-reference.s [lld-macho][nfc] Convert tabs to spaces 2021-04-11 23:25:23 -04:00
why-load.s [lld-macho] Have toString() emit full path to archive files 2021-04-13 10:43:28 -04:00
x86-64-reloc-got-load.s [lld-macho][nfc] Convert tabs to spaces 2021-04-11 23:25:23 -04:00
x86-64-reloc-signed.s [lld-macho] Fix handling of X86_64_RELOC_SIGNED_{1,2,4} 2021-03-11 13:28:11 -05:00
x86-64-reloc-unsigned.s [lld-macho] Make everything PIE by default 2021-04-29 15:11:23 -04:00
x86-64-relocs.s [lld-macho] Implement builtin section renaming 2021-05-03 21:26:51 -07:00
x86-64-stubs.s [lld-macho] Implement builtin section renaming 2021-05-03 21:26:51 -07:00
zippered.yaml [lld-macho] Support loading of zippered dylibs 2021-05-06 11:19:40 -04:00