[llvm-dev] Correctly linking against libLLVM (single shared library build)

Chris Bieneman via llvm-dev llvm-dev at lists.llvm.org
Mon Nov 13 16:26:01 PST 2017


Sorry for the delayed response. I've been out of town a lot lately.

The documentation you referenced is unfortunately out of date (you might notice it still references autoconf). I'll see if I can find time to update it, but the guidance should be to use the `llvm_config` CMake function instead. The proper usage of that in the example there would be to replace the call to `llvm_map_components_to_libnames` with `llvm_config(simple-tool support core irreader)`.

`llvm_config` should properly handle the LLVM shared library.

Thanks,
-Chris

> On Oct 23, 2017, at 7:19 AM, Michal Srb via llvm-dev <llvm-dev at lists.llvm.org> wrote:
> 
> Hi,
> 
> In SUSE we have recently switched from building LLVM as multiple shared 
> libraries (using BUILD_SHARED_LIBS) to building it as a single shared library 
> (using LLVM_BUILD_LLVM_DYLIB).
> 
> The multiple shared libraries build was causing issues and apparently it is 
> only meant for LLVM developers. Our guidelines prohibit linking against static 
> libraries unless there is no other option.
> 
> After this change, some external tools failed building because they try to 
> link against libraries given by the cmake function 
> `llvm_map_components_to_libnames`. This function returns library names as if 
> each component was in its own library. (LLVMSupport, LLVMCore, ...)
> Usage of this function comes from documentation:
>  https://llvm.org/docs/CMake.html#embedding-llvm-in-your-project
> 
> 1) Is `llvm_map_components_to_libnames` working as expected? Shouldn't it 
> return just "LLVM" if LLVM_BUILD_LLVM_DYLIB was used?
> 
> 2) I saw that there is a `add_llvm_library` function that chooses between 
> using `llvm_map_components_to_libnames` or just using "LLVM" directly based on 
> LLVM_BUILD_LLVM_DYLIB. Is this function suitable for use by external projects? 
> It doesn't seem to be documented. Is there also equivalent for executables?
> 
> Thank you,
> Michal Srb
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev



More information about the llvm-dev mailing list