-
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
Prevent aspects from executing on incompatible targets #15426
Conversation
@gregestren , are you a good person to review this? Happy to add more test cases too. |
Sure, happy to review! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It took me too long to get to this. I thought it was going to be a lot more code than it is. What a nice, concise surprise!
It basically looks good to me, including the test coverage. I just have some sanity check questions to make sure I get all the implications.
Basic question: as I understand aspects can automatically propagate down a target's dependencies. If an aspect hits an IncompatiblePlatformProvider
target, it gets short-circuited, which is great.
Will it continue to propagate down that target's dependencies? If they're not also IncompatiblePlatformProvider
targets, would that do something strange?
I think your test coverage shows the opposite? How when the bottom-most dependency is incompatible, everything depending on it also gets skipped?
What happens when that's reversed?
src/main/java/com/google/devtools/build/lib/skyframe/AspectFunction.java
Show resolved
Hide resolved
That is a great question. I will add a test case for this and fix it if it behaves unexpectedly. |
src/main/java/com/google/devtools/build/lib/skyframe/AspectFunction.java
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No other comments besides asking for a bit more line documentation in the test code.
src/main/java/com/google/devtools/build/lib/skyframe/AspectFunction.java
Show resolved
Hide resolved
I'm running this by @sdtwigg for the internal push and he asked if this works as expected with aliases (which always seem to work differently than everything else). Was that something you clarified? |
Haha, totally fair. I haven't validated that it works with aliases. I will add test cases and validate the behaviour. |
I mostly just saw that you did the change right before the special casing for alias handling and was wondering what the proper order between those two special cases is. |
It's a good question. As far as I can tell, the order of those two if statements doesn't matter. If you prefer, I can move it below the alias special casing. |
Sounds great @gregestren, thank you! |
Looks like this patch would help avoid work arounds like grailbio/bazel-compilation-database#100. |
Thanks for the ping now (and I'm back online). I'll get back on this... |
This patch prevents aspect functions from being evaluated when their
associated targets are incompatible. Otherwise aspects can generate
errors that should never be printed at all. For example, an aspect
evaluating an incompatible target may generate errors about missing
providers. This is not the desired behaviour.
The implementation in this patch short-circuits the
AspectValue
creation if the associated target is incompatible.
I had tried to add an
IncompatiblePlatformProvider
to thecorresponding
ConfiguredAspect
instance, but then Bazelcomplained about having duplicate
IncompatiblePlatformProvider
instances.
Fixes #15271