Skip to content

Rust: keep dependencies' build scripts in the target archive - #1

Merged
calavera merged 1 commit into
mainfrom
fix-rust-build-script-cache
Sep 25, 2026
Merged

calavera merged 1 commit into
mainfrom
fix-rust-build-script-cache

Conversation

@calavera

Copy link
Copy Markdown
Contributor

A warm cargo-lambda job (https://github.com/cargo-lambda/cargo-lambda/actions/runs/36042572512) restored 4.5 GiB from main but still compiled 381 of 577 crates, starting with proc-macro2, libc and serde_core.

cargo-lambda has a build.rs, so workspaceArtifacts added the build-script-build target name to its skip pattern. That name is shared by every build script, so the pattern also dropped each dependency's compiled script under target/debug/build/<dep>-<hash>/build_script_build-<hash>. On restore, cargo reported FailedToReadMetadata for those scripts and rebuilt every dependency with a build script plus all of its dependents.

  • Build-script targets are left out of the pattern. The package name already covers the workspace's own build/<crate>-<hash>/ directories.
  • The Rust key gains archive-revision: 2. Without it the key is unchanged, so existing entries would be restored and never re-saved. The first run after this restores the old entry, rebuilds once and saves; later runs are warm.
  • The workspace-artifacts test now includes a build.rs and checks that a dependency's build script is kept. It fails without the fix.

Reproduced locally with CARGO_LOG=cargo::core::compiler::fingerprint=info; with the fix only the workspace crate's own files are dropped. npm test passes (22/22).

A workspace crate with a build.rs added the build-script-build target
name to the skip pattern, which also matched every dependency's
compiled build script under target/debug/build/<dep>-<hash>/. Cargo
then rebuilt each dependency with a build script and all of its
dependents on every warm run.

Build-script targets are no longer part of the pattern; the package
name already covers the workspace's own build directories. The Rust
key gains an archive revision so entries saved without the scripts are
replaced instead of kept as unchanged.
@calavera
calavera merged commit e36ba24 into main Sep 25, 2026
1 check passed
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.

1 participant