[llvm-dev] Linking to any LLVM from CMake

Alexander Julian Reinking via llvm-dev llvm-dev at lists.llvm.org
Mon Nov 30 18:08:53 PST 2020


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20201130/b88d734a/attachment.html>


More information about the llvm-dev mailing list