Skip to content

Commit

Permalink
Link with libclang-cpp for out-of-tree build
Browse files Browse the repository at this point in the history
Signed-off-by: Alexey Sotkin <alexey.sotkin@intel.com>
  • Loading branch information
AlexeySotkin committed Apr 7, 2020
1 parent 0a5a9f6 commit 9f0c2c0
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 14 deletions.
8 changes: 7 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,17 @@ addons:
- llvm-10-tools
- llvm-10-dev
- libclang-10-dev
- lldb-10

install:
- 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
- unzip /tmp/SPIRV-LLVM-Translator-dev-build-linux-${BUILD_TYPE}.zip -d spirv-llvm-translator
# This is a work-around for a "wrong" dependency between libclang-10-dev and
# libclang-cpp10-dev packages from apt.llv.org. Normally, we should just
# install them both, as it is done on the master(ocl-open-110) branch. But for
# some reason (a bug?) they remove each other when being installed via apt get.
# Basically, all we need from libclang-cpp10-dev is the symlink below. Without
# this symlink linker can't find libclang-cpp.so.10.
- sudo ln -s ${TRAVIS_ROOT}/usr/lib/llvm-10/lib/libclang-cpp.so.10 ${TRAVIS_ROOT}/usr/lib/llvm-10/lib/libclang-cpp.so

compiler:
- gcc
Expand Down
33 changes: 20 additions & 13 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ if(NOT USE_PREBUILT_LLVM)

set(CLANG_BASE_REVISION master)
set(SPIRV_BASE_REVISION master)
set(TARGET_BRANCH "ocl-open-90")
set(TARGET_BRANCH "ocl-open-100")

apply_patches(${CLANG_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/patches/clang
Expand Down Expand Up @@ -206,27 +206,22 @@ link_directories(
${LLVM_LIBRARY_DIRS}
)

set(ADDITIONAL_LIBS ${CMAKE_DL_LIBS})
set(OPENCL_CLANG_LINK_LIBS ${CMAKE_DL_LIBS})

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

add_subdirectory(cl_headers)

set(LLVM_REQUIRES_EH ON)

add_llvm_library(${TARGET_NAME} SHARED
${TARGET_INCLUDE_FILES}
${TARGET_SOURCE_FILES}
$<TARGET_OBJECTS:cl_headers>

DEPENDS CClangCompileOptions
LINK_COMPONENTS
all
LINK_LIBS
if(USE_PREBUILT_LLVM OR CLANG_LINK_CLANG_DYLIB)
list(APPEND OPENCL_CLANG_LINK_LIBS clang-cpp)
else()
list(APPEND OPENCL_CLANG_LINK_LIBS
# The list of clang libraries is taken from clang makefile
# (build/tools/clang/tools/driver/CMakeFiles/clang.dir/link.txt)
# All duplicate libraries are there on purpose
Expand Down Expand Up @@ -258,7 +253,19 @@ add_llvm_library(${TARGET_NAME} SHARED
clangAST
clangLex
clangBasic
${ADDITIONAL_LIBS}
)
endif()

add_llvm_library(${TARGET_NAME} SHARED
${TARGET_INCLUDE_FILES}
${TARGET_SOURCE_FILES}
$<TARGET_OBJECTS:cl_headers>

DEPENDS CClangCompileOptions
LINK_COMPONENTS
all
LINK_LIBS
${OPENCL_CLANG_LINK_LIBS}
)

# Configure resource file on Windows
Expand Down

0 comments on commit 9f0c2c0

Please sign in to comment.