-
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
bool_flag in config_setting via alias seems broken #13463
Comments
Interesting observation thanks. I'll dig in some to find the root cause and report back... |
Some breakpoint debugging shows me this is what fails: bazel/src/main/java/com/google/devtools/build/lib/rules/config/ConfigSetting.java Lines 477 to 480 in 09c621e
fd2c682 has some precedent. I think extending some of its setup logic to user-defined flags can fix this easily enough. |
I prototyped the change, basically change to:
It works, with one blocking caveat. There's already code to support
So we'd need either some way to distinguish them, and implement different semantics accordingly, or change the semantics so they're both interpreted the same way. |
Re:
|
Hi @gregestren , I'm new here and I'm looking through this ticket. Would it be fine if I pick this ticket up? |
Hi @nikhilpothuru - you're welcome to. Do you feel like you can navigate effectively the conceptual challenge above of
? The smallest user footprint way would probably be to tell whether an alias is a |
Hi @gregestren, I take a look at this over the week and let you know if this is something I can handle. As I look through this ticket, I'll add any questions I have on this thread. |
Hi @gregestren, Is there any documentation for setting up the development environment? (i.e. setting up the debugger) |
Thank you for contributing to the Bazel repository! This issue has been marked as stale since it has not had any activity in the last 1+ years. It will be closed in the next 14 days unless any other activity occurs or one of the following labels is added: "not stale", "awaiting-bazeler". Please reach out to the triage team ( |
@bazelbuild/triage Not stale |
Could you please prioritize this? Kleaf hits this issue too, so we just put in a wonky workaround here: It is not urgent, but definitely annoying. |
@lberki noted this as a possible task for people looking for tasks. Still happily accepting contributors. This bug has some nice guidance in its history. |
We also encountered this on ChromeOS. We are generating alias so developers don't have to type the full package paths. For example we have this alias set up:
We hit this problem when we want to generate some target-specific build flags, along with the alias where
|
I have an internal change out to fix this. Hilariously, @jin just started working on this 2.5 years old bug the exact moment I did :( |
Any chance we get this in Bazel 7? |
@bazel-io flag |
@afq984 Bazel 7 has already been released, would Bazel 7.1 work? |
Apologies, I confused this issue with #20582. We were aliasing on the flag, not config_setting. |
@bazel-io fork 7.1.0 |
@iancha1992 Candidate for 7.0.1? |
@brentleyjones I don't think so, unless @meteorcloudy pushes hard for it. 7.0.1 is to fix serious regressions that slipped through into 7.0.0 and this doesn't look like one. |
Previously, if a config_setting referenced a Starlark setting through an alias, it was always evaluated as if the setting had its default value. Now, it is evaluated correctly. This is done by looking up the value of the build setting in the configuration based on its own label as specified in BuildSettingProvider. Fixes bazelbuild#13463 . RELNOTES: None. PiperOrigin-RevId: 585658985 Change-Id: Id534cd95282355f1143302bf703145bb53708a41
Previously, if a config_setting referenced a Starlark setting through an alias, it was always evaluated as if the setting had its default value. Now, it is evaluated correctly. This is done by looking up the value of the build setting in the configuration based on its own label as specified in BuildSettingProvider. Fixes #13463 . RELNOTES: None. Commit d44c3f9 PiperOrigin-RevId: 585658985 Change-Id: Id534cd95282355f1143302bf703145bb53708a41 Co-authored-by: Googler <lberki@google.com> Co-authored-by: Ian (Hee) Cha <heec@google.com>
A fix for this issue has been included in Bazel 7.1.0 RC1. Please test out the release candidate and report any issues as soon as possible. Thanks! |
Description of the problem / feature request:
When referencing a
bool_flag
in aconfig_setting
via analias
indirection, the flag value set on the command line seems to be ignored.NOTE: it isn't necessarily only broken for
bool_flags
, but that's just a simple example that illustrate the issue. I suspect other flag types would have the same problem.Feature requests: what underlying problem are you trying to solve with this feature?
I want to enable some sort of late-binding for enabling/disabling features, in a way that would 'point' to different workspaces based on a flag (boolean or otherwise). Since
select()
isn't possible in aWORKSPACE
, it seems that a recommended alternative is to go through aselect
,config_setting
+alias
indirection.I have tried to simplify my example to a minimum size, so this doesn't exactly illustrate what I'm trying to archive, but it does illustrate the bug I see when following that approach
Bugs: what's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.
With the following files, run
run_all.sh
which will run 4 builds, one by one, and execute the result, printingfeature a: 0
orfeature a: 1
depending on the outcome of theselect
in theBUILD
file.As we can see, we get
0
and1
(depending on the--//:enable_feature_a=xxx
command line option) when theselect
is for aconfig_setting
that references abool_flag
directly, but we always get0
regardless of the command line option when using aconfig_setting
that references abool_flag
via an alias.What operating system are you running Bazel on?
macOS Big Sur 11.3.1
What's the output of
bazel info release
?release 4.0.0
Have you found anything relevant by searching the web?
Looked online, couldn't find anything.
The original reference to using
alias
withselect
when selecting things in a WORKSPACE was found here:https://docs.bazel.build/versions/master/configurable-attributes.html
(see "Why doesn’t select() work with bind()?")
The text was updated successfully, but these errors were encountered: