Skip to content

build: consolidate Cargo workspace and pin Rust toolchain - #109

Merged
Xuanwo merged 11 commits into
mainfrom
xuanwo/consolidate-cargo-workspace
Nov 22, 2026
Merged

Xuanwo merged 11 commits into
mainfrom
xuanwo/consolidate-cargo-workspace

Conversation

@Xuanwo

@Xuanwo Xuanwo commented Nov 21, 2026 •

Copy link
Copy Markdown
Member

Why

The root crate and examples/object_store_provider kept separate lockfiles and toolchain assumptions, so every SDK upgrade had to update two dependency graphs in lockstep. The release profile was also implicit, which left debug-info stripping and panic behavior up to Cargo defaults.

What changes

  • Add a root Cargo workspace containing the C crate and the provider example, with the root crate as the default member. Cargo.lock is now the only lockfile; the example lockfile is removed.
  • Add rust-toolchain.toml pinned to Rust 1.95.0, matching rust-version in Cargo.toml.
  • Make [profile.release] explicit: opt-level = 3, strip = "debuginfo", and panic = "unwind". Unwinding stays enabled for the FFI boundary. Function symbols stay available for the existing Valgrind suppressions while debug sections are removed.
  • Run CMake's configuration-time rustc probes (host tuple, sysroot, version, and native static libraries) from the source tree, so an out-of-tree build selects the repository's pinned toolchain and its LLVM tools.
  • Select packages explicitly in CMake and the packaging workflow (lancedb-c and lancedb-object_store-provider) so workspace-wide commands keep building and packaging the intended crate. Both CMake builds still share the CMake target directory.
  • Install the pinned toolchain in rustup-based CI, including x86_64-pc-windows-gnu for the cross job and each matrix target for packaging. The AlmaLinux job keeps its system Rust to preserve distro toolchain coverage.
  • When a merge-base coverage baseline was measured with a different toolchain, rebuild that commit with the pull request's pinned toolchain and compare against the measured baseline. When the pin matches, keep the existing baseline path, including its missing-artifact behavior.
  • On a Release test failure, print CTest details and upload the Valgrind logs for both Ubuntu library variants.
  • Match the inlined Lance Blob v2 schema LazyLock construction in Valgrind, since Rust 1.95 no longer keeps the BLOB_V2_DESC frame. The new patterns keep possible-only classification and the observed frames adjacent.

The pinned LanceDB v0.42.0-beta.21 and Lance v15.0.0-beta.25 revisions, C binding version 0.0.0, default features, and the example's provider behavior are unchanged. Current main's #87 IPC/lock changes and #107 CI changes are integrated; the root lock keeps the direct arrow-ipc edge, and the example has no separate lock.

Validation

  • cargo metadata --locked, cargo fmt --check, and cargo check -p lancedb-c --locked on the pinned 1.95.0 toolchain after merging current main (94e84c2).
  • Out-of-tree CMake configuration from the build directory: the rustc probes select Rust 1.95.0, and the coverage build resolves llvm-profdata/llvm-cov from that toolchain rather than the caller's default. The static-library native probe also succeeds.
  • CMake configuration with -DBUILD_EXAMPLES=ON; the generated commands use the shared target directory and explicit packages.
  • .github/scripts/test_package.py: 22/22 fixture tests pass.
  • A pinned-1.95.0 coverage reference at 88168d1 measured 3309/3601 = 91.89%, identical to build: consolidate Cargo workspace and pin Rust toolchain #109. The old 1.100.0 baseline for that commit measured 3219/3502 = 91.92%, so the apparent drop came from toolchain line mapping, not product code.
  • The narrowed Valgrind patterns match all eight preserved raw stacks and reject field-name-clone and inserted-frame counterexamples.

Native release builds, Release Valgrind, CTest, packaging, and the cross-target jobs are left to hosted CI.

Closes #98

Move the ObjectStore provider example into the root Cargo workspace and
remove its separate lockfile so both crates share one locked dependency
graph. Pin Rust 1.95.0 in rust-toolchain.toml and make the release
profile explicit while keeping panic unwinding for the FFI boundary.

Select the C library package explicitly in CMake and packaging, and
install the pinned toolchain with its cross targets in CI.
Use strip=debuginfo so Release builds keep the function symbols that the
existing Valgrind suppressions match. Run CMake's configuration-time
rustc probes from the source tree so out-of-tree builds select the
repository toolchain and its LLVM tools, matching the Cargo working
directory.
When the merge-base baseline was measured with a different toolchain,
rebuild that commit with the pull request's pinned toolchain and compare
against that measured baseline instead of the stale artifact.

Show CTest failures and Valgrind logs when the Release test step fails,
and upload the same diagnostics for both Ubuntu matrix jobs.
A missing baseline artifact can be an upload race, not a toolchain
mismatch. Compare rust-toolchain.toml with the merge base and keep the
normal comparison path when it matches, including its existing
skip-on-missing behavior. Rebuild the merge base only for a real pin
transition.
Rust 1.95 inlines the Lance Blob v2 LazyLock closures into the generic
FnOnce frame, so the existing *BLOB_V2_DESC* suppression no longer
matches even without stripping. Match the two nested LazyLock frames, or
Field::try_from under one LazyLock, only when called from
FileReader::decode_schema. Keep the possible-only leak kind.
Match the observed mangled LazyLock sequence and the adjacent hashbrown
RawTable clone plus Field::try_from sequence. Keep only the allocator
wildcard and possible-only classification, so field-name clones and
allocations inserted between the Once frames no longer match.
…rgo-workspace

# Conflicts:
#	examples/external_provider/Cargo.lock
@Xuanwo
Xuanwo merged commit 1faebf0 into main Nov 22, 2026
10 checks passed
Xuanwo added a commit that referenced this pull request Nov 25, 2026
* build: reuse one lancedb-c Cargo unit and one target directory

The rust-lib edge passed the export wrapper and the SONAME through
`cargo rustc --` arguments. Those arguments change the unit profile, so
the external-provider build that pulls lancedb-c in as a dependency
rebuilt it with a plain profile, and the rust-lib run behind
check-install rebuilt it back. Select the wrapper through Cargo's target
linker configuration instead, which every invocation that compiles
lancedb-c presents identically, and hand the SONAME to the wrapper from
the rust-lib command environment so it reaches the lancedb cdylib alone.

The Cargo target directory moves into LANCEDB_CARGO_TARGET_DIR with the
same default, so a build can point Cargo at the directory CI caches.

* ci: repair Rust caching and install Rust from rust-toolchain.toml

Point CMake at the repository-root target directory that the cache action
restores, give each build matrix leg its own cache key, cache the
AlmaLinux job, and start a new cache generation because the linker
configuration is a Cargo fingerprint input the action's key cannot see.
Install cbindgen from the pinned official release asset instead of
compiling it on every cold run.

Every rustup-based CI and packaging job now installs its toolchain from
rust-toolchain.toml, so the pinned channel, profile and components come
from one file. The AlmaLinux job keeps the distro toolchain to preserve
the distro compatibility coverage from #109.

* ci: install the verified cbindgen binary with install(1)

/usr/local/bin belongs to root on the runner image, so the download is
verified in the workspace and only the checked file is copied with
privileges.

* build: resolve the Cargo target directory before use

LANCEDB_CARGO_TARGET_DIR could be typed as a relative path. CMake retyped
an untyped -D value against its invocation directory, Cargo passed the
string to --target-dir under the source directory, Ninja used it relative
to the build directory and the install rules resolved it against the
configure directory. All of them now use one absolute path resolved
against the build directory.

* build: keep the export wrapper on the final target only

Selecting the export wrapper through Cargo's target linker configuration
replaced a caller's configured linker for every unit and made the
provider and rust-lib commands share one Cargo unit whose SONAME identity
came from an environment variable the fingerprint ignores. Pass the
wrapper and SONAME as `cargo rustc --` arguments for the lancedb target
only: build.rs forwards the caller's configured linker through
RUSTC_LINKER, the provider never uplifts a library, and the rust-lib
command owns the artifact.

The provider keeps the CMake-resolved LANCEDB_BUILD_VERSION so its build
no longer reruns the lancedb-c build script for a changed environment.

* ci: drop the cache epoch for the reverted linker input

The build no longer selects a linker through Cargo's target
configuration, so the restored target directories keep valid
fingerprints and the cache keys do not need a new generation.

* build: use CMake paths for the Cargo target directory on Windows

CI passes ${{ github.workspace }}/target, which is a native Windows path
such as D:\a\lancedb-c\lancedb-c/target. CMake wrote that value into
cmake_install.cmake unchanged, where file(INSTALL ...) read the
backslash as an escape and either rejected the path or resolved a
different file.

Normalize the resolved target directory to CMake slash form on Windows
hosts. Other hosts keep their native characters, and the documented
relative resolution, spaces and cross-compile behavior are unchanged.

* ci: use the AlmaLinux container workspace for the Cargo target

The AlmaLinux job runs in a container where github.workspace is the host
path (/home/runner/work/...) while the checkout is mounted at /__w/....
CMake built into the host path while the Rust cache cleaned and saved
the container path, so this job never restored its target artifacts.

Use the step shell's GITHUB_WORKSPACE so CMake, Cargo and the cache name
the same container path. The previous full-match cache entry would
otherwise make the action skip saving the corrected target tree, so the
job gets its own cache key.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

build: unify root and example crates into a Cargo workspace with pinned toolchain

1 participant