Skip to content

Commit b55c7a2

Browse files
authored
Use llvm-config to fix link error if llvm is pre-built locally static or shared (#493)
llvm_map_components_to_libnames is empty in these cases. This fixes link error in Ubuntu 22.04 container. #484 and #454
1 parent 13b8eff commit b55c7a2

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

CMakeLists.txt

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -271,8 +271,16 @@ else()
271271
)
272272
endif()
273273

274+
if(USE_PREBUILT_LLVM AND UNIX)
275+
# llvm_map_components_to_libnames(... all) returns empty string if llvm is
276+
# pre-built locally in either static or shared type in Ubuntu 22.04 container.
277+
execute_process(COMMAND llvm-config --libs all OUTPUT_VARIABLE ALL_LIBS)
278+
string(REGEX REPLACE "( |\r|\n|-l)+" ";" ALL_LLVM_LIBS ${ALL_LIBS})
279+
set(ALL_LLVM_LIBS "LLVMSPIRVLib${ALL_LLVM_LIBS}")
280+
else()
281+
llvm_map_components_to_libnames(ALL_LLVM_LIBS all)
282+
endif()
274283
set(OPENCL_CLANG_EXCLUDE_LIBS_FROM_ALL "" CACHE STRING "Space-separated list of LLVM libraries to exclude from all")
275-
llvm_map_components_to_libnames(ALL_LLVM_LIBS all)
276284
if (NOT "${OPENCL_CLANG_EXCLUDE_LIBS_FROM_ALL}" STREQUAL "")
277285
list(REMOVE_ITEM ALL_LLVM_LIBS ${OPENCL_CLANG_EXCLUDE_LIBS_FROM_ALL})
278286
endif()

0 commit comments

Comments
 (0)