-
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
Emit Resolve.features_sorted in "cargo metadata" #5122
Emit Resolve.features_sorted in "cargo metadata" #5122
Conversation
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @alexcrichton (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
LGTM, but let's see what @alexcrichton things here! |
Thanks for the PR @acmcarther! Unfortunately though this may not actually be the best way to do this in the sense that it's exposing an existing bug in Cargo, the fact that Cargo knows feature selection at this point! To expand on that, it's actually a bug in Cargo that Cargo thinks it knows what features are applied just after crate graph resolution. Instead Cargo should only know feature selection once it actually goes to compile crates which ends up dealing with target-specific dependencies and such. The primary instances of this bug are:
I'm wary though to block integration of this based on existing bugs in Cargo which are otherwise pretty difficult to fix. It would of course always be relatively easy for Cargo to continue to support this format (even if it didn't internally have such easy access one day) so it may be worth landing this anyway. I'm curiuos, @matklad do you have thoughts on this aspect? |
@alexcrichton Am I correct that long-term, we'd love to split resolve into two phases:
In particular, is it true that dealing with So, I'd r+ this PR, because it doesn't make the situation significantly worse :-) When we fix the Cargo bug, I think we can backwards compatibly evolve |
I see. Yes I was at some level aware that neither
I'd love for this to work in this manner -- though I'd hope that I could have
I was actually confused that |
@matklad oh I don't think we'll ever be able to purge features from resolve because features can activate optional dependencies which need to get into the crate graph. That being said I do think the command line flags may also be a bug in the sense that the lock file (sort of what you get from In general though I think I'd agree in that we can probably get by with just adding this for now and dealing with it later (unfortunately). It seems prudent to add a @acmcarther ok you and @matklad have convinced me this should be fine to add for now, and we can always tweak it later likely in a backwards-compatible fashion if necessary. @bors: r+ |
📌 Commit 6a2b646 has been approved by |
…a, r=alexcrichton Emit Resolve.features_sorted in "cargo metadata" This PR adds `features` to `metadata.resolve.nodes[*]` using the Resolve object's known features. This is different from the `features` fields that already exist elsewhere within metadata as this one is the actual features that need to be used in order to build the code. Context: I'm currently using Cargo's internals to synthesize BUILD files for the Bazel build tool. `cargo metadata` currently provides almost everything I need in order to avoid using Cargo's internals -- *except* for this. cc google/cargo-raze#7
☀️ Test successful - status-appveyor, status-travis |
This PR adds
features
tometadata.resolve.nodes[*]
using the Resolve object's known features. This is different from thefeatures
fields that already exist elsewhere within metadata as this one is the actual features that need to be used in order to build the code.Context: I'm currently using Cargo's internals to synthesize BUILD files for the Bazel build tool.
cargo metadata
currently provides almost everything I need in order to avoid using Cargo's internals -- except for this.cc google/cargo-raze#7