[Beignet] [PATCH] Statically link to libllvm
Rebecca N. Palmer
rebecca_palmer at zoho.com
Sun Jan 6 23:24:18 UTC 2019
Dynamically linked LLVM crashes when two libraries using the same
LLVM version (e.g. Beignet and another OpenCL ICD) are dlopen()ed
in the same application, due to shared global state:
https://bugs.llvm.org/show_bug.cgi?id=30587
https://bugs.debian.org/852746
Signed-off-by: Rebecca N. Palmer <rebecca_palmer at zoho.com>
--- a/CMake/FindLLVM.cmake
+++ b/CMake/FindLLVM.cmake
@@ -87,18 +87,34 @@ execute_process(
OUTPUT_STRIP_TRAILING_WHITESPACE
)
+if (LLVM_VERSION_NODOT VERSION_GREATER 38)
+execute_process(
+ COMMAND ${LLVM_CONFIG_EXECUTABLE} --libs --link-static
+ OUTPUT_VARIABLE LLVM_MODULE_LIBS
+ OUTPUT_STRIP_TRAILING_WHITESPACE
+)
+else (LLVM_VERSION_NODOT VERSION_GREATER 38)
execute_process(
COMMAND ${LLVM_CONFIG_EXECUTABLE} --libs
OUTPUT_VARIABLE LLVM_MODULE_LIBS
OUTPUT_STRIP_TRAILING_WHITESPACE
)
+endif (LLVM_VERSION_NODOT VERSION_GREATER 38)
if (LLVM_VERSION_NODOT VERSION_GREATER 34)
+if (LLVM_VERSION_NODOT VERSION_GREATER 38)
+execute_process(
+ COMMAND ${LLVM_CONFIG_EXECUTABLE} --system-libs --link-static
+ OUTPUT_VARIABLE LLVM_SYSTEM_LIBS_ORIG
+ OUTPUT_STRIP_TRAILING_WHITESPACE
+)
+else (LLVM_VERSION_NODOT VERSION_GREATER 38)
execute_process(
COMMAND ${LLVM_CONFIG_EXECUTABLE} --system-libs
OUTPUT_VARIABLE LLVM_SYSTEM_LIBS_ORIG
OUTPUT_STRIP_TRAILING_WHITESPACE
)
+endif (LLVM_VERSION_NODOT VERSION_GREATER 38)
if (LLVM_SYSTEM_LIBS_ORIG)
string(REGEX REPLACE " *\n" "" LLVM_SYSTEM_LIBS ${LLVM_SYSTEM_LIBS_ORIG})
endif (LLVM_SYSTEM_LIBS_ORIG)
More information about the Beignet
mailing list