[llvm-bugs] [Bug 35245] New: llvm_map_components_to_libnames returns various libnames even when LLVM_LINK_LLVM_DYLIB=ON
via llvm-bugs
llvm-bugs at lists.llvm.org
Wed Nov 8 05:28:37 PST 2017
https://bugs.llvm.org/show_bug.cgi?id=35245
Bug ID: 35245
Summary: llvm_map_components_to_libnames returns various
libnames even when LLVM_LINK_LLVM_DYLIB=ON
Product: Build scripts
Version: 4.0
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: cmake
Assignee: unassignedbugs at nondot.org
Reporter: jirislaby at gmail.com
CC: llvm-bugs at lists.llvm.org
Michal Srb wrote to llvm-dev with no reply:
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_LINK_LLVM_DYLIB).
The multiple shared libraries build was causing issues and apparently it is
only meant for LLVM developers (see
https://github.com/klee/klee/pull/686#issuecomment-316745847). 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_LINK_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?
======
I add:
$ cat CMakeLists.txt
cmake_minimum_required(VERSION 3.4.3)
project(SimpleProject)
find_package(LLVM REQUIRED CONFIG)
message(STATUS "Found LLVM ${LLVM_PACKAGE_VERSION}")
message(STATUS "Using LLVMConfig.cmake in: ${LLVM_DIR}")
llvm_map_components_to_libnames(llvm_libs support core irreader)
message(STATUS "Components mapped to libnames: ${llvm_libs}")
$ cmake .
-- The C compiler identification is GNU 7.2.1
...
-- Found LLVM 4.0.1
-- Using LLVMConfig.cmake in: /usr/lib64/cmake/llvm
-- Components mapped to libnames: LLVMSupport;LLVMCore;LLVMIRReader
...
And llvm-config is correct, it seems:
$ llvm-config --libnames support core irreader
libLLVM.so
And if one tries to map "native" component to library:
CMake Error at /usr/lib64/cmake/llvm/LLVM-Config.cmake:126 (message):
Target X86 is not in the set of libraries.
Call Stack (most recent call first):
CMakeLists.txt:9 (llvm_map_components_to_libnames)
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20171108/acc9dd0e/attachment-0001.html>
More information about the llvm-bugs
mailing list