Repository navigation
ci: fix Rust caching and follow rust-toolchain.toml - #207
Merged
Merged
Conversation
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.
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.
/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.
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.
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.
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.
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.
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.
This was referenced Nov 26, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Advances #195 (caching) and #197. Two partials are called out below.
Caching (#195)
CMakeLists.txtresolves the Cargo target directory once intoLANCEDB_CARGO_TARGET_DIR(default unchanged:<build>/target). A relative value is resolved against the build directory, so Cargo, Ninja, the install rules and the exported package all name one absolute path. CI points it at$GITHUB_WORKSPACE/target, the directory the rust cache action restores by default;cargo clippyalready used the repository-root target, so the cache covers the lint step too. On Windows hosts the resolved value is also converted to CMake slash form, becausecmake_install.cmakereads a nativeD:\a\...path as an escape sequence and installs the wrong file or fails.buildmatrix leg gets its own cache key. Previously thestaticleg saved a cache under the shared job key and the latersharedleg found it up to date and skipped saving, socargo clippy --all-targetsrecompiled on every run.build_almalinuxnow caches the container workspace target under its own key: the container mounts the checkout at/__w/...whilegithub.workspaceis the host path, so the build previously wrote a directory the cache never saw, and the old full-match entry would otherwise make the action skip saving the corrected tree.mozilla/cbindgenrelease at the exact version already required by.github/scripts/check_abi.py, with the asset checksum verified, instead of compiling it from source on every cold run.external-provider-libnow passes the sameLANCEDB_BUILD_VERSIONasrust-lib, so an environment change no longer reruns the lancedb-c build script.Redundant rebuilds: what is and is not fixed
An earlier revision shared one Cargo unit between
rust-libandexternal-provider-libby selecting the export wrapper through Cargo's target linker configuration. Review found two problems, so it was reverted:CARGO_TARGET_<triple>_LINKER). The final-target wrapper preserves it:build.rsforwardsRUSTC_LINKERand the wrapper uses it.liblancedb.so. With the final-target wrapper the provider never uplifts the library, and the rust-lib command owns it in both invocation orders.Remaining:
ninjaplusninja check-installstill compiles lancedb-c three times (rust-lib, provider, check-install's rust-lib) because the two commands produce different Cargo units. Making it once needs either a structural split of the provider's type dependency or a global linker takeover; both are outside this change. The rebuilds no longer repeat for environment or version changes, and the cached target directory keeps the dependency crates from recompiling.Rust toolchain setup (#197)
Every rustup-based CI and packaging job runs
rustup toolchain install, taking channel, profile and components (rustfmt,clippy) fromrust-toolchain.toml. The cross job adds its Windows target and the packaging jobs add their matrix target withrustup target add. No workflow hardcodes a Rust version or@stable.CARGO_INCREMENTAL: 0is set at the workflow level to preserve what the removed action exported.The mechanism proposed in #197 (
dtolnay/rust-toolchain@masterwithout the toolchain input) does not work: the action requires that input and exits before rustup runs. #197 stays partial pending the #198 compatibility-matrix decision.AlmaLinux conflict
build_almalinuxkeeps the AlmaLinux system Rust to preserve distro-provided toolchain coverage from #109; #197's "every job compiles with the pinned Rust" criterion is intentionally not met for this job. Retiring that coverage is a direction decision, not made here.Validation
rust-libproduces the SONAME and export-filtered library; a provider-first build uplifts no library and the following rust-lib build produces the correct artifact. Rebuild counts on a fresh target are 1/1/1 for rust-lib/provider/rust-lib.packages.ymlandpackage.py) is unchanged by this workflow-only AlmaLinux fix, so the earlier five-platform build-only evidence remains valid and no new package dispatch is needed.