-
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
Attribute inheritance causes analysis failures for certain built-in attributes #24319
Comments
@bazel-io fork 8.0.0 |
…al_enable_macro_inherit_attrs flag We still have open questions about how macro attribute inheritance ought to interact with the tracking of whether rule attributes were or were not explicitly provided. In effect, this re-opens #24066 Part of addressing #24319 RELNOTES: symbolic macro attribute inheritance is now marked experimental; set --experimental_enable_macro_inherit_attrs flag to enable it. PiperOrigin-RevId: 696582223 Change-Id: I3d7cb434bf8fe2da9cd10019e6075990205e7153
Our discussion of this issue turned into a tangled web of confusion around the meaning of
This would seem to solve the direct bugs raised in this issue about crashes when inheriting built-in attributes. It also maintains the nice property that macro authors don't need to worry about |
The new attribute inheritance system handles attributes with computed defaults by setting their value to
None
within a symbolic macro. That way, when they're passed through to the wrapped rule, the computed-default logic considers it to be missing and computes its value as intended.But some attributes that are morally computed defaults are not in fact implemented that way. The
timeout
attribute of test rules is one example.restricted_to
is another (that one only fails at analysis time).A quick solution is to hardcode a list of these badly behaved builtin attributes and None-ify them all. Though this might require a backwards incompatible change to fix their behavior in the future.
Edit: Correction:
restricted_to
causes it to fail at loading time, not analysis.timeout
works for starlark-defined rules but not native ones, because it's specified as a computed default only for starlark rules. Yet we also found a crash bug here, when inheriting attributes of an unexported rule. We think a good fix is to hardcode problematic attribute names inMacroClass#forceDefaultToNone
, and only in cases where theAttribute
does not have the property flagSTARLARK_DEFINED
(to avoid triggering on user-defined attrs of the same name). Alternatively, we could give some of these problematic attributes trivial computed defaults, but that seems like it could subtly break things (query output or native.existing_rules perhaps).The text was updated successfully, but these errors were encountered: