Siddharth Bhat via llvm-dev
2018-Mar-19 10:55 UTC
[llvm-dev] How to link against all available targets - problems with NVPTX?
As the question asks, I'm having some trouble using initializeAllTargets().
I have a CMakeLists that uses:
llvm_map_components_to_libnames(LLVM_LIBS ...
AllTargetsAsmParsers
AllTargetsAsmPrinters
AllTargetsDescs
AllTargetsInfos
...)
However, even with these, when I try to compile my program, I get linker
errors:
CMakeFiles/sxhc.dir/src/main.cpp.o: In function
`llvm::InitializeAllTargets()':
/home/bollu/.local/include/llvm/Config/Targets.def:27: undefined reference
to `LLVMInitializeNVPTXTarget'
CMakeFiles/sxhc.dir/src/main.cpp.o: In function
`llvm::InitializeAllAsmPrinters()':
/home/bollu/.local/include/llvm/Config/AsmPrinters.def:28: undefined
reference to `LLVMInitializeNVPTXAsmPrinter'
collect2: error: ld returned 1 exit status
CMakeFiles/sxhc.dir/build.make:285: recipe for target 'sxhc' failed
make[2]: *** [sxhc] Error 1
CMakeFiles/Makefile2:131: recipe for target 'CMakeFiles/sxhc.dir/all'
failed
make[1]: *** [CMakeFiles/sxhc.dir/all] Error 2
Makefile:83: recipe for target 'all' failed
make: *** [all] Error 2
That is, NVPTX is not initialized as a target properly. I'm somewhat
puzzled by this, because I would have assumed that the NVPTXAsmPrinter
would have been linked by AllTargetsAsmPrinters.
The hack I have right now is to manually add NVPTXCodeGen to the list of
llvm_map_components_to_libnames.
Clearly, I'm doing something wrong, could someone point me to what I might
be screwing up? In short, *what is the correct way to setup targets*? Is
what I'm asking for (automatically link against all targets picked up by
initializeAllTargets() an anti-pattern? if so, why?)
Thanks,
~Siddharth
--
Sending this from my phone, please excuse any typos!
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://lists.llvm.org/pipermail/llvm-dev/attachments/20180319/8209ab64/attachment.html>
Philip Pfaffe via llvm-dev
2018-Mar-19 11:38 UTC
[llvm-dev] How to link against all available targets - problems with NVPTX?
Hi Siddharth,
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.
That being said, if you want to just link to everything all the included
targets require, you can do this:
llvm_map_components_to_libnames(LLVM_LIBS ${LLVM_TARGETS_TO_BUILD})
Cheers,
Philip
2018-03-19 11:55 GMT+01:00 Siddharth Bhat via llvm-dev <
llvm-dev at lists.llvm.org>:
> As the question asks, I'm having some trouble using
initializeAllTargets().
>
>
> I have a CMakeLists that uses:
>
> llvm_map_components_to_libnames(LLVM_LIBS ...
> AllTargetsAsmParsers
> AllTargetsAsmPrinters
> AllTargetsDescs
> AllTargetsInfos
> ...)
>
> However, even with these, when I try to compile my program, I get linker
> errors:
>
> CMakeFiles/sxhc.dir/src/main.cpp.o: In function
> `llvm::InitializeAllTargets()':
> /home/bollu/.local/include/llvm/Config/Targets.def:27: undefined
> reference to `LLVMInitializeNVPTXTarget'
> CMakeFiles/sxhc.dir/src/main.cpp.o: In function `llvm::
> InitializeAllAsmPrinters()':
> /home/bollu/.local/include/llvm/Config/AsmPrinters.def:28: undefined
> reference to `LLVMInitializeNVPTXAsmPrinter'
> collect2: error: ld returned 1 exit status
> CMakeFiles/sxhc.dir/build.make:285: recipe for target 'sxhc' failed
> make[2]: *** [sxhc] Error 1
> CMakeFiles/Makefile2:131: recipe for target
'CMakeFiles/sxhc.dir/all'
> failed
> make[1]: *** [CMakeFiles/sxhc.dir/all] Error 2
> Makefile:83: recipe for target 'all' failed
> make: *** [all] Error 2
>
>
> That is, NVPTX is not initialized as a target properly. I'm somewhat
> puzzled by this, because I would have assumed that the NVPTXAsmPrinter
> would have been linked by AllTargetsAsmPrinters.
>
>
> The hack I have right now is to manually add NVPTXCodeGen to the list of
> llvm_map_components_to_libnames.
>
> Clearly, I'm doing something wrong, could someone point me to what I
> might be screwing up? In short, *what is the correct way to setup targets*
> ? Is what I'm asking for (automatically link against all targets picked
> up by initializeAllTargets() an anti-pattern? if so, why?)
>
>
> Thanks,
> ~Siddharth
> --
> Sending this from my phone, please excuse any typos!
>
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL:
<http://lists.llvm.org/pipermail/llvm-dev/attachments/20180319/c185c861/attachment.html>
Seemingly Similar Threads
- Building A Project Against LLVM
- Building A Project Against LLVM
- D16945: LLVM overhaul to avoid linking LLVM component libraries with libLLVM
- Correctly linking against libLLVM (single shared library build)
- D16945: LLVM overhaul to avoid linking LLVM component libraries with libLLVM