[PATCH] D62935: [ThinLTO][LTO][Legacy] Fix dependent libraries support by adding querying of the IRSymtab

ben via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jun 10 18:11:16 PDT 2019


bd1976llvm added a comment.

In D62935#1537096 <https://reviews.llvm.org/D62935#1537096>, @steven_wu wrote:

> > We should look at either merging the implementations or providing an api function that provides access to the "llvm.linker.options" named metadata via the IRSymtab. It may not be possible to merge the implementations because in COFF and MACHO the representation of dependent libraries is a string of command line options; whereas, the ELF representation is an array of library strings. This is because for COFF and MACHO there is basically only one linker for each file format so the command line format is fixed. For ELF there are a greater variety of linkers, so I just pass the library strings through to the linker, without processing them into command line arguments, and it is deferred to the linker to interpret the library strings.
>
> It would be good if the API is flexible to return either. Not against having a different API to return linker options but I think that is less clean.


Actually, now I remember that we need both. Developers do want to use linker options on ELF in the future (LLVM retains support for linker options on ELF - https://llvm.org/docs/Extensions.html#linker-options-section-linker-options). It is not implemented yet in LLD; but, I believe that the idea is that in source code "#pragma comment(lib, "foo") writes "foo" into the llvm.dependent-libraries and some new pragma e.g. #pragma linker(lib, "foo") would write ("lib", "foo") into llvm.linker-options which will specify -lfoo to ELF linkers. Given that, I think that we need to have separate api functions in the LTO interface.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62935





More information about the llvm-commits mailing list