bazel: incompatible_use_platforms_repo_for_constraints: Don't use constraints from @bazel_tools, use @platforms instead
Available since: 0.28 Tracking issue: https://github.com/bazelbuild/bazel/issues/6516
Motivation
Bazel currently provides common constraints for platforms and toolchains in @bazel_tools//platforms
. We are migrating these out of the Bazel binary to a principled, standalone repository over at https://github.com/bazelbuild/platforms which can be released independently from the Bazel binary and which defines a process for adding more constraints.
Migration
Ideally, declare an explicit dependency on https://github.com/bazelbuild/platforms, name the repository as @platforms
, and use constraints from this repository. In cases where you cannot depend on https://github.com/bazelbuild/platforms (please tell us the reason in the comment), you can use the snapshot of https://github.com/bazelbuild/platforms in Bazel - Bazel implicitly provides this repository for Bazel’s needs.
The actual migration in BUILD files is simple - use @platforms//setting:value
instead of @bazel_tools//platforms:value
:
sed 's$@bazel_tools//platforms:(linux|osx|windows|android|freebsd|ios|os)$@platforms//os:\1$' -E -i **/*
sed 's$@bazel_tools//platforms:(cpu|x86_32|x86_64|ppc|arm|aarch64|s390x)$@platforms//cpu:\1$' -i -E **/*
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 3
- Comments: 31 (23 by maintainers)
Links to this issue
Commits related to this issue
- Add --incompatible_use_platforms_repo_for_constraints This change adds an incompatible flag to disable constrains bundled with Bazel in @bazel_tools. Incompatible change issue: https://github.com/ba... — committed to hlopko/bazel by hlopko 5 years ago
- Add --incompatible_use_platforms_repo_for_constraints This change adds an incompatible flag to disable constrains bundled with Bazel in @bazel_tools. Incompatible change issue: https://github.com/ba... — committed to bazelbuild/bazel by hlopko 5 years ago
- Automated rollback of commit 332379ad6f8c49b0e087b504d73d3483c529e399. *** Reason for rollback *** Broke Bazel downstream: https://buildkite.com/bazel/bazel-at-head-plus-downstream/builds/1039#72cf1... — committed to bazelbuild/bazel by hlopko 5 years ago
- Add --incompatible_use_platforms_repo_for_constraints This change adds an incompatible flag to disable constrains bundled with Bazel in @bazel_tools. Incompatible change issue: https://github.com/ba... — committed to irengrig/bazel by hlopko 5 years ago
- Automated rollback of commit 332379ad6f8c49b0e087b504d73d3483c529e399. *** Reason for rollback *** Broke Bazel downstream: https://buildkite.com/bazel/bazel-at-head-plus-downstream/builds/1039#72cf1... — committed to irengrig/bazel by hlopko 5 years ago
- Add --incompatible_use_platforms_repo_for_constraints This change adds an incompatible flag to disable constrains bundled with Bazel in @bazel_tools. Incompatible change issue: https://github.com/ba... — committed to bazelbuild/bazel by hlopko 5 years ago
- Add --incompatible_use_platforms_repo_for_constraints This change adds an incompatible flag to disable constrains bundled with Bazel in @bazel_tools. Incompatible change issue: https://github.com/ba... — committed to siberex/bazel by hlopko 5 years ago
- Automated rollback of commit 332379ad6f8c49b0e087b504d73d3483c529e399. *** Reason for rollback *** Broke Bazel downstream: https://buildkite.com/bazel/bazel-at-head-plus-downstream/builds/1039#72cf1... — committed to siberex/bazel by hlopko 5 years ago
- Add --incompatible_use_platforms_repo_for_constraints This change adds an incompatible flag to disable constrains bundled with Bazel in @bazel_tools. Incompatible change issue: https://github.com/ba... — committed to siberex/bazel by hlopko 5 years ago
- Release 0.28.0 (2019-07-10) Baseline: 2e374a9c6e3d4ed71f0145de287c4b2fe43c76d6 Cherry picks: + 6d0b14b95a71175362030b4811ca74512b00a890: rule_test: apply "tags" to all rules in the macro I... — committed to bazelbuild/bazel by a-googler 5 years ago
- Add --incompatible_use_platforms_repo_for_constraints This change adds an incompatible flag to disable constrains bundled with Bazel in @bazel_tools. Incompatible change issue: https://github.com/ba... — committed to irengrig/bazel by hlopko 5 years ago
- Automated rollback of commit 332379ad6f8c49b0e087b504d73d3483c529e399. *** Reason for rollback *** Broke Bazel downstream: https://buildkite.com/bazel/bazel-at-head-plus-downstream/builds/1039#72cf1... — committed to irengrig/bazel by hlopko 5 years ago
- Add --incompatible_use_platforms_repo_for_constraints This change adds an incompatible flag to disable constrains bundled with Bazel in @bazel_tools. Incompatible change issue: https://github.com/ba... — committed to irengrig/bazel by hlopko 5 years ago
- Release 0.28.0 (2019-07-10) Baseline: 2e374a9c6e3d4ed71f0145de287c4b2fe43c76d6 Cherry picks: + 6d0b14b95a71175362030b4811ca74512b00a890: rule_test: apply "tags" to all rules in the macro I... — committed to irengrig/bazel by a-googler 5 years ago
- Release 0.28.0 (2019-07-10) Baseline: 2e374a9c6e3d4ed71f0145de287c4b2fe43c76d6 Cherry picks: + 6d0b14b95a71175362030b4811ca74512b00a890: rule_test: apply "tags" to all rules in the macro I... — committed to bazelbuild/bazel by a-googler 5 years ago
- Migrate rules_go for incompatible_use_platforms_repo_for_constraints https://github.com/bazelbuild/bazel/issues/8622 — committed to hlopko/rules_go by hlopko 5 years ago
- Migrate rules_rust for incompatible_use_platforms_repo_for_constraints bazelbuild/bazel#8622 — committed to bazelbuild/rules_rust by deleted user 5 years ago
- go_compat_repo: alias constraint values and settings to bazel_tools or platforms os and cpu constraint settings and values are being removed from @bazel_tools//platforms. They are currently available... — committed to jayconrod/rules_go by deleted user 5 years ago
- go_compat_repo: alias constraint values and settings to bazel_tools or platforms (#2275) os and cpu constraint settings and values are being removed from @bazel_tools//platforms. They are currently ... — committed to bazelbuild/rules_go by deleted user 5 years ago
- go_compat_repo: alias constraint values and settings to bazel_tools or platforms (#2275) os and cpu constraint settings and values are being removed from @bazel_tools//platforms. They are currently ... — committed to bazelbuild/rules_go by deleted user 5 years ago
We are also seeing regression of the form reported by @schwehr with Bazel 6.0. For people using Bazelisk, as a temporary workaround, you can add a file called
.bazelversion
with the contentsto the root of your repo, to keep using Bazel 5.
I am quite happy Bazel is performing breaking changes. Imho the workflow based on incompatibility flags is working well and giving each project the possibility to adjust in its own pace. I am working a lot with C++ and would hate to see Bazel running into the same problem of ever growing complexity and need for best practices and linters just because nothing is ever deprecated.
Quick analysis. There are only about 10 instances of @bazel_tools//platforms in the code, so this should no be that hard to fix.
It actually looks like most of the work is done, so it might be as simple as flipping the flag, then eliminating the tests.
That’s a good question, and I appreciate that this is difficult for some users. That is one of the reasons this has taken so long to roll out. This particular change is specifically to decouple bazel versions from the ability to build for new hardware. Let’s say Bazel 6 had a set of CPUs built in based on what was made in 2022, and rules depend on that version of platforms. You want to use Bazel 6 for a 5 year long project, but new hardware keeps being developed. So you want to build the 3rd generation of your device with a new RISC-V variant. You don’t want to have to update Bazel to pick up a new CPU name. Instead, you just want to pick up a new version of platforms.
Now that the flag is in the graveyard. Can you delete tools/platforms/… I’m not sure if there is a distinct issue for that, but it should happen before bazel 7.
Bazelisk’s
--migrate
no longer relies on GitHub labels: https://github.com/bazelbuild/bazelisk/pull/248I would recommend to build / test your project with Bazel’s rolling releases (and additionally with the latest LTS, if you need to provide backwards compatibility to a long-term supported Bazel version) and also run a regular build / test with Bazelisk’s
--migrate
feature to detect whether any existing--incompatible_*
flags would break you.In that case, feel free to provide feedback to the author of the flag and/or file a bug, so that the team is aware and can take this into account prior to flipping.
I don’t know what the current practices are. Please send an email to bazel-dev to discuss this, since it’s a bigger question than this issue can manage.
s390x is a CPU, not an OS, so the constraint should be
@platforms/./cpu:s390x
.👍 @philwo its a bit annoying that the bazel flag bot adds a non actionable issue. I like the concept a lot but I think the implementation needs to change