-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
Features dependency graph appears to be shared across distinct root crates #8144
Comments
Thanks for the report! This is expected behavior because features are intended to be unioned. When building the workspace it builds all packages which unions the features of the |
This very sad as it makes testing incompatible features of a crate rather hacky. What would be the best practise way of testing incompatible features, just not using workspaces? |
@hnj2 it's not ideal, but the workaround I've been using is to encode the features in the crates themselves. Example: #[path = "../foo_common/lib.rs"]
mod foo_common;
pub use self::foo_common::*; Then repeat with Alternatively you can avoid Cargo Workspaces and just build the explicit manifests in a larger build script, but this has issues with relative paths (see #8506). |
@rickvanprim Thanks for the input. After some more testing I've adopted your method 🚀 |
Problem
With the following minimal workspace, it's not possible to run
cargo build
at the workspace level, however it works as expected when run inside the individual binary crates.Steps
Set up the following workspace:
Run
cargo build
inside ofroot/
.Note that it fails on a duplicate symbol.
Navigate into
bin_a
andbin_b
and executecargo build
in each.Note that both succeed and output into the same
target
directory, but there are two copies ofshared
with different hashes as expected.Possible Solution(s)
It seems like Cargo should have a distinct features dependency graph per root crate that is being built, so that being in a workspace doesn't cause unnecessary (or in this sample, contradictory) features to become enabled when they would not be enabled in a non-workspace build.
Notes
Output of
cargo version
: cargo 1.44.0-nightly (ebda506 2020-04-16)Some relation to #4361 and #7754 .
The text was updated successfully, but these errors were encountered: