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/bazelbuild/bazel/issues/8622
Tracking issue:
https://github.com/bazelbuild/bazel/issues/6516
RELNOTES: Incompatible change `--incompatible_use_platforms_repo_for_constraints` has been added. See https://github.com/bazelbuild/bazel/issues/8622 for details.
Closes #8625.
This is encore of https://github.com/bazelbuild/bazel/commit/332379ad6f8c49b0e087b504d73d3483c529e399. Previous implementation failed with dependency cycle with the configuration. In this attempt I don't use selects, but I've put the incompatible flag checking logic directly into the alias rule. Not nice, but get's thing done.
RELNOTES:
PiperOrigin-RevId: 254357477
diff --git a/tools/cpp/BUILD b/tools/cpp/BUILD
index ad1b12a..e9da96d 100644
--- a/tools/cpp/BUILD
+++ b/tools/cpp/BUILD
@@ -169,10 +169,10 @@
toolchain(
name = "cc-toolchain-ppc",
exec_compatible_with = [
- "@bazel_tools//platforms:ppc",
+ "@platforms//cpu:ppc",
],
target_compatible_with = [
- "@bazel_tools//platforms:ppc",
+ "@platforms//cpu:ppc",
],
toolchain = ":cc-compiler-ppc",
toolchain_type = ":toolchain_type",
@@ -196,10 +196,10 @@
toolchain(
name = "cc-toolchain-s390x",
exec_compatible_with = [
- "@bazel_tools//platforms:s390x",
+ "@platforms//cpu:s390x",
],
target_compatible_with = [
- "@bazel_tools//platforms:s390x",
+ "@platforms//cpu:s390x",
],
toolchain = ":cc-compiler-s390x",
toolchain_type = ":toolchain_type",
@@ -225,8 +225,8 @@
exec_compatible_with = [
],
target_compatible_with = [
- "@bazel_tools//platforms:arm",
- "@bazel_tools//platforms:android",
+ "@platforms//cpu:arm",
+ "@platforms//os:android",
],
toolchain = ":cc-compiler-armeabi-v7a",
toolchain_type = ":toolchain_type",
@@ -250,12 +250,12 @@
toolchain(
name = "cc-toolchain-k8",
exec_compatible_with = [
- "@bazel_tools//platforms:x86_64",
- "@bazel_tools//platforms:linux",
+ "@platforms//cpu:x86_64",
+ "@platforms//os:linux",
],
target_compatible_with = [
- "@bazel_tools//platforms:x86_64",
- "@bazel_tools//platforms:linux",
+ "@platforms//cpu:x86_64",
+ "@platforms//os:linux",
],
toolchain = ":cc-compiler-k8",
toolchain_type = ":toolchain_type",
@@ -289,12 +289,12 @@
toolchain(
name = "cc-toolchain-darwin",
exec_compatible_with = [
- "@bazel_tools//platforms:x86_64",
- "@bazel_tools//platforms:osx",
+ "@platforms//cpu:x86_64",
+ "@platforms//os:osx",
],
target_compatible_with = [
- "@bazel_tools//platforms:x86_64",
- "@bazel_tools//platforms:osx",
+ "@platforms//cpu:x86_64",
+ "@platforms//os:osx",
],
toolchain = ":cc-compiler-darwin",
toolchain_type = ":toolchain_type",
@@ -328,12 +328,12 @@
toolchain(
name = "cc-toolchain-freebsd",
exec_compatible_with = [
- "@bazel_tools//platforms:x86_64",
- "@bazel_tools//platforms:freebsd",
+ "@platforms//cpu:x86_64",
+ "@platforms//os:freebsd",
],
target_compatible_with = [
- "@bazel_tools//platforms:x86_64",
- "@bazel_tools//platforms:freebsd",
+ "@platforms//cpu:x86_64",
+ "@platforms//os:freebsd",
],
toolchain = ":cc-compiler-freebsd",
toolchain_type = ":toolchain_type",
@@ -367,12 +367,12 @@
toolchain(
name = "cc-toolchain-x64_windows",
exec_compatible_with = [
- "@bazel_tools//platforms:x86_64",
- "@bazel_tools//platforms:windows",
+ "@platforms//cpu:x86_64",
+ "@platforms//os:windows",
],
target_compatible_with = [
- "@bazel_tools//platforms:x86_64",
- "@bazel_tools//platforms:windows",
+ "@platforms//cpu:x86_64",
+ "@platforms//os:windows",
],
toolchain = ":cc-compiler-x64_windows",
toolchain_type = ":toolchain_type",
@@ -406,13 +406,13 @@
toolchain(
name = "cc-toolchain-x64_windows_msvc",
exec_compatible_with = [
- "@bazel_tools//platforms:x86_64",
- "@bazel_tools//platforms:windows",
+ "@platforms//cpu:x86_64",
+ "@platforms//os:windows",
":msvc",
],
target_compatible_with = [
- "@bazel_tools//platforms:x86_64",
- "@bazel_tools//platforms:windows",
+ "@platforms//cpu:x86_64",
+ "@platforms//os:windows",
],
toolchain = ":cc-compiler-x64_windows_msvc",
toolchain_type = ":toolchain_type",
diff --git a/tools/cpp/BUILD.static.freebsd b/tools/cpp/BUILD.static.freebsd
index 5dd2a8e..b21dc3d 100644
--- a/tools/cpp/BUILD.static.freebsd
+++ b/tools/cpp/BUILD.static.freebsd
@@ -62,12 +62,12 @@
toolchain(
name = "cc-toolchain-freebsd",
exec_compatible_with = [
- "@bazel_tools//platforms:x86_64",
- "@bazel_tools//platforms:freebsd",
+ "@platforms//cpu:x86_64",
+ "@platforms//os:freebsd",
],
target_compatible_with = [
- "@bazel_tools//platforms:x86_64",
- "@bazel_tools//platforms:freebsd",
+ "@platforms//cpu:x86_64",
+ "@platforms//os:freebsd",
],
toolchain = ":cc-compiler-freebsd",
toolchain_type = "@bazel_tools//tools/cpp:toolchain_type",
@@ -97,11 +97,11 @@
toolchain(
name = "cc-toolchain-armeabi-v7a",
exec_compatible_with = [
- "@bazel_tools//platforms:arm",
+ "@platforms//cpu:arm",
],
target_compatible_with = [
- "@bazel_tools//platforms:arm",
- "@bazel_tools//platforms:android",
+ "@platforms//cpu:arm",
+ "@platforms//os:android",
],
toolchain = ":cc-compiler-armeabi-v7a",
toolchain_type = "@bazel_tools//tools/cpp:toolchain_type",
diff --git a/tools/cpp/BUILD.toolchains.tpl b/tools/cpp/BUILD.toolchains.tpl
index 024d8bf..7aa08d0 100644
--- a/tools/cpp/BUILD.toolchains.tpl
+++ b/tools/cpp/BUILD.toolchains.tpl
@@ -11,8 +11,8 @@
name = "cc-toolchain-armeabi-v7a",
exec_compatible_with = HOST_CONSTRAINTS,
target_compatible_with = [
- "@bazel_tools//platforms:arm",
- "@bazel_tools//platforms:android",
+ "@platforms//cpu:arm",
+ "@platforms//os:android",
],
toolchain = "@local_config_cc//:cc-compiler-armabi-v7a",
toolchain_type = "@bazel_tools//tools/cpp:toolchain_type",
diff --git a/tools/cpp/BUILD.windows.tpl b/tools/cpp/BUILD.windows.tpl
index bd45b58..18df650 100644
--- a/tools/cpp/BUILD.windows.tpl
+++ b/tools/cpp/BUILD.windows.tpl
@@ -75,13 +75,13 @@
toolchain(
name = "cc-toolchain-x64_windows_msys",
exec_compatible_with = [
- "@bazel_tools//platforms:x86_64",
- "@bazel_tools//platforms:windows",
+ "@platforms//cpu:x86_64",
+ "@platforms//os:windows",
"@bazel_tools//tools/cpp:msys",
],
target_compatible_with = [
- "@bazel_tools//platforms:x86_64",
- "@bazel_tools//platforms:windows",
+ "@platforms//cpu:x86_64",
+ "@platforms//os:windows",
],
toolchain = ":cc-compiler-x64_windows_msys",
toolchain_type = "@bazel_tools//tools/cpp:toolchain_type",
@@ -121,13 +121,13 @@
toolchain(
name = "cc-toolchain-x64_windows_mingw",
exec_compatible_with = [
- "@bazel_tools//platforms:x86_64",
- "@bazel_tools//platforms:windows",
+ "@platforms//cpu:x86_64",
+ "@platforms//os:windows",
"@bazel_tools//tools/cpp:mingw",
],
target_compatible_with = [
- "@bazel_tools//platforms:x86_64",
- "@bazel_tools//platforms:windows",
+ "@platforms//cpu:x86_64",
+ "@platforms//os:windows",
],
toolchain = ":cc-compiler-x64_windows_mingw",
toolchain_type = "@bazel_tools//tools/cpp:toolchain_type",
@@ -186,12 +186,12 @@
toolchain(
name = "cc-toolchain-x64_windows",
exec_compatible_with = [
- "@bazel_tools//platforms:x86_64",
- "@bazel_tools//platforms:windows",
+ "@platforms//cpu:x86_64",
+ "@platforms//os:windows",
],
target_compatible_with = [
- "@bazel_tools//platforms:x86_64",
- "@bazel_tools//platforms:windows",
+ "@platforms//cpu:x86_64",
+ "@platforms//os:windows",
],
toolchain = ":cc-compiler-x64_windows",
toolchain_type = "@bazel_tools//tools/cpp:toolchain_type",
@@ -219,8 +219,8 @@
exec_compatible_with = [
],
target_compatible_with = [
- "@bazel_tools//platforms:arm",
- "@bazel_tools//platforms:android",
+ "@platforms//cpu:arm",
+ "@platforms//os:android",
],
toolchain = ":cc-compiler-armeabi-v7a",
toolchain_type = "@bazel_tools//tools/cpp:toolchain_type",