-
Notifications
You must be signed in to change notification settings - Fork 4.1k
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
cquery: more precise results #16310
Comments
@katre FYI. I also appreciate input from anyone else if this is interesting to you. Since I think the change is involved I don't think it's something we can just write up a PR for without having a clearer sense of the value offered. |
Proposal: More accurate cquery |
FYI stnma7e is taking a shot at this. |
Thanks so much for the heads, Greg :) |
For reference: https://bazel-review.googlesource.com/c/bazel/+/234613. |
@gregestren Hopefully this gets upstreamed for 7.0! |
I think 7.1 is more likely? But noted. This is an invasive enough change that we'll really want to gate it behind a flag for a while since there's real risk of bugs in all the different ways you can invoke a query. While we're not doing this review on Github, the author updated me today that he'll respond to my feedback this week and we'll mutually try to get the current core change checked in as soon as possible (the longer it lingers the greater the chance of disruptive merge conflicts). |
And to be clear, for the immediate moment we're focusing on aspects. Toolchain deps will have to be their own extension to this work. But the work is intended to be a baseline for both. |
I'm happy to report 81e1333 just landed at head. This means you can add This is flag-gated because it's only been tested against basic Note that while 81e1333 only enables aspects, most of the change generalizes When we have more confidence we've rooted out the bugs we can de-flag and enable by default. Feedback and testing welcome. Thanks again @stnm |
P1 -> P2: less bandwidth right now to follow up on polishing 81e1333 . |
Any plan on cherry-picking that commit to 7.2? It would let folks try out the new feature sooner and provide feedback earlier (rather than 1 year from now). |
Would love to. It's a somewhat invasive code change though, so merge conflicts could be worse than normal. Let's give it a try. |
@bazel-io fork 7.2.0 |
Is this still on track for 7.2? We're aiming to create the first RC on 5/13. |
Oh, I didn't know who'd do the cherrypick but I'm happy to. |
We can cherrypick. Wanted to make sure it's good to go since the issue isn't closed yet. |
Yes. But it's such a big change I wouldn't be surprised if there are merge issues. Let me know if you see any. |
@gregestren Yup. Looks like there is a bunch of conflicts I cannot resolve. Could you please take a look? cc: @bazelbuild/triage |
Give me a few days but I'll take a look. |
Any progress here? We're aiming to cut RC1 next Monday. |
Giving this a shot today. |
Turns out this is already in 7.2.0: #21776 (comment). Experiment away - nothing further we need to do. |
Looking at the documentation, this feature is supposed to decide whether to include aspect-generated-actions in the output. However, I think there's another use case here - accessing providers created by the aspect in cquery. The use case that I was trying to do for this is that if I run cquery on the following target:
Then I want cquery to attach a RustAnalyzerInfo object to I tried it at head, where this feature should be landed, and it didn't work. Here's how to reproduce, in case that's a bug:
The output contains:
As you can see from the print statement, the aspect does successfully return a |
Description of the feature request:
cquery only implicitly shows deps from aspects and toolchain resolution.
For example, assume
//tt:parent
depends on//tt:child
and that dependency adds "my_aspect" which has an implicit dep on//tt:aspect_dep
. Querying this produces:This result includes
my_aspect
's dep, but misleadingly makes it look like//tt:parent
's direct dep.With the proposed change you'd get:
Toolchains are a similar story.
The current behavior is no accident. We explicitly added the current implicit support to at least guarantee cquery doesn't under-eport dependencies. The problem with the full solution is it's a much more invasive change into the Java code that powers cquery and aquery.
I prototyped code to do this, which is why I'm writing this issue now. But it'll take some careful planning and tolerance for reliability issues (crashes in unexpected places) to fully land this extension and know we've properly captured every call sequence.
What underlying problem are you trying to solve with this feature?
foo
depend onbar
? I don't see any reference tobar
infoo
's deps")rpaths
works horribly with the current logic (it shows forward deps caused by aspects even thoughrpaths
should only show backward deps). This would allowrpaths
and possibly other query functions to work correctlyWhich operating system are you running Bazel on?
n/a
What is the output of
bazel info release
?n/a
If
bazel info release
returnsdevelopment version
or(@non-git)
, tell us how you built Bazel.No response
What's the output of
git remote get-url origin; git rev-parse master; git rev-parse HEAD
?No response
Have you found anything relevant by searching the web?
No response
Any other information, logs, or outputs that you want to share?
I think this update has to roll out over multiple PRs and behind a feature flag. It's really hard to audit every call point into the affected code: the full combination of
<cquery flags> x <output formats> x <query expressions>
. Current code assumes every node is aConfiguredTarget
, and makes assumptions accordingly. The essence of this fix is to generalize that toAspect
andToolchain
.There's also some API challenge:
//tt:defs.bzl%_my_aspect of //tt:child
is not a label. So$ bazel cquery 'somepath(//tt:parent, //tt:defs.bzl%_my_aspect of //tt:child)'
triggers a syntax error.We also need to consider appropriate syntax for
cquery
's various output formats.The text was updated successfully, but these errors were encountered: