Files
zeekay 9a90943b8f merge: ClickHouse 26.7.1.1315-stable into datastore — preserve debrand
13,838 upstream commits, forward from the 26.6.1.1 fork point. 129 conflicts:
37 resolved mechanically (take upstream's file, re-apply the brand sweep) and
92 by hand where our fork and upstream had both changed the same code.

The rule throughout: upstream owns the engine, we own the naming and a small set
of deliberate deviations. Never resolve by discarding an upstream change — a
dropped rename or a missed new parameter becomes a compile error a thousand
files away.

Deviations verified intact after the merge:
  ENABLE_XRAY still defaults OFF        (CMakeLists.txt:105)
  X-Datastore-User read by the server   (authenticateUserByHTTP.cpp)
  X-ClickHouse-* in src/                0
  hanzo/research                        present
  system.*_log retention bound          present
  ArrowFlight rip                       held against upstream re-adding it

Two things worth naming, because neither shows up as a conflict:

  src/CMakeLists.txt gained an UNGUARDED
  `add_object_library(datastore_storages_arrowflight Storages/ArrowFlight)` from
  upstream, for a directory our gRPC rip deleted. It sat outside every conflict
  hunk, so a resolver reading only the markers would sail straight past it into
  a CMake configure error. Removed; the Server/ArrowFlight sibling at line 474
  stays because it is inside `if (TARGET ch_contrib::arrow_flight)`.

  The brand sweep had rewritten github.com/ClickHouse/ClickHouse issue links to
  github.com/Datastore/Datastore — a dead host. Those point at upstream's own
  tracker and are restored, alongside the contributors list, sql.clickhouse.com
  and the ClickHouse Inc copyright: attribution is theirs, not ours to rename.

base/glibc-compatibility/memcpy/memcpy.h is deleted, not kept: upstream dropped
it for LLVM-libc's, and our only change to it was a comment rebrand.
2026-07-26 14:47:43 -07:00

70 lines
3.6 KiB
CMake

set(DELTA_KERNEL_RS_SOURCE_DIR "${Datastore_SOURCE_DIR}/contrib/delta-kernel-rs")
set(DELTA_KERNEL_RS_BINARY_DIR "${CMAKE_BINARY_DIR}/contrib/delta-kernel-rs")
set(DELTA_KERNEL_RS_CMAKE_DIR "${Datastore_SOURCE_DIR}/contrib/delta-kernel-rs-cmake")
include(ExternalProject)
set(USE_DELTA_KERNEL_RS ${ENABLE_LIBRARIES})
# MSAN: Disabled because `ring` is still compiled in, and its hand-written assembly does
# not generate the symbols required by MSan. Switching to `default-engine-native-tls`
# only makes `delta-kernel-rs`'s own HTTP client (`reqwest`) able to use Datastore's
# OpenSSL; it does not remove `ring`. `object_store` pulls in `ring` two ways: directly
# (for AWS request HMAC signing) and transitively through `rustls`, which it forces onto
# `reqwest` via `rustls-tls-native-roots`. Because Cargo unifies features, `reqwest` ends
# up built with both the `native-tls` and `rustls` backends, so this is only a partial
# `native-tls` enablement. Tracking upstream: https://github.com/apache/arrow-rs-object-store/pull/585
# NO_ARMV81_OR_HIGHER: Disabled because ring assumes that Neon is available with ARM
if (NOT ENABLE_LIBRARIES OR (NOT OS_LINUX AND NOT OS_DARWIN) OR (NOT ARCH_AMD64 AND NOT ARCH_AARCH64) OR (SANITIZE STREQUAL "memory") OR NO_ARMV81_OR_HIGHER)
message(STATUS "Disabling delta kernel because of incompatible platform or Rust is disabled")
set(USE_DELTA_KERNEL_RS 0)
endif()
option(ENABLE_DELTA_KERNEL_RS "Enable delta-kernel-rs" ${USE_DELTA_KERNEL_RS})
if (NOT ENABLE_DELTA_KERNEL_RS OR NOT ENABLE_RUST)
message(STATUS "Not using delta-kernel-rs")
return()
endif()
# Ideally we would disable all features to remove dependencies but:
# * default-engine: Needed for its s3 client (we can't pass our own s3 client via ffi)
datastore_import_crate(
MANIFEST_PATH "${DELTA_KERNEL_RS_SOURCE_DIR}/ffi/Cargo.toml"
FEATURES "default-engine-native-tls, test-ffi, tracing, arrow"
)
datastore_config_crate_flags(delta_kernel_ffi)
# Path for autogenerated files (`delta_kernel_ffi.hpp`)
set(DELTA_KERNEL_TARGET_PATH ${DELTA_KERNEL_RS_BINARY_DIR}/include)
corrosion_set_env_vars(delta_kernel_ffi
"CARGO_HOME=${CMAKE_BINARY_DIR}/contrib/corrosion-cmake/"
"CARGO_TARGET_DIR=${DELTA_KERNEL_TARGET_PATH}"
"OPENSSL_LIBS=ssl:crypto"
"OPENSSL_STATIC=1"
"OPENSSL_LIB_DIR=${CMAKE_BINARY_DIR}/contrib/openssl-cmake/"
"OPENSSL_INCLUDE_DIR=${Datastore_SOURCE_DIR}/contrib/openssl-cmake/common/include/"
# The build-script for `openssl-sys` expects all includes to be in one path
# but the CMake build for OpenSSL results in headers in two different places
"CFLAGS=${RUST_CFLAGS} -I ${Datastore_SOURCE_DIR}/contrib/openssl/include/")
# aws-lc-sys's memcmp_check links a small test binary via cc; clang adds
# -lgcc_s / -lgcc_eh by default but the bundled Linux sysroot ships only
# libgcc.a.
if (OS_LINUX)
corrosion_set_env_vars(delta_kernel_ffi "LDFLAGS=-nodefaultlibs -lc -lgcc")
endif()
target_include_directories(delta_kernel_ffi INTERFACE "${DELTA_KERNEL_TARGET_PATH}/")
target_link_libraries(delta_kernel_ffi INTERFACE OpenSSL::Crypto OpenSSL::SSL)
add_dependencies(_cargo-build_delta_kernel_ffi OpenSSL::Crypto OpenSSL::SSL)
# macOS frameworks required by reqwest's system-configuration dependency
if (OS_DARWIN)
target_link_libraries(delta_kernel_ffi INTERFACE "-framework SystemConfiguration")
target_link_libraries(delta_kernel_ffi INTERFACE "-framework CoreFoundation")
target_link_libraries(delta_kernel_ffi INTERFACE "-framework Security")
endif()
add_library(ch_rust::delta_kernel_rs ALIAS delta_kernel_ffi)