[PATCH] D119049: [LLD] Allow usage of LLD as a library

Alexandre Ganea via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 23 16:36:02 PST 2023


aganea added a comment.

@jerryyin The build errors were due to the fact that I only used LLD as stage-0 linker in my previous tests, assuming that its behavior is conformant with other system linkers. It is not, as described in this paragraph <https://github.com/llvm/llvm-project/blob/main/lld/ELF/Symbols.cpp#L420>. The same holds for both ELF and COFF drivers.

It seems that there's no universal solution for overriding a symbol in a LIB by a symbol in another LIB. MSVC has `/alternatename` which works, but there's no such thing on ELF side -- weak symbols cannot be overriden by another LIB once they are visible in the module, or at least I don't know how. There's also the `--include=symbol` for MSVC and `--u=symbol` for Unix that can solve the issue by pushing the symbol early in the symbol table, but then we have to deal with the mangling and that doesn't sounds fun. In the end, if users want to use a partial set of the LLD drivers, I resorted to simply implementing the missing drivers with the `LLD_IMPLEMENT_SHALLOW_DRIVER` macro (see ROCm test). If there's a better/simpler solution for a user perspective, let me know and I'll try it.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D119049/new/

https://reviews.llvm.org/D119049



More information about the llvm-commits mailing list