Skip to content

Commit c32ba7d

Browse files
DavidWoortonDavidKeller
authored andcommitted
Add options to use system abseil, lz4 and cityhash
This change solves ClickHouse#86, ClickHouse#99. Signed-off-by: David Keller <[email protected]>
1 parent ba90272 commit c32ba7d

39 files changed

+137
-87
lines changed

.github/workflows/linux.yml

+43-18
Original file line numberDiff line numberDiff line change
@@ -12,55 +12,80 @@ env:
1212
jobs:
1313
build:
1414
runs-on: ubuntu-latest
15+
1516
strategy:
17+
fail-fast: false
1618
matrix:
17-
compiler: [clang-6, gcc-7, gcc-8, gcc-9]
19+
compiler: [clang-6, clang-10-libc++, gcc-7, gcc-8, gcc-9]
1820
ssl: [ssl_ON, ssl_OFF]
21+
dependencies: [dependencies_SYSTEM, dependencies_BUILT_IN]
1922
include:
2023
- compiler: clang-6
21-
INSTALL: clang-6.0
2224
C_COMPILER: clang-6.0
2325
CXX_COMPILER: clang++-6.0
2426

27+
- compiler: clang-10-libc++
28+
COMPILER_INSTALL: clang-10 libc++-dev
29+
C_COMPILER: clang-10
30+
CXX_COMPILER: clang++-10
31+
2532
- compiler: gcc-7
26-
INSTALL: gcc-7 g++-7
33+
COMPILER_INSTALL: gcc-7 g++-7
2734
C_COMPILER: gcc-7
2835
CXX_COMPILER: g++-7
2936

3037
- compiler: gcc-8
31-
INSTALL: gcc-8 g++-8
38+
COMPILER_INSTALL: gcc-8 g++-8
3239
C_COMPILER: gcc-8
3340
CXX_COMPILER: g++-8
3441

3542
- compiler: gcc-9
36-
INSTALL: gcc-9 g++-9
43+
COMPILER_INSTALL: gcc-9 g++-9
3744
C_COMPILER: gcc-9
3845
CXX_COMPILER: g++-9
3946

4047
- ssl: ssl_ON
41-
INSTALL_SSL: libssl-dev
42-
EXTRA_CMAKE_FLAGS: -DWITH_OPENSSL=ON
48+
SSL_CMAKE_OPTION: -D WITH_OPENSSL=ON
4349

4450
- ssl: ssl_OFF
45-
EXTRA_CMAKE_FLAGS: -DWITH_OPENSSL=OFF
51+
52+
- dependencies: dependencies_SYSTEM
53+
DEPENDENCIES_INSTALL: libabsl-dev liblz4-dev libcityhash-dev
54+
DEPENDENCIES_CMAKE_OPTIONS: >-
55+
-D WITH_SYSTEM_LZ4=ON
56+
-D WITH_SYSTEM_CITYHASH=ON
57+
-D WITH_SYSTEM_ABSEIL=ON
58+
59+
- dependencies: dependencies_BUILT_IN
4660

4761
steps:
4862
- uses: actions/checkout@v2
4963

5064
- name: Install dependencies
51-
run: sudo apt-get install -y cmake ${{ matrix.INSTALL }} ${{ matrix.INSTALL_SSL }}
65+
run: |
66+
sudo apt-get install -y \
67+
cmake \
68+
${{matrix.COMPILER_INSTALL}} \
69+
${{matrix.DEPENDENCIES_INSTALL}}
70+
71+
- name: Configure project
72+
run: |
73+
cmake \
74+
-D CMAKE_C_COMPILER=${{matrix.C_COMPILER}} \
75+
-D CMAKE_CXX_COMPILER=${{matrix.CXX_COMPILER}} \
76+
-D CMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} \
77+
-D BUILD_TESTS=ON \
78+
${{matrix.SSL_CMAKE_OPTION}} \
79+
${{matrix.DEPENDENCIES_CMAKE_OPTIONS}} \
80+
-S ${{github.workspace}} \
81+
-B ${{github.workspace}}/build
5282
53-
- name: Configure CMake
83+
- name: Build project
5484
run: |
5585
cmake \
56-
-DCMAKE_C_COMPILER=${{ matrix.C_COMPILER}} \
57-
-DCMAKE_CXX_COMPILER=${{ matrix.CXX_COMPILER}} \
58-
-B ${{github.workspace}}/build \
59-
-DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DBUILD_TESTS=ON \
60-
${{ matrix.EXTRA_CMAKE_FLAGS }}
61-
62-
- name: Build
63-
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} --target all
86+
--build ${{github.workspace}}/build \
87+
--config ${{env.BUILD_TYPE}} \
88+
--target all
6489
6590
- name: Start ClickHouse server
6691
run: |

.github/workflows/macos.yml

+17-7
Original file line numberDiff line numberDiff line change
@@ -21,24 +21,34 @@ jobs:
2121
build: [nossl, ssl]
2222
include:
2323
- build: nossl
24-
extra_cmake_flags: -DWITH_OPENSSL=OFF
25-
extra_install:
2624

2725
- build: ssl
28-
extra_cmake_flags: -DWITH_OPENSSL=ON -DOPENSSL_ROOT_DIR=/usr/local/opt/openssl/
29-
extra_install: openssl
26+
SSL_CMAKE_OPTION: >-
27+
-D WITH_OPENSSL=ON
28+
-D OPENSSL_ROOT_DIR=/usr/local/opt/openssl/
29+
SSL_INSTALL: openssl
3030

3131
steps:
3232
- uses: actions/checkout@v2
3333

3434
- name: Install dependencies
35-
run: brew install cmake ${{matrix.extra_install}}
35+
run: brew install cmake ${{matrix.SSL_INSTALL}}
3636

3737
- name: Configure CMake
38-
run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -DBUILD_TESTS=ON ${{matrix.extra_cmake_flags}}
38+
run: |
39+
cmake \
40+
-D CMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} \
41+
-D BUILD_TESTS=ON \
42+
${{matrix.SSL_CMAKE_OPTION}} \
43+
-S ${{github.workspace}} \
44+
-B ${{github.workspace}}/build
3945
4046
- name: Build
41-
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}} --target all
47+
run: |
48+
cmake \
49+
--build ${{github.workspace}}/build \
50+
--config ${{env.BUILD_TYPE}} \
51+
--target all
4252
4353
- name: Start tls offoader proxy
4454
# that mimics non-secure clickhouse running on localhost

CMakeLists.txt

+47-4
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ INCLUDE (cmake/openssl.cmake)
77
OPTION (BUILD_BENCHMARK "Build benchmark" OFF)
88
OPTION (BUILD_TESTS "Build tests" OFF)
99
OPTION (WITH_OPENSSL "Use OpenSSL for TLS connections" OFF)
10+
OPTION (WITH_SYSTEM_ABSEIL "Use system ABSEIL" OFF)
11+
OPTION (WITH_SYSTEM_LZ4 "Use system LZ4" OFF)
12+
OPTION (WITH_SYSTEM_CITYHASH "Use system cityhash" OFF)
1013

1114
PROJECT (CLICKHOUSE-CLIENT)
1215

@@ -26,14 +29,54 @@ PROJECT (CLICKHOUSE-CLIENT)
2629
SET (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Werror")
2730
ENDIF ()
2831

32+
IF (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
33+
INCLUDE (CheckCXXSourceCompiles)
34+
35+
CHECK_CXX_SOURCE_COMPILES("#include <bits/c++config.h>\nint main() { return __GLIBCXX__ != 0; }"
36+
CLANG_WITH_LIB_STDCXX)
37+
ENDIF ()
38+
39+
IF (CLANG_WITH_LIB_STDCXX)
40+
# there is a problem with __builtin_mul_overflow call at link time
41+
# the error looks like: ... undefined reference to `__muloti4' ...
42+
# caused by clang bug https://bugs.llvm.org/show_bug.cgi?id=16404
43+
# explicit linking to compiler-rt allows to workaround the problem
44+
SET (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} --rtlib=compiler-rt")
45+
SET (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --rtlib=compiler-rt")
46+
47+
# some workaround for linking issues on linux:
48+
# /usr/bin/ld: CMakeFiles/simple-test.dir/main.cpp.o: undefined reference to symbol '_Unwind_Resume@@GCC_3.0'
49+
# /usr/bin/ld: /lib/x86_64-linux-gnu/libgcc_s.so.1: error adding symbols: DSO missing from command line
50+
# FIXME: that workaround breaks clang build on mingw
51+
SET (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -lgcc_s")
52+
SET (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -lgcc_s")
53+
ENDIF ()
54+
2955
INCLUDE_DIRECTORIES (.)
30-
INCLUDE_DIRECTORIES (contrib)
56+
57+
IF (WITH_SYSTEM_ABSEIL)
58+
FIND_PACKAGE(absl REQUIRED)
59+
ELSE ()
60+
INCLUDE_DIRECTORIES (contrib/absl)
61+
SUBDIRS (contrib/absl/absl)
62+
ENDIF ()
63+
64+
IF (WITH_SYSTEM_LZ4)
65+
FIND_PACKAGE(lz4 REQUIRED)
66+
ELSE ()
67+
INCLUDE_DIRECTORIES (contrib/lz4/lz4)
68+
SUBDIRS (contrib/lz4/lz4)
69+
ENDIF ()
70+
71+
IF (WITH_SYSTEM_CITYHASH)
72+
FIND_PACKAGE(cityhash REQUIRED)
73+
ELSE ()
74+
INCLUDE_DIRECTORIES (contrib/cityhash/cityhash)
75+
SUBDIRS (contrib/cityhash/cityhash)
76+
ENDIF ()
3177

3278
SUBDIRS (
3379
clickhouse
34-
contrib/absl
35-
contrib/cityhash
36-
contrib/lz4
3780
)
3881

3982
IF (BUILD_BENCHMARK)

clickhouse/CMakeLists.txt

+6-29
Original file line numberDiff line numberDiff line change
@@ -39,46 +39,23 @@ ENDIF ()
3939
ADD_LIBRARY (clickhouse-cpp-lib SHARED ${clickhouse-cpp-lib-src})
4040
SET_TARGET_PROPERTIES(clickhouse-cpp-lib PROPERTIES LINKER_LANGUAGE CXX)
4141
TARGET_LINK_LIBRARIES (clickhouse-cpp-lib
42-
absl-lib
43-
cityhash-lib
44-
lz4-lib
42+
absl::absl
43+
cityhash::cityhash
44+
lz4::lz4
4545
)
4646

4747
ADD_LIBRARY (clickhouse-cpp-lib-static STATIC ${clickhouse-cpp-lib-src})
4848
TARGET_LINK_LIBRARIES (clickhouse-cpp-lib-static
49-
absl-lib
50-
cityhash-lib
51-
lz4-lib
49+
absl::absl
50+
cityhash::cityhash
51+
lz4::lz4
5252
)
5353

54-
IF (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
55-
INCLUDE (CheckCXXSourceCompiles)
56-
57-
CHECK_CXX_SOURCE_COMPILES("#include <bits/c++config.h>\nint main() { return __GLIBCXX__ != 0; }"
58-
BUILDING_WITH_LIB_STDCXX)
59-
60-
IF (BUILDING_WITH_LIB_STDCXX)
61-
# there is a problem with __builtin_mul_overflow call at link time
62-
# the error looks like: ... undefined reference to `__muloti4' ...
63-
# caused by clang bug https://bugs.llvm.org/show_bug.cgi?id=16404
64-
# explicit linking to compiler-rt allows to workaround the problem
65-
SET (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} --rtlib=compiler-rt")
66-
67-
# some workaround for linking issues on linux:
68-
# /usr/bin/ld: CMakeFiles/simple-test.dir/main.cpp.o: undefined reference to symbol '_Unwind_Resume@@GCC_3.0'
69-
# /usr/bin/ld: /lib/x86_64-linux-gnu/libgcc_s.so.1: error adding symbols: DSO missing from command line
70-
# FIXME: that workaround breaks clang build on mingw
71-
TARGET_LINK_LIBRARIES (clickhouse-cpp-lib gcc_s)
72-
TARGET_LINK_LIBRARIES (clickhouse-cpp-lib-static gcc_s)
73-
ENDIF ()
74-
ENDIF ()
75-
7654
INSTALL (TARGETS clickhouse-cpp-lib clickhouse-cpp-lib-static
7755
ARCHIVE DESTINATION lib
7856
LIBRARY DESTINATION lib
7957
)
8058

81-
8259
# general
8360
INSTALL(FILES block.h DESTINATION include/clickhouse/)
8461
INSTALL(FILES client.h DESTINATION include/clickhouse/)

clickhouse/base/compressed.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
#include "output.h"
44
#include "../exceptions.h"
55

6-
#include <cityhash/city.h>
7-
#include <lz4/lz4.h>
6+
#include <city.h>
7+
#include <lz4.h>
88
#include <stdexcept>
99
#include <system_error>
1010

clickhouse/columns/lowcardinality.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#include "nullable.h"
55
#include "../base/wire_format.h"
66

7-
#include <cityhash/city.h>
7+
#include <city.h>
88

99
#include <functional>
1010
#include <string_view>

clickhouse/types/types.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
#include "../exceptions.h"
44

5-
#include <cityhash/city.h>
5+
#include <city.h>
66

77
#include <stdexcept>
88

contrib/absl/CMakeLists.txt

-3
This file was deleted.

contrib/absl/absl/CMakeLists.txt

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
ADD_LIBRARY (absl STATIC
2+
numeric/int128.cc
3+
)
4+
5+
ADD_LIBRARY (absl::absl ALIAS absl)
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

contrib/cityhash/CMakeLists.txt

-5
This file was deleted.
File renamed without changes.
+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
ADD_LIBRARY (cityhash STATIC
2+
city.cc
3+
)
4+
5+
set_property(TARGET cityhash PROPERTY POSITION_INDEPENDENT_CODE ON)
6+
7+
ADD_LIBRARY (cityhash::cityhash ALIAS cityhash)
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

contrib/lz4/CMakeLists.txt

-6
This file was deleted.
File renamed without changes.

contrib/lz4/lz4/CMakeLists.txt

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
ADD_LIBRARY (lz4 STATIC
2+
lz4.c
3+
lz4hc.c
4+
)
5+
6+
set_property(TARGET lz4 PROPERTY POSITION_INDEPENDENT_CODE ON)
7+
8+
ADD_LIBRARY(lz4::lz4 ALIAS lz4)
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

tests/simple/CMakeLists.txt

-8
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,3 @@ ADD_EXECUTABLE (simple-test
66
TARGET_LINK_LIBRARIES (simple-test
77
clickhouse-cpp-lib-static
88
)
9-
10-
IF (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
11-
# there is a problem with __builtin_mul_overflow call at link time
12-
# the error looks like: ... undefined reference to `__muloti4' ...
13-
# caused by clang bug https://bugs.llvm.org/show_bug.cgi?id=16404
14-
# explicit linking to compiler-rt allows to workaround the problem
15-
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --rtlib=compiler-rt")
16-
ENDIF ()

ut/CMakeLists.txt

-3
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,3 @@ TARGET_LINK_LIBRARIES (clickhouse-cpp-ut
3838
clickhouse-cpp-lib-static
3939
gtest-lib
4040
)
41-
IF (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
42-
set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --rtlib=compiler-rt")
43-
ENDIF ()

0 commit comments

Comments
 (0)