Is there any way to force same set of features for all the dependencies shared across targets in workspace?
Cargo will use minimal set of features for each target (https://github.com/rust-lang/cargo/issues/4463 & related). This causes problems for us due to all the recompilation that happens across different targets.
For example, we have two chains of dependencies:
- A => huge_crate => some_derive => syn
- B => huge_crate => some_derive => syn
When compiling “A”, “syn” is compiled with default features. However, when compiling “B”, “syn” is compiled with feature [“extra-traits”] enabled (because of some other dependency only used for “B”, but not for “A”).
This triggers chain of discrepancies and in the end, when both “A” and “B” are compiled independently (for example, “cargo run --package A”, then separately “cargo run --package B”), causes some of our pretty big crates (“huge_crate”) to be compiled twice.
What I would prefer is some way to unify features across the whole workspace, maybe something like a superset of features? Like a workspace setting saying “when depending on ‘syn’, turn on [“extra-traits”] feature”.
Is anything like this possible?
Currently I’m using a pretty crude workaround, a crate used as dev-dependency both for “A” and “B” and which depends on all of the crates where we have discrepancy in features, with a superset of features turned on.