<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_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.cpp.o: In function `llvm::InitializeAllTargets()':<br>/home/bollu/.local/include/llvm/Config/Targets.def:27: undefined reference to `LLVMInitializeNVPTXTarget'<br>CMakeFiles/sxhc.dir/src/main.cpp.o: In function `llvm::InitializeAllAsmPrinters()':<br>/home/bollu/.local/include/llvm/Config/AsmPrinters.def:28: undefined reference to `LLVMInitializeNVPTXAsmPrinter'<br>collect2: error: ld returned 1 exit status<br>CMakeFiles/sxhc.dir/build.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_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<br></div></div></div></div></div>-- <br><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr">Sending this from my phone, please excuse any typos!</div></div>