[llvm-dev] Linking to any LLVM from CMake

Stephen Neuendorffer via llvm-dev llvm-dev at lists.llvm.org
Mon Nov 30 18:58:31 PST 2020


Hi Alexander,

The best way I've found is to use LLVM_LINK_COMPONENTS, which ends up
calling llvm_map_components_to_libnames() underneath hood.
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...

Steve


On Mon, Nov 30, 2020 at 6:09 PM Alexander Julian Reinking via llvm-dev <
llvm-dev at lists.llvm.org> wrote:

> Hi all,
>
> Maybe I'm missing something in the documentation somewhere, but I've found
> the officially suggested way to link an application to LLVM to be quite
> brittle. I'm referring to the way listed here:
> https://llvm.org/docs/CMake.html
>
> If I use llvm_map_components_to_libnames with an LLVM that was built with
> LLVM_LINK_LLVM_DYLIB set to true, and then try to link to both some LLVM
> components and lldWasm, then my library will compile, but it will fail at
> runtime since it is linked to both the shared LLVM library (via lldWasm)
> and the static libraries I requested with the function. Linuxbrew builds
> this way.
>
> Furthermore, if only the shared library was built and packaged, then the
> function will throw a fatal error. This broke our build on Gentoo.
>
> For context, I work on the Halide CMake build and you can see the hoops we
> have to jump through here:
>
>
> https://github.com/halide/Halide/blob/master/dependencies/llvm/CMakeLists.txt
>
> What is the correct way to link to LLVM, no matter the configuration?
>
> Thanks,
>
> Alex
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> https://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/20201130/3fa3817c/attachment.html>


More information about the llvm-dev mailing list