[all-commits] [llvm/llvm-project] d838bf: [ELF] Allow non-bitcode archive with an empty index
Fangrui Song via All-commits
all-commits at lists.llvm.org
Wed Jan 19 10:02:07 PST 2022
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: d838bf2adc9cba1ef56e446fc2070dda233c1d05
https://github.com/llvm/llvm-project/commit/d838bf2adc9cba1ef56e446fc2070dda233c1d05
Author: Fangrui Song <i at maskray.me>
Date: 2022-01-19 (Wed, 19 Jan 2022)
Changed paths:
M lld/ELF/Driver.cpp
M lld/test/ELF/archive-no-index.s
M lld/test/ELF/lto/archive-no-index.ll
Log Message:
-----------
[ELF] Allow non-bitcode archive with an empty index
When an archive with an empty index contains only bitcode files, it is
handled as a group of lazy (--start-lib) object files. If there is a
non-bitcode file, there will be a diagnostic a la GNU ld.
For some programs, the archive member extraction ratio is high (e.g. for chrome,
79% archive members are extracted according to --print-archive-stats=). Because
symbol interning is cached for ObjFile::parseLazy but not for ArchiveFile,
parsing an archive as a group of --start-lib object files may be faster.
If the linker speculatively creates section representations for archive members,
the archive index will not be used.
If we take the above view, the archive index is essentially useless. If a user
wants a fast build without using --start-lib, they may just build thin archives
without index (`ar rcS --thin`).
Therefore, I suggest that we no longer treat the code as a hack, instead as a
supported feature. I believe we will do this anyway if we add parallel symbol
interning (parallel symbol interning for lazy object files is simpler than that
for archives).
Ecosystem issues:
* parseLazy actually has nearly the same behavior as ArchiveFile::parse, but the symbol order may be different.
* users may get addicted to the behavior and build archives not working with GNU ld and gold. I think it is easy to rebuild archives to be compatible.
Reviewed By: ikudrin
Differential Revision: https://reviews.llvm.org/D117284
More information about the All-commits
mailing list