Skip to content

Commit

Permalink
Use llvm-config to fix link error if llvm is pre-built locally static…
Browse files Browse the repository at this point in the history
… or shared

llvm_map_components_to_libnames is empty in these cases.
This fixes link error in Ubuntu 22.04 container. intel#484 and intel#454
  • Loading branch information
wenju-he committed Oct 7, 2023
1 parent 13b8eff commit cd99213
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -271,8 +271,16 @@ else()
)
endif()

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

0 comments on commit cd99213

Please sign in to comment.