-
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
Bazel 7 no longer allow label_flag
used as constraint values for platforms
#20494
Comments
This is an intended change (and there was a previous issue about the same thing for rules_docker: bazelbuild/rules_docker#2275). I do not understand what the intention behind this code is: there is already a perfectly good way to change the target platform with a flag, it is You should have fully static, non-configurable platform definitions, and use This change will not be reverted. |
To back up a step: @tgeng, why are you using this construct, and what do you think are the benefits? |
I am using platform to set some additional constraint values, for example java and scala version (we did some platform/constraint gymnastics to support multiple language and dependency versions for our particular use case). We also do cross compiling across x86 and arm and currently the target os/arch switching is done through Without this ability, we will need to duplicate all of the platforms for every os/arch we need to support. Also, the transition logic would be much more complicated because one now loses the ability to change "an aspect" of the configuration. Instead, one must always change all the constraints through |
I'd recommend using parent platforms, then, to get the same effect:
But, honestly, I recommend not using constraints for language versions, for the reasons you note: this leads very quickly to combinatorial explosion of platforms. Instead, I recommend using user-defined flags for such things, since they can be set conveniently from bazelrc files and represent data that isn't actually tied to the platform. To go back into the reasons behind 87fb462, as Bazel uses platforms more and more heavily, it becomes difficult if they depend on the configuration: every configured target needs to reference at least one platform, so reducing the number in memory has a large impact on Bazel's memory usage and efficiency. |
As far as I understand, using flags won't be sufficient for our use case. Language version also affects dependency versions and we are using configurable dependencies to abstract away that. For example, scala 2 doesn't have binary backward-compatibility, so a scala library needs to depend on different standard library targets, depending on the current language version being set. In our use case, "platform" is more than just the platform of the host, it also includes language version and dependency versions. (we can't realistically enforce single version for everything because we needed a lot of external dependencies). So I guess the way forward is to just bite the bullet and live with the combinatorial explosion of platforms in our transition logic. |
label_flag
used as constraint valueslabel_flag
used as constraint values for platforms
I think that's right, although I'd encourage you to try using the flag-based scala version (and others) first: I don't see what you can select with platforms that you can't select with an actual flag. Closing this since it's working as intended. |
Description of the bug:
With Bazel 7 it seems one can no longer use a
label_flag
target when a constraint value is expected. I keep getting the following errorWhich category does this issue belong to?
No response
What's the simplest, easiest way to reproduce this bug? Please provide a minimal example if possible.
The following works with Bazel 6.4.0
But with Bazel 7 I have the following error:
Which operating system are you running Bazel on?
macOS, Linux
What is the output of
bazel info release
?release 7.0.0
If
bazel info release
returnsdevelopment version
or(@non-git)
, tell us how you built Bazel.No response
What's the output of
git remote get-url origin; git rev-parse master; git rev-parse HEAD
?No response
Is this a regression? If yes, please try to identify the Bazel commit where the bug was introduced.
I tried running bisect but it failed.
Have you found anything relevant by searching the web?
No response
Any other information, logs, or outputs that you want to share?
No response
The text was updated successfully, but these errors were encountered: