From 6b2d6e93926ac9da1dc32d3692f7dc940bec248b Mon Sep 17 00:00:00 2001 From: proller Date: Fri, 28 Feb 2020 03:07:42 +0300 Subject: [PATCH] Build fixes (#9381) * Revert "Revert "Build fixes"" This reverts commit 355ff00c2eb74eeebf4cdb46f795efa05c9ffbd7. * zlib link fix --- cmake/find/h3.cmake | 3 +-- cmake/find/zlib.cmake | 6 +----- cmake/tools.cmake | 8 +++++--- contrib/CMakeLists.txt | 17 +++++++++-------- contrib/arrow-cmake/CMakeLists.txt | 1 + contrib/boost-cmake/CMakeLists.txt | 1 + contrib/libxml2-cmake/CMakeLists.txt | 2 +- contrib/replxx-cmake/CMakeLists.txt | 5 ++++- dbms/CMakeLists.txt | 8 ++++++-- dbms/src/Functions/geoToH3.cpp | 6 +++++- dbms/src/Functions/h3EdgeAngle.cpp | 6 +++++- dbms/src/Functions/h3EdgeLengthM.cpp | 9 +++++++-- dbms/src/Functions/h3GetResolution.cpp | 6 +++++- dbms/src/Functions/h3IsValid.cpp | 6 +++++- dbms/src/Functions/h3kRing.cpp | 6 +++++- debian/pbuilder-hooks/B90test-server | 7 ------- 16 files changed, 61 insertions(+), 36 deletions(-) diff --git a/cmake/find/h3.cmake b/cmake/find/h3.cmake index 6abe1ee657c..e01f0269507 100644 --- a/cmake/find/h3.cmake +++ b/cmake/find/h3.cmake @@ -15,9 +15,8 @@ if (USE_INTERNAL_H3_LIBRARY) set (H3_LIBRARY h3) set (H3_INCLUDE_DIR ${ClickHouse_SOURCE_DIR}/contrib/h3/src/h3lib/include) elseif (NOT MISSING_INTERNAL_H3_LIBRARY) - set (H3_INCLUDE_PATHS /usr/local/include/h3) find_library (H3_LIBRARY h3) - find_path (H3_INCLUDE_DIR NAMES h3api.h PATHS ${H3_INCLUDE_PATHS}) + find_path (H3_INCLUDE_DIR NAMES h3/h3api.h PATHS ${H3_INCLUDE_PATHS}) endif () if (H3_LIBRARY AND H3_INCLUDE_DIR) diff --git a/cmake/find/zlib.cmake b/cmake/find/zlib.cmake index 42cfce871d7..fb91622e298 100644 --- a/cmake/find/zlib.cmake +++ b/cmake/find/zlib.cmake @@ -29,11 +29,7 @@ if (NOT ZLIB_FOUND AND NOT MISSING_INTERNAL_ZLIB_LIBRARY) set (ZLIB_INCLUDE_DIRS ${ZLIB_INCLUDE_DIR}) # for poco set (ZLIB_INCLUDE_DIRECTORIES ${ZLIB_INCLUDE_DIR}) # for protobuf set (ZLIB_FOUND 1) # for poco - if (USE_STATIC_LIBRARIES) - set (ZLIB_LIBRARIES zlibstatic CACHE INTERNAL "") - else () - set (ZLIB_LIBRARIES zlib CACHE INTERNAL "") - endif () + set (ZLIB_LIBRARIES zlib CACHE INTERNAL "") endif () message (STATUS "Using ${INTERNAL_ZLIB_NAME}: ${ZLIB_INCLUDE_DIR} : ${ZLIB_LIBRARIES}") diff --git a/cmake/tools.cmake b/cmake/tools.cmake index 025aac79b53..6aaeb5b8a16 100644 --- a/cmake/tools.cmake +++ b/cmake/tools.cmake @@ -32,8 +32,9 @@ else () find_program (GOLD_PATH NAMES "ld.gold" "gold") endif () +if (NOT OS_FREEBSD) # We prefer LLD linker over Gold or BFD. -if (NOT LINKER_NAME) + if (NOT LINKER_NAME) if (LLD_PATH) if (COMPILER_GCC) # GCC driver requires one of supported linker names like "lld". @@ -43,9 +44,9 @@ if (NOT LINKER_NAME) set (LINKER_NAME ${LLD_PATH}) endif () endif () -endif () + endif () -if (NOT LINKER_NAME) + if (NOT LINKER_NAME) if (GOLD_PATH) if (COMPILER_GCC) set (LINKER_NAME "gold") @@ -53,6 +54,7 @@ if (NOT LINKER_NAME) set (LINKER_NAME ${GOLD_PATH}) endif () endif () + endif () endif () if (LINKER_NAME) diff --git a/contrib/CMakeLists.txt b/contrib/CMakeLists.txt index 8257d1a21b0..0208b4e859a 100644 --- a/contrib/CMakeLists.txt +++ b/contrib/CMakeLists.txt @@ -49,7 +49,6 @@ if (USE_INTERNAL_BTRIE_LIBRARY) endif () if (USE_INTERNAL_ZLIB_LIBRARY) - unset (BUILD_SHARED_LIBS CACHE) set (ZLIB_ENABLE_TESTS 0 CACHE INTERNAL "") set (SKIP_INSTALL_ALL 1 CACHE INTERNAL "") set (ZLIB_COMPAT 1 CACHE INTERNAL "") # also enables WITH_GZFILEOP @@ -65,10 +64,14 @@ if (USE_INTERNAL_ZLIB_LIBRARY) add_subdirectory (${INTERNAL_ZLIB_NAME}) # We should use same defines when including zlib.h as used when zlib compiled target_compile_definitions (zlib PUBLIC ZLIB_COMPAT WITH_GZFILEOP) - target_compile_definitions (zlibstatic PUBLIC ZLIB_COMPAT WITH_GZFILEOP) + if (TARGET zlibstatic) + target_compile_definitions (zlibstatic PUBLIC ZLIB_COMPAT WITH_GZFILEOP) + endif () if (ARCH_AMD64 OR ARCH_AARCH64) - target_compile_definitions (zlib PUBLIC X86_64 UNALIGNED_OK) - target_compile_definitions (zlibstatic PUBLIC X86_64 UNALIGNED_OK) + target_compile_definitions (zlib PUBLIC X86_64 UNALIGNED_OK) + if (TARGET zlibstatic) + target_compile_definitions (zlibstatic PUBLIC X86_64 UNALIGNED_OK) + endif () endif () endif () @@ -111,7 +114,7 @@ function(mysql_support) endif() if (USE_INTERNAL_ZLIB_LIBRARY) set(ZLIB_FOUND ON) - set(ZLIB_LIBRARY zlibstatic) + set(ZLIB_LIBRARY ${ZLIB_LIBRARIES}) set(WITH_EXTERNAL_ZLIB ON) endif() add_subdirectory (mariadb-connector-c) @@ -143,9 +146,6 @@ endif () if(USE_INTERNAL_SNAPPY_LIBRARY) set(SNAPPY_BUILD_TESTS 0 CACHE INTERNAL "") - if (NOT MAKE_STATIC_LIBRARIES) - set(BUILD_SHARED_LIBS 1) # TODO: set at root dir - endif() add_subdirectory(snappy) @@ -254,6 +254,7 @@ if (USE_EMBEDDED_COMPILER AND USE_INTERNAL_LLVM_LIBRARY) set (LLVM_ENABLE_PIC 0 CACHE INTERNAL "") set (LLVM_TARGETS_TO_BUILD "X86;AArch64" CACHE STRING "") add_subdirectory (llvm/llvm) + target_include_directories(LLVMSupport SYSTEM BEFORE PRIVATE ${ZLIB_INCLUDE_DIR}) endif () if (USE_INTERNAL_LIBGSASL_LIBRARY) diff --git a/contrib/arrow-cmake/CMakeLists.txt b/contrib/arrow-cmake/CMakeLists.txt index 1f09bba8d31..20ff5c49eea 100644 --- a/contrib/arrow-cmake/CMakeLists.txt +++ b/contrib/arrow-cmake/CMakeLists.txt @@ -348,6 +348,7 @@ if (ARROW_WITH_ZLIB) endif () if (ARROW_WITH_ZSTD) target_link_libraries(${ARROW_LIBRARY} PRIVATE ${ZSTD_LIBRARY}) + target_include_directories(${ARROW_LIBRARY} SYSTEM BEFORE PRIVATE ${ZLIB_INCLUDE_DIR}) endif () target_include_directories(${ARROW_LIBRARY} PRIVATE SYSTEM ${ORC_INCLUDE_DIR}) diff --git a/contrib/boost-cmake/CMakeLists.txt b/contrib/boost-cmake/CMakeLists.txt index 54dcd750320..582cc84a552 100644 --- a/contrib/boost-cmake/CMakeLists.txt +++ b/contrib/boost-cmake/CMakeLists.txt @@ -41,4 +41,5 @@ endif() if (USE_INTERNAL_AVRO_LIBRARY) add_boost_lib(iostreams) target_link_libraries(boost_iostreams_internal PUBLIC ${ZLIB_LIBRARIES}) + target_include_directories(boost_iostreams_internal SYSTEM BEFORE PRIVATE ${ZLIB_INCLUDE_DIR}) endif() diff --git a/contrib/libxml2-cmake/CMakeLists.txt b/contrib/libxml2-cmake/CMakeLists.txt index 71127fb9e35..f0b2135a7c8 100644 --- a/contrib/libxml2-cmake/CMakeLists.txt +++ b/contrib/libxml2-cmake/CMakeLists.txt @@ -59,4 +59,4 @@ endif() target_include_directories(libxml2 PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/linux_x86_64/include) target_include_directories(libxml2 PUBLIC ${LIBXML2_SOURCE_DIR}/include) -target_include_directories(libxml2 PRIVATE ${ZLIB_INCLUDE_DIR}/include) +target_include_directories(libxml2 SYSTEM BEFORE PRIVATE ${ZLIB_INCLUDE_DIR}) diff --git a/contrib/replxx-cmake/CMakeLists.txt b/contrib/replxx-cmake/CMakeLists.txt index 1240eb56b39..cc428d957cf 100644 --- a/contrib/replxx-cmake/CMakeLists.txt +++ b/contrib/replxx-cmake/CMakeLists.txt @@ -45,7 +45,10 @@ if (ENABLE_REPLXX) endif () endif () - target_compile_options(replxx PUBLIC -Wno-documentation) + if (NOT (COMPILER_GCC AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 9)) + target_compile_options(replxx PUBLIC -Wno-documentation) + endif () + target_compile_definitions(replxx PUBLIC USE_REPLXX=1) message (STATUS "Using replxx") diff --git a/dbms/CMakeLists.txt b/dbms/CMakeLists.txt index d1a041bc293..821cf3f6654 100644 --- a/dbms/CMakeLists.txt +++ b/dbms/CMakeLists.txt @@ -176,8 +176,12 @@ elseif (COMPILER_GCC) add_cxx_compile_options(-Wsizeof-array-argument) # Warn for suspicious length parameters to certain string and memory built-in functions if the argument uses sizeof add_cxx_compile_options(-Wsizeof-pointer-memaccess) - # Warn about overriding virtual functions that are not marked with the override keyword - add_cxx_compile_options(-Wsuggest-override) + + if (CMAKE_CXX_COMPILER_VERSION VERSION_GREATER_EQUAL 9) + # Warn about overriding virtual functions that are not marked with the override keyword + add_cxx_compile_options(-Wsuggest-override) + endif () + # Warn whenever a switch statement has an index of boolean type and the case values are outside the range of a boolean type add_cxx_compile_options(-Wswitch-bool) # Warn if a self-comparison always evaluates to true or false diff --git a/dbms/src/Functions/geoToH3.cpp b/dbms/src/Functions/geoToH3.cpp index d227196a428..efd5e535afa 100644 --- a/dbms/src/Functions/geoToH3.cpp +++ b/dbms/src/Functions/geoToH3.cpp @@ -10,7 +10,11 @@ #include #include -#include +#if __has_include(

) +# include

+#else +# include +#endif namespace DB diff --git a/dbms/src/Functions/h3EdgeAngle.cpp b/dbms/src/Functions/h3EdgeAngle.cpp index f7d757a5407..bcb55b3f346 100644 --- a/dbms/src/Functions/h3EdgeAngle.cpp +++ b/dbms/src/Functions/h3EdgeAngle.cpp @@ -7,7 +7,11 @@ # include # include -# include +# if __has_include(

) +# include

+# else +# include +# endif namespace DB diff --git a/dbms/src/Functions/h3EdgeLengthM.cpp b/dbms/src/Functions/h3EdgeLengthM.cpp index cab6dd22776..969f4d7e68b 100644 --- a/dbms/src/Functions/h3EdgeLengthM.cpp +++ b/dbms/src/Functions/h3EdgeLengthM.cpp @@ -8,8 +8,13 @@ # include # include -# include -# include +# if __has_include(

) +# include

+# include

+# else +# include +# include +# endif namespace DB diff --git a/dbms/src/Functions/h3GetResolution.cpp b/dbms/src/Functions/h3GetResolution.cpp index 1c079e5e15e..7decd6f51ba 100644 --- a/dbms/src/Functions/h3GetResolution.cpp +++ b/dbms/src/Functions/h3GetResolution.cpp @@ -7,7 +7,11 @@ # include # include -# include +# if __has_include(

) +# include

+# else +# include +# endif namespace DB diff --git a/dbms/src/Functions/h3IsValid.cpp b/dbms/src/Functions/h3IsValid.cpp index fa5e5abbe6b..01e4f538f17 100644 --- a/dbms/src/Functions/h3IsValid.cpp +++ b/dbms/src/Functions/h3IsValid.cpp @@ -7,7 +7,11 @@ # include # include -# include +# if __has_include(

) +# include

+# else +# include +# endif namespace DB diff --git a/dbms/src/Functions/h3kRing.cpp b/dbms/src/Functions/h3kRing.cpp index 3628ddb7504..fade5ef8155 100644 --- a/dbms/src/Functions/h3kRing.cpp +++ b/dbms/src/Functions/h3kRing.cpp @@ -11,7 +11,11 @@ # include # include -# include +# if __has_include(

) +# include

+# else +# include +# endif namespace DB diff --git a/debian/pbuilder-hooks/B90test-server b/debian/pbuilder-hooks/B90test-server index 670b0c15fcc..e36c255f9fc 100755 --- a/debian/pbuilder-hooks/B90test-server +++ b/debian/pbuilder-hooks/B90test-server @@ -8,11 +8,6 @@ PACKAGE_INSTALL=${PACKAGE_INSTALL=1} TEST_PORT_RANDOM=${TEST_PORT_RANDOM=1} if [ "${PACKAGE_INSTALL}" ]; then - #for PKG in $(ls /tmp/buildd/*.deb | sed -e's,.*/,,;s,_.*,,' ); do - # apt-get install -y --force-yes "$PKG" ||: - # apt-get remove -y "$PKG" ||: - #done - dpkg --auto-deconfigure -i /tmp/buildd/*.deb ||: apt install -y -f --allow-downgrades ||: dpkg -l | grep clickhouse ||: @@ -45,8 +40,6 @@ export CLICKHOUSE_PORT_TCP_SECURE=${CLICKHOUSE_PORT_TCP_SECURE:=9440} export CLICKHOUSE_PORT_HTTPS=${CLICKHOUSE_PORT_HTTPS:=8443} if [ "${TEST_CONNECT}" ]; then - sed -i 's/ssl_conf = ssl_sect/#ssl_conf = ssl_sect/g' /etc/ssl/openssl.cnf ||: - [ "${TEST_PORT_RANDOM}" ] && echo "${CLICKHOUSE_PORT_HTTP}${CLICKHOUSE_PORT_TCP}${CLICKHOUSE_PORT_INTERSERVER}" > /etc/clickhouse-server/config.d/port.xml if [ "${TEST_SSL}" ]; then