Skip to content

Commit 81e12df

Browse files
authored
Merge pull request #591 from ClickHouse/use-system-stdlib
Use the system C++ standard library and link the runtime statically
2 parents 74027bc + 16a2b07 commit 81e12df

33 files changed

Lines changed: 294 additions & 622 deletions

‎.github/workflows/Coverage.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ jobs:
5656
sudo apt upgrade -y
5757
sudo apt install -y \
5858
build-essential git cmake docker perl libdbi-perl libdbd-odbc-perl \
59-
python-is-python3 python3 python3-pip python3-setuptools libpoco-dev libssl-dev libicu-dev
59+
python-is-python3 python3 python3-pip python3-setuptools
6060
sudo apt install -y unixodbc unixodbc-dev
6161
sudo apt install -y clang llvm lldb
6262
sudo apt autoremove -y

‎.github/workflows/Linux.yml‎

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,9 @@ jobs:
3333
matrix:
3434
os: [ubuntu-22.04]
3535
odbc_provider: [UnixODBC]
36-
compiler: [Clang]
36+
compiler: [Clang, GCC]
3737
build_type: [Debug, Release]
3838
architecture: [x86_64]
39-
runtime_link: [static-runtime, dynamic-runtime]
40-
third_parties: [bundled-third-parties, system-third-parties]
4139
# exclude:
4240
# - os: ubuntu-18.04
4341
# compiler: Clang
@@ -66,7 +64,7 @@ jobs:
6664
sudo apt update -q
6765
sudo apt remove -y php* node* mysql* mssql-tools
6866
sudo apt upgrade -y
69-
sudo apt install -y build-essential git cmake docker perl libdbi-perl libdbd-odbc-perl python-is-python3 python3 python3-pip python3-setuptools libpoco-dev libssl-dev libicu-dev
67+
sudo apt install -y build-essential git cmake docker perl libdbi-perl libdbd-odbc-perl python-is-python3 python3 python3-pip python3-setuptools
7068
7169
- name: Install dependencies - UnixODBC
7270
if: ${{ matrix.odbc_provider == 'UnixODBC' }}
@@ -82,7 +80,8 @@ jobs:
8280

8381
- name: Install dependencies - GCC
8482
if: ${{ matrix.compiler == 'GCC' }}
85-
run: sudo apt install -y gcc g++ gdb
83+
# GCC 12 is the oldest GCC with adequate C++23 support; Ubuntu 22.04 defaults to GCC 11.
84+
run: sudo apt install -y gcc-12 g++-12 gdb
8685

8786
- name: Install dependencies - Cleanup
8887
run: sudo apt autoremove -y
@@ -105,14 +104,12 @@ jobs:
105104
)
106105
dsn_string=$(IFS=';'; echo "${dsn_list[*]}")
107106
108-
CC=${{ fromJSON('{"Clang": "clang", "GCC": "gcc"}')[matrix.compiler] }} \
109-
CXX=${{ fromJSON('{"Clang": "clang++", "GCC": "g++"}')[matrix.compiler] }} \
107+
CC=${{ fromJSON('{"Clang": "clang", "GCC": "gcc-12"}')[matrix.compiler] }} \
108+
CXX=${{ fromJSON('{"Clang": "clang++", "GCC": "g++-12"}')[matrix.compiler] }} \
110109
cmake -S ${{ github.workspace }}/source -B ${{ github.workspace }}/build \
111110
-DCMAKE_POLICY_VERSION_MINIMUM=3.5 \
112111
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \
113112
-DODBC_PROVIDER=${{ matrix.odbc_provider }} \
114-
-DCH_ODBC_RUNTIME_LINK_STATIC=${{ fromJSON('{"static-runtime": "ON", "dynamic-runtime": "OFF"}')[matrix.runtime_link] }} \
115-
-DCH_ODBC_PREFER_BUNDLED_THIRD_PARTIES=${{ fromJSON('{"bundled-third-parties": "ON", "system-third-parties": "OFF"}')[matrix.third_parties] }} \
116113
-DTEST_DSN_LIST="$dsn_string" \
117114
-DBUILD_TESTING=YES
118115
@@ -134,6 +131,21 @@ jobs:
134131
done
135132
exit $rc
136133
134+
- name: Check driver does not depend on a shared C++ runtime
135+
working-directory: ${{ github.workspace }}/build/driver
136+
run: |
137+
rc=0
138+
for f in libclickhouseodbc.so libclickhouseodbcw.so; do
139+
if readelf -dW "$f" | grep -E 'NEEDED.*\b(libstdc\+\+|libgcc_s)\b'; then
140+
echo "FAIL (shared C++ runtime dependency): $f"; rc=1
141+
elif readelf -VW "$f" | grep -qE 'GLIBCXX_|CXXABI_'; then
142+
echo "FAIL (libstdc++ symbol version requirement): $f"; rc=1
143+
else
144+
echo "ok (static C++ runtime): $f"
145+
fi
146+
done
147+
exit $rc
148+
137149
- name: Package
138150
run: cmake --build ${{ github.workspace }}/build --config ${{ matrix.build_type }} --target package
139151

@@ -143,7 +155,7 @@ jobs:
143155
ls -lahR ${{ github.workspace }}/build/
144156
145157
- name: Upload the artifacts
146-
if: ${{ matrix.odbc_provider == 'UnixODBC' && matrix.build_type == 'Release' && matrix.runtime_link == 'dynamic-runtime' && matrix.third_parties == 'bundled-third-parties' }}
158+
if: ${{ matrix.odbc_provider == 'UnixODBC' && matrix.build_type == 'Release' }}
147159
uses: actions/upload-artifact@v4
148160
with:
149161
name: clickhouse-odbc-linux-${{ matrix.compiler }}-${{ matrix.odbc_provider }}-${{ matrix.build_type }}

‎.github/workflows/Sanitizer.yml‎

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,12 @@ jobs:
2929
matrix:
3030
os: [ubuntu-24.04]
3131
build_type: [RelWithDebInfo]
32-
third_parties: [bundled-third-parties]
33-
sanitizer: [address, memory, undefined]
32+
# MemorySanitizer is deliberately absent: it requires every library in the process
33+
# (C++ standard library, OpenSSL, ICU, ...) to be MSan-instrumented, which is not
34+
# the case since the driver uses the system C++ standard library. Uninitialized
35+
# memory reads are covered by Valgrind's Memcheck instead, which needs no
36+
# instrumentation and runs against a regular build.
37+
checker: [address, undefined, valgrind]
3438

3539
runs-on: ${{ matrix.os }}
3640

@@ -57,6 +61,10 @@ jobs:
5761
chmod +x llvm.sh
5862
sudo ./llvm.sh 20 all
5963
64+
- name: Install dependencies - Valgrind
65+
if: ${{ matrix.checker == 'valgrind' }}
66+
run: sudo apt install -y valgrind
67+
6068
- name: Clone the repo
6169
uses: actions/checkout@v4
6270
with:
@@ -71,7 +79,7 @@ jobs:
7179
-DCMAKE_POLICY_VERSION_MINIMUM=3.5
7280
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
7381
-DTEST_DSN_LIST="ClickHouse DSN (ANSI);ClickHouse DSN (Unicode);ClickHouse DSN (ANSI) ZSTD;ClickHouse DSN (Unicode) ZSTD"
74-
-DSANITIZE=${{ matrix.sanitizer }}
82+
-DSANITIZE=${{ matrix.checker != 'valgrind' && matrix.checker || '' }}
7583
-DBUILD_TESTING=YES
7684
7785
- name: Build
@@ -146,9 +154,31 @@ jobs:
146154
EOF
147155
148156
- name: Test - Run C++ integration tests
157+
if: ${{ matrix.checker != 'valgrind' }}
149158
working-directory: ${{ github.workspace }}/build
150159
run: |
151160
export ODBCSYSINI=
152161
export ODBCINSTINI="${{ github.workspace }}/run/.odbcinst.ini"
153162
export ODBCINI="${{ github.workspace }}/run/.odbc.ini"
154163
ctest --output-on-failure --build-config ${{ matrix.build_type }}
164+
165+
- name: Test - Run C++ integration tests under Valgrind
166+
if: ${{ matrix.checker == 'valgrind' }}
167+
working-directory: ${{ github.workspace }}/build/driver/test
168+
timeout-minutes: 60
169+
run: |
170+
export ODBCSYSINI=
171+
export ODBCINSTINI="${{ github.workspace }}/run/.odbcinst.ini"
172+
export ODBCINI="${{ github.workspace }}/run/.odbc.ini"
173+
rc=0
174+
for dsn in "ClickHouse DSN (ANSI)" "ClickHouse DSN (Unicode)" "ClickHouse DSN (ANSI) ZSTD" "ClickHouse DSN (Unicode) ZSTD"; do
175+
case "$dsn" in
176+
*Unicode*) exe=./clickhouse-odbcw-client-it ;;
177+
*) exe=./clickhouse-odbc-client-it ;;
178+
esac
179+
echo "::group::$dsn"
180+
valgrind --tool=memcheck --error-exitcode=1 --track-origins=yes --gen-suppressions=all \
181+
"$exe" "$dsn" --gtest_filter='-*PerformanceTest*' || rc=1
182+
echo "::endgroup::"
183+
done
184+
exit $rc

‎.github/workflows/Windows.yml‎

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,14 +77,28 @@ jobs:
7777
-DCMAKE_POLICY_VERSION_MINIMUM="3.5" `
7878
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }} `
7979
-DODBC_PROVIDER=${{ matrix.odbc_provider }} `
80-
-DCH_ODBC_RUNTIME_LINK_STATIC=OFF `
81-
-DCH_ODBC_PREFER_BUNDLED_THIRD_PARTIES=ON `
8280
-DTEST_DSN_LIST="$dsnList" `
8381
-DBUILD_TESTING=YES
8482
8583
- name: Build
8684
run: cmake --build ${{ github.workspace }}/build --config ${{ matrix.build_type }}
8785

86+
- name: Check driver does not depend on the Visual C++ Redistributable
87+
working-directory: ${{ github.workspace }}/build/driver/${{ matrix.build_type }}
88+
run: |
89+
$failed = $false
90+
foreach ($f in @("clickhouseodbc.dll", "clickhouseodbcw.dll")) {
91+
$deps = (dumpbin /dependents $f) -join "`n"
92+
if ($deps -match '(?i)\b(vcruntime|msvcp|ucrtbase|api-ms-win-crt)[^\s]*\.dll') {
93+
Write-Host "FAIL (shared CRT dependency): $f"
94+
Write-Host $deps
95+
$failed = $true
96+
} else {
97+
Write-Host "ok (static CRT): $f"
98+
}
99+
}
100+
if ($failed) { exit 1 }
101+
88102
- name: Package
89103
run: cmake --build ${{ github.workspace }}/build --config ${{ matrix.build_type }} --target package
90104

‎.github/workflows/WindowsSigning.yml‎

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,6 @@ jobs:
6262
-DCMAKE_POLICY_VERSION_MINIMUM="3.5"
6363
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }}
6464
-DODBC_PROVIDER=${{ matrix.odbc_provider }}
65-
-DCH_ODBC_RUNTIME_LINK_STATIC=OFF
66-
-DCH_ODBC_PREFER_BUNDLED_THIRD_PARTIES=ON
6765
-DTEST_DSN_LIST="ClickHouse DSN ANSI;ClickHouse DSN Unicode"
6866
-DBUILD_TESTING=NO
6967

‎.github/workflows/macOS.yml‎

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,6 @@ jobs:
3737
odbc_provider: [UnixODBC]
3838
compiler: [AppleClang]
3939
build_type: [Debug, Release]
40-
runtime_link: [dynamic-runtime]
41-
third_parties: [bundled-third-parties]
4240

4341
runs-on: ${{ matrix.os }}
4442

@@ -62,7 +60,7 @@ jobs:
6260
- name: Install dependencies - Common
6361
run: |
6462
brew remove -f --ignore-dependencies -q libiodbc unixodbc freetds php node composer
65-
brew install git cmake perl python openssl poco icu4c binutils curl
63+
brew install git cmake perl python binutils curl
6664
pip3 install --break-system-packages --user 'testflows==1.6.56'
6765
6866
- name: Install dependencies - UnixODBC
@@ -107,10 +105,6 @@ jobs:
107105
-DCMAKE_POLICY_VERSION_MINIMUM=3.5 \
108106
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \
109107
-DODBC_PROVIDER=${{ matrix.odbc_provider }} \
110-
-DICU_ROOT="$(brew --prefix icu4c)" \
111-
-DOPENSSL_ROOT_DIR="$(brew --prefix openssl)" \
112-
-DCH_ODBC_RUNTIME_LINK_STATIC=${{ fromJSON('{"static-runtime": "ON", "dynamic-runtime": "OFF"}')[matrix.runtime_link] }} \
113-
-DCH_ODBC_PREFER_BUNDLED_THIRD_PARTIES=${{ fromJSON('{"bundled-third-parties": "ON", "system-third-parties": "OFF"}')[matrix.third_parties] }} \
114108
-DTEST_DSN_LIST="$dsn_string" \
115109
-DBUILD_TESTING=YES
116110

‎.gitmodules‎

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,6 @@
1414
[submodule "contrib/nanodbc"]
1515
path = contrib/nanodbc
1616
url = https://github.com/ClickHouse/nanodbc.git
17-
[submodule "contrib/llvm-project"]
18-
path = contrib/llvm-project
19-
url = https://github.com/ClickHouse/llvm-project
2017
[submodule "contrib/zlib-ng"]
2118
path = contrib/zlib-ng
2219
url = https://github.com/ClickHouse/zlib-ng.git
@@ -29,9 +26,6 @@
2926
[submodule "contrib/double-conversion"]
3027
path = contrib/double-conversion
3128
url = https://github.com/ClickHouse/double-conversion
32-
[submodule "contrib/libunwind"]
33-
path = contrib/libunwind
34-
url = https://github.com/ClickHouse/libunwind
3529
[submodule "contrib/asio"]
3630
path = contrib/asio
3731
url = https://github.com/chriskohlhoff/asio

0 commit comments

Comments
 (0)