<div dir="ltr">No quite, that's the _vtable_ for cl::opt<...>. Are you loading a library that's built with RTTI in an LLVM linked without?<div><br></div><div>Philip</div></div><br><div class="gmail_quote"><div dir="ltr">On Thu, Jul 12, 2018 at 2:20 AM Viktor Was <<a href="mailto:gs15m015@technikum-wien.at">gs15m015@technikum-wien.at</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Philip,<br>
<br>
thanks for the quick answer.<br>
That makes sense, but when leaving the set LLVM_LINK_COMPONENTS out<br>
I get an undefined symbol when loading the plugin:  <br>
_ZTVN4llvm2cl3optINSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEELb0ENS0_6parserIS7_EEEE<br>
<br>
which boils down to<br>
<br>
llvm::cl::opt<std::__cxx11::basic_string<char, std::char_traits<char>,  <br>
std::allocator<char>>, false,  <br>
llvm::cl::parser<std::__cxx11::basic_string<char,  <br>
std::char_traits<char>, std::allocator<char>>>><br>
<br>
aka<br>
<br>
llvm::cl::opt<std::string, false, llvm::cl::parser<std::string>><br>
<br>
I guess...<br>
<br>
any ideas?<br>
<br>
Viktor<br>
<br>
Quoting Philip Pfaffe <<a href="mailto:philip.pfaffe@gmail.com" target="_blank">philip.pfaffe@gmail.com</a>>:<br>
<br>
> Hi Viktor,<br>
><br>
> I believe you shouldn't set LLVM_LINK_COMPONENTS.<br>
><br>
> You don't need to link your TestPass against anything since opt is expected<br>
> to have everything loaded already. If you're linking against a statically<br>
> built LLVM, then this way you'll pull in other definitions of cl::opt'ions,<br>
> which'll then clash with the ones that are in opt.<br>
><br>
> Cheers,<br>
> Philip<br>
><br>
> On Tue, Jul 10, 2018 at 3:26 PM Viktor Was via llvm-dev <<br>
> <a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>> wrote:<br>
><br>
>> Hi,<br>
>> I'm working on an LLVM Pass plugin and I'm running into a problem when<br>
>> loading it into opt.<br>
>> I want to have a custom option for my pass and added an llvm::cl::opt<br>
>> #include'ing "llvm/Support/CommandLine.h"<br>
>><br>
>> linking the dependant libs causes the following error when loading it<br>
>> with opt:<br>
>> opt: CommandLine Error: Option 'debug-pass' registered more than once!<br>
>><br>
>> I narrowed it down to the Core lib but without it I get this<br>
>><br>
>> opt:<br>
>> /home/qwert/projects/ext/repos/llvm/6.0.0/lib/Support/CommandLine.cpp:281:<br>
>><br>
>> void (anonymous<br>
>> namespace)::CommandLineParser::registerCategory(llvm::cl::OptionCategory<br>
>> *):<br>
>> Assertion `count_if(RegisteredOptionCategories, [cat](const<br>
>> OptionCategory *Category) { return cat->getName() ==<br>
>> Category->getName(); }) == 0 && "Duplicate option categories"' failed.<br>
>> LLVMSymbolizer: error reading file: No such file or directory<br>
>> #0 0x0000000001d8eea4 (opt+0x1d8eea4)<br>
>> #1 0x0000000001d8f206 (opt+0x1d8f206)<br>
>> #2 0x00007fb283220390 __restore_rt<br>
>> (/lib/x86_64-linux-gnu/libpthread.so.0+0x11390)<br>
>> #3 0x00007fb2821cd428 gsignal (/lib/x86_64-linux-gnu/libc.so.6+0x35428)<br>
>> #4 0x00007fb2821cf02a abort (/lib/x86_64-linux-gnu/libc.so.6+0x3702a)<br>
>> #5 0x00007fb2821c5bd7 (/lib/x86_64-linux-gnu/libc.so.6+0x2dbd7)<br>
>> #6 0x00007fb2821c5c82 (/lib/x86_64-linux-gnu/libc.so.6+0x2dc82)<br>
>> #7 0x0000000001d2b2a9 (opt+0x1d2b2a9)<br>
>> #8 0x00007fb281efebc2 _GLOBAL__sub_I_CommandLine.cpp<br>
>><br>
>> (/home/qwert/projects/ext/projects/cmake/llvm/6.0.0/lib/TestPass.so+0x28bc2)<br>
>> #9 0x00007fb28343c6ba (/lib64/ld-linux-x86-64.so.2+0x106ba)<br>
>> #10 0x00007fb28343c7cb (/lib64/ld-linux-x86-64.so.2+0x107cb)<br>
>> #11 0x00007fb2834418e2 (/lib64/ld-linux-x86-64.so.2+0x158e2)<br>
>> #12 0x00007fb28343c564 (/lib64/ld-linux-x86-64.so.2+0x10564)<br>
>> #13 0x00007fb283440da9 (/lib64/ld-linux-x86-64.so.2+0x14da9)<br>
>> #14 0x00007fb282e03f09 __asprintf (/lib/x86_64-linux-gnu/libdl.so.2+0xf09)<br>
>> #15 0x00007fb28343c564 (/lib64/ld-linux-x86-64.so.2+0x10564)<br>
>> #16 0x00007fb282e04571 (/lib/x86_64-linux-gnu/libdl.so.2+0x1571)<br>
>> #17 0x00007fb282e03fa1 dlopen (/lib/x86_64-linux-gnu/libdl.so.2+0xfa1)<br>
>> #18 0x0000000001d7b88b (opt+0x1d7b88b)<br>
>> #19 0x0000000001d44de9 (opt+0x1d44de9)<br>
>> #20 0x000000000069f0b4 (opt+0x69f0b4)<br>
>> #21 0x0000000001d35a91 (opt+0x1d35a91)<br>
>> #22 0x0000000001d2e3b9 (opt+0x1d2e3b9)<br>
>> #23 0x00000000006958b4 (opt+0x6958b4)<br>
>> #24 0x00007fb2821b8830 __libc_start_main<br>
>> (/lib/x86_64-linux-gnu/libc.so.6+0x20830)<br>
>> #25 0x0000000000686be9 (opt+0x686be9)<br>
>> Stack dump:<br>
>> 0.      Program arguments: opt -load<br>
>> /home/maliusarth/projects/ext/projects/cmake/llvm/6.0.0/lib/TestPass.so<br>
>> -testPass test.cpp<br>
>> Aborted<br>
>><br>
>><br>
>> in my cmakelists.txt I have the following:<br>
>><br>
>> set(CMAKE_BUILD_TYPE Debug)<br>
>><br>
>> set(LLVM_LINK_COMPONENTS<br>
>>         Core # narrowed it down to this<br>
>>         BinaryFormat<br>
>>         Support<br>
>>         Demangle<br>
>> )<br>
>><br>
>> add_llvm_loadable_module( TestPass<br>
>>         TestPass.cpp<br>
>><br>
>>         DEPENDS<br>
>>         intrinsics_gen<br>
>>         PLUGIN_TOOL<br>
>>         opt<br>
>> )<br>
>><br>
>> in my cpp I have this:<br>
>><br>
>> #include "llvm/IR/Constants.h"<br>
>> #include "llvm/IR/Function.h"<br>
>> #include "llvm/IR/Module.h"<br>
>> #include "llvm/IR/PassManager.h"<br>
>> #include "llvm/Support/raw_ostream.h"<br>
>> #include "llvm/Support/CommandLine.h"<br>
>><br>
>> #include <string><br>
>><br>
>> namespace<br>
>> {<br>
>> // Apply a custom category to all command-line options so that they are the<br>
>> // only ones displayed.<br>
>> static llvm::cl::OptionCategory testCategory("testPass Options");<br>
>><br>
>> static llvm::cl::opt<std::string><br>
>>         testOpt("testOpt", llvm::cl::desc("testOpt"),<br>
>>                    llvm::cl::value_desc("test pass opt"),<br>
>> llvm::cl::cat(testCategory));<br>
>> }<br>
>><br>
>> namespace test<br>
>> {<br>
>> char TestPass::ID = 0;<br>
>><br>
>> static ::llvm::RegisterPass<test::TestPass><br>
>>         X("testPass", "test pass", false /* Only looks at CFG */,<br>
>>           false /* Analysis Pass */);<br>
>> }<br>
>><br>
>> the rest of the file is more or less straight out of the Hello example.<br>
>><br>
>> I'm working with this llvm version<br>
>> <a href="http://llvm.org/svn/llvm-project/llvm/tags/RELEASE_600/final" rel="noreferrer" target="_blank">http://llvm.org/svn/llvm-project/llvm/tags/RELEASE_600/final</a><br>
>><br>
>> I'd appreciate any help on this issue.<br>
>><br>
>> Viktor<br>
>><br>
>> _______________________________________________<br>
>> LLVM Developers mailing list<br>
>> <a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
>> <a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
>><br>
<br>
<br>
<br>
</blockquote></div>