Skip to content

Commit 3899815

Browse files
committed
chore: support delta lake on linux x86-64 platform
1 parent b87f017 commit 3899815

36 files changed

+4737
-7
lines changed

.github/workflows/build_linux_arm64_wheels-gh.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,4 +158,3 @@ jobs:
158158
env:
159159
TWINE_USERNAME: __token__
160160
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
161-

.github/workflows/build_linux_x86_wheels.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,8 @@ jobs:
2828
fail-fast: false
2929
matrix:
3030
os: [ ubuntu-22.04 ]
31-
python-version: [ "3.8", "3.9", "3.10", "3.11", "3.12", "3.13" ]
32-
# python-version: [ "3.7" ]
31+
# python-version: [ "3.8", "3.9", "3.10", "3.11", "3.12", "3.13" ]
32+
python-version: [ "3.13" ]
3333
env:
3434
RUNNER_OS: ${{ matrix.os }}
3535
PYTHON_VERSION: ${{ matrix.python-version }}

.github/workflows/build_macos_x86_wheels.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -163,4 +163,3 @@ jobs:
163163
env:
164164
TWINE_USERNAME: __token__
165165
TWINE_PASSWORD: ${{ secrets.PYPI_PASSWORD }}
166-

chdb/build.sh

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ BUILD_DIR=${PROJ_DIR}/buildlib
1313

1414
HDFS="-DENABLE_HDFS=1 -DENABLE_GSASL_LIBRARY=1 -DENABLE_KRB5=1"
1515
MYSQL="-DENABLE_MYSQL=1"
16+
RUST_FEATURES="-DENABLE_RUST=0"
1617
# check current os type
1718
if [ "$(uname)" == "Darwin" ]; then
1819
export CXX=$(brew --prefix llvm@19)/bin/clang++
@@ -60,6 +61,18 @@ elif [ "$(uname)" == "Linux" ]; then
6061
if [ "$(uname -m)" == "x86_64" ]; then
6162
CPU_FEATURES="-DENABLE_AVX=1 -DENABLE_AVX2=0"
6263
LLVM="-DENABLE_EMBEDDED_COMPILER=1 -DENABLE_DWARF_PARSER=1"
64+
RUST_FEATURES="-DENABLE_RUST=1 -DENABLE_DELTA_KERNEL_RS=1"
65+
CORROSION_CMAKE_FILE="${PROJ_DIR}/contrib/corrosion-cmake/CMakeLists.txt"
66+
if [ -f "${CORROSION_CMAKE_FILE}" ]; then
67+
if ! grep -q 'OPENSSL_NO_DEPRECATED_3_0' "${CORROSION_CMAKE_FILE}"; then
68+
echo "Modifying corrosion CMakeLists.txt for Linux x86_64..."
69+
${SED_INPLACE} 's/corrosion_set_env_vars(${target_name} "RUSTFLAGS=${RUSTFLAGS}")/corrosion_set_env_vars(${target_name} "RUSTFLAGS=${RUSTFLAGS} --cfg osslconf=\\\"OPENSSL_NO_DEPRECATED_3_0\\\"")/g' "${CORROSION_CMAKE_FILE}"
70+
else
71+
echo "corrosion CMakeLists.txt already modified, skipping..."
72+
fi
73+
else
74+
echo "Warning: corrosion CMakeLists.txt not found at ${CORROSION_CMAKE_FILE}"
75+
fi
6376
else
6477
CPU_FEATURES="-DENABLE_AVX=0 -DENABLE_AVX2=0 -DNO_ARMV81_OR_HIGHER=1"
6578
LLVM="-DENABLE_EMBEDDED_COMPILER=0 -DENABLE_DWARF_PARSER=0"
@@ -84,7 +97,7 @@ CMAKE_ARGS="-DCMAKE_BUILD_TYPE=${build_type} -DENABLE_THINLTO=0 -DENABLE_TESTS=0
8497
-DENABLE_LDAP=0 \
8598
${MYSQL} \
8699
${HDFS} \
87-
-DENABLE_LIBRARIES=0 -DENABLE_RUST=0 \
100+
-DENABLE_LIBRARIES=0 ${RUST_FEATURES} \
88101
${GLIBC_COMPATIBILITY} \
89102
-DENABLE_UTILS=0 ${LLVM} ${UNWIND} \
90103
${ICU} -DENABLE_UTF8PROC=1 ${JEMALLOC} \

rust/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
add_subdirectory (workspace)
2+
add_subdirectory (chcache)

rust/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Read more about the Rust integration in the blog:
2+
3+
## https://clickhouse.com/blog/rust

rust/VENDOR.md

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
As we have multiple projects we use a workspace to manage them (it's way simpler and leads to less issues). In order
2+
to vendor all the dependencies we need to store both the registry and the packages themselves.
3+
4+
Note that this includes the exact `std` dependencies for the rustc version used in CI (currently nightly-2024-12-01),
5+
so you need to install `rustup component add rust-src` for the specific version.
6+
7+
* First step: (Re)-generate the Cargo.lock file (run under `workspace/`).
8+
9+
```bash
10+
cargo generate-lockfile
11+
```
12+
13+
* Generate the local registry:
14+
15+
Note that we use both commands to vendor both registry and crates. No idea why both are necessary.
16+
17+
* First we need to install the tool if you don't already have it:
18+
```bash
19+
cargo install --version 0.2.7 cargo-local-registry
20+
```
21+
22+
* Now add the local packages:
23+
24+
```bash
25+
export CH_TOP_DIR=$(git rev-parse --show-toplevel)
26+
export RUSTC_ROOT=$(rustc --print=sysroot)
27+
# Currently delta-lake is built outside the workspace (TODO)
28+
export DELTA_LAKE_DIR="$CH_TOP_DIR"/contrib/delta-kernel-rs
29+
30+
# Clean the vendor repo
31+
rm -rf "$CH_TOP_DIR"/contrib/rust_vendor/*
32+
33+
cd "$CH_TOP_DIR"/rust/workspace
34+
cargo local-registry --git --sync Cargo.lock "$CH_TOP_DIR"/contrib/rust_vendor
35+
36+
# Now handle delta-lake
37+
cd "$DELTA_LAKE_DIR"
38+
cargo local-registry --no-delete --git --sync "$DELTA_LAKE_DIR/Cargo.lock" "$CH_TOP_DIR"/contrib/rust_vendor
39+
40+
# Standard library deps
41+
cp "$RUSTC_ROOT"/lib/rustlib/src/rust/library/Cargo.lock "$RUSTC_ROOT"/lib/rustlib/src/rust/library/std/
42+
cargo local-registry --no-delete --git --sync "$RUSTC_ROOT"/lib/rustlib/src/rust/library/std/Cargo.lock "$CH_TOP_DIR"/contrib/rust_vendor
43+
cp "$RUSTC_ROOT"/lib/rustlib/src/rust/library/Cargo.lock "$RUSTC_ROOT"/lib/rustlib/src/rust/library/test/
44+
cargo local-registry --no-delete --git --sync "$RUSTC_ROOT"/lib/rustlib/src/rust/library/test/Cargo.lock "$CH_TOP_DIR"/contrib/rust_vendor
45+
46+
# Now we vendor the modules themselves
47+
cd "$CH_TOP_DIR"/rust/workspace
48+
cargo vendor --no-delete --locked "$CH_TOP_DIR"/contrib/rust_vendor
49+
cd "$DELTA_LAKE_DIR"
50+
cargo vendor --no-delete --locked "$CH_TOP_DIR"/contrib/rust_vendor
51+
cd "$RUSTC_ROOT"/lib/rustlib/src/rust/library/std/
52+
cargo vendor --no-delete "$CH_TOP_DIR"/contrib/rust_vendor
53+
cd "$RUSTC_ROOT"/lib/rustlib/src/rust/library/test/
54+
cargo vendor --no-delete "$CH_TOP_DIR"/contrib/rust_vendor
55+
56+
# Remove windows only dependencies (which are really heavy and we don't want in the repo)
57+
rm -rf "$CH_TOP_DIR"/contrib/rust_vendor/winapi* "$CH_TOP_DIR"/contrib/rust_vendor/windows*
58+
59+
# Cleanup the lock files we copied
60+
rm "$RUSTC_ROOT"/lib/rustlib/src/rust/library/std/Cargo.lock "$RUSTC_ROOT"/lib/rustlib/src/rust/library/test/Cargo.lock
61+
cd "$CH_TOP_DIR"/rust/workspace
62+
```
63+
64+
The `rustc --print=sysroot` part includes `std` dependencies, required to build with sanitizer flags. It must be kept
65+
in sync with the rustc version used in CI.

rust/chcache/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/target

rust/chcache/CMakeLists.txt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
if (COMPILER_CACHE STREQUAL "chcache")
2+
corrosion_import_crate(
3+
MANIFEST_PATH Cargo.toml
4+
PROFILE release
5+
LOCKED
6+
)
7+
8+
corrosion_set_env_vars(
9+
chcache
10+
RUSTFLAGS=
11+
RUST_CFLAGS=
12+
RUST_CXXFLAGS=
13+
CFLAGS=
14+
CXXFLAGS=
15+
)
16+
17+
corrosion_set_hostbuild(chcache)
18+
endif()

0 commit comments

Comments
 (0)