Closed
Description
Implementation: #7820
Documentation: https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#features
Summary
-Z features=host_dep
causes the feature resolver to prevent features enabled on build dependencies or proc-macros from being enabled for normal dependencies. For example:
[dependencies]
log = "0.4"
[build-dependencies]
log = {version = "0.4", features=['std']}
When building the build script, the log
crate will be built with the std
feature. When building the library of your package, it will not enable the feature.
Unresolved issues
- Update
cargo metadata
- Does this cause existing projects to fail?
- Projects can add missing features as a backwards-compatible workaround. However, if it causes problems for too many projects, we may need to find some way to opt-in.
- Does this significantly increase build times?
- This can cause common dependencies to be built multiple times, when they were previously shared (when
--target
is not used). Projects can add features to re-unify if they want, but it may not be clear or obvious what to add and when. We may need something that identifies these duplicate dependencies, and give suggestions on how to unify them. Or, we may need to make this opt-in somehow so the user needs to make this an explicit decision.
- This can cause common dependencies to be built multiple times, when they were previously shared (when
- Does the feature resolver need to support decoupling of shared proc-macro dependencies?
- Currently this isn't possible because Cargo does not have the necessary information to know which dependencies are proc-macros during resolution time. Either we would need to add the proc-macro status to the index, or try to do feature resolution while dependencies are downloaded. The latter is very difficult due to the way downloading works. The former isn't too hard. Nobody has asked for this ability, so it is unclear how important it is. Presumably that is because proc-macros are relatively new, and tend to only use proc-macro-specific dependencies like syn/quote.
- Implemented in Re-implement proc-macro feature decoupling. #8028.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
Done