diff --git a/.gitmodules b/.gitmodules index b36e030364e..233c2df55c9 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,6 @@ +[submodule "contrib/poco"] + path = contrib/poco + url = https://github.com/ClickHouse-Extras/poco [submodule "contrib/zstd"] path = contrib/zstd url = https://github.com/facebook/zstd.git diff --git a/cmake/find_boost.cmake b/cmake/find_boost.cmake index 72693bafe8e..603b8d51d2f 100644 --- a/cmake/find_boost.cmake +++ b/cmake/find_boost.cmake @@ -19,7 +19,6 @@ if (NOT USE_INTERNAL_BOOST_LIBRARY) endif () if (NOT Boost_SYSTEM_LIBRARY) - add_definitions(-DBOOST_SYSTEM_NO_DEPRECATED) set (USE_INTERNAL_BOOST_LIBRARY 1) set (Boost_PROGRAM_OPTIONS_LIBRARY boost_program_options_internal) set (Boost_SYSTEM_LIBRARY boost_system_internal) diff --git a/cmake/find_poco.cmake b/cmake/find_poco.cmake index cd14b68fa4a..6d3c8dee94b 100644 --- a/cmake/find_poco.cmake +++ b/cmake/find_poco.cmake @@ -5,42 +5,55 @@ if (NOT USE_INTERNAL_POCO_LIBRARY) endif () if (Poco_INCLUDE_DIRS AND Poco_Foundation_LIBRARY) - include_directories (${Poco_INCLUDE_DIRS}) + #include_directories (${Poco_INCLUDE_DIRS}) else () set (USE_INTERNAL_POCO_LIBRARY 1) - include (${ClickHouse_SOURCE_DIR}/cmake/find_ltdl.cmake) - include (${ClickHouse_SOURCE_DIR}/contrib/libpoco/cmake/FindODBC.cmake) + set (ENABLE_ZIP 0 CACHE BOOL "") + set (ENABLE_PAGECOMPILER 0 CACHE BOOL "") + set (ENABLE_PAGECOMPILER_FILE2PAGE 0 CACHE BOOL "") + set (ENABLE_REDIS 0 CACHE BOOL "") + set (ENABLE_DATA_SQLITE 0 CACHE BOOL "") + set (ENABLE_DATA_MYSQL 0 CACHE BOOL "") + set (ENABLE_DATA_POSTGRESQL 0 CACHE BOOL "") + set (POCO_UNBUNDLED 1 CACHE BOOL "") + set (POCO_UNBUNDLED_PCRE 0 CACHE BOOL "") + set (POCO_UNBUNDLED_EXPAT 0 CACHE BOOL "") + set (POCO_STATIC ${MAKE_STATIC_LIBRARIES} CACHE BOOL "") + set (POCO_VERBOSE_MESSAGES 1 CACHE BOOL "") + include (${ClickHouse_SOURCE_DIR}/cmake/find_ltdl.cmake) + include (${ClickHouse_SOURCE_DIR}/contrib/poco/cmake/FindODBC.cmake) + + # used in internal compiler list (APPEND Poco_INCLUDE_DIRS - "${ClickHouse_SOURCE_DIR}/contrib/libpoco/Foundation/include/" - "${ClickHouse_SOURCE_DIR}/contrib/libpoco/Util/include/" - "${ClickHouse_SOURCE_DIR}/contrib/libpoco/Net/include/" - "${ClickHouse_SOURCE_DIR}/contrib/libpoco/Data/include/" - "${ClickHouse_SOURCE_DIR}/contrib/libpoco/XML/include/" + "${ClickHouse_SOURCE_DIR}/contrib/poco/Foundation/include/" + "${ClickHouse_SOURCE_DIR}/contrib/poco/Util/include/" ) if (NOT DEFINED POCO_ENABLE_MONGODB OR POCO_ENABLE_MONGODB) set (Poco_MongoDB_FOUND 1) set (Poco_MongoDB_LIBRARY PocoMongoDB) - list (APPEND Poco_INCLUDE_DIRS "${ClickHouse_SOURCE_DIR}/contrib/libpoco/MongoDB/include/") + set (Poco_MongoDB_INCLUDE_DIRS "${ClickHouse_SOURCE_DIR}/contrib/poco/MongoDB/include/") endif () if (ODBC_FOUND) set (Poco_DataODBC_FOUND 1) set (Poco_DataODBC_LIBRARY PocoDataODBC) - list (APPEND Poco_DataODBC_LIBRARY ${LTDL_LIB}) - list (APPEND Poco_INCLUDE_DIRS "${ClickHouse_SOURCE_DIR}/contrib/libpoco/Data/ODBC/include/") + if (USE_STATIC_LIBRARIES) + list (APPEND Poco_DataODBC_LIBRARY ${LTDL_LIB}) + endif () + set (Poco_DataODBC_INCLUDE_DIRS "${ClickHouse_SOURCE_DIR}/contrib/poco/Data/ODBC/include/") endif () if (OPENSSL_FOUND) set (Poco_NetSSL_FOUND 1) set (Poco_NetSSL_LIBRARY PocoNetSSL) set (Poco_Crypto_LIBRARY PocoCrypto) - list (APPEND Poco_INCLUDE_DIRS - "${ClickHouse_SOURCE_DIR}/contrib/libpoco/NetSSL_OpenSSL/include/" - "${ClickHouse_SOURCE_DIR}/contrib/libpoco/Crypto/include/" + set (Poco_NetSSL_INCLUDE_DIRS + "${ClickHouse_SOURCE_DIR}/contrib/poco/NetSSL_OpenSSL/include/" + "${ClickHouse_SOURCE_DIR}/contrib/poco/Crypto/include/" ) endif () @@ -56,7 +69,23 @@ else () set (Poco_Net_LIBRARY PocoNet) set (Poco_Data_LIBRARY PocoData) set (Poco_XML_LIBRARY PocoXML) - include_directories (BEFORE ${Poco_INCLUDE_DIRS}) + + #include_directories (BEFORE ${Poco_INCLUDE_DIRS}) + endif () message(STATUS "Using Poco: ${Poco_INCLUDE_DIRS} : ${Poco_Foundation_LIBRARY},${Poco_Util_LIBRARY},${Poco_Net_LIBRARY},${Poco_NetSSL_LIBRARY},${Poco_XML_LIBRARY},${Poco_Data_LIBRARY},${Poco_DataODBC_LIBRARY},${Poco_MongoDB_LIBRARY}; MongoDB=${Poco_MongoDB_FOUND}, DataODBC=${Poco_DataODBC_FOUND}, NetSSL=${Poco_NetSSL_FOUND}") + +# How to make sutable poco: +# use branch: +# develop OR poco-1.7.9-release + 6a49c94d18c654d7a20b8c8ea47071b1fdd4813b +# and merge: +# ClickHouse-Extras/clickhouse_unbundled +# ClickHouse-Extras/clickhouse_unbundled_zlib +# ClickHouse-Extras/clickhouse_task # uses c++11, can't push to poco +# ClickHouse-Extras/clickhouse_misc +# ClickHouse-Extras/clickhouse_anl +# ClickHouse-Extras/clickhouse_http_header https://github.com/pocoproject/poco/pull/1574 +# ClickHouse-Extras/clickhouse_socket +# ClickHouse-Extras/clickhouse_warning + diff --git a/cmake/find_zlib.cmake b/cmake/find_zlib.cmake index 66a8734b1ba..bbfc75e5e24 100644 --- a/cmake/find_zlib.cmake +++ b/cmake/find_zlib.cmake @@ -6,8 +6,14 @@ endif () if (NOT ZLIB_FOUND) set (USE_INTERNAL_ZLIB_LIBRARY 1) - set (ZLIB_INCLUDE_DIR "${ClickHouse_SOURCE_DIR}/contrib/libzlib-ng") - set (ZLIB_LIBRARIES zlibstatic) + set (ZLIB_INCLUDE_DIR "${ClickHouse_SOURCE_DIR}/contrib/libzlib-ng" "${ClickHouse_BINARY_DIR}/contrib/libzlib-ng") # generated zconf.h + set (ZLIB_INCLUDE_DIRS ${ZLIB_INCLUDE_DIR}) # for poco + set (ZLIB_FOUND 1) # for poco + if (USE_STATIC_LIBRARIES) + set (ZLIB_LIBRARIES zlibstatic) + else () + set (ZLIB_LIBRARIES zlib) + endif () endif () message (STATUS "Using zlib: ${ZLIB_INCLUDE_DIR} : ${ZLIB_LIBRARIES}") diff --git a/cmake/print_include_directories.cmake b/cmake/print_include_directories.cmake index 83b8064d262..d9a60389fc8 100644 --- a/cmake/print_include_directories.cmake +++ b/cmake/print_include_directories.cmake @@ -12,6 +12,10 @@ if (USE_INTERNAL_BOOST_LIBRARY) list(APPEND dirs ${dirs1}) endif () +if (USE_INTERNAL_POCO_LIBRARY) + list(APPEND dirs "./contrib/poco/Foundation/include") +endif () + list(REMOVE_DUPLICATES dirs) file (WRITE ${CMAKE_CURRENT_BINARY_DIR}/include_directories.txt "") foreach (dir ${dirs}) diff --git a/contrib/CMakeLists.txt b/contrib/CMakeLists.txt index 0d5df8b94b3..c726520eee7 100644 --- a/contrib/CMakeLists.txt +++ b/contrib/CMakeLists.txt @@ -4,9 +4,6 @@ if (USE_INTERNAL_BOOST_LIBRARY) add_subdirectory (libboost) endif () -if (USE_INTERNAL_POCO_LIBRARY) - add_subdirectory (libpoco) -endif () if (USE_INTERNAL_LZ4_LIBRARY) add_subdirectory (lz4-cmake) @@ -63,3 +60,12 @@ endif () if (NOT ARCH_ARM) add_subdirectory (libcpuid) endif () + +if (USE_INTERNAL_POCO_LIBRARY) + set (_save ${ENABLE_TESTS}) + set (ENABLE_TESTS 0) + set (CMAKE_DISABLE_FIND_PACKAGE_ZLIB 1) + add_subdirectory (poco) + unset (CMAKE_DISABLE_FIND_PACKAGE_ZLIB) + set (ENABLE_TESTS ${_save}) +endif () diff --git a/contrib/libboost/CMakeLists.txt b/contrib/libboost/CMakeLists.txt index 908ddfc1e43..8cfe084636a 100644 --- a/contrib/libboost/CMakeLists.txt +++ b/contrib/libboost/CMakeLists.txt @@ -30,3 +30,7 @@ boost_1_65_0/libs/system/src/error_code.cpp) target_include_directories (boost_program_options_internal BEFORE PUBLIC ${Boost_INCLUDE_DIRS}) target_include_directories (boost_filesystem_internal BEFORE PUBLIC ${Boost_INCLUDE_DIRS}) target_include_directories (boost_system_internal BEFORE PUBLIC ${Boost_INCLUDE_DIRS}) + +target_compile_definitions (boost_program_options_internal PUBLIC BOOST_SYSTEM_NO_DEPRECATED) +target_compile_definitions (boost_filesystem_internal PUBLIC BOOST_SYSTEM_NO_DEPRECATED) +target_compile_definitions (boost_system_internal PUBLIC BOOST_SYSTEM_NO_DEPRECATED) diff --git a/contrib/libtcmalloc/CMakeLists.txt b/contrib/libtcmalloc/CMakeLists.txt index 57b7cd9c553..64c99e41c71 100644 --- a/contrib/libtcmalloc/CMakeLists.txt +++ b/contrib/libtcmalloc/CMakeLists.txt @@ -74,3 +74,5 @@ endif () target_include_directories (tcmalloc_minimal_internal PUBLIC include) target_include_directories (tcmalloc_minimal_internal PRIVATE src) +find_package (Threads) +target_link_libraries (tcmalloc_minimal_internal ${CMAKE_THREAD_LIBS_INIT}) diff --git a/contrib/poco b/contrib/poco new file mode 160000 index 00000000000..d28d05def4b --- /dev/null +++ b/contrib/poco @@ -0,0 +1 @@ +Subproject commit d28d05def4b7b701b56b9edb24e2f1bea880534b diff --git a/libs/libdaemon/src/BaseDaemon.cpp b/libs/libdaemon/src/BaseDaemon.cpp index 9da9531a7ee..f25aa96f30f 100644 --- a/libs/libdaemon/src/BaseDaemon.cpp +++ b/libs/libdaemon/src/BaseDaemon.cpp @@ -812,6 +812,13 @@ void BaseDaemon::initialize(Application & self) /// Ставим terminate_handler std::set_terminate(terminate_handler); + /// We want to avoid SIGPIPE when working with sockets and pipes, and just handle return value/errno instead. + { + sigset_t sig_set; + if (sigemptyset(&sig_set) || sigaddset(&sig_set, SIGPIPE) || pthread_sigmask(SIG_BLOCK, &sig_set, nullptr)) + throw Poco::Exception("Cannot block signal."); + } + /// Ставим обработчики сигналов auto add_signal_handler = [](const std::vector & signals, signal_function handler)