Fingerprint of dependency in workspace changes when running cargo build
and cargo build -p <crate>
· Issue #12345 · rust-lang/cargo (original) (raw)
Problem
Context: I have a project that is a workspace that contains multiple library crates that are outputting cdylib types.
Bug/Expectation: When I build in the root of the workspace, I would expect running cargo build -p <crate>
to be a noop as the workspace cargo build
should have built all of it. If running cargo build -p <crate>
outputs to a different cache, then I would expect that the cargo build
and cargo build -p
to not affect each other at all. Instead, whenever I build cargo build
, it invalidates the individual cargo build of the crate's dependencies and forces a rebuild...
Steps
https://github.com/Kevin-Reactor/Fingerprint-Repro
Here is a public repo of a minimal reproduction of the issue.
Step 1: Download the repo
Step 2: run cargo build
in the root directory
Step 3: run cargo build -p test_2
Step 4: Alternate between running cargo build
and CARGO_LOG=cargo::core::compiler::fingerprint=info cargo build -p test_2
and you can see it complain that the fingerprint for serde_yaml
has changed
Possible Solution(s)
No response
Notes
I have tested a few configurations, this only seems to happen when the libraries output cdylib
, and only happens when there are two crates (i.e. a workspace with only one crate doesn't have this issue)
It also seems to happen with specific crates. quiche
and serde_yaml
specifically but I have no idea why.
I know that there's an issue with the features of the crates potentially being different between building in root and building with -p, but it makes no sense that this configuration doesn't require rebuilds with lib
instead of cdylib
and that they don't have any shared features...
Version
cargo 1.70.0 (ec8a8a0ca 2023-04-25)
release: 1.70.0
commit-hash: ec8a8a0cabb0e0cadef58902470f6c7ee7868bdc
commit-date: 2023-04-25
host: x86_64-unknown-linux-gnu
libgit2: 1.6.3 (sys:0.17.0 vendored)
libcurl: 8.0.1-DEV (sys:0.4.61+curl-8.0.1 vendored ssl:OpenSSL/1.1.1t)
os: Ubuntu 22.04 (jammy) [64-bit]