mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-04 21:42:39 +00:00
0e95dba3ef
Without ADDITIONAL_CLEAN_FILES it reports an error: Cleaning... ninja: error: remove(contrib/llvm/llvm/NATIVE): Directory not empty ninja: error: remove(/bld/contrib/llvm/llvm/NATIVE): Directory not empty 0 files. Note, that ADDITIONAL_CLEAN_FILES had been added since cmake 3.15. Signed-off-by: Azat Khuzhin <a.khuzhin@semrush.com>
113 lines
3.8 KiB
CMake
113 lines
3.8 KiB
CMake
if (APPLE OR NOT ARCH_AMD64 OR SANITIZE STREQUAL "undefined")
|
|
set (ENABLE_EMBEDDED_COMPILER_DEFAULT OFF)
|
|
else()
|
|
set (ENABLE_EMBEDDED_COMPILER_DEFAULT ON)
|
|
endif()
|
|
|
|
option (ENABLE_EMBEDDED_COMPILER "Enable support for 'compile_expressions' option for query execution" ${ENABLE_EMBEDDED_COMPILER_DEFAULT})
|
|
|
|
if (NOT ENABLE_EMBEDDED_COMPILER)
|
|
message(STATUS "Not using LLVM")
|
|
return()
|
|
endif()
|
|
|
|
set (LLVM_FOUND 1)
|
|
set (LLVM_VERSION "12.0.0bundled")
|
|
set (LLVM_INCLUDE_DIRS
|
|
"${ClickHouse_SOURCE_DIR}/contrib/llvm/llvm/include"
|
|
"${ClickHouse_BINARY_DIR}/contrib/llvm/llvm/include"
|
|
)
|
|
set (LLVM_LIBRARY_DIRS "${ClickHouse_BINARY_DIR}/contrib/llvm/llvm")
|
|
|
|
# This list was generated by listing all LLVM libraries, compiling the binary and removing all libraries while it still compiles.
|
|
set (REQUIRED_LLVM_LIBRARIES
|
|
LLVMExecutionEngine
|
|
LLVMRuntimeDyld
|
|
LLVMAsmPrinter
|
|
LLVMDebugInfoDWARF
|
|
LLVMGlobalISel
|
|
LLVMSelectionDAG
|
|
LLVMMCDisassembler
|
|
LLVMPasses
|
|
LLVMCodeGen
|
|
LLVMipo
|
|
LLVMBitWriter
|
|
LLVMInstrumentation
|
|
LLVMScalarOpts
|
|
LLVMAggressiveInstCombine
|
|
LLVMInstCombine
|
|
LLVMVectorize
|
|
LLVMTransformUtils
|
|
LLVMTarget
|
|
LLVMAnalysis
|
|
LLVMProfileData
|
|
LLVMObject
|
|
LLVMBitReader
|
|
LLVMCore
|
|
LLVMRemarks
|
|
LLVMBitstreamReader
|
|
LLVMMCParser
|
|
LLVMMC
|
|
LLVMBinaryFormat
|
|
LLVMDebugInfoCodeView
|
|
LLVMSupport
|
|
LLVMDemangle
|
|
)
|
|
|
|
if (ARCH_AMD64)
|
|
list(APPEND REQUIRED_LLVM_LIBRARIES LLVMX86Info LLVMX86Desc LLVMX86CodeGen)
|
|
elseif (ARCH_AARCH64)
|
|
list(APPEND REQUIRED_LLVM_LIBRARIES LLVMAArch64Info LLVMAArch64Desc LLVMAArch64CodeGen)
|
|
endif ()
|
|
|
|
#function(llvm_libs_all REQUIRED_LLVM_LIBRARIES)
|
|
# llvm_map_components_to_libnames (result all)
|
|
# if (USE_STATIC_LIBRARIES OR NOT "LLVM" IN_LIST result)
|
|
# list (REMOVE_ITEM result "LTO" "LLVM")
|
|
# else()
|
|
# set (result "LLVM")
|
|
# endif ()
|
|
# list (APPEND result ${CMAKE_DL_LIBS} ch_contrib::zlib)
|
|
# set (${REQUIRED_LLVM_LIBRARIES} ${result} PARENT_SCOPE)
|
|
#endfunction()
|
|
|
|
message (STATUS "LLVM include Directory: ${LLVM_INCLUDE_DIRS}")
|
|
message (STATUS "LLVM library Directory: ${LLVM_LIBRARY_DIRS}")
|
|
message (STATUS "LLVM C++ compiler flags: ${LLVM_CXXFLAGS}")
|
|
|
|
# ld: unknown option: --color-diagnostics
|
|
set (LINKER_SUPPORTS_COLOR_DIAGNOSTICS 0 CACHE INTERNAL "")
|
|
|
|
# Do not adjust RPATH in llvm, since then it will not be able to find libcxx/libcxxabi/libunwind
|
|
set (CMAKE_INSTALL_RPATH "ON")
|
|
set (LLVM_COMPILER_CHECKED 1 CACHE INTERNAL "")
|
|
set (LLVM_ENABLE_EH 1 CACHE INTERNAL "")
|
|
set (LLVM_ENABLE_RTTI 1 CACHE INTERNAL "")
|
|
set (LLVM_ENABLE_PIC 0 CACHE INTERNAL "")
|
|
set (LLVM_TARGETS_TO_BUILD "X86;AArch64" CACHE STRING "")
|
|
|
|
# Need to use C++17 since the compilation is not possible with C++20 currently, due to ambiguous operator != etc.
|
|
# LLVM project will set its default value for the -std=... but our global setting from CMake will override it.
|
|
set (CMAKE_CXX_STANDARD 17)
|
|
|
|
set (LLVM_SOURCE_DIR "${ClickHouse_SOURCE_DIR}/contrib/llvm/llvm")
|
|
set (LLVM_BINARY_DIR "${ClickHouse_BINARY_DIR}/contrib/llvm/llvm")
|
|
add_subdirectory ("${LLVM_SOURCE_DIR}" "${LLVM_BINARY_DIR}")
|
|
set_directory_properties (PROPERTIES
|
|
# due to llvm crosscompile cmake does not know how to clean it, and on clean
|
|
# will lead to the following error:
|
|
#
|
|
# ninja: error: remove(contrib/llvm/llvm/NATIVE): Directory not empty
|
|
#
|
|
ADDITIONAL_CLEAN_FILES "${LLVM_BINARY_DIR}"
|
|
# llvm's cmake configuring this file only when cmake runs,
|
|
# and after clean cmake will not know that it should re-run,
|
|
# add explicitly depends from llvm-config.h
|
|
CMAKE_CONFIGURE_DEPENDS "${LLVM_BINARY_DIR}/include/llvm/Config/llvm-config.h"
|
|
)
|
|
|
|
add_library (_llvm INTERFACE)
|
|
target_link_libraries (_llvm INTERFACE ${REQUIRED_LLVM_LIBRARIES})
|
|
target_include_directories (_llvm SYSTEM BEFORE INTERFACE ${LLVM_INCLUDE_DIRS})
|
|
add_library(ch_contrib::llvm ALIAS _llvm)
|