Skip to content
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

Closed
wants to merge 2 commits into from

Conversation

katre
Copy link
Member

@katre katre commented Apr 19, 2021

value.

This prevents an extra analysis, since the dependency should only be on
the value being used.

Fixes #11291.

value.

This prevents an extra analysis, since the dependency should only be on
the value being used.

Fixes bazelbuild#11291.
Copy link
Contributor

@lberki lberki left a 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) {
Copy link
Contributor

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)

Copy link
Member Author

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.

Copy link
Contributor

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?

Copy link
Member Author

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.

Copy link
Contributor

@lberki lberki Apr 20, 2021

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.

Copy link
Member Author

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.

@bazel-io bazel-io closed this in c9f9eed Apr 20, 2021
@katre katre deleted the i11291-dep-cycle branch April 20, 2021 15:32
katre added a commit to katre/bazel that referenced this pull request Jul 12, 2021
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
katre added a commit to katre/bazel that referenced this pull request Jul 13, 2021
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
katre added a commit to katre/bazel that referenced this pull request Jul 13, 2021
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
katre added a commit to katre/bazel that referenced this pull request Jul 13, 2021
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Dependency cycle involving label_flag and configuration transition
3 participants