-
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
Incorrect dependency feature set used for same-target bindep dependency compilation #11463
Labels
C-bug
Category: bug
Comments
musl
compilation target with a bindep
Thank you for the report and the reproducer! I believe it is more or less the same as #10837. The possible root cause was described in #10837 (comment). Closing as it is a duplicate. If this is wrong for you, we can consider re-open it. |
rvolosatovs
added a commit
to rvolosatovs/cargo
that referenced
this issue
Dec 13, 2022
This is a unit test reproducing the bindep transitive dependency bug based upon example from rust-lang#11463 Signed-off-by: Roman Volosatovs <rvolosatovs@riseup.net>
rvolosatovs
added a commit
to rvolosatovs/cargo
that referenced
this issue
Dec 14, 2022
This is a unit test reproducing the bindep transitive dependency bug based upon examples from - rust-lang#10837 - rust-lang#11463 Signed-off-by: Roman Volosatovs <rvolosatovs@riseup.net>
rvolosatovs
added a commit
to rvolosatovs/cargo
that referenced
this issue
Dec 16, 2022
This is a unit test reproducing the bindep transitive dependency bug based upon examples from - rust-lang#10837 - rust-lang#11463 Signed-off-by: Roman Volosatovs <rvolosatovs@riseup.net>
rvolosatovs
added a commit
to rvolosatovs/cargo
that referenced
this issue
Dec 19, 2022
This is a unit test reproducing the bindep transitive dependency bug based upon examples from - rust-lang#10837 - rust-lang#11463 Signed-off-by: Roman Volosatovs <rvolosatovs@riseup.net>
rvolosatovs
added a commit
to rvolosatovs/cargo
that referenced
this issue
Dec 22, 2022
This is a unit test reproducing the bindep transitive dependency bug based upon examples from - rust-lang#10837 - rust-lang#11463 Signed-off-by: Roman Volosatovs <rvolosatovs@riseup.net>
bors
added a commit
that referenced
this issue
Dec 23, 2022
fix: deduplicate dependencies by artifact target ### What does this PR try to resolve? In cases when a compile target is specified for a bindep and the crate depending on it, cargo fails to deduplicate the crate dependencies and attempts to build the dependent crate only once with non-deterministic feature set, which breaks e.g. https://github.com/rvolosatovs/musl-bindep-feature-bug Fix the issue by including the optional artifact compile target in the `Unit` in order to avoid wrongfully deduplicating the dependent crates Fixes #11463 Fixes #10837 Fixes #10525 Note, that this issue is already accounted for by `cargo`, but in different context a similar situation can occur while building the build script, which: 1. may be built for different target than the actual package target 2. may contain dependencies with different feature sets than the same dependencies in the dependency graph of the package itself That's why this PR is simply reusing the existing functionality for deduplication ### How should we test and review this PR? Build https://github.com/rvolosatovs/musl-bindep-feature-bug ### Additional information This is based on analysis by `@weihanglo` in #10837 (comment) I experimented with adding the whole `UnitFor` to the internal unit struct, but that seems unnecessary. It would probably be nicer to refactor `IsArtifact` and instead turn it into a 3-variant enum with a possible compile target, but I decided against that to minimize the diff. Perhaps it's worth a follow-up?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Full example available at https://github.com/rvolosatovs/musl-bindep-feature-bug
It appears that in presence of the same dependency specified multiple times with different feature sets within a workspace it is only compiled once when bindeps are used.
I tried this top-level
Cargo.toml
:With following subcrate
Cargo.toml
:I expected to see this happen: successful compilation with
cargo build --target x86_64-unknown-linux-musl
Instead, this happened:
Note, that the issue does not happen if compilation is done for the native triple.
This issue also does not occur if the subcrate is turned into a regular dependency, as opposed to a bindep.
Note, that build for
wasm32-wasi
would fail as well, but only ifbindep
target is changed towasm32-wasi
Meta
rustc --version --verbose
:With
RUST_BACKTRACE=1
output is identical to the log aboveThe text was updated successfully, but these errors were encountered: