File llvm_build_tablegen_component_as_shared_library.patch of Package SLE153-llvm11
xxxxxxxxxx
1
The LLVMTableGen component is a special case that is excluded from libLLVM and
2
normally is only built as static library and linked into llvm-tblgen.
3
4
We need to have it as a shared library to be available for other projects such
5
as ldc.
6
7
This patch makes it even more special and forces it to be build and installed
8
as separate shared library.
9
10
Index: llvm-8.0.0rc3.src/cmake/modules/AddLLVM.cmake
11
===================================================================
12
--- llvm-8.0.0rc3.src.orig/cmake/modules/AddLLVM.cmake
13
+++ llvm-8.0.0rc3.src/cmake/modules/AddLLVM.cmake
14
15
if(ARG_MODULE AND LLVM_EXPORT_SYMBOLS_FOR_PLUGINS AND ARG_PLUGIN_TOOL AND (WIN32 OR CYGWIN))
16
# On DLL platforms symbols are imported from the tool by linking against it.
17
set(llvm_libs ${ARG_PLUGIN_TOOL})
18
- elseif (NOT ARG_COMPONENT_LIB)
19
+ elseif (NOT ARG_COMPONENT_LIB OR (${name} STREQUAL "LLVMTableGen" AND LLVM_BUILD_LLVM_DYLIB))
20
if (LLVM_LINK_LLVM_DYLIB AND NOT ARG_DISABLE_LLVM_LINK_LLVM_DYLIB)
21
set(llvm_libs LLVM)
22
else()
23
Index: llvm-8.0.0rc3.src/cmake/modules/TableGen.cmake
24
===================================================================
25
--- llvm-8.0.0rc3.src.orig/cmake/modules/TableGen.cmake
26
+++ llvm-8.0.0rc3.src/cmake/modules/TableGen.cmake
27
28
set(LLVM_ENABLE_OBJLIB ON)
29
endif()
30
31
- add_llvm_executable(${target} DISABLE_LLVM_LINK_LLVM_DYLIB ${ARGN})
32
+ add_llvm_executable(${target} ${ARGN})
33
+ target_link_libraries(${target} PRIVATE LLVMTableGen)
34
set(LLVM_LINK_COMPONENTS ${${target}_OLD_LLVM_LINK_COMPONENTS})
35
36
set(${project}_TABLEGEN "${target}" CACHE
37
Index: llvm-8.0.0rc3.src/lib/TableGen/CMakeLists.txt
38
===================================================================
39
--- llvm-8.0.0rc3.src.orig/lib/TableGen/CMakeLists.txt
40
+++ llvm-8.0.0rc3.src/lib/TableGen/CMakeLists.txt
41
42
+if (LLVM_BUILD_LLVM_DYLIB)
43
+ set(MAYBE_SHARED SHARED)
44
+endif()
45
+
46
add_llvm_component_library(LLVMTableGen
47
Error.cpp
48
JSONBackend.cpp
49
50
TGLexer.cpp
51
TGParser.cpp
52
53
+ ${MAYBE_SHARED}
54
+
55
ADDITIONAL_HEADER_DIRS
56
${LLVM_MAIN_INCLUDE_DIR}/llvm/TableGen
57
)
58