From 687f7033f0e69100911049a2b5214a26f313c94a Mon Sep 17 00:00:00 2001 From: Frank Urbach <33724682+FrankUrbach@users.noreply.github.com> Date: Sun, 1 Mar 2026 22:13:35 +0100 Subject: [PATCH 1/7] Add TypeDBDriverClib_jll v3.8.1 --- T/TypeDBDriverClib_jll/build_tarballs.jl | 63 ++++++++++++++++++++++++ 1 file changed, 63 insertions(+) create mode 100644 T/TypeDBDriverClib_jll/build_tarballs.jl diff --git a/T/TypeDBDriverClib_jll/build_tarballs.jl b/T/TypeDBDriverClib_jll/build_tarballs.jl new file mode 100644 index 00000000000..b1db3ad199f --- /dev/null +++ b/T/TypeDBDriverClib_jll/build_tarballs.jl @@ -0,0 +1,63 @@ +using BinaryBuilder, Pkg + +# JLL-Paketname gemäß Yggdrasil-Konvention: Bibliotheksname ohne lib-Prefix, CamelCase +name = "TypeDBDriverClib_jll" +version = v"3.8.1" + +sources = [ + GitSource( + "https://github.com/typedb/typedb-driver.git", + "8e8d4a43da32adc1c56084f4d34174bebd0ce34a", # tag 3.8.1 + ), +] + +script = raw""" +cd ${WORKSPACE}/srcdir/typedb-driver + +# BinaryBuilder setzt CARGO_BUILD_TARGET bei Cross-Compilation. +# Bei nativem Build liegt das Ergebnis in target/release/. +cargo build --release --manifest-path c/Cargo.toml + +if [ -n "${CARGO_BUILD_TARGET}" ]; then + CARGO_OUT="target/${CARGO_BUILD_TARGET}/release" +else + CARGO_OUT="target/release" +fi + +mkdir -p "${libdir}" + +if [[ "${target}" == *-apple-darwin* ]]; then + install -vm 755 "${CARGO_OUT}/libtypedb_driver_clib.dylib" "${libdir}/" +elif [[ "${target}" == *-linux-* ]]; then + install -vm 755 "${CARGO_OUT}/libtypedb_driver_clib.so" "${libdir}/" +elif [[ "${target}" == *-w64-mingw* ]]; then + # Windows: Rust erzeugt typedb_driver_clib.dll (ohne lib-Prefix) + install -vm 755 "${CARGO_OUT}/typedb_driver_clib.dll" "${libdir}/" +else + echo "ERROR: Unsupported target ${target}" >&2 + exit 1 +fi +""" + +platforms = [ + Platform("x86_64", "linux"; libc="glibc"), + Platform("aarch64", "linux"; libc="glibc"), + Platform("x86_64", "macos"), + Platform("aarch64", "macos"), + Platform("x86_64", "windows"), +] + +# Rust-Bibliotheken müssen für jede C++-ABI-Variante gebaut werden, +# da sie über Cargo-Dependencies C++-Code einziehen können. +platforms = expand_cxxstring_abis(platforms) + +products = [ + # LibraryProduct akzeptiert eine Liste möglicher Namen (lib-Prefix optional auf Windows) + LibraryProduct(["libtypedb_driver_clib", "typedb_driver_clib"], :libtypedb_driver_clib), +] + +dependencies = Dependency[] + +build_tarballs(ARGS, name, version, sources, script, platforms, products, dependencies; + compilers = [:c, :rust], + julia_compat = "1.6") From d98bc8c32763fb3dc77c02afd9e8e06861d5583b Mon Sep 17 00:00:00 2001 From: Frank Urbach <33724682+FrankUrbach@users.noreply.github.com> Date: Sun, 1 Mar 2026 22:31:04 +0100 Subject: [PATCH 2/7] Remove incorrectly named directory (had _jll suffix) --- T/TypeDBDriverClib_jll/build_tarballs.jl | 63 ------------------------ 1 file changed, 63 deletions(-) delete mode 100644 T/TypeDBDriverClib_jll/build_tarballs.jl diff --git a/T/TypeDBDriverClib_jll/build_tarballs.jl b/T/TypeDBDriverClib_jll/build_tarballs.jl deleted file mode 100644 index b1db3ad199f..00000000000 --- a/T/TypeDBDriverClib_jll/build_tarballs.jl +++ /dev/null @@ -1,63 +0,0 @@ -using BinaryBuilder, Pkg - -# JLL-Paketname gemäß Yggdrasil-Konvention: Bibliotheksname ohne lib-Prefix, CamelCase -name = "TypeDBDriverClib_jll" -version = v"3.8.1" - -sources = [ - GitSource( - "https://github.com/typedb/typedb-driver.git", - "8e8d4a43da32adc1c56084f4d34174bebd0ce34a", # tag 3.8.1 - ), -] - -script = raw""" -cd ${WORKSPACE}/srcdir/typedb-driver - -# BinaryBuilder setzt CARGO_BUILD_TARGET bei Cross-Compilation. -# Bei nativem Build liegt das Ergebnis in target/release/. -cargo build --release --manifest-path c/Cargo.toml - -if [ -n "${CARGO_BUILD_TARGET}" ]; then - CARGO_OUT="target/${CARGO_BUILD_TARGET}/release" -else - CARGO_OUT="target/release" -fi - -mkdir -p "${libdir}" - -if [[ "${target}" == *-apple-darwin* ]]; then - install -vm 755 "${CARGO_OUT}/libtypedb_driver_clib.dylib" "${libdir}/" -elif [[ "${target}" == *-linux-* ]]; then - install -vm 755 "${CARGO_OUT}/libtypedb_driver_clib.so" "${libdir}/" -elif [[ "${target}" == *-w64-mingw* ]]; then - # Windows: Rust erzeugt typedb_driver_clib.dll (ohne lib-Prefix) - install -vm 755 "${CARGO_OUT}/typedb_driver_clib.dll" "${libdir}/" -else - echo "ERROR: Unsupported target ${target}" >&2 - exit 1 -fi -""" - -platforms = [ - Platform("x86_64", "linux"; libc="glibc"), - Platform("aarch64", "linux"; libc="glibc"), - Platform("x86_64", "macos"), - Platform("aarch64", "macos"), - Platform("x86_64", "windows"), -] - -# Rust-Bibliotheken müssen für jede C++-ABI-Variante gebaut werden, -# da sie über Cargo-Dependencies C++-Code einziehen können. -platforms = expand_cxxstring_abis(platforms) - -products = [ - # LibraryProduct akzeptiert eine Liste möglicher Namen (lib-Prefix optional auf Windows) - LibraryProduct(["libtypedb_driver_clib", "typedb_driver_clib"], :libtypedb_driver_clib), -] - -dependencies = Dependency[] - -build_tarballs(ARGS, name, version, sources, script, platforms, products, dependencies; - compilers = [:c, :rust], - julia_compat = "1.6") From f3f041119c2f085035896ca804fec29c8e2700cc Mon Sep 17 00:00:00 2001 From: Frank Urbach <33724682+FrankUrbach@users.noreply.github.com> Date: Sun, 1 Mar 2026 22:31:14 +0100 Subject: [PATCH 3/7] Add TypeDBDriverClib v3.8.1 (fix: correct dir name, rust_target, dont_dlopen) --- T/TypeDBDriverClib/build_tarballs.jl | 50 ++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 T/TypeDBDriverClib/build_tarballs.jl diff --git a/T/TypeDBDriverClib/build_tarballs.jl b/T/TypeDBDriverClib/build_tarballs.jl new file mode 100644 index 00000000000..3cbd8045363 --- /dev/null +++ b/T/TypeDBDriverClib/build_tarballs.jl @@ -0,0 +1,50 @@ +using BinaryBuilder, Pkg + +name = "TypeDBDriverClib" # BinaryBuilder appends _jll → TypeDBDriverClib_jll +version = v"3.8.1" + +sources = [ + GitSource( + "https://github.com/typedb/typedb-driver.git", + "8e8d4a43da32adc1c56084f4d34174bebd0ce34a", # tag 3.8.1 + ), +] + +script = raw""" +cd ${WORKSPACE}/srcdir/typedb-driver + +# Build the C FFI crate from the Cargo workspace. +# BinaryBuilder sets `rust_target` for cross-compilation. +cargo build --release -p typedb_driver_clib + +mkdir -p "${libdir}" + +if [[ "${target}" == *-w64-mingw* ]]; then + # Windows: Rust omits the lib prefix + install -Dvm 755 "target/${rust_target}/release/typedb_driver_clib.dll" \ + "${libdir}/typedb_driver_clib.dll" +else + install -Dvm 755 "target/${rust_target}/release/libtypedb_driver_clib.${dlext}" \ + "${libdir}/libtypedb_driver_clib.${dlext}" +fi +""" + +platforms = [ + Platform("x86_64", "linux"; libc="glibc"), + Platform("aarch64", "linux"; libc="glibc"), + Platform("x86_64", "macos"), + Platform("aarch64", "macos"), + Platform("x86_64", "windows"), +] + +products = [ + LibraryProduct(["libtypedb_driver_clib", "typedb_driver_clib"], :libtypedb_driver_clib), +] + +dependencies = Dependency[] + +build_tarballs(ARGS, name, version, sources, script, platforms, products, dependencies; + compilers = [:c, :rust], + julia_compat = "1.6", + preferred_gcc_version = v"5", + dont_dlopen = true) From e89ffe158b8570fa7727c270f1de81742ef16523 Mon Sep 17 00:00:00 2001 From: Frank Urbach <33724682+FrankUrbach@users.noreply.github.com> Date: Sun, 1 Mar 2026 23:27:20 +0100 Subject: [PATCH 4/7] Fix: use cargo rustc --crate-type=cdylib to produce shared library c/Cargo.toml in typedb-driver does not declare crate-type = ["cdylib"], so plain `cargo build` only produces an rlib. Using `cargo rustc -- --crate-type=cdylib` forces output of a proper C-ABI shared library (.dylib/.so/.dll). --- T/TypeDBDriverClib/build_tarballs.jl | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/T/TypeDBDriverClib/build_tarballs.jl b/T/TypeDBDriverClib/build_tarballs.jl index 3cbd8045363..10ac3556e6d 100644 --- a/T/TypeDBDriverClib/build_tarballs.jl +++ b/T/TypeDBDriverClib/build_tarballs.jl @@ -13,9 +13,10 @@ sources = [ script = raw""" cd ${WORKSPACE}/srcdir/typedb-driver -# Build the C FFI crate from the Cargo workspace. -# BinaryBuilder sets `rust_target` for cross-compilation. -cargo build --release -p typedb_driver_clib +# Build the C FFI crate as a cdylib (shared library). +# c/Cargo.toml does not declare crate-type = ["cdylib"], so we pass it +# explicitly via `cargo rustc`. BinaryBuilder sets `rust_target`. +cargo rustc --release -p typedb_driver_clib -- --crate-type=cdylib mkdir -p "${libdir}" From d265527a94783b39cf794ba3bb9d7ab6a29ead1e Mon Sep 17 00:00:00 2001 From: Frank Urbach <33724682+FrankUrbach@users.noreply.github.com> Date: Sun, 1 Mar 2026 23:40:05 +0100 Subject: [PATCH 5/7] Fix: cargo rustc --lib --crate-type=cdylib (no -- separator) --crate-type must be passed as a cargo-level flag, not after -- (which would pass it to rustc directly). Also add --lib to explicitly select the library compilation unit, matching the known-working iceberg_rust_ffi pattern. --- T/TypeDBDriverClib/build_tarballs.jl | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/T/TypeDBDriverClib/build_tarballs.jl b/T/TypeDBDriverClib/build_tarballs.jl index 10ac3556e6d..d06f9be7784 100644 --- a/T/TypeDBDriverClib/build_tarballs.jl +++ b/T/TypeDBDriverClib/build_tarballs.jl @@ -14,9 +14,10 @@ script = raw""" cd ${WORKSPACE}/srcdir/typedb-driver # Build the C FFI crate as a cdylib (shared library). -# c/Cargo.toml does not declare crate-type = ["cdylib"], so we pass it -# explicitly via `cargo rustc`. BinaryBuilder sets `rust_target`. -cargo rustc --release -p typedb_driver_clib -- --crate-type=cdylib +# c/Cargo.toml does not declare crate-type = ["cdylib"], so we pass it as a +# cargo-level flag (not after --). --lib selects the library unit explicitly. +# BinaryBuilder sets `rust_target` for cross-compilation. +cargo rustc --release -p typedb_driver_clib --lib --crate-type=cdylib mkdir -p "${libdir}" From e261c9a3e9c841edd531997e8582af8ccf3ffa77 Mon Sep 17 00:00:00 2001 From: Frank Urbach <33724682+FrankUrbach@users.noreply.github.com> Date: Sun, 1 Mar 2026 23:44:55 +0100 Subject: [PATCH 6/7] Fix: patch c/Cargo.toml via sed to add crate-type = ["cdylib"] cargo rustc --crate-type flag requires cargo >=1.64 which may not be available in the sandbox. Use sed to patch c/Cargo.toml directly, then plain cargo build --release. This avoids any cargo version dependency. --- T/TypeDBDriverClib/build_tarballs.jl | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/T/TypeDBDriverClib/build_tarballs.jl b/T/TypeDBDriverClib/build_tarballs.jl index d06f9be7784..32aff63b2bc 100644 --- a/T/TypeDBDriverClib/build_tarballs.jl +++ b/T/TypeDBDriverClib/build_tarballs.jl @@ -13,11 +13,13 @@ sources = [ script = raw""" cd ${WORKSPACE}/srcdir/typedb-driver -# Build the C FFI crate as a cdylib (shared library). -# c/Cargo.toml does not declare crate-type = ["cdylib"], so we pass it as a -# cargo-level flag (not after --). --lib selects the library unit explicitly. +# c/Cargo.toml (auto-generated by TypeDB's Bazel sync tool) does not declare +# crate-type = ["cdylib"]. Patch it in-place so that `cargo build` produces +# a C-ABI shared library (.dylib/.so/.dll). +sed -i 's/path = "src\/lib.rs"/path = "src\/lib.rs"\ncrate-type = ["cdylib"]/' c/Cargo.toml + # BinaryBuilder sets `rust_target` for cross-compilation. -cargo rustc --release -p typedb_driver_clib --lib --crate-type=cdylib +cargo build --release -p typedb_driver_clib mkdir -p "${libdir}" From fdc7090f7a6f8feb83f23034847f4ebd153d02a6 Mon Sep 17 00:00:00 2001 From: Frank Urbach <33724682+FrankUrbach@users.noreply.github.com> Date: Sun, 1 Mar 2026 23:56:32 +0100 Subject: [PATCH 7/7] Fix: add HostBuildDependency("protoc_jll") + export PROTOC Root cause: typedb-protocol (git dep of typedb-driver) has a build.rs that calls tonic_build::compile_protos(), which invokes `protoc` to generate Rust gRPC stubs from .proto files. Without protoc in PATH the build fails immediately. Also set PROTOC env var explicitly for prost-build to find it. --- T/TypeDBDriverClib/build_tarballs.jl | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/T/TypeDBDriverClib/build_tarballs.jl b/T/TypeDBDriverClib/build_tarballs.jl index 32aff63b2bc..17dec990855 100644 --- a/T/TypeDBDriverClib/build_tarballs.jl +++ b/T/TypeDBDriverClib/build_tarballs.jl @@ -18,6 +18,10 @@ cd ${WORKSPACE}/srcdir/typedb-driver # a C-ABI shared library (.dylib/.so/.dll). sed -i 's/path = "src\/lib.rs"/path = "src\/lib.rs"\ncrate-type = ["cdylib"]/' c/Cargo.toml +# typedb-protocol (a git dependency) has a build.rs that calls tonic_build +# which invokes protoc. Make the host protoc binary visible to prost-build. +export PROTOC=$(which protoc) + # BinaryBuilder sets `rust_target` for cross-compilation. cargo build --release -p typedb_driver_clib @@ -45,7 +49,11 @@ products = [ LibraryProduct(["libtypedb_driver_clib", "typedb_driver_clib"], :libtypedb_driver_clib), ] -dependencies = Dependency[] +dependencies = [ + # typedb-protocol/grpc/rust/build.rs calls tonic_build::compile_protos(), + # which invokes `protoc` at build time to generate Rust gRPC stubs. + HostBuildDependency("protoc_jll"), +] build_tarballs(ARGS, name, version, sources, script, platforms, products, dependencies; compilers = [:c, :rust],