-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Non-deterministic builds with new resolver #8549
Comments
Thanks for the detailed report! I see what is wrong, it is being over-eager to unify transitive dependencies ( I'll try to fix this soonish, but it might take a while. In the meantime, you should be able to use the |
Wonderful, thank you!
This works great, thank you! |
@ehuss I've been encountering more situations where this is occurring, even with the I have a situation that's possibly similar to #8563: There's a crate ( This seems to create a "fork" in the dependency tree when building with dev-deps (e.g. for testing): The issue seems to cause this same "cache jumping" so-to-speak, where the resolver incorrectly thinks that it found the crate it was looking for already in the cache, but in reality, there should have been separation between these 2 dependency trees. An alternative explaination is not that the 2 dependency trees should have been separated, but that a given dependency, in the context of the cache, should reflect the total cargo feature unification that is occurring deeper in the dependency tree of that crate, not just the features that the crate in question has enabled. In the original example in this bug report, the issue was side-stepped by specifying However, in the circular dev-dependency situation, (Edit: disclaimer: this is my best guess for what is going on, but not necessarily what is actually going on) |
@kylefleming Do you think you can put together a reproduction with the circular dev-dependency similar to the original one you made? It was very useful, and I'm uncertain if your situation is much different from #8563. |
@ehuss I noticed that this issue was auto-closed. Would you still like a reproduction? Alternatively, I can just report back whether the fix fixes the issue for my project. |
Yea, if you can put together a repro with a circular dev-dependency, that would be helpful. I'm uncertain if the fix will address what you ran into, but I'd have a bit more confidence if I could try it out. Thanks! (BTW, it takes at least a few days for changes to land in nightly. If I remember, I'll try to ping this issue to let you know when it is available.) |
I'm not sure I'm going to be able to create a reproduction. I can't seem to get it to occur it in a demo environment. It occurred to me however that the project is open source. I fully expect you probably won't want to go down this route, but I'll post it here anyways. Here's an example of a commit where it happens intermittently. I'm not 100% positive that the issue is directly caused by the circular dependency, but I am positive that cargo is building and unifying features non-deterministically, despite using
|
Problem
When using the new resolver, I'm encountering a bug where cargo seems to be unifying features inconsistently when a feature is enable on a build-dependency that is also the dependency of another dependency, when building with multiple roots (e.g.
cargo build --bin bin1 --bin bin2
).It's a bit hard to narrow down the exact circumstances under which this seems to be occurring since the configuration is somewhat complex, however, I've noticed it in several other configurations, not just the one below.
The essentials seem to be:
bin1
bin2
dep
dep
, is in the same configuration when declared as crate A's dependency as it is when declared as crate B's build-dependencydep
, declares another dependenncy,subdep
subdep
, is configured differently between crate A's dependency tree and crate B's build-dependency tree (in the example below, crate B's build-dependency declaration enablessubdep
'sfeat
feature)cargo build
invocation, crate B's build-dependency ondep
is built against a build ofsubdep
that is sometimes compiled in the configuration of crate A's dependency tree and sometimes compiled in the configuration of crate B's build-dependency tree.Note: In this explanation of what's going on, I'm making the assumption that
-Zfeatures=host_dep
is intended to completely separate the feature unification ofbuild-dependencies
from normal dependencies. However, even if this assumption is incorrect, there is still a bug related to build determinism, since no matter the intended behavior of feature unification, I'm assuming cargo is not meant to unify features arbitrarily between successive invocations.Steps
The following script illustrates the issue:
Sample output (the relevant parts only):
Notes
The text was updated successfully, but these errors were encountered: