Skip to content

Commit 0bede73

Browse files
committed
A cry for help with a fix for the issue that looks like a hack.
In order not to give up and create a basis for discussion while ending my 3h oddisey on finding a fix for today, I present something that seems to work even though I hope there are better ways to solve this.
1 parent 14ddbf3 commit 0bede73

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

src/cargo/core/resolver/features.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -857,7 +857,7 @@ impl<'a, 'cfg> FeatureResolver<'a, 'cfg> {
857857
)
858858
});
859859

860-
let dep_fks = match artifact_target_keys {
860+
let mut dep_fks = match artifact_target_keys {
861861
// The artifact is also a library and does specify custom
862862
// targets.
863863
// The library's feature key needs to be used alongside
@@ -873,6 +873,16 @@ impl<'a, 'cfg> FeatureResolver<'a, 'cfg> {
873873
// Use the standard feature key without any alteration.
874874
Some((_, None)) | None => vec![lib_fk],
875875
};
876+
877+
// This is more of a hack to fix a particular issue with platform-gated
878+
// dependencies' build scripts, which unfortunately we can't determine
879+
// here any better than checking for a platform and blindly adding the
880+
// feature key that it will later query.
881+
// If it matters, the dependency that actually should add this key
882+
// drops out in line 798.
883+
if dep.platform().is_some() {
884+
dep_fks.push(FeaturesFor::NormalOrDevOrArtifactTarget(None));
885+
}
876886
dep_fks.into_iter().map(move |dep_fk| (dep, dep_fk))
877887
})
878888
.collect::<Vec<_>>();

tests/testsuite/artifact_dep.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,6 @@ fn features_are_not_unified_among_lib_and_bin_dep_of_different_target() {
426426
}
427427

428428
#[cargo_test]
429-
#[ignore]
430429
fn feature_resolution_works_for_cfg_target_specification() {
431430
if cross_compile::disabled() {
432431
return;

0 commit comments

Comments
 (0)