Skip to content

Commit

Permalink
Fix link error if llvm is pre-built locally static or shared
Browse files Browse the repository at this point in the history
This fixes link error in Ubuntu 22.04 container.
  • Loading branch information
wenju-he committed Oct 7, 2023
1 parent b991349 commit 1cde56c
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -298,8 +298,17 @@ 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(STRIP ${ALL_LIBS} ALL_LIBS_STRIP)
string(REGEX REPLACE "[ ]*-l" ";" ALL_LLVM_LIBS ${ALL_LIBS_STRIP})
set(ALL_LLVM_LIBS "${ALL_LLVM_LIBS};LLVMSPIRVLib")
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 1cde56c

Please sign in to comment.