Skip to content

Commit 9f0c2c0

Browse files
committed
Link with libclang-cpp for out-of-tree build
Signed-off-by: Alexey Sotkin <[email protected]>
1 parent 0a5a9f6 commit 9f0c2c0

File tree

2 files changed

+27
-14
lines changed

2 files changed

+27
-14
lines changed

.travis.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,17 @@ addons:
3030
- llvm-10-tools
3131
- llvm-10-dev
3232
- libclang-10-dev
33-
- lldb-10
3433

3534
install:
3635
- wget https://github.com/KhronosGroup/SPIRV-LLVM-Translator/releases/download/dev-build/SPIRV-LLVM-Translator-dev-build-linux-Release.zip -O /tmp/SPIRV-LLVM-Translator-dev-build-linux-${BUILD_TYPE}.zip
3736
- unzip /tmp/SPIRV-LLVM-Translator-dev-build-linux-${BUILD_TYPE}.zip -d spirv-llvm-translator
37+
# This is a work-around for a "wrong" dependency between libclang-10-dev and
38+
# libclang-cpp10-dev packages from apt.llv.org. Normally, we should just
39+
# install them both, as it is done on the master(ocl-open-110) branch. But for
40+
# some reason (a bug?) they remove each other when being installed via apt get.
41+
# Basically, all we need from libclang-cpp10-dev is the symlink below. Without
42+
# this symlink linker can't find libclang-cpp.so.10.
43+
- sudo ln -s ${TRAVIS_ROOT}/usr/lib/llvm-10/lib/libclang-cpp.so.10 ${TRAVIS_ROOT}/usr/lib/llvm-10/lib/libclang-cpp.so
3844

3945
compiler:
4046
- gcc

CMakeLists.txt

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ if(NOT USE_PREBUILT_LLVM)
119119

120120
set(CLANG_BASE_REVISION master)
121121
set(SPIRV_BASE_REVISION master)
122-
set(TARGET_BRANCH "ocl-open-90")
122+
set(TARGET_BRANCH "ocl-open-100")
123123

124124
apply_patches(${CLANG_SOURCE_DIR}
125125
${CMAKE_CURRENT_SOURCE_DIR}/patches/clang
@@ -206,27 +206,22 @@ link_directories(
206206
${LLVM_LIBRARY_DIRS}
207207
)
208208

209-
set(ADDITIONAL_LIBS ${CMAKE_DL_LIBS})
209+
set(OPENCL_CLANG_LINK_LIBS ${CMAKE_DL_LIBS})
210210

211211
if(NOT LLVMSPIRVLib IN_LIST LLVM_AVAILABLE_LIBS)
212212
# SPIRV-LLVM-Translator is not included into LLVM as a component.
213213
# So, we need to list it here explicitly as an external library
214-
list(APPEND ADDITIONAL_LIBS LLVMSPIRVLib)
214+
list(APPEND OPENCL_CLANG_LINK_LIBS LLVMSPIRVLib)
215215
endif()
216216

217217
add_subdirectory(cl_headers)
218218

219219
set(LLVM_REQUIRES_EH ON)
220220

221-
add_llvm_library(${TARGET_NAME} SHARED
222-
${TARGET_INCLUDE_FILES}
223-
${TARGET_SOURCE_FILES}
224-
$<TARGET_OBJECTS:cl_headers>
225-
226-
DEPENDS CClangCompileOptions
227-
LINK_COMPONENTS
228-
all
229-
LINK_LIBS
221+
if(USE_PREBUILT_LLVM OR CLANG_LINK_CLANG_DYLIB)
222+
list(APPEND OPENCL_CLANG_LINK_LIBS clang-cpp)
223+
else()
224+
list(APPEND OPENCL_CLANG_LINK_LIBS
230225
# The list of clang libraries is taken from clang makefile
231226
# (build/tools/clang/tools/driver/CMakeFiles/clang.dir/link.txt)
232227
# All duplicate libraries are there on purpose
@@ -258,7 +253,19 @@ add_llvm_library(${TARGET_NAME} SHARED
258253
clangAST
259254
clangLex
260255
clangBasic
261-
${ADDITIONAL_LIBS}
256+
)
257+
endif()
258+
259+
add_llvm_library(${TARGET_NAME} SHARED
260+
${TARGET_INCLUDE_FILES}
261+
${TARGET_SOURCE_FILES}
262+
$<TARGET_OBJECTS:cl_headers>
263+
264+
DEPENDS CClangCompileOptions
265+
LINK_COMPONENTS
266+
all
267+
LINK_LIBS
268+
${OPENCL_CLANG_LINK_LIBS}
262269
)
263270

264271
# Configure resource file on Windows

0 commit comments

Comments
 (0)