[llvm-dev] linker warning while using PluginLoader with PassInfo

Bekket McClane via llvm-dev llvm-dev at lists.llvm.org
Mon Jul 17 21:00:49 PDT 2017


Hi,

I tried to write a simple Pass plugin loader to load passes.

Here is the brief steps I did:
1. Declare a command line option like this:
static cl::list<const PassInfo*, bool, PassNameParser>
 PassList(cl::desc(...));

2. include “llvm/Support/PluginLoader.h”

3. Iterate over PassList to get each PassInfo, then invoke getNormalCtor to construct the pass

Everything goes fine, I can also load plugin normally. However, there are some warning thrown during link time(of this tool):

ld: warning: direct access in function 'llvm::cl::list<llvm::PassInfo const*, bool, llvm::PassNameParser>::pri
ntOptionInfo(unsigned long) const' from file '/usr/local/opt/llvm-clang/current/lib/libLLVMCore.a(LegacyPassMa
nager.cpp.o)' to global weak symbol 'llvm::PassNameParser::ValLessThan(llvm::cl::parser<llvm::PassInfo const*>
::OptionInfo const*, llvm::cl::parser<llvm::PassInfo const*>::OptionInfo const*)' from file ‘MY OBJECT FILE' means the weak symbol cannot be overridden at runtime. This was likely caused by different translation units being compiled with different visibility settings.

ld: warning: direct access in function 'llvm::PassNameParser::printOptionInfo(llvm::cl::Option const&, unsigned long) const' from file '/usr/local/opt/llvm-clang/current/lib/libLLVMCore.a(Pass.cpp.o)' to global weak symbol 'llvm::PassNameParser::ValLessThan(llvm::cl::parser<llvm::PassInfo const*>::OptionInfo const*, llvm::cl::parser<llvm::PassInfo const*>::OptionInfo const*)' from file 'MY OBJECT FILE' means the weak symbol cannot be overridden at runtime. This was likely caused by different translation units being compiled with different visibility settings.

ld: warning: direct access in function 'non-virtual thunk to llvm::PassNameParser::printOptionInfo(llvm::cl::Option const&, unsigned long) const' from file '/usr/local/opt/llvm-clang/current/lib/libLLVMCore.a(Pass.cpp.o)' to global weak symbol 'llvm::PassNameParser::ValLessThan(llvm::cl::parser<llvm::PassInfo const*>::OptionInfo const*, llvm::cl::parser<llvm::PassInfo const*>::OptionInfo const*)' from file 'MY OBJECT FILE' means the weak symbol cannot be overridden at runtime. This was likely caused by different translation units being compiled with different visibility settings.

I’m not quiet understand what it said. I copy nearly every code related to plugin loading from the opt tool.
Could somebody answer this?
Thank you

Best Regards,
Bekket McClane


More information about the llvm-dev mailing list