<div dir="ltr">Hi Siddharth,<div><br></div><div>can you verify that LLVMNVPTXAsmPrinter is actually the missing component library and not LLVMNVPTXCodeGen? Because AllTargetsAsmPrinter should absolutely pull in the former, but I can see how the latter is missing.</div><div><br></div><div>That being said, if you want to just link to everything all the included targets require, you can do this:</div><div><br></div><div>llvm_map_components_to_libnames(LLVM_LIBS ${LLVM_TARGETS_TO_BUILD})</div><div><br></div><div>Cheers,</div><div>Philip</div><div><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">2018-03-19 11:55 GMT+01:00 Siddharth Bhat via llvm-dev <span dir="ltr"><<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div><div><div><div><div>As the question asks, I'm having some trouble using <span style="font-family:monospace">initializeAllTargets()</span>. <br><br></div>I have a CMakeLists that uses:<br><br><span style="font-family:monospace">llvm_map_components_to_<wbr>libnames(LLVM_LIBS ...<br>    AllTargetsAsmParsers<br>    AllTargetsAsmPrinters<br>    AllTargetsDescs<br>    AllTargetsInfos<br>    ...)</span><br><br></div>However, even with these,  when I try to compile my program, I get linker errors:<br><br><span style="font-family:monospace">CMakeFiles/sxhc.dir/src/main.<wbr>cpp.o: In function `llvm::InitializeAllTargets()'<wbr>:<br>/home/bollu/.local/include/<wbr>llvm/Config/Targets.def:27: undefined reference to `LLVMInitializeNVPTXTarget'<br>CMakeFiles/sxhc.dir/src/main.<wbr>cpp.o: In function `llvm::<wbr>InitializeAllAsmPrinters()':<br>/home/bollu/.local/include/<wbr>llvm/Config/AsmPrinters.def:<wbr>28: undefined reference to `<wbr>LLVMInitializeNVPTXAsmPrinter'<br>collect2: error: ld returned 1 exit status<br>CMakeFiles/sxhc.dir/build.<wbr>make:285: recipe for target 'sxhc' failed<br>make[2]: *** [sxhc] Error 1<br>CMakeFiles/Makefile2:131: recipe for target 'CMakeFiles/sxhc.dir/all' failed<br>make[1]: *** [CMakeFiles/sxhc.dir/all] Error 2<br>Makefile:83: recipe for target 'all' failed<br>make: *** [all] Error 2</span><br><br><br></div>That is, NVPTX is not initialized as a target properly. I'm somewhat puzzled by this, because I would have assumed that the  <span style="font-family:monospace">NVPTXAsmPrinter</span> would have been linked by  <span style="font-family:monospace">AllTargetsAsmPrinters.<br><br><br></span>The hack I have right now is to manually add <span style="font-family:monospace">NVPTXCodeGen</span> to the list of <span style="font-family:monospace">llvm_map_components_to_<wbr>libnames.<br></span></div><span style="font-family:monospace"><br></span></div><span style="font-family:monospace"><font face="sans-serif">Clearly, I'm doing something wrong, </font></span><font size="2">could someone point me to what I might be screwing up? In short, <i>what is the correct way to setup targets</i>?</font><span style="font-family:monospace"> <font face="sans-serif">Is what I'm asking for (automatically link against all targets picked up by </font>initializeAllTargets()<font face="sans-serif"> an anti-pattern? if so, why?)</font><br></span><div><div><div><div><br><br></div><div>Thanks,<br></div><div>~Siddharth<span class="HOEnZb"><font color="#888888"><br></font></span></div></div></div></div></div><span class="HOEnZb"><font color="#888888">-- <br><div dir="ltr" class="m_636102170989354091gmail_signature" data-smartmail="gmail_signature"><div dir="ltr">Sending this from my phone, please excuse any typos!</div></div>
</font></span><br>______________________________<wbr>_________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org">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/<wbr>mailman/listinfo/llvm-dev</a><br>
<br></blockquote></div><br></div>