-
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
Fix label_flag and label_setting to not have a dependency on the default #13372
Conversation
value. This prevents an extra analysis, since the dependency should only be on the value being used. Fixes bazelbuild#11291.
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.
Feel free to submit; I don't want to hold up this change for another day, regardless of the answer to the single comment I had.
Maybe also add a test case?
@@ -941,7 +942,7 @@ public RuleClass build(String name, String key) { | |||
attr(STARLARK_BUILD_SETTING_DEFAULT_ATTR_NAME, type) | |||
.nonconfigurable(BUILD_SETTING_DEFAULT_NONCONFIGURABLE) | |||
.mandatory(); | |||
if (BuildType.isLabelType(type)) { | |||
if (type.getLabelClass() == LabelClass.DEPENDENCY) { |
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.
When is this true? It doesn't seem to be true at any call site and AFAIU in order to fix the associated bug, the build_setting_default
attribute must not create any dependencies, and allowedFilesTypes()
/ allowedRuleClasses()
only make sense if a dependency is created. Assert that it's not true instead? (either here or in BuildSetting
)
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.
I changed this from isLabelType()
to == LabelClass.DEPENDENCY
specifically because of the change to NODEP_LABEL
: with this change, the calls to allowedFileTypes()
and allowedRuleClasses()
were failing because they only accept real labels, not nodep labels.
Sorry I didn't wait for your review, this is currently internal at cl/369288702.
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.
Let me rephrase this: when I look at the code, RuleClass.getBuildSetting()
never returns a Type
where getLabelClass()
would return DEPENDENCY
. But then why is this branch here?
In addition, if there was any case where that did return DEPENDENCY
, that would trigger the bug you are fixing here, so why not assert the opposite?
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.
Ah, now I see your point. This entire check should be removed, since it's not possible to trigger it.
Should I add a check in BuildSetting.create()
to ensure that only NODEP_LABEL
and NODEP_LABEL_CLASS
are used? I will make changes in the internal version and test this.
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.
I think a better approach is to assert buildSetting.getType().getLabelClass() != LabelClass.DEPENDENCY
beacuse that says exactly what is needed: that the type shouldn't be one that creates a dependency.
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.
But allowedFileTypes
can only validly be called when the type is LabelClass.DEPENDENCY
(see the definitions). Since it is now not possible to have an attribute with that type, there's no valid way to call this.
value. This prevents an extra analysis, since the dependency should only be on the value being used. Fixes bazelbuild#11291. Closes bazelbuild#13372. PiperOrigin-RevId: 369445041
value. This prevents an extra analysis, since the dependency should only be on the value being used. Fixes bazelbuild#11291. Closes bazelbuild#13372. PiperOrigin-RevId: 369445041
value. This prevents an extra analysis, since the dependency should only be on the value being used. Fixes bazelbuild#11291. Closes bazelbuild#13372. PiperOrigin-RevId: 369445041
value. This prevents an extra analysis, since the dependency should only be on the value being used. Fixes bazelbuild#11291. Closes bazelbuild#13372. PiperOrigin-RevId: 369445041
value.
This prevents an extra analysis, since the dependency should only be on
the value being used.
Fixes #11291.