Fixed build [#CLICKHOUSE-3396].

This commit is contained in:
Alexey Milovidov 2017-11-12 19:45:30 +03:00
parent 16358603a9
commit 2029b38527
2 changed files with 14 additions and 5 deletions

View File

@ -90,12 +90,18 @@ endif ()
set (COMPILER_FLAGS "${COMPILER_FLAGS} ${CXX11_ABI_FLAGS}")
find_program (LINKER_PROGRAM NAMES gold ld) # TODO Add lld at front. For somewhat reason, right now gcc doesn't recognise when we type -fuse-ld=lld.
get_filename_component (LINKER_NAME ${LINKER_PROGRAM} NAME CACHE)
find_program (LLD_PATH NAMES lld)
find_program (GOLD_PATH NAMES gold)
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fuse-ld=${LINKER_NAME}")
if (LINKER_NAME STREQUAL lld)
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -L/usr/local/lib")
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND LLD_PATH)
set (LINKER_NAME "lld")
elseif (GOLD_PATH)
set (LINKER_NAME "gold")
endif ()
if (LINKER_NAME)
message(STATUS "Using linker: ${LINKER_NAME}")
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fuse-ld=${LINKER_NAME}")
endif ()
option (PIPE "-pipe compiler option [less /tmp usage, more ram usage]" ON)

View File

@ -11,6 +11,9 @@ llvm_map_components_to_libraries(REQUIRED_LLVM_LIBRARIES all)
# We link statically with zlib, and LLVM (sometimes) tries to bring its own dependency.
list(REMOVE_ITEM REQUIRED_LLVM_LIBRARIES "-lz")
target_include_directories(clickhouse-compiler PRIVATE ${LLVM_INCLUDE_DIRS})
link_directories(${LLVM_LIBRARY_DIRS})
# This is extracted almost directly from CMakeFiles/.../link.txt in LLVM build directory.
target_link_libraries(clickhouse-compiler