[PATCH] D77704: [gold] Add support for loading pass plugins

Dominic Chen via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 16 19:30:04 PDT 2020


ddcc marked an inline comment as done.
ddcc added inline comments.


================
Comment at: llvm/tools/gold/CMakeLists.txt:1
 set(LLVM_EXPORTED_SYMBOL_FILE ${CMAKE_CURRENT_SOURCE_DIR}/gold.exports)
 
----------------
efriedma wrote:
> ddcc wrote:
> > efriedma wrote:
> > > Oh, duh, I just realized the problem with the symbol exports.  The LLVM_EXPORTED_SYMBOL_FILE line suppresses exporting all the symbols pass plugins would normally use.
> > > 
> > > (And I should have realized export_executable_symbols_for_plugins shouldn't be necessary for a shared library: shared libraries export all symbols by default.)
> > Hmm, I tried both with and without `LLVM_EXPORTED_SYMBOL_FILE`, but it didn't seem to make a difference.
> > 
> > I think the fundamental problem here is that when gold calls `dlopen(LLVMgold.so, RTLD_LAZY)`, it doesn't load provide the `RTLD_GLOBAL` argument, so any symbols in `LLVMgold.so` aren't available to subsequent dynamically-loaded plugins.
> Oh, hmm, that makes sense.  That's harder to solve.
> 
> We could make LLVMgold.so dlopen() itself, I guess? That seems terribly hacky, though.
I haven't tried it, but I'm not sure if that would work. Wouldn't there be two copies of LLVM loaded into gold, with each initialized separately? It seems like a proper fix would be in gold itself, but otherwise, I'd consider having this working for `LLVM_LINK_LLVM_DYLIB` still an improvement.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D77704





More information about the llvm-commits mailing list