-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fingerprint of dependency in workspace changes when running cargo build
and cargo build -p <crate>
#12345
Comments
Can you check whether this is being affected by cargo activating different sets of features based on what packages are selected? See #5210 as an example of the different issues we have on the topic. |
In your case
That led to a feature unification when running This is at this moment a expected behavior. And feel like this may be a duplicate of #4463. Going to close this. If I am closing it wrong, please let us know. |
Hi, appreciate the quick response! Just for my own understanding, why does the feature unification not happen when the libraries output |
I am also a bit confused as it seems like in the thread linked, |
Just verified it again. I believe it happens with and without The only difference is that, when your final artifact is
Not only
|
I'd say the current fingerpint log is not really a thing a normal user ought to understand. There are rooms making the recompile reason more friendly 😆.
I am not aware of any, and people usually want the opposite behaivor — not unify at all. I would suggest |
Hi, @weihanglo , thanks for the quick reply! I work with @Kevin-Reactor and I wanted to chime in as well. So, I understand that the feature unification leads to different sets of features depending on which leaf package is being built. I agree that is definitely working as intended. To me, the problem here is that cargo's dependency cache seems to be (from an user's perspective) almost always append only except than in obscure cases such as this one. In this case instead, Plus, this behavior does slow down our iteration speed by quite a lot (we have a fairly big workspace in a monorepo) so whether it's technically correct or not, it would just be nice if it didn't work this way. tl;dr: me and Kevin both though that cargo's dependency cache was immutable and append only but it's not when it comes to features, which is very confusing if you aren't familiar with cargo's resolver internals. |
Sure. I can reopen this if we want to figure out what's going on. I had a hard time reproducing what you've talked about — serde continues recompiling. To me, this went like this:
Is there something I missed or reproduced it wrong? |
They are supposed to be cached separately with different hash suffixes. See https://doc.rust-lang.org/nightly/nightly-rustc/cargo/core/compiler/fingerprint/index.html#fingerprints-and-metadata. If you run If you can't find something mentioned above, that is probably a real bug. |
if it is being separated on the cache, why is anything even being rebuilt? here is how tommaso and I would expect it to go:
we do correctly see the correct amount of .d and .rlib and the four serde directories, but if that was working as intended, why are there any recompiles at all? |
I see. Thanks for the prompt response! So we are on the same page that there is no From #12345 (comment):
I guess I've already talked about it but in a less obvious way. That's my fault. It basically means that you have the only Sorry for my bad communication skill. |
I don't really know about the workflow you have. If you are going to copy dylib to somewhere outside Cargo project, this tip might help if applicable: remove |
ok, i guess that makes sense considering the cdylib bug. Is there work being done to output the dylib to a different directory? I assume that its not quite that simple though haha Either way, thank you so much for your help, it was very much appreciated. We'll end up probably emitting the cdylib only when its needed, and remove it from the Cargo.toml for now. |
There is an Personally I feel like the solution in the code comment might be doable but not easy:
See #5045 for more on I'ved linked to this issue from the meta tracking issue of duplicate artifact. Going to close this in favor of that. Thank you all for the discussion! |
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 workspacecargo build
should have built all of it. If runningcargo build -p <crate>
outputs to a different cache, then I would expect that thecargo build
andcargo build -p
to not affect each other at all. Instead, whenever I buildcargo 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 directoryStep 3: run
cargo build -p test_2
Step 4: Alternate between running
cargo build
andCARGO_LOG=cargo::core::compiler::fingerprint=info cargo build -p test_2
and you can see it complain that the fingerprint forserde_yaml
has changedPossible 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
andserde_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 ofcdylib
and that they don't have any shared features...Version
The text was updated successfully, but these errors were encountered: