-
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
--bin B resolves features differently than -p B in a workspace #8157
Comments
I can see how that can be confusing. It may be very difficult to work around that. Generating the target proposals requires having resolution already being performed. It may be possible to special-case this scenario and constrain the initial specs (so it would infer if you did |
But is it actually wanted that even when all packages are built, |
It's questionable, some projects will want the unification (because it cuts down on compile time), and some do not (because it can alter behavior or prevent compilation). This is tracked in #4463 among others. |
I see, in that this case fixing this will just be a minor enhancement, as I can just use the working command. It would be nice if one could just configure such things for each workspace. |
I don't think so, apparently |
As explained above, it selects the entire workspace, and then filters it down to whichever package contains the named binary. The sequence is roughly:
It may be possible to move step 3 above step 2 (so it resolves features only for the selected package), but I think it will be tricky. |
This issue is very confusing. I have a WASM binary in the same workspace as a cross-platform binary. The WASM binary was failing to compile because of dep features leaking in from the other binary when using |
FYI I've posted rust-lang/rfcs#3692 |
#5799 modified the `cargo build` command line omicron-package runs. Previously it built up a list of packages to be built using the `-p` flag; that PR changed it to use `--bin`. The goal was to build only the binaries that are necessary for shipping; this avoids building sled-agent-sim during releng, for instance. We did not realize it at the time, but this invited the specter of rust-lang/cargo#8157 to wreak havoc; namely: - Without `--package`, Cargo uses the `default-members` key of the workspace Cargo.toml to determine which packages to build. `--bin` does not cause the same thing to happen; saying `--bin` does _not_ imply `--package [the package that the bin belongs to]`. - `omicron-dev` belongs to `default-members` and has a normal dependency on `nexus-test-utils`, which enables the `"testing"` feature of `nexus-db-queries`. #7208 is a known result of this problem, but there might be more. Fortunately the solution seems fairly easy, without reverting the relevant changes from #5799: use _both_ `--package` and `--bin`. With this change, the `"testing"` feature is no longer shown in the `cargo build --unit-graph` and `nm target/release/nexus | demangle | grep validate_volume_invar` no longer shows any matching testing-only symbols.
Problem
Suppose I have a workspace, containing crate
A
,B
andC
.A
has the featureF
, but it is not a default-feature. BothB
andC
depend onA
, howeverB
does not useF
, whileC
does.The file
./A/src/lib.rs
looks like this:, while B and C just call
A::A()
in their main function.Behaviour:
This behaviour just seems inconsistent. I don't understand how B is ever built with F, as in my real use case this imposes a performance penalty for B, so I will have to fall back to using
cargo run -p B
. The behaviour I expect is:Steps
A/src/lib.rs
as aboveB/src/main.rs
:A/Cargo.toml
:B/Cargo.toml
C/Cargo.toml
Possible Solution(s)
Notes
Output of
cargo version
:cargo 1.43.0 (3532cf738 2020-03-17)
Using latest stable Rust,
rustc --version
:rustc 1.43.0 (4fb7144ed 2020-04-20)
The text was updated successfully, but these errors were encountered: