https://maskray.me/blog/2022-01-16-archives-and-start-lib For every definition in an extracted archive member, we intern the symbol twice, once for the archive index entry, once for the .o symbol table after extraction. This is inefficient. Symbols in a --start-lib ObjFile/BitcodeFile are only interned once because the result is cached in symbols[i]. Just handle an archive using the --start-lib code path. We can therefore remove ArchiveFile and LazyArchive. For many projects, archive member extraction ratio is high and it is a net performance win. Linking a Release build of clang is 1.01x as fast. Note: --start-lib scans symbols in the same order that llvm-ar adds them to the index, so in the common case the semantics should be identical. If the archive symbol table was created in a different order, or is incomplete, this strategy may have different semantics. Such cases are considered user error. The `is neither ET_REL nor LLVM bitcode` error is changed to a warning. Previously an archive may have such members without a diagnostic. Using a warning prevents breakage. * For some tests, the diagnostics get improved where we did not consider the archive member name: `b.a:` => `b.a(b.o):`. * `no-obj.s`: the link is now allowed, matching GNU ld * `archive-no-index.s`: the `is neither ET_REL nor LLVM bitcode` diagnostic is demoted to a warning. * `incompatible.s`: even when an archive is unextracted, we may report an "incompatible with" error. --- I recently decreased sizeof(SymbolUnion) by 8 and decreased memory usage quite a bit, so retaining `symbols` for un-extracted archive members should not cause a memory usage problem. Reviewed By: peter.smith Differential Revision: https://reviews.llvm.org/D119074
25 lines
1.2 KiB
ArmAsm
25 lines
1.2 KiB
ArmAsm
# REQUIRES: x86
|
|
|
|
# RUN: rm -f %t-no-syms.a
|
|
# RUN: rm -f %t-syms.a
|
|
# RUN: llvm-mc -filetype=obj -triple=x86_64-pc-linux %s -o %t.o
|
|
# RUN: llvm-ar rcTS %t-no-syms.a %t.o
|
|
# RUN: llvm-ar rcT %t-syms.a %t.o
|
|
# RUN: rm %t.o
|
|
|
|
# Test error when loading symbols from missing thin archive member.
|
|
# RUN: not ld.lld --entry=_Z1fi %t-no-syms.a -o /dev/null 2>&1 | FileCheck -DMSG=%errc_ENOENT %s --check-prefix=ERR1
|
|
# ERR1: {{.*}}-no-syms.a: could not get the buffer for a child of the archive: '{{.*}}.o': [[MSG]]
|
|
|
|
# Test error when thin archive has symbol table but member is missing.
|
|
# RUN: not ld.lld --entry=_Z1fi -m elf_amd64_fbsd %t-syms.a -o /dev/null 2>&1 | FileCheck -DMSG=%errc_ENOENT %s --check-prefix=ERR2
|
|
# RUN: not ld.lld --entry=_Z1fi --no-demangle -m elf_amd64_fbsd %t-syms.a -o /dev/null 2>&1 | FileCheck -DMSG=%errc_ENOENT %s --check-prefix=ERR2
|
|
|
|
# Test error when thin archive is linked using --whole-archive but member is missing.
|
|
# RUN: not ld.lld --entry=_Z1fi --whole-archive %t-syms.a -o /dev/null 2>&1 | FileCheck -DMSG=%errc_ENOENT %s --check-prefix=ERR2
|
|
# ERR2: {{.*}}-syms.a: could not get the buffer for a child of the archive: '{{.*}}.o': [[MSG]]
|
|
|
|
.global _Z1fi
|
|
_Z1fi:
|
|
nop
|