Skip to content

Commit

Permalink
Linking with all LLVM libraries
Browse files Browse the repository at this point in the history
Also adding " -Wl,--no-undefined" to the link flags.
  • Loading branch information
AlexeySotkin committed Mar 25, 2019
1 parent a11c3c6 commit daf5e4d
Showing 1 changed file with 10 additions and 48 deletions.
58 changes: 10 additions & 48 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -175,54 +175,13 @@ link_directories(
${LLVM_LIBRARY_DIRS}
)

if (LLVM_LINK_LLVM_DYLIB)
set (LLVM_LIBS LLVM)
else (LLVM_LINK_LLVM_DYLIB)
set (LLVM_LIBS
Analysis
AsmParser
AsmPrinter
BitReader
BitWriter
CodeGen
Core
IRReader
InstCombine
Instrumentation
MC
MCDisassembler
MCParser
ObjCARCOpts
Object
Option
ProfileData
ScalarOpts
SelectionDAG
Support
Target
TransformUtils
Vectorize
X86AsmParser
X86AsmPrinter
X86CodeGen
X86Desc
X86Disassembler
X86Info
X86Utils)
endif (LLVM_LINK_LLVM_DYLIB)

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

if(USE_PREBUILT_LLVM AND NOT LLVMSPIRV_INCLUDED_IN_LLVM)
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 there explicitly as a library
set(ADDITIONAL_LIBS ${ADDITIONAL_LIBS} LLVMSPIRVLib)
elseif(NOT LLVM_LINK_LLVM_DYLIB)
# SPIRV-LLVM-Translator is included into LLVM as a component, but
# LLVM components is not linked together into an umbrella library.
# So, we need to list SPIRV-LLVM-Translator there explicitly as a component
set(LLVM_LIBS ${LLVM_LIBS} SPIRVLib)
endif(USE_PREBUILT_LLVM AND NOT LLVMSPIRV_INCLUDED_IN_LLVM)
# So, we need to list it here explicitly as an external library
list(APPEND ADDITIONAL_LIBS LLVMSPIRVLib)
endif()

add_subdirectory(cl_headers)

Expand All @@ -235,7 +194,7 @@ add_llvm_library(${TARGET_NAME} SHARED

DEPENDS CClangCompileOptions
LINK_COMPONENTS
${LLVM_LIBS}
all
LINK_LIBS
# The list of clang libraries is taken from clang makefile
# (build/tools/clang/tools/driver/CMakeFiles/clang.dir/link.txt)
Expand Down Expand Up @@ -269,7 +228,7 @@ add_llvm_library(${TARGET_NAME} SHARED
clangLex
clangBasic
${ADDITIONAL_LIBS}
${CMAKE_DL_LIBS})
)

# Configure resource file on Windows
if (WIN32)
Expand Down Expand Up @@ -303,6 +262,9 @@ if (WIN32)
"RC_PRODUCT_NAME=\"${RC_PRODUCT_NAME}\""
"RC_PRODUCT_VERSION=\"${RC_FILE_VERSION}\""
"RC_COPYRIGHT=\"Copyright ${RC_CHAR_C} 2018 Intel Corporation. All rights reserved.\"")
elseif(UNIX)
set_property(TARGET ${TARGET_NAME} APPEND_STRING PROPERTY
LINK_FLAGS " -Wl,--no-undefined")
endif(WIN32)

install(FILES common_clang.h
Expand Down

0 comments on commit daf5e4d

Please sign in to comment.