mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-26 01:22:04 +00:00
Customizable internal compiler
This commit is contained in:
parent
e8aa65f802
commit
067ff7a5c7
@ -1,11 +1,12 @@
|
||||
include(${ClickHouse_SOURCE_DIR}/cmake/dbms_include.cmake)
|
||||
|
||||
include_directories (BEFORE ${ClickHouse_SOURCE_DIR}/contrib/libdivide)
|
||||
include_directories (BEFORE ${ClickHouse_SOURCE_DIR}/contrib/libcpuid/include/)
|
||||
include_directories (BEFORE ${ClickHouse_SOURCE_DIR}/contrib/libcpuid/include)
|
||||
include_directories (BEFORE ${ClickHouse_SOURCE_DIR}/contrib/libfarmhash)
|
||||
include_directories (BEFORE ${ClickHouse_SOURCE_DIR}/contrib/libmetrohash/src)
|
||||
include_directories (${ClickHouse_SOURCE_DIR}/libs/libdaemon/include/)
|
||||
include_directories (${ClickHouse_SOURCE_DIR}/libs/libdaemon/include)
|
||||
include_directories (${ODBC_INCLUDE_DIRECTORIES})
|
||||
include_directories (${ClickHouse_BINARY_DIR}/dbms/include)
|
||||
|
||||
if (NOT NO_WERROR)
|
||||
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror")
|
||||
|
12
dbms/include/DB/Interpreters/config_compile.h.in
Normal file
12
dbms/include/DB/Interpreters/config_compile.h.in
Normal file
@ -0,0 +1,12 @@
|
||||
#pragma once
|
||||
|
||||
#cmakedefine PATH_SHARE "@PATH_SHARE@"
|
||||
#cmakedefine INTERNAL_COMPILER_FLAGS "@INTERNAL_COMPILER_FLAGS@"
|
||||
#cmakedefine INTERNAL_COMPILER_EXECUTABLE "@INTERNAL_COMPILER_EXECUTABLE@"
|
||||
#cmakedefine INTERNAL_COMPILER_HEADERS "@INTERNAL_COMPILER_HEADERS@"
|
||||
#cmakedefine INTERNAL_COMPILER_HEADERS_ROOT "@INTERNAL_COMPILER_HEADERS_ROOT@"
|
||||
#cmakedefine01 INTERNAL_COMPILER_CUSTOM_ROOT
|
||||
#cmakedefine INTERNAL_DOUBLE_CONVERSION_INCLUDE_DIR "@INTERNAL_DOUBLE_CONVERSION_INCLUDE_DIR@"
|
||||
#cmakedefine INTERNAL_Poco_Foundation_INCLUDE_DIR "@INTERNAL_Poco_Foundation_INCLUDE_DIR@"
|
||||
#cmakedefine INTERNAL_Poco_Util_INCLUDE_DIR "@INTERNAL_Poco_Util_INCLUDE_DIR@"
|
||||
#cmakedefine INTERNAL_Boost_INCLUDE_DIRS "@INTERNAL_Boost_INCLUDE_DIRS@"
|
@ -20,6 +20,7 @@
|
||||
|
||||
#include <DB/Interpreters/Aggregator.h>
|
||||
#include <common/ClickHouseRevision.h>
|
||||
#include <DB/Interpreters/config_compile.h>
|
||||
|
||||
|
||||
namespace ProfileEvents
|
||||
@ -353,7 +354,7 @@ void Aggregator::compileIfPossible(AggregatedDataVariants::Type type)
|
||||
* по окончании которой вызывается колбэк on_ready.
|
||||
*/
|
||||
SharedLibraryPtr lib = params.compiler->getOrCount(key, params.min_count_to_compile,
|
||||
"-include /usr/share/clickhouse/headers/dbms/include/DB/Interpreters/SpecializedAggregator.h",
|
||||
"-include " INTERNAL_COMPILER_HEADERS "/dbms/include/DB/Interpreters/SpecializedAggregator.h",
|
||||
get_code, on_ready);
|
||||
|
||||
/// Если результат уже готов.
|
||||
|
@ -1,3 +1,43 @@
|
||||
|
||||
if (CMAKE_SYSTEM MATCHES "FreeBSD")
|
||||
set (PATH_SHARE "/usr/local/share" CACHE STRING "")
|
||||
else ()
|
||||
set (PATH_SHARE "/usr/share" CACHE STRING "")
|
||||
endif ()
|
||||
|
||||
if (INTERNAL_COMPILER_SAME)
|
||||
set (INTERNAL_COMPILER_EXECUTABLE "${CMAKE_CXX_COMPILER}" CACHE STRING "")
|
||||
else ()
|
||||
set (INTERNAL_COMPILER_EXECUTABLE "${PATH_SHARE}/clickhouse/bin/clang" CACHE STRING "")
|
||||
endif ()
|
||||
|
||||
set (INTERNAL_COMPILER_NO_WARNING OFF CACHE BOOL "")
|
||||
|
||||
#original string:
|
||||
# -x c++ -std=gnu++1y -O3 -g -Wall -Werror -Wnon-virtual-dtor -march=native -msse4 -mpopcnt -D NDEBUG -D_GLIBCXX_USE_CXX11_ABI=0 -shared -fPIC -fvisibility=hidden -fno-implement-inlines
|
||||
set (INTERNAL_COMPILER_FLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_RELEASE} -x c++ -march=native -shared -fPIC -fvisibility=hidden -fno-implement-inlines " CACHE STRING "")
|
||||
string(REPLACE "-no-pie" "" INTERNAL_COMPILER_FLAGS ${INTERNAL_COMPILER_FLAGS})
|
||||
if (INTERNAL_COMPILER_NO_WARNING)
|
||||
string (REPLACE "-Wall" "" INTERNAL_COMPILER_FLAGS ${INTERNAL_COMPILER_FLAGS})
|
||||
string (REPLACE "-Werror" "" INTERNAL_COMPILER_FLAGS ${INTERNAL_COMPILER_FLAGS})
|
||||
endif ()
|
||||
|
||||
set (INTERNAL_COMPILER_HEADERS "${PATH_SHARE}/clickhouse/headers" CACHE STRING "")
|
||||
set (INTERNAL_COMPILER_HEADERS_ROOT "${INTERNAL_COMPILER_HEADERS}" CACHE STRING "")
|
||||
set (INTERNAL_COMPILER_CUSTOM_ROOT ON CACHE BOOL "")
|
||||
list(GET Poco_INCLUDE_DIRS 0 Poco_Foundation_INCLUDE_DIR)
|
||||
list(GET Poco_INCLUDE_DIRS 1 Poco_Util_INCLUDE_DIR)
|
||||
|
||||
string (REPLACE ${ClickHouse_SOURCE_DIR} ${INTERNAL_COMPILER_HEADERS} INTERNAL_DOUBLE_CONVERSION_INCLUDE_DIR ${DOUBLE_CONVERSION_INCLUDE_DIR})
|
||||
string (REPLACE ${ClickHouse_SOURCE_DIR} ${INTERNAL_COMPILER_HEADERS} INTERNAL_Boost_INCLUDE_DIRS ${Boost_INCLUDE_DIRS})
|
||||
string (REPLACE ${ClickHouse_SOURCE_DIR} ${INTERNAL_COMPILER_HEADERS} INTERNAL_Poco_Foundation_INCLUDE_DIR ${Poco_Foundation_INCLUDE_DIR})
|
||||
string (REPLACE ${ClickHouse_SOURCE_DIR} ${INTERNAL_COMPILER_HEADERS} INTERNAL_Poco_Util_INCLUDE_DIR ${Poco_Util_INCLUDE_DIR})
|
||||
|
||||
message (STATUS "Using internal compiler: headers=${INTERNAL_COMPILER_HEADERS} : ${INTERNAL_COMPILER_EXECUTABLE} ${INTERNAL_COMPILER_FLAGS}")
|
||||
|
||||
set (CONFIG_COMPILE ${ClickHouse_BINARY_DIR}/dbms/include/DB/Interpreters/config_compile.h)
|
||||
configure_file (${ClickHouse_SOURCE_DIR}/dbms/include/DB/Interpreters/config_compile.h.in ${CONFIG_COMPILE})
|
||||
|
||||
if (ENABLE_TESTS)
|
||||
add_subdirectory (tests)
|
||||
endif (ENABLE_TESTS)
|
||||
|
@ -12,6 +12,7 @@
|
||||
#include <DB/IO/WriteBufferFromFile.h>
|
||||
|
||||
#include <DB/Interpreters/Compiler.h>
|
||||
#include <DB/Interpreters/config_compile.h>
|
||||
|
||||
|
||||
namespace ProfileEvents
|
||||
@ -182,31 +183,27 @@ void Compiler::compile(
|
||||
|
||||
/// Слегка неудобно.
|
||||
command <<
|
||||
"LD_LIBRARY_PATH=/usr/share/clickhouse/bin/"
|
||||
" /usr/share/clickhouse/bin/clang"
|
||||
" -B /usr/share/clickhouse/bin/"
|
||||
" -x c++ -std=gnu++1y -O3 -g -Wall -Werror -Wnon-virtual-dtor -march=native -msse4 -mpopcnt -D NDEBUG"
|
||||
#if _GLIBCXX_USE_CXX11_ABI == 0
|
||||
" -D_GLIBCXX_USE_CXX11_ABI=0"
|
||||
#elif _GLIBCXX_USE_CXX11_ABI == 1
|
||||
" -D_GLIBCXX_USE_CXX11_ABI=1"
|
||||
#endif
|
||||
" -shared -fPIC -fvisibility=hidden -fno-implement-inlines"
|
||||
" -isystem /usr/share/clickhouse/headers/usr/local/include/"
|
||||
" -isystem /usr/share/clickhouse/headers/usr/include/"
|
||||
" -isystem /usr/share/clickhouse/headers/usr/include/mysql/"
|
||||
" -isystem /usr/share/clickhouse/headers/usr/include/c++/*/"
|
||||
" -isystem /usr/share/clickhouse/headers/usr/include/x86_64-linux-gnu/"
|
||||
" -isystem /usr/share/clickhouse/headers/usr/include/x86_64-linux-gnu/c++/*/"
|
||||
" -isystem /usr/share/clickhouse/headers/usr/local/lib/clang/*/include/"
|
||||
" -I /usr/share/clickhouse/headers/dbms/include/"
|
||||
" -I /usr/share/clickhouse/headers/contrib/libcityhash/include/"
|
||||
" -I /usr/share/clickhouse/headers/contrib/libdouble-conversion/"
|
||||
" -I /usr/share/clickhouse/headers/contrib/libpoco/Foundation/include/"
|
||||
" -I /usr/share/clickhouse/headers/contrib/libpoco/Util/include/"
|
||||
" -I /usr/share/clickhouse/headers/contrib/libboost/boost_1_62_0/"
|
||||
" -I /usr/share/clickhouse/headers/libs/libcommon/include/"
|
||||
" -I /usr/share/clickhouse/headers/libs/libmysqlxx/include/"
|
||||
"LD_LIBRARY_PATH=" PATH_SHARE "/clickhouse/bin/"
|
||||
" " INTERNAL_COMPILER_EXECUTABLE
|
||||
" -B " PATH_SHARE "/clickhouse/bin/"
|
||||
" " INTERNAL_COMPILER_FLAGS
|
||||
#if INTERNAL_COMPILER_CUSTOM_ROOT
|
||||
" -isystem " INTERNAL_COMPILER_HEADERS_ROOT "/usr/local/include/"
|
||||
" -isystem " INTERNAL_COMPILER_HEADERS_ROOT "/usr/include/"
|
||||
" -isystem " INTERNAL_COMPILER_HEADERS_ROOT "/usr/include/mysql/"
|
||||
" -isystem " INTERNAL_COMPILER_HEADERS_ROOT "/usr/include/c++/*/"
|
||||
" -isystem " INTERNAL_COMPILER_HEADERS_ROOT "/usr/include/x86_64-linux-gnu/"
|
||||
" -isystem " INTERNAL_COMPILER_HEADERS_ROOT "/usr/include/x86_64-linux-gnu/c++/*/"
|
||||
" -isystem " INTERNAL_COMPILER_HEADERS_ROOT "/usr/local/lib/clang/*/include/"
|
||||
#endif
|
||||
" -I " INTERNAL_COMPILER_HEADERS "/dbms/include/"
|
||||
" -I " INTERNAL_COMPILER_HEADERS "/contrib/libcityhash/include/"
|
||||
" -I " INTERNAL_DOUBLE_CONVERSION_INCLUDE_DIR
|
||||
" -I " INTERNAL_Poco_Foundation_INCLUDE_DIR
|
||||
" -I " INTERNAL_Poco_Util_INCLUDE_DIR
|
||||
" -I " INTERNAL_Boost_INCLUDE_DIRS
|
||||
" -I " INTERNAL_COMPILER_HEADERS "/libs/libcommon/include/"
|
||||
" -I " INTERNAL_COMPILER_HEADERS "/libs/libmysqlxx/include/"
|
||||
" " << additional_compiler_flags <<
|
||||
" -o " << so_tmp_file_path << " " << cpp_file_path
|
||||
<< " 2>&1 || echo Exit code: $?";
|
||||
|
Loading…
Reference in New Issue
Block a user