1 From: Matthias Maier <tamiko@43-1.org>
2 Date: Sat, 11 Jun 2022 01:44:54 -0500
3 Subject: [PATCH] Fix cmake configure for shared LLVM libraries
5 Gentoo builds LLVM into a combined shared library. The CMake
6 configuration shipped with LLVM is evidently broken in this case, see
8 https://github.com/llvm/llvm-project/issues/34593
9 https://bugs.gentoo.org/745915
11 We work around this issue by simply linking against the monolithic
14 CMakeLists.txt | 23 +----------------------
15 1 file changed, 1 insertion(+), 22 deletions(-)
17 diff --git a/CMakeLists.txt b/CMakeLists.txt
18 index cf5ab3b..dfa6605 100644
21 @@ -402,28 +402,7 @@ if (WITH_LLVM)
23 set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} -DNDEBUG")
25 - llvm_map_components_to_libnames(llvm_libs_direct ${SYMENGINE_LLVM_COMPONENTS})
26 - llvm_expand_dependencies(llvm_libs ${llvm_libs_direct})
28 - if (BUILD_SHARED_LIBS)
29 - set(SYMENGINE_LLVM_LINK_DOWNSTREAM_DEFAULT False)
30 - foreach(LLVM_LIB ${llvm_libs})
31 - get_target_property(${LLVM_LIB}_IMPORT_LOCATION ${LLVM_LIB} LOCATION)
32 - if (NOT "${${LLVM_LIB}_IMPORT_LOCATION}" MATCHES "NOTFOUND")
33 - if (NOT "${${LLVM_LIB}_IMPORT_LOCATION}" MATCHES ".a$|.lib$")
34 - set(SYMENGINE_LLVM_LINK_DOWNSTREAM_DEFAULT True)
39 - set(SYMENGINE_LLVM_LINK_DOWNSTREAM_DEFAULT True)
41 - set(SYMENGINE_LLVM_LINK_DOWNSTREAM ${SYMENGINE_LLVM_LINK_DOWNSTREAM_DEFAULT}
42 - CACHE INTERNAL "Link to llvm in SymEngineConfig.cmake")
43 - if (NOT SYMENGINE_LLVM_LINK_DOWNSTREAM)
44 - unset(SYMENGINE_LLVM_COMPONENTS)
46 - set(LIBS ${LIBS} ${llvm_libs})
47 + set(LIBS ${LIBS} LLVM)
48 include_directories(SYSTEM ${LLVM_INCLUDE_DIRS})
49 set(HAVE_SYMENGINE_LLVM yes)
50 set(PKGS ${PKGS} "LLVM")
51 diff --git a/cmake/SymEngineConfig.cmake.in b/cmake/SymEngineConfig.cmake.in
52 index b01ef9b..6d82c10 100644
53 --- a/cmake/SymEngineConfig.cmake.in
54 +++ b/cmake/SymEngineConfig.cmake.in
55 @@ -67,9 +67,7 @@ set(SYMENGINE_LLVM_COMPONENTS @SYMENGINE_LLVM_COMPONENTS@)
57 if (NOT "${SYMENGINE_LLVM_COMPONENTS}" STREQUAL "")
58 find_package(LLVM REQUIRED ${SYMENGINE_LLVM_COMPONENTS} HINTS @LLVM_DIR@)
59 - llvm_map_components_to_libnames(llvm_libs_direct ${SYMENGINE_LLVM_COMPONENTS})
60 - llvm_expand_dependencies(llvm_libs ${llvm_libs_direct})
61 - set(SYMENGINE_LIBRARIES ${SYMENGINE_LIBRARIES} ${llvm_libs})
62 + set(SYMENGINE_LIBRARIES ${SYMENGINE_LIBRARIES} LLVM)
64 set(SYMENGINE_LLVM_INCLUDE_DIRS)