-
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
bindeps: wrong features in a build script for a shared dependency #10452
Comments
That's interesting, wouldn't this mean that the unit-dependencies are built correctly (as After applying this patch… diff --git a/tests/testsuite/artifact_dep.rs b/tests/testsuite/artifact_dep.rs
index 12090a245..aa67e085e 100644
--- a/tests/testsuite/artifact_dep.rs
+++ b/tests/testsuite/artifact_dep.rs
@@ -2245,6 +2245,8 @@ fn build_script_features_for_shared_dependency() {
&r#"
use std::env::var_os;
fn main() {
+ assert_eq!(var_os("CARGO_FEATURE_F1").is_some(), cfg!(feature="f1"));
+ assert_eq!(var_os("CARGO_FEATURE_F2").is_some(), cfg!(feature="f2"));
if std::env::var("TARGET").unwrap() == "$TARGET" {
assert!(var_os("CARGO_FEATURE_F1").is_none());
assert!(var_os("CARGO_FEATURE_F2").is_some());
@@ -2252,15 +2254,13 @@ fn build_script_features_for_shared_dependency() {
assert!(var_os("CARGO_FEATURE_F1").is_some());
assert!(var_os("CARGO_FEATURE_F2").is_none());
}
- assert_eq!(var_os("CARGO_FEATURE_F1").is_some(), cfg!(feature="f1"));
- assert_eq!(var_os("CARGO_FEATURE_F2").is_some(), cfg!(feature="f2"));
}
"#
.replace("$TARGET", target),
)
.build();
- p.cargo("build -Z bindeps")
+ p.cargo("build -Z bindeps -v")
.masquerade_as_nightly_cargo()
.run();
} …and running I get this output:
What I see from the above is that
That doesn't make much sense to me as if the unit dependencies are configured correctly, they would be built and invoked correctly. Maybe the issue is indeed caused by the way features are resolved, there is a bunch of special cases about placing features into a different key so later queries will succeed, those features might be wrong. |
Fix panic when artifact target is used for `[target.'cfg(<target>)'.dependencies` With an artifact dependency like this in package `a`… ```toml [dependencies.a] path = "b" artifact = "bin" target = "$TARGET" ``` …and when using `$TARGET` like this in another package `b`… ```toml [target.'cfg(target_arch = "$ARCHOF_$TARGET")'.dependencies] c = { path = "../c" } ``` …it panics with `thread 'main' panicked at 'activated_features for invalid package: features did not find PackageId <dbg-info>`, but we would expect this to work normally. ### Tasks - [x] reproduce issue in new test - [x] figure out why the test is fixed but the real-world example isn't - [x] find a fix Fixes #10431 and #10452.
With
-Zbindeps
, if there is a dependency that is used as a binary artifact, and also as a normal dependency, the build script for that shared dependency is receiving the wrong features.In the following example,
common
gets built twice, once as the target bindep with feature f2, and once as a normal dependency with feature f1. However, the build script only hasCARGO_FEATURE_F1
set in both cases.cc @Byron
The text was updated successfully, but these errors were encountered: