Skip to content

build: use llvm_config and full symbols resolution #45

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 5 additions & 36 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -175,42 +175,6 @@ 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 )

if(USE_PREBUILT_LLVM AND NOT LLVMSPIRV_INCLUDED_IN_LLVM)
Expand Down Expand Up @@ -271,6 +235,8 @@ add_llvm_library(${TARGET_NAME} SHARED
${ADDITIONAL_LIBS}
${CMAKE_DL_LIBS})

llvm_config(${TARGET_NAME} all)
Copy link
Contributor

@tripzero tripzero Mar 20, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should probably be llvm_config(${TARGET_NAME} USE_SHARED all) if I'm reading https://github.com/llvm-mirror/llvm/blob/master/cmake/modules/LLVM-Config.cmake#L67 correctly. Without it, I got linker errors during build because linker is trying to link against a bunch of libraries that don't exist on clearlinux (all compiled into libLLVM.so).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please take a look at #53

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tripzero : you might need USE_SHARED if you build against LLVM built into dynamic library, but I built LLVM into range of static libraries (well, this was a default) and if I follow your suggestion I get:

[ 92%] Linking CXX shared library libcommon_clang.so
/opt/rh/devtoolset-7/root/usr/libexec/gcc/x86_64-redhat-linux/7/ld: cannot find -lLLVM

Hence, some condition might be needed to differentiate between 2 kind of LLVM builds: dynamic and static. I originally missed this attribute and thought hat llvm_config will take care about differentiation on its own.

I see that @AlexeySotkin provides slightly different way to handle the same in #53. Let's take a look on it, it might be a better option if it provides internal differentiation between dynamic or static LLVM builds


# Configure resource file on Windows
if (WIN32)
# windows_resource_file should be defined by llvm_add_library and should
Expand Down Expand Up @@ -303,6 +269,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