-
Notifications
You must be signed in to change notification settings - Fork 4.3k
Add --incompatible_eagerly_resolve_select_keys
#26216
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
base: master
Are you sure you want to change the base?
Conversation
--incompatible_eagerly_resolve_select_keys
--incompatible_resolve_select_keys_eagerly
187c6d1
to
e46e8dc
Compare
--incompatible_resolve_select_keys_eagerly
--incompatible_eagerly_resolve_select_keys
e46e8dc
to
5e6ea48
Compare
@bazel-io fork 8.3.0 |
I didn't have time to look at the code yet. The described behavior change seems reasonable at first glance, but I would like @brandjon to take a look and verify for gotchas. Also, this this change will require documentation updates (can be in followup PRs). |
Could you add a sentence or two as RELNOTES? |
# Conflicts: # src/main/java/com/google/devtools/build/lib/packages/semantics/BuildLanguageOptions.java
3202026
to
1de426a
Compare
Done!
I can add it in a separate PR. Should I make the docs conditional on the flag value or only change them after the flip? |
I filed #26281. |
I agree with the spirit of this change, i.e. having strings canonicalized into label objects at the point where they're passed to One problem might be
Usually we include the effect of a flag in the documentation of the API that it affects. So the same PR that introduces the flag would also update the user docstrings for |
src/test/java/com/google/devtools/build/lib/packages/SelectTest.java
Outdated
Show resolved
Hide resolved
packageContext != null | ||
? Label.parseWithPackageContext( | ||
labelString, packageContext, repoMappingRecorder) | ||
: labelString, |
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'm a bit disappointed that we're adding complexity to the select machinery without getting the benefit of ensuring that SelectorValue
s hold Label
keys in all cases, which would perhaps be progress toward merging this class into BuildType.Selector
in the future. Is there any fundamental reason we can't normalize to Label
s even when there is no packageContext
/ repoMappingRecorder
?
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 I got this now, thanks for pushing me. It also avoids explicit references to repoMappingRecorder
.
I think that this problem is mostly orthogonal to this change, but I sent #26290 to fix these issues. Since selects aren't inspectable (unless you parse the string representation), it doesn't seem like much of a breaking change to preserve |
I also added doc updates, PTAL. |
I have no feedback beyond the existing conversation: particularly @brandjon 's approval. |
@brandjon Friendly ping |
@brandjon @gregestren Friendly ping |
This avoids a common gotcha in which a
select
in a macro with repo names in string keys will generally not work correctly when loaded in the context of a different Bazel (Bzlmod) module that uses a different set of apparent names.In the rare case where resolution relative to the loading
BUILD
file is necessary (e.g. in Skylib'sselects.config_setting_group
or other macros that generateconfig_setting
s), the keys can be preprocessed withnative.package_relative_label
.RELNOTES: With the new
--incompatible_eagerly_resolve_select_keys
flag, the label string keys ofselect
dicts in.bzl
files are resolved relative to the containing file instead of relative to the BUILD file that ends up using theselect
. Usenative.package_relative_label
if this is not desired.