Skip to content

Rust: keep dependencies that share a name with a workspace target - #2

Closed
rockwotj wants to merge 1 commit into
tensorlakeai:mainfrom
rockwotj:keep-dependencies-sharing-a-workspace-name
Closed

rockwotj wants to merge 1 commit into
tensorlakeai:mainfrom
rockwotj:keep-dependencies-sharing-a-workspace-name

Conversation

@rockwotj

Copy link
Copy Markdown

workspaceArtifacts() drops artifacts by name, using every package and target name from cargo metadata --no-deps. When a workspace target has the same name as a dependency, the dependency's artifacts are dropped too.

In our repository, app/jobserver declares [lib] name = "jobserver", which is also the name of the crates.io jobserver crate that cc depends on. The saved archive left out libjobserver-<hash>.rlib and .fingerprint/jobserver-<hash>, so every warm run rebuilt jobserver, then cc, then every crate that uses cc in a build script (aws-lc-sys, zstd-sys, lz4-sys, libmimalloc-sys, ...) and everything downstream of those: 57 crates instead of the 3 workspace crates.

This change reads the registry and git packages from each root's Cargo.lock and removes their names from the set that is stripped. Workspace artifacts that share such a name are then kept in the archive. They rebuild anyway, so the only cost is archive size.

Measured on tensorlake-large with the same Rust workspace (cargo fmt, clippy, test), warm runs:

Crates compiled clippy + test
v1 57 80–92 s
this branch 3 20–25 s

npm test includes a new case with a workspace lib named jobserver and a Cargo.lock that lists the registry crate. It fails on main and passes here.

@rockwotj rockwotj closed this Sep 24, 2026
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