Skip to content

Commit 1cde56c

Browse files
committed
Fix link error if llvm is pre-built locally static or shared
This fixes link error in Ubuntu 22.04 container.
1 parent b991349 commit 1cde56c

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

CMakeLists.txt

+10-1
Original file line numberDiff line numberDiff line change
@@ -298,8 +298,17 @@ else()
298298
)
299299
endif()
300300

301+
if(USE_PREBUILT_LLVM AND UNIX)
302+
# llvm_map_components_to_libnames(... all) returns empty string if llvm is
303+
# pre-built locally in either static or shared type in Ubuntu 22.04 container.
304+
execute_process(COMMAND llvm-config --libs all OUTPUT_VARIABLE ALL_LIBS)
305+
string(STRIP ${ALL_LIBS} ALL_LIBS_STRIP)
306+
string(REGEX REPLACE "[ ]*-l" ";" ALL_LLVM_LIBS ${ALL_LIBS_STRIP})
307+
set(ALL_LLVM_LIBS "${ALL_LLVM_LIBS};LLVMSPIRVLib")
308+
else()
309+
llvm_map_components_to_libnames(ALL_LLVM_LIBS all)
310+
endif()
301311
set(OPENCL_CLANG_EXCLUDE_LIBS_FROM_ALL "" CACHE STRING "Space-separated list of LLVM libraries to exclude from all")
302-
llvm_map_components_to_libnames(ALL_LLVM_LIBS all)
303312
if (NOT "${OPENCL_CLANG_EXCLUDE_LIBS_FROM_ALL}" STREQUAL "")
304313
list(REMOVE_ITEM ALL_LLVM_LIBS ${OPENCL_CLANG_EXCLUDE_LIBS_FROM_ALL})
305314
endif()

0 commit comments

Comments
 (0)