-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Tracking issue for -Z features=dev_dep #7916
Comments
This is a complete overhaul of the way platform-specific dependencies are handled. Based on my experimentation and reading the Cargo source code, I believe that this is now correct. Doing so also required feature graph construction to be updated, so the feature graph construction is ready for the new feature resolver, and is now platform-sensitive as well. The APIs for the feature graph are still to come, but making the data model be full-fidelity allows for both the current and new feature resolvers to be implemented. For more about the new feature resolver, see: * https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#features * rust-lang/cargo#7914 * rust-lang/cargo#7915 * rust-lang/cargo#7916
This is a complete overhaul of the way platform-specific dependencies are handled. Based on my experimentation and reading the Cargo source code, I believe that this is now correct. Doing so also required feature graph construction to be updated, so the feature graph construction is ready for the new feature resolver, and is now platform-sensitive as well. The APIs for the feature graph are still to come, but making the data model be full-fidelity allows for both the current and new feature resolvers to be implemented. For more about the new feature resolver, see: * https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#features * rust-lang/cargo#7914 * rust-lang/cargo#7915 * rust-lang/cargo#7916
This is a complete overhaul of the way platform-specific dependencies are handled. Based on my experimentation and reading the Cargo source code, I believe that this is now correct. Doing so also required feature graph construction to be updated, so the feature graph construction is ready for the new feature resolver, and is now platform-sensitive as well. The APIs for the feature graph are still to come, but making the data model be full-fidelity allows for both the current and new feature resolvers to be implemented. Now that target logic is internalized in guppy, cargo-guppy no longer needs to do its own evaluation. For more about the new feature resolver, see: * https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#features * rust-lang/cargo#7914 * rust-lang/cargo#7915 * rust-lang/cargo#7916
This is a complete overhaul of the way platform-specific dependencies are handled. Based on my experimentation and reading the Cargo source code, I believe that this is now correct. Doing so also required feature graph construction to be updated, so the feature graph construction is ready for the new feature resolver, and is now platform-sensitive as well. The APIs for the feature graph are still to come, but making the data model be full-fidelity allows for both the current and new feature resolvers to be implemented. Now that target logic is internalized in guppy, cargo-guppy no longer needs to do its own evaluation. For more about the new feature resolver, see: * https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#features * rust-lang/cargo#7914 * rust-lang/cargo#7915 * rust-lang/cargo#7916
This is a complete overhaul of the way platform-specific dependencies are handled. Based on my experimentation and reading the Cargo source code, I believe that this is now correct. Doing so also required feature graph construction to be updated, so the feature graph construction is ready for the new feature resolver, and is now platform-sensitive as well. The APIs for the feature graph are still to come, but making the data model be full-fidelity allows for both the current and new feature resolvers to be implemented. Now that target logic is internalized in guppy, cargo-guppy no longer needs to do its own evaluation. For more about the new feature resolver, see: * https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#features * rust-lang/cargo#7914 * rust-lang/cargo#7915 * rust-lang/cargo#7916
This is a complete overhaul of the way platform-specific dependencies are handled. Based on my experimentation and reading the Cargo source code, I believe that this is now correct. Doing so also required feature graph construction to be updated, so the feature graph construction is ready for the new feature resolver, and is now platform-sensitive as well. The APIs for the feature graph are still to come, but making the data model be full-fidelity allows for both the current and new feature resolvers to be implemented. Now that target logic is internalized in guppy, cargo-guppy no longer needs to do its own evaluation. For more about the new feature resolver, see: * https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#features * rust-lang/cargo#7914 * rust-lang/cargo#7915 * rust-lang/cargo#7916
This is a complete overhaul of the way platform-specific dependencies are handled. Based on my experimentation and reading the Cargo source code, I believe that this is now correct. Doing so also required feature graph construction to be updated, so the feature graph construction is ready for the new feature resolver, and is now platform-sensitive as well. The APIs for the feature graph are still to come, but making the data model be full-fidelity allows for both the current and new feature resolvers to be implemented. Now that target logic is internalized in guppy, cargo-guppy no longer needs to do its own evaluation. For more about the new feature resolver, see: * https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#features * rust-lang/cargo#7914 * rust-lang/cargo#7915 * rust-lang/cargo#7916
This is a complete overhaul of the way platform-specific dependencies are handled. Based on my experimentation and reading the Cargo source code, I believe that this is now correct. Doing so also required feature graph construction to be updated, so the feature graph construction is ready for the new feature resolver, and is now platform-sensitive as well. The APIs for the feature graph are still to come, but making the data model be full-fidelity allows for both the current and new feature resolvers to be implemented. Now that target logic is internalized in guppy, cargo-guppy no longer needs to do its own evaluation. For more about the new feature resolver, see: * https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#features * rust-lang/cargo#7914 * rust-lang/cargo#7915 * rust-lang/cargo#7916
This is a complete overhaul of the way platform-specific dependencies are handled. Based on my experimentation and reading the Cargo source code, I believe that this is now correct. Doing so also required feature graph construction to be updated, so the feature graph construction is ready for the new feature resolver, and is now platform-sensitive as well. The APIs for the feature graph are still to come, but making the data model be full-fidelity allows for both the current and new feature resolvers to be implemented. Now that target logic is internalized in guppy, cargo-guppy no longer needs to do its own evaluation. For more about the new feature resolver, see: * https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#features * rust-lang/cargo#7914 * rust-lang/cargo#7915 * rust-lang/cargo#7916
This is a complete overhaul of the way platform-specific dependencies are handled. Based on my experimentation and reading the Cargo source code, I believe that this is now correct. Doing so also required feature graph construction to be updated, so the feature graph construction is ready for the new feature resolver, and is now platform-sensitive as well. The APIs for the feature graph are still to come, but making the data model be full-fidelity allows for both the current and new feature resolvers to be implemented. Now that target logic is internalized in guppy, cargo-guppy no longer needs to do its own evaluation. For more about the new feature resolver, see: * https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#features * rust-lang/cargo#7914 * rust-lang/cargo#7915 * rust-lang/cargo#7916
Seems not working with [package]
name = "foo"
version = "0.1.0"
authors = ["Kevin Wang"]
edition = "2018"
[dependencies]
log = {version = "0.4", default-features = false}
[build-dependencies]
bindgen = "0.49"
Build it with: cargo +nightly build -Z features=dev_dep -Z build-std=core,alloc --target=x86_64-linux-kernel Output:
Cargo version:
|
Ohh, |
Would feature flags in i.e., # crate-a:
[dev-dependencies]
crate-b = "1.1.0"
crate-c = { version = "0.1.0", features = ["foo"] } # crate-b:
[dev-dependencies]
crate-c = { version = "0.1.0", features = ["bar"] } Will For what is worth I expect the latter since dev dependencies do not propagate so the features shouldn't either. |
dev-dependencies inside other dependencies are ignored the same as they are today. |
Dev-dependency version-sync crate uses `serde/std` feature. `cargo build` on CI build library with features from dev-deps. Use `-Z features=dev_dep` on nightly to check build without `serde/std`. See rust-lang/cargo#7916 for more details.
Updates to use the `group` crate. See: RustCrypto/traits#287. This crate has a hard `rand_core` dependency so this commit gets rid of the `rand` features across the board and makes them mandatory. (Even if we don't end up shipping the `group` crate this release, that's probably for the best to keep the number of features down) This commit additionally splits out `no_std` build testing into `tests/*_no_std` Cargo projects. This is a workaround until the Cargo resolver is fixed upstream: rust-lang/cargo#7915 rust-lang/cargo#7916
Updates to use the `group` crate. See: RustCrypto/traits#287. This crate has a hard `rand_core` dependency so this commit gets rid of the `rand` features across the board and makes them mandatory. (Even if we don't end up shipping the `group` crate this release, that's probably for the best to keep the number of features down) This commit additionally splits out `no_std` build testing into `tests/*_no_std` Cargo projects. This is a workaround until the Cargo resolver is fixed upstream: rust-lang/cargo#7915 rust-lang/cargo#7916
Updates to use the `group` crate. See: RustCrypto/traits#287. This crate has a hard `rand_core` dependency so this commit gets rid of the `rand` features across the board and makes them mandatory. (Even if we don't end up shipping the `group` crate this release, that's probably for the best to keep the number of features down) This commit additionally splits out `no_std` build testing into `tests/*_no_std` Cargo projects. This is a workaround until the Cargo resolver is fixed upstream: rust-lang/cargo#7915 rust-lang/cargo#7916
This feature is explicitly enabled via the ron dev dependency. This is cargo bug rust-lang/cargo#7916 This was reported on URLO https://users.rust-lang.org/t/serde-hashmap-serialization-key-error/49776/5
If we don't do this, package becomes unusable as dependency rust-lang/cargo#1796 rust-lang/cargo#7916
Implementation: #7820
Documentation: https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#features
Summary
-Z features=dev_dep
causes the feature resolver to prevent features enabled on dev dependencies from being enabled for normal dependencies. For example:In this example, the library will normally link against
serde
without thestd
feature. However, when built as a test or example, it will include thestd
feature.This mode is ignored if you are building any test, bench, or example. That is, dev dependency features will still be unified if you run commands like
cargo test
orcargo build --all-targets
.Unresolved issues
cargo metadata
cargo test
to rebuild some dependencies after acargo build
, where previously those dependencies were built once. 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.cargo test
, binaries will use dependencies with the dev-dependency features. Changing this would be very difficult, requiring major changes to how Cargo builds its unit graph. It may also cause longer build times when it is not necessary, since common dependencies with different features would need to be built twice duringcargo test
.The text was updated successfully, but these errors were encountered: