[llvm-dev] Linking to any LLVM from CMake

Alexander Julian Reinking via llvm-dev llvm-dev at lists.llvm.org
Mon Nov 30 21:37:47 PST 2020


Hi Steve,

The best way I've found is to use LLVM_LINK_COMPONENTS, which ends up
> calling llvm_map_components_to_libnames() underneath hood.
>

I tried grepping for LLVM_LINK_COMPONENTS in my installed lib/cmake/llvm
directory, but I only see it used as a global variable. Should it also be
a function?

I see that symbol in AddLLVM.cmake and TableGen.cmake. In the former, it
appears in add_llvm_executable and add_llvm_library. The documentation I
linked to earlier states that add_llvm_library is an "internal" macro, so
I assume that it shouldn't be used by fully external client code? The uses
in TableGen.cmake don't seem relevant.


> The biggest pitfall is that lldWasm needs to be linked the same way so
> that both link against libLLVM.so or both not.
> It's possible you're trying to work around issues in the way that lldWasm
> is linked...
>

The workaround we found for the way lldWasm is linked is simply to add an
error message to fail early in this case. The main issue was that nothing
was stopping our users from falling into this trap.

Best,

Alex
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20201130/a05e1aa1/attachment-0001.html>


More information about the llvm-dev mailing list