Skip to content

Commit daf5e4d

Browse files
committed
Linking with all LLVM libraries
Also adding " -Wl,--no-undefined" to the link flags.
1 parent a11c3c6 commit daf5e4d

File tree

1 file changed

+10
-48
lines changed

1 file changed

+10
-48
lines changed

CMakeLists.txt

Lines changed: 10 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -175,54 +175,13 @@ link_directories(
175175
${LLVM_LIBRARY_DIRS}
176176
)
177177

178-
if (LLVM_LINK_LLVM_DYLIB)
179-
set (LLVM_LIBS LLVM)
180-
else (LLVM_LINK_LLVM_DYLIB)
181-
set (LLVM_LIBS
182-
Analysis
183-
AsmParser
184-
AsmPrinter
185-
BitReader
186-
BitWriter
187-
CodeGen
188-
Core
189-
IRReader
190-
InstCombine
191-
Instrumentation
192-
MC
193-
MCDisassembler
194-
MCParser
195-
ObjCARCOpts
196-
Object
197-
Option
198-
ProfileData
199-
ScalarOpts
200-
SelectionDAG
201-
Support
202-
Target
203-
TransformUtils
204-
Vectorize
205-
X86AsmParser
206-
X86AsmPrinter
207-
X86CodeGen
208-
X86Desc
209-
X86Disassembler
210-
X86Info
211-
X86Utils)
212-
endif (LLVM_LINK_LLVM_DYLIB)
213-
214-
set(ADDITIONAL_LIBS )
178+
set(ADDITIONAL_LIBS ${CMAKE_DL_LIBS})
215179

216-
if(USE_PREBUILT_LLVM AND NOT LLVMSPIRV_INCLUDED_IN_LLVM)
180+
if(NOT LLVMSPIRVLib IN_LIST LLVM_AVAILABLE_LIBS)
217181
# SPIRV-LLVM-Translator is not included into LLVM as a component.
218-
# So, we need to list it there explicitly as a library
219-
set(ADDITIONAL_LIBS ${ADDITIONAL_LIBS} LLVMSPIRVLib)
220-
elseif(NOT LLVM_LINK_LLVM_DYLIB)
221-
# SPIRV-LLVM-Translator is included into LLVM as a component, but
222-
# LLVM components is not linked together into an umbrella library.
223-
# So, we need to list SPIRV-LLVM-Translator there explicitly as a component
224-
set(LLVM_LIBS ${LLVM_LIBS} SPIRVLib)
225-
endif(USE_PREBUILT_LLVM AND NOT LLVMSPIRV_INCLUDED_IN_LLVM)
182+
# So, we need to list it here explicitly as an external library
183+
list(APPEND ADDITIONAL_LIBS LLVMSPIRVLib)
184+
endif()
226185

227186
add_subdirectory(cl_headers)
228187

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

236195
DEPENDS CClangCompileOptions
237196
LINK_COMPONENTS
238-
${LLVM_LIBS}
197+
all
239198
LINK_LIBS
240199
# The list of clang libraries is taken from clang makefile
241200
# (build/tools/clang/tools/driver/CMakeFiles/clang.dir/link.txt)
@@ -269,7 +228,7 @@ add_llvm_library(${TARGET_NAME} SHARED
269228
clangLex
270229
clangBasic
271230
${ADDITIONAL_LIBS}
272-
${CMAKE_DL_LIBS})
231+
)
273232

274233
# Configure resource file on Windows
275234
if (WIN32)
@@ -303,6 +262,9 @@ if (WIN32)
303262
"RC_PRODUCT_NAME=\"${RC_PRODUCT_NAME}\""
304263
"RC_PRODUCT_VERSION=\"${RC_FILE_VERSION}\""
305264
"RC_COPYRIGHT=\"Copyright ${RC_CHAR_C} 2018 Intel Corporation. All rights reserved.\"")
265+
elseif(UNIX)
266+
set_property(TARGET ${TARGET_NAME} APPEND_STRING PROPERTY
267+
LINK_FLAGS " -Wl,--no-undefined")
306268
endif(WIN32)
307269

308270
install(FILES common_clang.h

0 commit comments

Comments
 (0)