Skip to content

Commit

Permalink
A cry for help with a fix for the issue that looks like a hack.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Byron committed Mar 1, 2022
1 parent 14ddbf3 commit 0bede73
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
12 changes: 11 additions & 1 deletion src/cargo/core/resolver/features.rs
Original file line number Diff line number Diff line change
Expand Up @@ -857,7 +857,7 @@ impl<'a, 'cfg> FeatureResolver<'a, 'cfg> {
)
});

let dep_fks = match artifact_target_keys {
let mut dep_fks = match artifact_target_keys {
// The artifact is also a library and does specify custom
// targets.
// The library's feature key needs to be used alongside
Expand All @@ -873,6 +873,16 @@ impl<'a, 'cfg> FeatureResolver<'a, 'cfg> {
// Use the standard feature key without any alteration.
Some((_, None)) | None => vec![lib_fk],
};

// This is more of a hack to fix a particular issue with platform-gated
// dependencies' build scripts, which unfortunately we can't determine
// here any better than checking for a platform and blindly adding the
// feature key that it will later query.
// If it matters, the dependency that actually should add this key
// drops out in line 798.
if dep.platform().is_some() {
dep_fks.push(FeaturesFor::NormalOrDevOrArtifactTarget(None));
}
dep_fks.into_iter().map(move |dep_fk| (dep, dep_fk))
})
.collect::<Vec<_>>();
Expand Down
1 change: 0 additions & 1 deletion tests/testsuite/artifact_dep.rs
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,6 @@ fn features_are_not_unified_among_lib_and_bin_dep_of_different_target() {
}

#[cargo_test]
#[ignore]
fn feature_resolution_works_for_cfg_target_specification() {
if cross_compile::disabled() {
return;
Expand Down

0 comments on commit 0bede73

Please sign in to comment.