Problem
If on one platform a crate enables a feature which enables a transitive dependency, and on another it doesn't, there's no way to capture this from the output of cargo metadata.
Steps
- In this repo run
cargo metadata or cargo metadata --filter-platform=x86_64-unknown-linux-gnu. In this crate, serde's derive feature is enabled for x86_64-apple-darwin but not for x86_64-unknown-linux-gnu, which means it depends on serde-derive on x86_64-apple-darwin but not on x86_64-unknown-linux-gnu.
- Try to work out whether
serde-derive should be built on x86_64-unknown-linux-gnu.
- Find that there's not enough information to determine this.
Possible Solution(s)
- We could populate
DepKindInfo.target for these dependencies, such that they can be identified as platform-specific
- When running with
--filter-platform for a non-matching platform, we could omit these dependencies. That may require callers to run cargo metadata multiple times and splice the results, which would be a bit unfortunate.
Notes
Output of cargo version: cargo 1.54.0 (5ae8d74b3 2021-06-22), also cargo 1.56.0-nightly (f559c109c 2021-08-26)
This issue makes it hard to translate crates.io packages for building with non-cargo build systems.
Problem
If on one platform a crate enables a feature which enables a transitive dependency, and on another it doesn't, there's no way to capture this from the output of
cargo metadata.Steps
cargo metadataorcargo metadata --filter-platform=x86_64-unknown-linux-gnu. In this crate,serde'sderivefeature is enabled forx86_64-apple-darwinbut not forx86_64-unknown-linux-gnu, which means it depends onserde-deriveonx86_64-apple-darwinbut not onx86_64-unknown-linux-gnu.serde-deriveshould be built onx86_64-unknown-linux-gnu.Possible Solution(s)
DepKindInfo.targetfor these dependencies, such that they can be identified as platform-specific--filter-platformfor a non-matching platform, we could omit these dependencies. That may require callers to runcargo metadatamultiple times and splice the results, which would be a bit unfortunate.Notes
Output of
cargo version:cargo 1.54.0 (5ae8d74b3 2021-06-22), alsocargo 1.56.0-nightly (f559c109c 2021-08-26)This issue makes it hard to translate crates.io packages for building with non-cargo build systems.