diff --git a/CMakeLists.txt b/CMakeLists.txt index 31e2da6295c..559291e8c34 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -113,14 +113,14 @@ endif () set (CMAKE_BUILD_COLOR_MAKEFILE ON) set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${COMPILER_FLAGS} -std=gnu++1y ${PLATFORM_EXTRA_CXX_FLAG} -fno-omit-frame-pointer ${COMMON_WARNING_FLAGS} ${CXX_WARNING_FLAGS} ${MACHINE_FLAGS} ${GLIBC_COMPATIBILITY_COMPILE_FLAGS}") -set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${COMPILER_FLAGS}") -set (CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} ${COMPILER_FLAGS} -O3") -set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${COMPILER_FLAGS} -O0 -g3 -ggdb3 -fno-inline") +#set (CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}") +set (CMAKE_CXX_FLAGS_RELWITHDEBINFO "${CMAKE_CXX_FLAGS_RELWITHDEBINFO} -O3") +set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -O0 -g3 -ggdb3 -fno-inline") set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${COMPILER_FLAGS} -fno-omit-frame-pointer ${COMMON_WARNING_FLAGS} ${MACHINE_FLAGS} ${GLIBC_COMPATIBILITY_COMPILE_FLAGS}") -set (CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} ${COMPILER_FLAGS}") -set (CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} ${COMPILER_FLAGS} -O3") -set (CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} ${COMPILER_FLAGS} -O0 -g3 -ggdb3 -fno-inline") +#set (CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}") +set (CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} -O3") +set (CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -O0 -g3 -ggdb3 -fno-inline") if (NOT APPLE AND NOT (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" AND CMAKE_SYSTEM MATCHES "FreeBSD")) set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -static-libgcc -static-libstdc++") @@ -183,6 +183,12 @@ if (ENABLE_LIBTCMALLOC) include (cmake/find_gperftools.cmake) endif () +set(FULL_C_FLAGS "${CMAKE_C_FLAGS} ${CMAKE_C_FLAGS_${CMAKE_BUILD_TYPE}}") +set(FULL_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_${CMAKE_BUILD_TYPE}}") +message (STATUS "C_FLAGS = ${FULL_C_FLAGS}") +message (STATUS "CXX_FLAGS = ${FULL_CXX_FLAGS}") +message (STATUS "LINK_FLAGS = ${CMAKE_EXE_LINKER_FLAGS}") + # Directory for Yandex specific files set (CLICKHOUSE_PRIVATE_DIR ${ClickHouse_SOURCE_DIR}/private/) if (EXISTS ${CLICKHOUSE_PRIVATE_DIR}) @@ -194,8 +200,4 @@ add_subdirectory (libs) add_subdirectory (utils) add_subdirectory (dbms) -message (STATUS "C_FLAGS = ${CMAKE_C_FLAGS} ${CMAKE_C_FLAGS_${CMAKE_BUILD_TYPE}}") -message (STATUS "CXX_FLAGS = ${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_${CMAKE_BUILD_TYPE}}") -message (STATUS "LINK_FLAGS = ${CMAKE_EXE_LINKER_FLAGS}") - include (cmake/print_include_directories.cmake) diff --git a/dbms/include/DB/Storages/System/StorageSystemBuildOptions.h b/dbms/include/DB/Storages/System/StorageSystemBuildOptions.h new file mode 100644 index 00000000000..64068266095 --- /dev/null +++ b/dbms/include/DB/Storages/System/StorageSystemBuildOptions.h @@ -0,0 +1,43 @@ +#pragma once + +#include +#include + + +namespace DB +{ + +class Context; + + +/** System table "build_options" with many params used for clickhouse building + */ +class StorageSystemBuildOptions : private ext::shared_ptr_helper, public IStorage +{ +friend class ext::shared_ptr_helper; + +public: + static StoragePtr create(const std::string & name_); + + std::string getName() const override { return "SystemBuildOptions"; } + std::string getTableName() const override { return name; } + + const NamesAndTypesList & getColumnsListImpl() const override { return columns; } + + BlockInputStreams read( + const Names & column_names, + ASTPtr query, + const Context & context, + const Settings & settings, + QueryProcessingStage::Enum & processed_stage, + size_t max_block_size = DEFAULT_BLOCK_SIZE, + unsigned threads = 1) override; + +private: + const std::string name; + NamesAndTypesList columns; + + StorageSystemBuildOptions(const std::string & name_); +}; + +} diff --git a/dbms/include/DB/Storages/System/StorageSystemSettings.h b/dbms/include/DB/Storages/System/StorageSystemSettings.h index 7ab57e2d00e..abe973b91e0 100644 --- a/dbms/include/DB/Storages/System/StorageSystemSettings.h +++ b/dbms/include/DB/Storages/System/StorageSystemSettings.h @@ -10,7 +10,7 @@ namespace DB class Context; -/** Реализует системную таблицу settings, которая позволяет получить информацию о текущих настройках. +/** implements system table "settings", which allows to get information about the current settings. */ class StorageSystemSettings : private ext::shared_ptr_helper, public IStorage { diff --git a/dbms/src/Server/LocalServer.cpp b/dbms/src/Server/LocalServer.cpp index ec4930d7f7c..ef07e97d83b 100644 --- a/dbms/src/Server/LocalServer.cpp +++ b/dbms/src/Server/LocalServer.cpp @@ -16,6 +16,7 @@ #include #include #include +#include #include #include @@ -410,6 +411,7 @@ void LocalServer::attachSystemTables() system_database->attachTable("functions", StorageSystemFunctions::create("functions")); system_database->attachTable("events", StorageSystemEvents::create("events")); system_database->attachTable("settings", StorageSystemSettings::create("settings")); + system_database->attachTable("build_options", StorageSystemBuildOptions::create("build_options")); } diff --git a/dbms/src/Server/Server.cpp b/dbms/src/Server/Server.cpp index 745247d4f17..7462f322d3b 100644 --- a/dbms/src/Server/Server.cpp +++ b/dbms/src/Server/Server.cpp @@ -41,6 +41,7 @@ #include #include #include +#include #include #include #include @@ -367,6 +368,7 @@ int Server::main(const std::vector & args) system_database->attachTable("columns", StorageSystemColumns::create("columns")); system_database->attachTable("functions", StorageSystemFunctions::create("functions")); system_database->attachTable("clusters", StorageSystemClusters::create("clusters", *global_context)); + system_database->attachTable("build_options", StorageSystemBuildOptions::create("build_options")); if (has_zookeeper) system_database->attachTable("zookeeper", StorageSystemZooKeeper::create("zookeeper")); diff --git a/dbms/src/Storages/System/StorageSystemBuildOptions.cpp b/dbms/src/Storages/System/StorageSystemBuildOptions.cpp new file mode 100644 index 00000000000..681935cf7b1 --- /dev/null +++ b/dbms/src/Storages/System/StorageSystemBuildOptions.cpp @@ -0,0 +1,58 @@ +#include +#include +#include +#include +#include +#include +#include + +namespace DB +{ + + +StorageSystemBuildOptions::StorageSystemBuildOptions(const std::string & name_) + : name(name_) + , columns{ + { "name", std::make_shared() }, + { "value", std::make_shared() }, + } +{ +} + +StoragePtr StorageSystemBuildOptions::create(const std::string & name_) +{ + return make_shared(name_); +} + + +BlockInputStreams StorageSystemBuildOptions::read( + const Names & column_names, + ASTPtr query, + const Context & context, + const Settings & settings, + QueryProcessingStage::Enum & processed_stage, + const size_t max_block_size, + const unsigned threads) +{ + check(column_names); + processed_stage = QueryProcessingStage::FetchColumns; + + ColumnWithTypeAndName col_name{std::make_shared(), std::make_shared(), "name"}; + ColumnWithTypeAndName col_value{std::make_shared(), std::make_shared(), "value"}; + + for (const auto & option : auto_config_build) + { + col_name.column->insert(String(option.first)); + col_value.column->insert(String(option.second)); + } + + Block block{ + col_name, + col_value, + }; + + return BlockInputStreams(1, std::make_shared(block)); +} + + +} diff --git a/dbms/tests/queries/0_stateless/00417_system_build_options.reference b/dbms/tests/queries/0_stateless/00417_system_build_options.reference new file mode 100644 index 00000000000..721c284e6ef --- /dev/null +++ b/dbms/tests/queries/0_stateless/00417_system_build_options.reference @@ -0,0 +1,5 @@ +BUILD_DATE +BUILD_TYPE +CXX_COMPILER +CXX_FLAGS +LINK_FLAGS diff --git a/dbms/tests/queries/0_stateless/00417_system_build_options.sh b/dbms/tests/queries/0_stateless/00417_system_build_options.sh new file mode 100755 index 00000000000..353ba761f4d --- /dev/null +++ b/dbms/tests/queries/0_stateless/00417_system_build_options.sh @@ -0,0 +1,3 @@ +#!/usr/bin/env bash + +clickhouse-client --query="SELECT * FROM system.build_options" | perl -lnE 'print $1 if /(BUILD_DATE|BUILD_TYPE|CXX_COMPILER|CXX_FLAGS|LINK_FLAGS)\s+\S+/'; diff --git a/libs/libcommon/CMakeLists.txt b/libs/libcommon/CMakeLists.txt index 851db0ef521..2e4e46a113a 100644 --- a/libs/libcommon/CMakeLists.txt +++ b/libs/libcommon/CMakeLists.txt @@ -1,5 +1,6 @@ -SET(CONFIG_VERSION ${CMAKE_CURRENT_BINARY_DIR}/include/common/config_version.h) -SET(CONFIG_COMMON ${CMAKE_CURRENT_BINARY_DIR}/include/common/config_common.h) +set (CONFIG_VERSION ${CMAKE_CURRENT_BINARY_DIR}/include/common/config_version.h) +set (CONFIG_COMMON ${CMAKE_CURRENT_BINARY_DIR}/include/common/config_common.h) +set (CONFIG_BUILD ${CMAKE_CURRENT_BINARY_DIR}/include/common/config_build.h) include_directories (include) include_directories (BEFORE ${CMAKE_SOURCE_DIR}/contrib/libcctz/include) @@ -12,19 +13,25 @@ if (APPLE) else () set (APPLE_SIERRA_OR_NEWER 0) endif () -endif() +endif () -include(cmake/version.cmake) -message(STATUS "Will build ${VERSION_FULL}") -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/include/common/config_common.h.in ${CONFIG_COMMON}) -configure_file(${CMAKE_CURRENT_SOURCE_DIR}/include/common/config_version.h.in ${CONFIG_VERSION}) +include (cmake/version.cmake) +message (STATUS "Will build ${VERSION_FULL}") +configure_file (${CMAKE_CURRENT_SOURCE_DIR}/include/common/config_common.h.in ${CONFIG_COMMON}) +configure_file (${CMAKE_CURRENT_SOURCE_DIR}/include/common/config_version.h.in ${CONFIG_VERSION}) + +get_property (BUILD_COMPILE_DEFINITIONS DIRECTORY ${CMAKE_SOURCE_DIR} PROPERTY COMPILE_DEFINITIONS) +get_property (BUILD_INCLUDE_DIRECTORIES DIRECTORY ${CMAKE_SOURCE_DIR} PROPERTY INCLUDE_DIRECTORIES) + +string (TIMESTAMP BUILD_DATE UTC) +configure_file (${CMAKE_CURRENT_SOURCE_DIR}/include/common/config_build.h.in ${CONFIG_BUILD}) if (APPLE) add_library (apple_rt src/apple_rt.cpp include/common/apple_rt.h ) -endif() +endif () add_library (common src/DateLUT.cpp diff --git a/libs/libcommon/include/common/config_build.h.in b/libs/libcommon/include/common/config_build.h.in new file mode 100644 index 00000000000..de3d2d5ed76 --- /dev/null +++ b/libs/libcommon/include/common/config_build.h.in @@ -0,0 +1,25 @@ +#pragma once + +// .h autogenerated by cmake ! + +#include +#include + +const std::array, 16> auto_config_build { { + {"BUILD_DATE", "@BUILD_DATE@"}, + {"CMAKE_VERSION", "@CMAKE_VERSION@"}, + {"SYSTEM_NAME", "@CMAKE_SYSTEM_NAME@"}, + {"SYSTEM_VERSION", "@CMAKE_SYSTEM_VERSION@"}, + {"BUILD_TYPE", "@CMAKE_BUILD_TYPE@"}, + {"SYSTEM_PROCESSOR", "@CMAKE_SYSTEM_PROCESSOR@"}, + {"LIBRARY_ARCHITECTURE", "@CMAKE_LIBRARY_ARCHITECTURE@"}, + {"C_COMPILER", "@CMAKE_C_COMPILER@"}, + {"C_COMPILE_FEATURES", "@CMAKE_C_COMPILE_FEATURES@"}, + {"CXX_COMPILER", "@CMAKE_CXX_COMPILER@"}, + {"CXX_COMPILE_FEATURES", "@CMAKE_CXX_COMPILE_FEATURES@"}, + {"C_FLAGS", "@FULL_C_FLAGS@"}, + {"CXX_FLAGS", "@FULL_CXX_FLAGS@"}, + {"LINK_FLAGS", "@CMAKE_EXE_LINKER_FLAGS@"}, + {"BUILD_COMPILE_DEFINITIONS", "@BUILD_COMPILE_DEFINITIONS@"}, + {"BUILD_INCLUDE_DIRECTORIES", "@BUILD_INCLUDE_DIRECTORIES@"}, +} };