diff --git a/.github/workflows/linux.yml b/.github/workflows/linux.yml index e64b8406..dece9f16 100644 --- a/.github/workflows/linux.yml +++ b/.github/workflows/linux.yml @@ -11,56 +11,83 @@ env: CH_SERVER_VERSION: 21.3.17.2 jobs: build: - runs-on: ubuntu-latest strategy: + fail-fast: false matrix: - compiler: [clang-6, gcc-7, gcc-8, gcc-9] + os: [ubuntu-20.04] + compiler: [clang-6, clang-10-libc++, gcc-7, gcc-8, gcc-9] ssl: [ssl_ON, ssl_OFF] + dependencies: [dependencies_BUILT_IN] + include: - compiler: clang-6 - INSTALL: clang-6.0 + COMPILER_INSTALL: clang-6.0 libc++-dev C_COMPILER: clang-6.0 CXX_COMPILER: clang++-6.0 + - compiler: clang-10-libc++ + COMPILER_INSTALL: clang-10 libc++-dev + C_COMPILER: clang-10 + CXX_COMPILER: clang++-10 + - compiler: gcc-7 - INSTALL: gcc-7 g++-7 + COMPILER_INSTALL: gcc-7 g++-7 C_COMPILER: gcc-7 CXX_COMPILER: g++-7 - compiler: gcc-8 - INSTALL: gcc-8 g++-8 + COMPILER_INSTALL: gcc-8 g++-8 C_COMPILER: gcc-8 CXX_COMPILER: g++-8 - compiler: gcc-9 - INSTALL: gcc-9 g++-9 + COMPILER_INSTALL: gcc-9 g++-9 C_COMPILER: gcc-9 CXX_COMPILER: g++-9 - ssl: ssl_ON - INSTALL_SSL: libssl-dev - EXTRA_CMAKE_FLAGS: -DWITH_OPENSSL=ON + SSL_CMAKE_OPTION: -D WITH_OPENSSL=ON - - ssl: ssl_OFF - EXTRA_CMAKE_FLAGS: -DWITH_OPENSSL=OFF + - dependencies: dependencies_SYSTEM + compiler: compiler_SYSTEM + os: ubuntu-22.04 + COMPILER_INSTALL: gcc g++ + DEPENDENCIES_INSTALL: libabsl-dev liblz4-dev + DEPENDENCIES_CMAKE_OPTIONS: >- + -D WITH_SYSTEM_LZ4=ON + -D WITH_SYSTEM_ABSEIL=ON + + runs-on: ${{matrix.os}} steps: - uses: actions/checkout@v2 - name: Install dependencies - run: sudo apt-get install -y cmake ${{ matrix.INSTALL }} ${{ matrix.INSTALL_SSL }} + run: | + sudo apt-get update && \ + sudo apt-get install -y \ + cmake \ + ${{matrix.COMPILER_INSTALL}} \ + ${{matrix.DEPENDENCIES_INSTALL}} + + - name: Configure project + run: | + cmake \ + -D CMAKE_C_COMPILER=${{matrix.C_COMPILER}} \ + -D CMAKE_CXX_COMPILER=${{matrix.CXX_COMPILER}} \ + -D CMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} \ + -D BUILD_TESTS=ON \ + ${{matrix.SSL_CMAKE_OPTION}} \ + ${{matrix.DEPENDENCIES_CMAKE_OPTIONS}} \ + -S ${{github.workspace}} \ + -B ${{github.workspace}}/build - - name: Configure CMake + - name: Build project run: | cmake \ - -DCMAKE_C_COMPILER=${{ matrix.C_COMPILER}} \ - -DCMAKE_CXX_COMPILER=${{ matrix.CXX_COMPILER}} \ - -B ${{github.workspace}}/build \ - -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DBUILD_TESTS=ON \ - ${{ matrix.EXTRA_CMAKE_FLAGS }} - - - name: Build - run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} --target all + --build ${{github.workspace}}/build \ + --config ${{env.BUILD_TYPE}} \ + --target all - name: Start ClickHouse server run: | diff --git a/.github/workflows/macos.yml b/.github/workflows/macos.yml index a2bb171f..33973df2 100644 --- a/.github/workflows/macos.yml +++ b/.github/workflows/macos.yml @@ -21,24 +21,34 @@ jobs: build: [nossl, ssl] include: - build: nossl - extra_cmake_flags: -DWITH_OPENSSL=OFF - extra_install: - build: ssl - extra_cmake_flags: -DWITH_OPENSSL=ON -DOPENSSL_ROOT_DIR=/usr/local/opt/openssl/ - extra_install: openssl + SSL_CMAKE_OPTION: >- + -D WITH_OPENSSL=ON + -D OPENSSL_ROOT_DIR=/usr/local/opt/openssl/ + SSL_INSTALL: openssl steps: - uses: actions/checkout@v2 - name: Install dependencies - run: brew install cmake ${{matrix.extra_install}} + run: brew install cmake ${{matrix.SSL_INSTALL}} - name: Configure CMake - run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DBUILD_TESTS=ON ${{matrix.extra_cmake_flags}} + run: | + cmake \ + -D CMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} \ + -D BUILD_TESTS=ON \ + ${{matrix.SSL_CMAKE_OPTION}} \ + -S ${{github.workspace}} \ + -B ${{github.workspace}}/build - name: Build - run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} --target all + run: | + cmake \ + --build ${{github.workspace}}/build \ + --config ${{env.BUILD_TYPE}} \ + --target all - name: Start tls offoader proxy # that mimics non-secure clickhouse running on localhost diff --git a/CMakeLists.txt b/CMakeLists.txt index 31cd8a5a..15169753 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,6 +7,9 @@ INCLUDE (cmake/openssl.cmake) OPTION (BUILD_BENCHMARK "Build benchmark" OFF) OPTION (BUILD_TESTS "Build tests" OFF) OPTION (WITH_OPENSSL "Use OpenSSL for TLS connections" OFF) +OPTION (WITH_SYSTEM_ABSEIL "Use system ABSEIL" OFF) +OPTION (WITH_SYSTEM_LZ4 "Use system LZ4" OFF) +OPTION (WITH_SYSTEM_CITYHASH "Use system cityhash" OFF) PROJECT (CLICKHOUSE-CLIENT) @@ -26,14 +29,54 @@ PROJECT (CLICKHOUSE-CLIENT) SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Werror") ENDIF () + IF (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") + INCLUDE (CheckCXXSourceCompiles) + + CHECK_CXX_SOURCE_COMPILES("#include \nint main() { return __GLIBCXX__ != 0; }" + CLANG_WITH_LIB_STDCXX) + ENDIF () + + IF (CLANG_WITH_LIB_STDCXX) + # there is a problem with __builtin_mul_overflow call at link time + # the error looks like: ... undefined reference to `__muloti4' ... + # caused by clang bug https://bugs.llvm.org/show_bug.cgi?id=16404 + # explicit linking to compiler-rt allows to workaround the problem + SET (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} --rtlib=compiler-rt") + SET (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --rtlib=compiler-rt") + + # some workaround for linking issues on linux: + # /usr/bin/ld: CMakeFiles/simple-test.dir/main.cpp.o: undefined reference to symbol '_Unwind_Resume@@GCC_3.0' + # /usr/bin/ld: /lib/x86_64-linux-gnu/libgcc_s.so.1: error adding symbols: DSO missing from command line + # FIXME: that workaround breaks clang build on mingw + SET (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -lgcc_s") + SET (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lgcc_s") + ENDIF () + INCLUDE_DIRECTORIES (.) - INCLUDE_DIRECTORIES (contrib) + + IF (WITH_SYSTEM_ABSEIL) + FIND_PACKAGE(absl REQUIRED) + ELSE () + INCLUDE_DIRECTORIES (contrib/absl) + SUBDIRS (contrib/absl/absl) + ENDIF () + + IF (WITH_SYSTEM_LZ4) + FIND_PACKAGE(lz4 REQUIRED) + ELSE () + INCLUDE_DIRECTORIES (contrib/lz4/lz4) + SUBDIRS (contrib/lz4/lz4) + ENDIF () + + IF (WITH_SYSTEM_CITYHASH) + FIND_PACKAGE(cityhash REQUIRED) + ELSE () + INCLUDE_DIRECTORIES (contrib/cityhash/cityhash) + SUBDIRS (contrib/cityhash/cityhash) + ENDIF () SUBDIRS ( clickhouse - contrib/absl - contrib/cityhash - contrib/lz4 ) IF (BUILD_BENCHMARK) diff --git a/clickhouse/CMakeLists.txt b/clickhouse/CMakeLists.txt index d96ff88a..9d3714b9 100644 --- a/clickhouse/CMakeLists.txt +++ b/clickhouse/CMakeLists.txt @@ -39,46 +39,23 @@ ENDIF () ADD_LIBRARY (clickhouse-cpp-lib SHARED ${clickhouse-cpp-lib-src}) SET_TARGET_PROPERTIES(clickhouse-cpp-lib PROPERTIES LINKER_LANGUAGE CXX) TARGET_LINK_LIBRARIES (clickhouse-cpp-lib - absl-lib - cityhash-lib - lz4-lib + absl::absl + cityhash::cityhash + lz4::lz4 ) ADD_LIBRARY (clickhouse-cpp-lib-static STATIC ${clickhouse-cpp-lib-src}) TARGET_LINK_LIBRARIES (clickhouse-cpp-lib-static - absl-lib - cityhash-lib - lz4-lib + absl::absl + cityhash::cityhash + lz4::lz4 ) -IF (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") - INCLUDE (CheckCXXSourceCompiles) - - CHECK_CXX_SOURCE_COMPILES("#include \nint main() { return __GLIBCXX__ != 0; }" - BUILDING_WITH_LIB_STDCXX) - - IF (BUILDING_WITH_LIB_STDCXX) - # there is a problem with __builtin_mul_overflow call at link time - # the error looks like: ... undefined reference to `__muloti4' ... - # caused by clang bug https://bugs.llvm.org/show_bug.cgi?id=16404 - # explicit linking to compiler-rt allows to workaround the problem - SET (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} --rtlib=compiler-rt") - - # some workaround for linking issues on linux: - # /usr/bin/ld: CMakeFiles/simple-test.dir/main.cpp.o: undefined reference to symbol '_Unwind_Resume@@GCC_3.0' - # /usr/bin/ld: /lib/x86_64-linux-gnu/libgcc_s.so.1: error adding symbols: DSO missing from command line - # FIXME: that workaround breaks clang build on mingw - TARGET_LINK_LIBRARIES (clickhouse-cpp-lib gcc_s) - TARGET_LINK_LIBRARIES (clickhouse-cpp-lib-static gcc_s) - ENDIF () -ENDIF () - INSTALL (TARGETS clickhouse-cpp-lib clickhouse-cpp-lib-static ARCHIVE DESTINATION lib LIBRARY DESTINATION lib ) - # general INSTALL(FILES block.h DESTINATION include/clickhouse/) INSTALL(FILES client.h DESTINATION include/clickhouse/) diff --git a/clickhouse/base/compressed.cpp b/clickhouse/base/compressed.cpp index 8478ad28..4d5cc65d 100644 --- a/clickhouse/base/compressed.cpp +++ b/clickhouse/base/compressed.cpp @@ -3,8 +3,8 @@ #include "output.h" #include "../exceptions.h" -#include -#include +#include +#include #include #include diff --git a/clickhouse/columns/lowcardinality.cpp b/clickhouse/columns/lowcardinality.cpp index 0ffef7e0..339ebba3 100644 --- a/clickhouse/columns/lowcardinality.cpp +++ b/clickhouse/columns/lowcardinality.cpp @@ -4,7 +4,7 @@ #include "nullable.h" #include "../base/wire_format.h" -#include +#include #include #include diff --git a/clickhouse/types/types.cpp b/clickhouse/types/types.cpp index c34c0b4e..806ba1d9 100644 --- a/clickhouse/types/types.cpp +++ b/clickhouse/types/types.cpp @@ -2,7 +2,7 @@ #include "../exceptions.h" -#include +#include #include diff --git a/contrib/absl/CMakeLists.txt b/contrib/absl/CMakeLists.txt deleted file mode 100644 index 87c8dff1..00000000 --- a/contrib/absl/CMakeLists.txt +++ /dev/null @@ -1,3 +0,0 @@ -ADD_LIBRARY (absl-lib STATIC - numeric/int128.cc -) diff --git a/contrib/absl/absl/CMakeLists.txt b/contrib/absl/absl/CMakeLists.txt new file mode 100644 index 00000000..eaec8673 --- /dev/null +++ b/contrib/absl/absl/CMakeLists.txt @@ -0,0 +1,5 @@ +ADD_LIBRARY (absl STATIC + numeric/int128.cc +) + +ADD_LIBRARY (absl::absl ALIAS absl) diff --git a/contrib/absl/base/attributes.h b/contrib/absl/absl/base/attributes.h similarity index 100% rename from contrib/absl/base/attributes.h rename to contrib/absl/absl/base/attributes.h diff --git a/contrib/absl/base/config.h b/contrib/absl/absl/base/config.h similarity index 100% rename from contrib/absl/base/config.h rename to contrib/absl/absl/base/config.h diff --git a/contrib/absl/base/internal/bits.h b/contrib/absl/absl/base/internal/bits.h similarity index 100% rename from contrib/absl/base/internal/bits.h rename to contrib/absl/absl/base/internal/bits.h diff --git a/contrib/absl/base/macros.h b/contrib/absl/absl/base/macros.h similarity index 100% rename from contrib/absl/base/macros.h rename to contrib/absl/absl/base/macros.h diff --git a/contrib/absl/base/optimization.h b/contrib/absl/absl/base/optimization.h similarity index 100% rename from contrib/absl/base/optimization.h rename to contrib/absl/absl/base/optimization.h diff --git a/contrib/absl/base/options.h b/contrib/absl/absl/base/options.h similarity index 100% rename from contrib/absl/base/options.h rename to contrib/absl/absl/base/options.h diff --git a/contrib/absl/base/policy_checks.h b/contrib/absl/absl/base/policy_checks.h similarity index 100% rename from contrib/absl/base/policy_checks.h rename to contrib/absl/absl/base/policy_checks.h diff --git a/contrib/absl/base/port.h b/contrib/absl/absl/base/port.h similarity index 100% rename from contrib/absl/base/port.h rename to contrib/absl/absl/base/port.h diff --git a/contrib/absl/numeric/int128.cc b/contrib/absl/absl/numeric/int128.cc similarity index 100% rename from contrib/absl/numeric/int128.cc rename to contrib/absl/absl/numeric/int128.cc diff --git a/contrib/absl/numeric/int128.h b/contrib/absl/absl/numeric/int128.h similarity index 100% rename from contrib/absl/numeric/int128.h rename to contrib/absl/absl/numeric/int128.h diff --git a/contrib/absl/numeric/int128_have_intrinsic.inc b/contrib/absl/absl/numeric/int128_have_intrinsic.inc similarity index 100% rename from contrib/absl/numeric/int128_have_intrinsic.inc rename to contrib/absl/absl/numeric/int128_have_intrinsic.inc diff --git a/contrib/absl/numeric/int128_no_intrinsic.inc b/contrib/absl/absl/numeric/int128_no_intrinsic.inc similarity index 100% rename from contrib/absl/numeric/int128_no_intrinsic.inc rename to contrib/absl/absl/numeric/int128_no_intrinsic.inc diff --git a/contrib/cityhash/CMakeLists.txt b/contrib/cityhash/CMakeLists.txt deleted file mode 100644 index e31bc245..00000000 --- a/contrib/cityhash/CMakeLists.txt +++ /dev/null @@ -1,5 +0,0 @@ -ADD_LIBRARY (cityhash-lib STATIC - city.cc -) - -set_property(TARGET cityhash-lib PROPERTY POSITION_INDEPENDENT_CODE ON) diff --git a/contrib/cityhash/BUCK b/contrib/cityhash/cityhash/BUCK similarity index 100% rename from contrib/cityhash/BUCK rename to contrib/cityhash/cityhash/BUCK diff --git a/contrib/cityhash/cityhash/CMakeLists.txt b/contrib/cityhash/cityhash/CMakeLists.txt new file mode 100644 index 00000000..d1311562 --- /dev/null +++ b/contrib/cityhash/cityhash/CMakeLists.txt @@ -0,0 +1,7 @@ +ADD_LIBRARY (cityhash STATIC + city.cc +) + +set_property(TARGET cityhash PROPERTY POSITION_INDEPENDENT_CODE ON) + +ADD_LIBRARY (cityhash::cityhash ALIAS cityhash) diff --git a/contrib/cityhash/COPYING b/contrib/cityhash/cityhash/COPYING similarity index 100% rename from contrib/cityhash/COPYING rename to contrib/cityhash/cityhash/COPYING diff --git a/contrib/cityhash/city.cc b/contrib/cityhash/cityhash/city.cc similarity index 100% rename from contrib/cityhash/city.cc rename to contrib/cityhash/cityhash/city.cc diff --git a/contrib/cityhash/city.h b/contrib/cityhash/cityhash/city.h similarity index 100% rename from contrib/cityhash/city.h rename to contrib/cityhash/cityhash/city.h diff --git a/contrib/cityhash/citycrc.h b/contrib/cityhash/cityhash/citycrc.h similarity index 100% rename from contrib/cityhash/citycrc.h rename to contrib/cityhash/cityhash/citycrc.h diff --git a/contrib/cityhash/config.h b/contrib/cityhash/cityhash/config.h similarity index 100% rename from contrib/cityhash/config.h rename to contrib/cityhash/cityhash/config.h diff --git a/contrib/lz4/CMakeLists.txt b/contrib/lz4/CMakeLists.txt deleted file mode 100644 index 7b471da3..00000000 --- a/contrib/lz4/CMakeLists.txt +++ /dev/null @@ -1,6 +0,0 @@ -ADD_LIBRARY (lz4-lib STATIC - lz4.c - lz4hc.c -) - -set_property(TARGET lz4-lib PROPERTY POSITION_INDEPENDENT_CODE ON) diff --git a/contrib/lz4/BUCK b/contrib/lz4/lz4/BUCK similarity index 100% rename from contrib/lz4/BUCK rename to contrib/lz4/lz4/BUCK diff --git a/contrib/lz4/lz4/CMakeLists.txt b/contrib/lz4/lz4/CMakeLists.txt new file mode 100644 index 00000000..1ec7fb07 --- /dev/null +++ b/contrib/lz4/lz4/CMakeLists.txt @@ -0,0 +1,8 @@ +ADD_LIBRARY (lz4 STATIC + lz4.c + lz4hc.c +) + +set_property(TARGET lz4 PROPERTY POSITION_INDEPENDENT_CODE ON) + +ADD_LIBRARY(lz4::lz4 ALIAS lz4) diff --git a/contrib/lz4/LICENSE b/contrib/lz4/lz4/LICENSE similarity index 100% rename from contrib/lz4/LICENSE rename to contrib/lz4/lz4/LICENSE diff --git a/contrib/lz4/lz4.c b/contrib/lz4/lz4/lz4.c similarity index 100% rename from contrib/lz4/lz4.c rename to contrib/lz4/lz4/lz4.c diff --git a/contrib/lz4/lz4.h b/contrib/lz4/lz4/lz4.h similarity index 100% rename from contrib/lz4/lz4.h rename to contrib/lz4/lz4/lz4.h diff --git a/contrib/lz4/lz4hc.c b/contrib/lz4/lz4/lz4hc.c similarity index 100% rename from contrib/lz4/lz4hc.c rename to contrib/lz4/lz4/lz4hc.c diff --git a/contrib/lz4/lz4hc.h b/contrib/lz4/lz4/lz4hc.h similarity index 100% rename from contrib/lz4/lz4hc.h rename to contrib/lz4/lz4/lz4hc.h diff --git a/tests/simple/CMakeLists.txt b/tests/simple/CMakeLists.txt index cd102ec3..0fd4ab3a 100644 --- a/tests/simple/CMakeLists.txt +++ b/tests/simple/CMakeLists.txt @@ -6,11 +6,3 @@ ADD_EXECUTABLE (simple-test TARGET_LINK_LIBRARIES (simple-test clickhouse-cpp-lib-static ) - -IF (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") - # there is a problem with __builtin_mul_overflow call at link time - # the error looks like: ... undefined reference to `__muloti4' ... - # caused by clang bug https://bugs.llvm.org/show_bug.cgi?id=16404 - # explicit linking to compiler-rt allows to workaround the problem - set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --rtlib=compiler-rt") -ENDIF () diff --git a/ut/CMakeLists.txt b/ut/CMakeLists.txt index 86066965..f19a6ecb 100644 --- a/ut/CMakeLists.txt +++ b/ut/CMakeLists.txt @@ -38,6 +38,3 @@ TARGET_LINK_LIBRARIES (clickhouse-cpp-ut clickhouse-cpp-lib-static gtest-lib ) -IF (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") - set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --rtlib=compiler-rt") -ENDIF ()