Switch everything to platforms

This patch switches the codebase over from using the "cpu"
mechanism to using bazel platforms. See
https://docs.bazel.build/versions/master/platforms.html for some more
information.

Most of the substantial changes are in //tools. Instead of using
`cc_toolchain_suite` rules, we now use regular `toolchain` rules that
are registered in the WORKSPACE. That also means that bazel now uses
the target platform to select the compiler.

All --cpu=* arguments should now be --config=* arguments. For example,
`--cpu=roborio` should now be `--config=roborio`. The CI script and
all documentation has been updated to reflect that.

The remainder of the changes revolve around tagging all targets with
`target_compatible_with`.  The old mechanism allowed us to specify
repo-wide defaults. The new mechanism does not. That means every
target that didn't have any compatibility specified, now requires
compatibility with `@platforms//os:linux`.

I used buildozer for the vast majority of `target_compatible_with`
changes. buildozer automatically buildifies any BUILD files it
touches. That means this patch also contains a few non-functional
changes that I was too lazy to remove.

Change-Id: I66d6e6ad9161520ee397597cdb492585820a3acd
diff --git a/third_party/BUILD b/third_party/BUILD
index 8bd83d7..4ecad0d 100644
--- a/third_party/BUILD
+++ b/third_party/BUILD
@@ -1,23 +1,30 @@
+load("//tools:platforms.bzl", "platforms")
 load("//tools/build_rules:select.bzl", "cpu_select")
 
+# Incompatible library in case one isn't available for a specific architecture.
+cc_library(
+    name = "unavailable",
+    target_compatible_with = ["@platforms//:incompatible"],
+)
+
 cc_library(
     name = "wpilib",
     linkstatic = True,
-    restricted_to = ["//tools:roborio"],
+    target_compatible_with = ["//tools/platforms/hardware:roborio"],
     visibility = ["//visibility:public"],
     deps = ["//frc971/wpilib/ahal"],
 )
 
 cc_library(
     name = "wpilib_hal",
-    restricted_to = ["//tools:roborio"],
+    target_compatible_with = ["//tools/platforms/hardware:roborio"],
     visibility = ["//visibility:public"],
     deps = ["//third_party/allwpilib:hal"],
 )
 
 cc_library(
     name = "phoenix",
-    restricted_to = ["//tools:roborio"],
+    target_compatible_with = ["//tools/platforms/hardware:roborio"],
     visibility = ["//visibility:public"],
     deps = [
         "@ctre_phoenix_api_cpp_athena//:api-cpp",
@@ -31,80 +38,61 @@
 
 cc_library(
     name = "opencv",
-    restricted_to = [
-        "//tools:k8",
-        "//tools:armhf-debian",
-    ],
     visibility = ["//visibility:public"],
     deps = select({
         "//tools:cpu_k8": ["@opencv_k8//:opencv"],
         "//tools:cpu_armhf": ["@opencv_armhf//:opencv"],
-        "//conditions:default": [],
+        "//conditions:default": [":unavailable"],
     }),
 )
 
 cc_library(
     name = "gstreamer",
-    restricted_to = [
-        "//tools:k8",
-        "//tools:armhf-debian",
-    ],
     visibility = ["//visibility:public"],
     deps = select({
         "//tools:cpu_k8": ["@gstreamer_k8//:gstreamer"],
         "//tools:cpu_armhf": ["@gstreamer_armhf//:gstreamer"],
-        "//conditions:default": [],
+        "//conditions:default": [":unavailable"],
     }),
 )
 
 cc_library(
     name = "halide",
-    restricted_to = [
-        "//tools:k8",
-        "//tools:armhf-debian",
-    ],
     visibility = ["//visibility:public"],
     deps = select({
         "//tools:cpu_k8": ["@halide_k8//:halide"],
         "//tools:cpu_armhf": ["@halide_armhf//:halide"],
-        "//conditions:default": [],
+        "//conditions:default": [":unavailable"],
     }),
 )
 
 cc_library(
     name = "halide_gengen",
-    restricted_to = [
-        "//tools:k8",
-        "//tools:armhf-debian",
-    ],
     visibility = ["//visibility:public"],
     # It's the same file in either version, but we'll pick the native version
     # to minimize the chances of needing to download the other version unnecessarily.
     deps = select({
         "//tools:cpu_k8": ["@halide_k8//:gengen"],
         "//tools:cpu_armhf": ["@halide_armhf//:gengen"],
-        "//conditions:default": [],
+        "//conditions:default": [":unavailable"],
     }),
 )
 
 cc_library(
     name = "halide_runtime",
-    restricted_to = [
-        "//tools:k8",
-        "//tools:armhf-debian",
-    ],
     visibility = ["//visibility:public"],
     # It's the same file in either version, but we'll pick the native version
     # to minimize the chances of needing to download the other version unnecessarily.
     deps = select({
         "//tools:cpu_k8": ["@halide_k8//:runtime"],
         "//tools:cpu_armhf": ["@halide_armhf//:runtime"],
-        "//conditions:default": [],
+        "//conditions:default": [":unavailable"],
     }),
 )
 
 cc_library(
     name = "webrtc",
+    target_compatible_with = ["@platforms//os:linux"],
     visibility = ["//visibility:public"],
     deps = cpu_select({
         "amd64": ["@webrtc_x64//:webrtc"],
@@ -114,14 +102,12 @@
     }),
 )
 
-# TODO(Brian): Properly restrict this to specific platforms and remove the
-# default deps once we have support for that which interacts with select properly.
 cc_library(
     name = "lzma",
     visibility = ["//visibility:public"],
     deps = select({
         "//tools:cpu_k8": ["@lzma_amd64//:lib"],
         "//tools:cpu_aarch64": ["@lzma_arm64//:lib"],
-        "//conditions:default": [],
+        "//conditions:default": [":unavailable"],
     }),
 )
diff --git a/third_party/Catch2/BUILD b/third_party/Catch2/BUILD
index 5dab07c..f318a06 100644
--- a/third_party/Catch2/BUILD
+++ b/third_party/Catch2/BUILD
@@ -7,5 +7,6 @@
     name = "Catch2",
     hdrs = ["catch/catch.hpp"],
     includes = ["."],
+    target_compatible_with = ["@platforms//os:linux"],
     visibility = ["//visibility:public"],
 )
diff --git a/third_party/GSL/BUILD b/third_party/GSL/BUILD
index 62a28f3..cd85e93 100644
--- a/third_party/GSL/BUILD
+++ b/third_party/GSL/BUILD
@@ -1,11 +1,9 @@
 licenses(["notice"])
 
-load("//tools:environments.bzl", "mcu_cpus")
 
 cc_library(
     name = "GSL",
     hdrs = glob(["include/**"]),
-    compatible_with = mcu_cpus,
     includes = ["include"],
     visibility = ["//visibility:public"],
 )
diff --git a/third_party/GSL/tests/BUILD b/third_party/GSL/tests/BUILD
index 503a29f..4a0fcc6 100644
--- a/third_party/GSL/tests/BUILD
+++ b/third_party/GSL/tests/BUILD
@@ -26,6 +26,7 @@
         "-frtti",
         "-DGSL_THROW_ON_CONTRACT_VIOLATION",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":test",
         "//third_party/Catch2",
@@ -42,6 +43,7 @@
     copts = _copts + [
         "-DGSL_TERMINATE_ON_CONTRACT_VIOLATION",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":test",
         "//third_party/Catch2",
@@ -58,6 +60,7 @@
         "-frtti",
         "-DGSL_THROW_ON_CONTRACT_VIOLATION",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         "//third_party/Catch2",
         "//third_party/GSL",
diff --git a/third_party/allwpilib/BUILD b/third_party/allwpilib/BUILD
index 61f6098..bee2e64 100644
--- a/third_party/allwpilib/BUILD
+++ b/third_party/allwpilib/BUILD
@@ -34,6 +34,7 @@
     srcs = [
         "generate_FRCUsageReporting.py",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
 )
 
 genrule(
@@ -53,6 +54,7 @@
         "$(location hal/src/generate/ResourceType.txt)",
         "$(location hal/src/main/native/include/hal/FRCUsageReporting.h)",
     ]),
+    target_compatible_with = ["@platforms//os:linux"],
     tools = [
         ":generate_FRCUsageReporting",
     ],
@@ -79,7 +81,7 @@
         "-Wno-cast-align",
     ],
     includes = _hal_header_dirs,
-    restricted_to = ["//tools:roborio"],
+    target_compatible_with = ["//tools/platforms/hardware:roborio"],
     visibility = ["//third_party:__pkg__"],
     deps = [
         "//aos/logging",
diff --git a/third_party/allwpilib/wpiutil/BUILD b/third_party/allwpilib/wpiutil/BUILD
index 98ed173..8c1b8db 100644
--- a/third_party/allwpilib/wpiutil/BUILD
+++ b/third_party/allwpilib/wpiutil/BUILD
@@ -23,6 +23,6 @@
     includes = [
         "src/main/native/include",
     ],
-    restricted_to = ["//tools:roborio"],
+    target_compatible_with = ["//tools/platforms/hardware:roborio"],
     visibility = ["//visibility:public"],
 )
diff --git a/third_party/bazel/BUILD b/third_party/bazel/BUILD
index 282cdad..4ff89c7 100644
--- a/third_party/bazel/BUILD
+++ b/third_party/bazel/BUILD
@@ -8,5 +8,6 @@
     srcs = [
         "protos/extra_actions_base_pb2.py",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     visibility = ["//visibility:public"],
 )
diff --git a/third_party/blasfeo/BUILD b/third_party/blasfeo/BUILD
index f6efd3c..1b6f8c1 100644
--- a/third_party/blasfeo/BUILD
+++ b/third_party/blasfeo/BUILD
@@ -79,7 +79,7 @@
     includes = [
         "include",
     ],
-    restricted_to = ["//tools:k8"],
+    target_compatible_with = ["@platforms//cpu:x86_64"],
     textual_hdrs = [
         "blas/x_blas2_diag_lib.c",
     ],
diff --git a/third_party/boostorg/algorithm/BUILD b/third_party/boostorg/algorithm/BUILD
index 2531e98..8efc7ca 100644
--- a/third_party/boostorg/algorithm/BUILD
+++ b/third_party/boostorg/algorithm/BUILD
@@ -4,6 +4,7 @@
     name = "algorithm",
     hdrs = glob(["include/**"]),
     includes = ["include"],
+    target_compatible_with = ["@platforms//os:linux"],
     visibility = ["//visibility:public"],
     deps = [
         "//third_party/boostorg/assert",
diff --git a/third_party/boostorg/any/BUILD b/third_party/boostorg/any/BUILD
index c260ecc..892d710 100644
--- a/third_party/boostorg/any/BUILD
+++ b/third_party/boostorg/any/BUILD
@@ -4,5 +4,6 @@
     name = "any",
     hdrs = glob(["include/**"]),
     includes = ["include"],
+    target_compatible_with = ["@platforms//os:linux"],
     visibility = ["//visibility:public"],
 )
diff --git a/third_party/boostorg/array/BUILD b/third_party/boostorg/array/BUILD
index 448d164..2dbb0e9 100644
--- a/third_party/boostorg/array/BUILD
+++ b/third_party/boostorg/array/BUILD
@@ -4,5 +4,6 @@
     name = "array",
     hdrs = glob(["include/**"]),
     includes = ["include"],
+    target_compatible_with = ["@platforms//os:linux"],
     visibility = ["//visibility:public"],
 )
diff --git a/third_party/boostorg/assert/BUILD b/third_party/boostorg/assert/BUILD
index 3aa13e1..db94e30 100644
--- a/third_party/boostorg/assert/BUILD
+++ b/third_party/boostorg/assert/BUILD
@@ -4,5 +4,6 @@
     name = "assert",
     hdrs = glob(["include/**"]),
     includes = ["include"],
+    target_compatible_with = ["@platforms//os:linux"],
     visibility = ["//visibility:public"],
 )
diff --git a/third_party/boostorg/atomic/BUILD b/third_party/boostorg/atomic/BUILD
index d28c896..a9aff83 100644
--- a/third_party/boostorg/atomic/BUILD
+++ b/third_party/boostorg/atomic/BUILD
@@ -4,5 +4,6 @@
     name = "atomic",
     hdrs = glob(["include/**"]),
     includes = ["include"],
+    target_compatible_with = ["@platforms//os:linux"],
     visibility = ["//visibility:public"],
 )
diff --git a/third_party/boostorg/bind/BUILD b/third_party/boostorg/bind/BUILD
index 71d64c2..d34bb82 100644
--- a/third_party/boostorg/bind/BUILD
+++ b/third_party/boostorg/bind/BUILD
@@ -4,5 +4,6 @@
     name = "bind",
     hdrs = glob(["include/**"]),
     includes = ["include"],
+    target_compatible_with = ["@platforms//os:linux"],
     visibility = ["//visibility:public"],
 )
diff --git a/third_party/boostorg/concept_check/BUILD b/third_party/boostorg/concept_check/BUILD
index e232b94..5dab6d7 100644
--- a/third_party/boostorg/concept_check/BUILD
+++ b/third_party/boostorg/concept_check/BUILD
@@ -4,5 +4,6 @@
     name = "concept_check",
     hdrs = glob(["include/**"]),
     includes = ["include"],
+    target_compatible_with = ["@platforms//os:linux"],
     visibility = ["//visibility:public"],
 )
diff --git a/third_party/boostorg/config/BUILD b/third_party/boostorg/config/BUILD
index 8b23ec2..093853d 100644
--- a/third_party/boostorg/config/BUILD
+++ b/third_party/boostorg/config/BUILD
@@ -4,6 +4,7 @@
     name = "config",
     hdrs = glob(["include/**"]),
     includes = ["include"],
+    target_compatible_with = ["@platforms//os:linux"],
     visibility = ["//visibility:public"],
     deps = [
         "//third_party/boostorg/core",
diff --git a/third_party/boostorg/container/BUILD b/third_party/boostorg/container/BUILD
index e6813ba..f36f44b 100644
--- a/third_party/boostorg/container/BUILD
+++ b/third_party/boostorg/container/BUILD
@@ -4,5 +4,6 @@
     name = "container",
     hdrs = glob(["include/**"]),
     includes = ["include"],
+    target_compatible_with = ["@platforms//os:linux"],
     visibility = ["//visibility:public"],
 )
diff --git a/third_party/boostorg/container_hash/BUILD b/third_party/boostorg/container_hash/BUILD
index fcaef6c..0d44824 100644
--- a/third_party/boostorg/container_hash/BUILD
+++ b/third_party/boostorg/container_hash/BUILD
@@ -4,5 +4,6 @@
     name = "container_hash",
     hdrs = glob(["include/**"]),
     includes = ["include"],
+    target_compatible_with = ["@platforms//os:linux"],
     visibility = ["//visibility:public"],
 )
diff --git a/third_party/boostorg/core/BUILD b/third_party/boostorg/core/BUILD
index c93902b..51ea944 100644
--- a/third_party/boostorg/core/BUILD
+++ b/third_party/boostorg/core/BUILD
@@ -4,6 +4,7 @@
     name = "core",
     hdrs = glob(["include/**"]),
     includes = ["include"],
+    target_compatible_with = ["@platforms//os:linux"],
     visibility = ["//visibility:public"],
     deps = [
         "//third_party/boostorg/static_assert",
diff --git a/third_party/boostorg/detail/BUILD b/third_party/boostorg/detail/BUILD
index d317109..94496ee 100644
--- a/third_party/boostorg/detail/BUILD
+++ b/third_party/boostorg/detail/BUILD
@@ -4,5 +4,6 @@
     name = "detail",
     hdrs = glob(["include/**"]),
     includes = ["include"],
+    target_compatible_with = ["@platforms//os:linux"],
     visibility = ["//visibility:public"],
 )
diff --git a/third_party/boostorg/foreach/BUILD b/third_party/boostorg/foreach/BUILD
index 25dce16..38dd8ab 100644
--- a/third_party/boostorg/foreach/BUILD
+++ b/third_party/boostorg/foreach/BUILD
@@ -4,5 +4,6 @@
     name = "foreach",
     hdrs = glob(["include/**"]),
     includes = ["include"],
+    target_compatible_with = ["@platforms//os:linux"],
     visibility = ["//visibility:public"],
 )
diff --git a/third_party/boostorg/format/BUILD b/third_party/boostorg/format/BUILD
index 96be264..e0c4123 100644
--- a/third_party/boostorg/format/BUILD
+++ b/third_party/boostorg/format/BUILD
@@ -4,5 +4,6 @@
     name = "format",
     hdrs = glob(["include/**"]),
     includes = ["include"],
+    target_compatible_with = ["@platforms//os:linux"],
     visibility = ["//visibility:public"],
 )
diff --git a/third_party/boostorg/function/BUILD b/third_party/boostorg/function/BUILD
index 92b7c11..e6e3ba3 100644
--- a/third_party/boostorg/function/BUILD
+++ b/third_party/boostorg/function/BUILD
@@ -4,5 +4,6 @@
     name = "function",
     hdrs = glob(["include/**"]),
     includes = ["include"],
+    target_compatible_with = ["@platforms//os:linux"],
     visibility = ["//visibility:public"],
 )
diff --git a/third_party/boostorg/function_types/BUILD b/third_party/boostorg/function_types/BUILD
index 50bbf55..31985ae 100644
--- a/third_party/boostorg/function_types/BUILD
+++ b/third_party/boostorg/function_types/BUILD
@@ -4,5 +4,6 @@
     name = "function_types",
     hdrs = glob(["include/**"]),
     includes = ["include"],
+    target_compatible_with = ["@platforms//os:linux"],
     visibility = ["//visibility:public"],
 )
diff --git a/third_party/boostorg/functional/BUILD b/third_party/boostorg/functional/BUILD
index 6f0c2d6..3d6b28a 100644
--- a/third_party/boostorg/functional/BUILD
+++ b/third_party/boostorg/functional/BUILD
@@ -4,5 +4,6 @@
     name = "functional",
     hdrs = glob(["include/**"]),
     includes = ["include"],
+    target_compatible_with = ["@platforms//os:linux"],
     visibility = ["//visibility:public"],
 )
diff --git a/third_party/boostorg/fusion/BUILD b/third_party/boostorg/fusion/BUILD
index e0e1e33..9a12bff 100644
--- a/third_party/boostorg/fusion/BUILD
+++ b/third_party/boostorg/fusion/BUILD
@@ -4,5 +4,6 @@
     name = "fusion",
     hdrs = glob(["include/**"]),
     includes = ["include"],
+    target_compatible_with = ["@platforms//os:linux"],
     visibility = ["//visibility:public"],
 )
diff --git a/third_party/boostorg/integer/BUILD b/third_party/boostorg/integer/BUILD
index daddbaf..a8b38dc 100644
--- a/third_party/boostorg/integer/BUILD
+++ b/third_party/boostorg/integer/BUILD
@@ -4,5 +4,6 @@
     name = "integer",
     hdrs = glob(["include/**"]),
     includes = ["include"],
+    target_compatible_with = ["@platforms//os:linux"],
     visibility = ["//visibility:public"],
 )
diff --git a/third_party/boostorg/iterator/BUILD b/third_party/boostorg/iterator/BUILD
index fa0d26d..5bb18d7 100644
--- a/third_party/boostorg/iterator/BUILD
+++ b/third_party/boostorg/iterator/BUILD
@@ -4,5 +4,6 @@
     name = "iterator",
     hdrs = glob(["include/**"]),
     includes = ["include"],
+    target_compatible_with = ["@platforms//os:linux"],
     visibility = ["//visibility:public"],
 )
diff --git a/third_party/boostorg/lexical_cast/BUILD b/third_party/boostorg/lexical_cast/BUILD
index 76185fe..9013614 100644
--- a/third_party/boostorg/lexical_cast/BUILD
+++ b/third_party/boostorg/lexical_cast/BUILD
@@ -4,5 +4,6 @@
     name = "lexical_cast",
     hdrs = glob(["include/**"]),
     includes = ["include"],
+    target_compatible_with = ["@platforms//os:linux"],
     visibility = ["//visibility:public"],
 )
diff --git a/third_party/boostorg/math/BUILD b/third_party/boostorg/math/BUILD
index cbc8581..97214f5 100644
--- a/third_party/boostorg/math/BUILD
+++ b/third_party/boostorg/math/BUILD
@@ -4,5 +4,6 @@
     name = "math",
     hdrs = glob(["include/**"]),
     includes = ["include"],
+    target_compatible_with = ["@platforms//os:linux"],
     visibility = ["//visibility:public"],
 )
diff --git a/third_party/boostorg/move/BUILD b/third_party/boostorg/move/BUILD
index e39c98b..8f09042 100644
--- a/third_party/boostorg/move/BUILD
+++ b/third_party/boostorg/move/BUILD
@@ -4,5 +4,6 @@
     name = "move",
     hdrs = glob(["include/**"]),
     includes = ["include"],
+    target_compatible_with = ["@platforms//os:linux"],
     visibility = ["//visibility:public"],
 )
diff --git a/third_party/boostorg/mpl/BUILD b/third_party/boostorg/mpl/BUILD
index d6c9685..72aefbb 100644
--- a/third_party/boostorg/mpl/BUILD
+++ b/third_party/boostorg/mpl/BUILD
@@ -4,5 +4,6 @@
     name = "mpl",
     hdrs = glob(["include/**"]),
     includes = ["include"],
+    target_compatible_with = ["@platforms//os:linux"],
     visibility = ["//visibility:public"],
 )
diff --git a/third_party/boostorg/multi_array/BUILD b/third_party/boostorg/multi_array/BUILD
index 89cac9e..e1ef0d3 100644
--- a/third_party/boostorg/multi_array/BUILD
+++ b/third_party/boostorg/multi_array/BUILD
@@ -4,5 +4,6 @@
     name = "multi_array",
     hdrs = glob(["include/**"]),
     includes = ["include"],
+    target_compatible_with = ["@platforms//os:linux"],
     visibility = ["//visibility:public"],
 )
diff --git a/third_party/boostorg/multi_index/BUILD b/third_party/boostorg/multi_index/BUILD
index 143fb0a..28ad13b 100644
--- a/third_party/boostorg/multi_index/BUILD
+++ b/third_party/boostorg/multi_index/BUILD
@@ -4,5 +4,6 @@
     name = "multi_index",
     hdrs = glob(["include/**"]),
     includes = ["include"],
+    target_compatible_with = ["@platforms//os:linux"],
     visibility = ["//visibility:public"],
 )
diff --git a/third_party/boostorg/numeric_conversion/BUILD b/third_party/boostorg/numeric_conversion/BUILD
index 053f6fc..900452c 100644
--- a/third_party/boostorg/numeric_conversion/BUILD
+++ b/third_party/boostorg/numeric_conversion/BUILD
@@ -4,5 +4,6 @@
     name = "numeric_conversion",
     hdrs = glob(["include/**"]),
     includes = ["include"],
+    target_compatible_with = ["@platforms//os:linux"],
     visibility = ["//visibility:public"],
 )
diff --git a/third_party/boostorg/odeint/BUILD b/third_party/boostorg/odeint/BUILD
index 0f5dfac..3900fb0 100644
--- a/third_party/boostorg/odeint/BUILD
+++ b/third_party/boostorg/odeint/BUILD
@@ -4,6 +4,7 @@
     name = "odeint",
     hdrs = glob(["include/**"]),
     includes = ["include"],
+    target_compatible_with = ["@platforms//os:linux"],
     visibility = ["//visibility:public"],
     deps = [
         "//third_party/boostorg/assert",
diff --git a/third_party/boostorg/optional/BUILD b/third_party/boostorg/optional/BUILD
index b355d53..df2d1be 100644
--- a/third_party/boostorg/optional/BUILD
+++ b/third_party/boostorg/optional/BUILD
@@ -4,6 +4,7 @@
     name = "optional",
     hdrs = glob(["include/**"]),
     includes = ["include"],
+    target_compatible_with = ["@platforms//os:linux"],
     visibility = ["//visibility:public"],
     deps = [
         "//third_party/boostorg/assert",
diff --git a/third_party/boostorg/predef/BUILD b/third_party/boostorg/predef/BUILD
index 9c04b7e..d245379 100644
--- a/third_party/boostorg/predef/BUILD
+++ b/third_party/boostorg/predef/BUILD
@@ -4,5 +4,6 @@
     name = "predef",
     hdrs = glob(["include/**"]),
     includes = ["include"],
+    target_compatible_with = ["@platforms//os:linux"],
     visibility = ["//visibility:public"],
 )
diff --git a/third_party/boostorg/preprocessor/BUILD b/third_party/boostorg/preprocessor/BUILD
index 7c7499a..d7d06d2 100644
--- a/third_party/boostorg/preprocessor/BUILD
+++ b/third_party/boostorg/preprocessor/BUILD
@@ -4,5 +4,6 @@
     name = "preprocessor",
     hdrs = glob(["include/**"]),
     includes = ["include"],
+    target_compatible_with = ["@platforms//os:linux"],
     visibility = ["//visibility:public"],
 )
diff --git a/third_party/boostorg/property_tree/BUILD b/third_party/boostorg/property_tree/BUILD
index 536ec40..fee61af 100644
--- a/third_party/boostorg/property_tree/BUILD
+++ b/third_party/boostorg/property_tree/BUILD
@@ -4,6 +4,7 @@
     name = "property_tree",
     hdrs = glob(["include/**"]),
     includes = ["include"],
+    target_compatible_with = ["@platforms//os:linux"],
     visibility = ["//visibility:public"],
     deps = [
         "//third_party/boostorg/any",
diff --git a/third_party/boostorg/range/BUILD b/third_party/boostorg/range/BUILD
index b68cee7..7b96045 100644
--- a/third_party/boostorg/range/BUILD
+++ b/third_party/boostorg/range/BUILD
@@ -4,5 +4,6 @@
     name = "range",
     hdrs = glob(["include/**"]),
     includes = ["include"],
+    target_compatible_with = ["@platforms//os:linux"],
     visibility = ["//visibility:public"],
 )
diff --git a/third_party/boostorg/serialization/BUILD b/third_party/boostorg/serialization/BUILD
index 5f60759..87c8467 100644
--- a/third_party/boostorg/serialization/BUILD
+++ b/third_party/boostorg/serialization/BUILD
@@ -4,5 +4,6 @@
     name = "serialization",
     hdrs = glob(["include/**"]),
     includes = ["include"],
+    target_compatible_with = ["@platforms//os:linux"],
     visibility = ["//visibility:public"],
 )
diff --git a/third_party/boostorg/smart_ptr/BUILD b/third_party/boostorg/smart_ptr/BUILD
index f2f1352..46ced1b 100644
--- a/third_party/boostorg/smart_ptr/BUILD
+++ b/third_party/boostorg/smart_ptr/BUILD
@@ -4,5 +4,6 @@
     name = "smart_ptr",
     hdrs = glob(["include/**"]),
     includes = ["include"],
+    target_compatible_with = ["@platforms//os:linux"],
     visibility = ["//visibility:public"],
 )
diff --git a/third_party/boostorg/static_assert/BUILD b/third_party/boostorg/static_assert/BUILD
index da56484..f579b4a 100644
--- a/third_party/boostorg/static_assert/BUILD
+++ b/third_party/boostorg/static_assert/BUILD
@@ -4,5 +4,6 @@
     name = "static_assert",
     hdrs = glob(["include/**"]),
     includes = ["include"],
+    target_compatible_with = ["@platforms//os:linux"],
     visibility = ["//visibility:public"],
 )
diff --git a/third_party/boostorg/throw_exception/BUILD b/third_party/boostorg/throw_exception/BUILD
index 32998e8..153d8e2 100644
--- a/third_party/boostorg/throw_exception/BUILD
+++ b/third_party/boostorg/throw_exception/BUILD
@@ -4,6 +4,7 @@
     name = "throw_exception",
     hdrs = glob(["include/**"]),
     includes = ["include"],
+    target_compatible_with = ["@platforms//os:linux"],
     visibility = ["//visibility:public"],
     deps = [
         "//third_party/boostorg/assert",
diff --git a/third_party/boostorg/tuple/BUILD b/third_party/boostorg/tuple/BUILD
index 040c778..ba44766 100644
--- a/third_party/boostorg/tuple/BUILD
+++ b/third_party/boostorg/tuple/BUILD
@@ -4,5 +4,6 @@
     name = "tuple",
     hdrs = glob(["include/**"]),
     includes = ["include"],
+    target_compatible_with = ["@platforms//os:linux"],
     visibility = ["//visibility:public"],
 )
diff --git a/third_party/boostorg/type_index/BUILD b/third_party/boostorg/type_index/BUILD
index 3801d5c..6731eea 100644
--- a/third_party/boostorg/type_index/BUILD
+++ b/third_party/boostorg/type_index/BUILD
@@ -4,5 +4,6 @@
     name = "type_index",
     hdrs = glob(["include/**"]),
     includes = ["include"],
+    target_compatible_with = ["@platforms//os:linux"],
     visibility = ["//visibility:public"],
 )
diff --git a/third_party/boostorg/type_traits/BUILD b/third_party/boostorg/type_traits/BUILD
index 672a32c..a8c8fb0 100644
--- a/third_party/boostorg/type_traits/BUILD
+++ b/third_party/boostorg/type_traits/BUILD
@@ -4,5 +4,6 @@
     name = "type_traits",
     hdrs = glob(["include/**"]),
     includes = ["include"],
+    target_compatible_with = ["@platforms//os:linux"],
     visibility = ["//visibility:public"],
 )
diff --git a/third_party/boostorg/typeof/BUILD b/third_party/boostorg/typeof/BUILD
index 781e0e1..da04272 100644
--- a/third_party/boostorg/typeof/BUILD
+++ b/third_party/boostorg/typeof/BUILD
@@ -4,5 +4,6 @@
     name = "typeof",
     hdrs = glob(["include/**"]),
     includes = ["include"],
+    target_compatible_with = ["@platforms//os:linux"],
     visibility = ["//visibility:public"],
 )
diff --git a/third_party/boostorg/ublas/BUILD b/third_party/boostorg/ublas/BUILD
index 4544f9f..2bccf3a 100644
--- a/third_party/boostorg/ublas/BUILD
+++ b/third_party/boostorg/ublas/BUILD
@@ -4,5 +4,6 @@
     name = "ublas",
     hdrs = glob(["include/**"]),
     includes = ["include"],
+    target_compatible_with = ["@platforms//os:linux"],
     visibility = ["//visibility:public"],
 )
diff --git a/third_party/boostorg/units/BUILD b/third_party/boostorg/units/BUILD
index 26e5dbb..e3c2aa2 100644
--- a/third_party/boostorg/units/BUILD
+++ b/third_party/boostorg/units/BUILD
@@ -4,5 +4,6 @@
     name = "units",
     hdrs = glob(["include/**"]),
     includes = ["include"],
+    target_compatible_with = ["@platforms//os:linux"],
     visibility = ["//visibility:public"],
 )
diff --git a/third_party/boostorg/utility/BUILD b/third_party/boostorg/utility/BUILD
index 8d38605..2136e67 100644
--- a/third_party/boostorg/utility/BUILD
+++ b/third_party/boostorg/utility/BUILD
@@ -4,5 +4,6 @@
     name = "utility",
     hdrs = glob(["include/**"]),
     includes = ["include"],
+    target_compatible_with = ["@platforms//os:linux"],
     visibility = ["//visibility:public"],
 )
diff --git a/third_party/cddlib/BUILD b/third_party/cddlib/BUILD
index fa2f50a..08684fc 100644
--- a/third_party/cddlib/BUILD
+++ b/third_party/cddlib/BUILD
@@ -31,6 +31,7 @@
         "gcc": ["-Wno-unused-but-set-variable"],
         "clang": [],
     }),
+    target_compatible_with = ["@platforms//os:linux"],
     visibility = ["//visibility:public"],
 )
 
@@ -38,6 +39,7 @@
     name = "_cddlib.so",
     linkshared = True,
     linkstatic = False,
+    target_compatible_with = ["@platforms//os:linux"],
     visibility = ["//visibility:public"],
     deps = [":cddlib"],
 )
diff --git a/third_party/cimg/BUILD b/third_party/cimg/BUILD
index 0dfc79b..fc73f38 100644
--- a/third_party/cimg/BUILD
+++ b/third_party/cimg/BUILD
@@ -6,6 +6,7 @@
         "CImg.h",
         "plugins/*.h",
     ]),
+    target_compatible_with = ["@platforms//os:linux"],
     visibility = ["//visibility:public"],
     deps = [
         "//third_party/libjpeg",
diff --git a/third_party/ct/BUILD b/third_party/ct/BUILD
index ad7ce4b..39af5d7 100644
--- a/third_party/ct/BUILD
+++ b/third_party/ct/BUILD
@@ -268,7 +268,7 @@
         "ct_core/include/external",
         "ct_optcon/include",
     ],
-    restricted_to = ["//tools:k8"],
+    target_compatible_with = ["@platforms//cpu:x86_64"],
     visibility = ["//visibility:public"],
     deps = [
         "//third_party/boostorg/algorithm",
diff --git a/third_party/eigen/BUILD b/third_party/eigen/BUILD
index 54c5cd1..02f259d 100644
--- a/third_party/eigen/BUILD
+++ b/third_party/eigen/BUILD
@@ -1,7 +1,5 @@
 licenses(["notice"])
 
-load("@//tools:environments.bzl", "mcu_cpus")
-
 cc_library(
     name = "eigen",
     srcs = glob(["Eigen/src/**/*.h"]),
@@ -20,7 +18,6 @@
     ) + ["unsupported/Eigen/MatrixFunctions"] + glob([
         "unsupported/Eigen/src/MatrixFunctions/*.h",
     ]),
-    compatible_with = mcu_cpus,
     includes = ["."],
     visibility = ["//visibility:public"],
 )
diff --git a/third_party/empty_config_h/BUILD b/third_party/empty_config_h/BUILD
index d1a8093..3cd587c 100644
--- a/third_party/empty_config_h/BUILD
+++ b/third_party/empty_config_h/BUILD
@@ -5,5 +5,6 @@
     hdrs = [
         "config.h",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     visibility = ["//third_party:__subpackages__"],
 )
diff --git a/third_party/flatbuffers/BUILD b/third_party/flatbuffers/BUILD
index 3114495..57f2b8e 100644
--- a/third_party/flatbuffers/BUILD
+++ b/third_party/flatbuffers/BUILD
@@ -1,11 +1,9 @@
-licenses(["notice"])
-
-load("@//tools:environments.bzl", "mcu_cpus")
-
 package(
     default_visibility = ["//visibility:public"],
 )
 
+licenses(["notice"])
+
 exports_files([
     "LICENSE",
     "tsconfig.json",
@@ -79,7 +77,6 @@
         "include/flatbuffers/stl_emulation.h",
         "include/flatbuffers/util.h",
     ],
-    compatible_with = mcu_cpus,
     linkstatic = 1,
     strip_include_prefix = "/include",
 )
diff --git a/third_party/flatbuffers/build_defs.bzl b/third_party/flatbuffers/build_defs.bzl
index f9c06f8..4462c8e 100644
--- a/third_party/flatbuffers/build_defs.bzl
+++ b/third_party/flatbuffers/build_defs.bzl
@@ -52,8 +52,10 @@
         reflection_visibility = None,
         compatible_with = None,
         restricted_to = None,
+        target_compatible_with = None,
         output_to_bindir = False):
-    """Generates code files for reading/writing the given flatbuffers in the requested language using the public compiler.
+    """Generates code files for reading/writing the given flatbuffers in the
+    requested language using the public compiler.
 
     Args:
       name: Rule name.
@@ -73,6 +75,8 @@
         built for, in addition to default-supported environments.
       restricted_to: Optional, The list of environments this rule can be built
         for, instead of default-supported environments.
+      target_compatible_with: Optional, the list of constraints the target
+        platform must satisfy for this target to be considered compatible.
       output_to_bindir: Passed to genrule for output to bin directory.
 
 
@@ -108,6 +112,7 @@
         cmd = genrule_cmd,
         compatible_with = compatible_with,
         restricted_to = restricted_to,
+        target_compatible_with = target_compatible_with,
         message = "Generating flatbuffer files for %s:" % (name),
     )
     if reflection_name:
@@ -135,6 +140,7 @@
             tools = [flatc_path],
             compatible_with = compatible_with,
             restricted_to = restricted_to,
+            target_compatible_with = target_compatible_with,
             cmd = reflection_genrule_cmd,
             message = "Generating flatbuffer reflection binary for %s:" % (name),
         )
@@ -157,6 +163,7 @@
         visibility = None,
         compatible_with = None,
         restricted_to = None,
+        target_compatible_with = None,
         srcs_filegroup_visibility = None,
         gen_reflections = False):
     '''A cc_library with the generated reader/writers for the given flatbuffer definitions.
@@ -176,6 +183,8 @@
           (e.g. --gen-mutable).
       visibility: The visibility of the generated cc_library. By default, use the
           default visibility of the project.
+      target_compatible_with: Optional, the list of constraints the target
+        platform must satisfy for this target to be considered compatible.
       srcs_filegroup_visibility: The visibility of the generated srcs filegroup.
           By default, use the value of the visibility parameter above.
       gen_reflections: Optional, if true this will generate the flatbuffer
@@ -239,6 +248,7 @@
         includes = includes,
         include_paths = include_paths,
         flatc_args = flatc_args,
+        target_compatible_with = target_compatible_with,
         compatible_with = compatible_with,
         restricted_to = restricted_to,
         reflection_name = reflection_name,
@@ -261,6 +271,7 @@
         includes = [],
         compatible_with = compatible_with,
         restricted_to = restricted_to,
+        target_compatible_with = target_compatible_with,
         linkstatic = 1,
         visibility = visibility,
     )
@@ -281,6 +292,7 @@
         namespace,
         tables,
         compatible_with = None,
+        target_compatible_with = None,
         includes = [],
         include_paths = DEFAULT_INCLUDE_PATHS,
         flatc_args = DEFAULT_FLATC_ARGS,
@@ -314,12 +326,14 @@
         include_paths = include_paths,
         flatc_args = flatc_args,
         compatible_with = compatible_with,
+        target_compatible_with = target_compatible_with,
     )
     native.py_library(
         name = name,
         srcs = python_files,
         visibility = visibility,
         compatible_with = compatible_with,
+        target_compatible_with = target_compatible_with,
         imports = ["."],
         deps = ["@com_github_google_flatbuffers//:flatpy"],
     )
@@ -328,6 +342,7 @@
         name,
         srcs,
         compatible_with = None,
+        target_compatible_with = None,
         includes = [],
         include_paths = DEFAULT_INCLUDE_PATHS,
         flatc_args = DEFAULT_FLATC_TS_ARGS,
@@ -350,12 +365,14 @@
         include_paths = include_paths,
         flatc_args = flatc_args,
         compatible_with = compatible_with,
+        target_compatible_with = target_compatible_with,
     )
     ts_library(
         name = name,
         srcs = outs,
         visibility = visibility,
         compatible_with = compatible_with,
+        target_compatible_with = target_compatible_with,
         deps = [
             "@npm//@types",
         ],
diff --git a/third_party/flatbuffers/grpc/src/compiler/BUILD b/third_party/flatbuffers/grpc/src/compiler/BUILD
index d3ffd1f..12972c7 100644
--- a/third_party/flatbuffers/grpc/src/compiler/BUILD
+++ b/third_party/flatbuffers/grpc/src/compiler/BUILD
@@ -1,4 +1,3 @@
-
 package(
     default_visibility = ["//visibility:public"],
 )
diff --git a/third_party/flatbuffers/src/BUILD b/third_party/flatbuffers/src/BUILD
index 41968b6..63f0426 100644
--- a/third_party/flatbuffers/src/BUILD
+++ b/third_party/flatbuffers/src/BUILD
@@ -2,7 +2,6 @@
     default_visibility = ["//visibility:private"],
 )
 
-
 # Public flatc library to compile flatbuffer files at runtime.
 cc_library(
     name = "flatbuffers",
diff --git a/third_party/flatbuffers/tests/BUILD b/third_party/flatbuffers/tests/BUILD
index 203a08c..6fbda6b 100644
--- a/third_party/flatbuffers/tests/BUILD
+++ b/third_party/flatbuffers/tests/BUILD
@@ -14,13 +14,13 @@
         "namespace_test/namespace_test2_generated.h",
         "native_type_test_impl.cpp",
         "native_type_test_impl.h",
+        "optional_scalars_generated.h",
         "test.cpp",
         "test_assert.cpp",
         "test_assert.h",
         "test_builder.cpp",
         "test_builder.h",
         "union_vector/union_vector_generated.h",
-        "optional_scalars_generated.h",
     ],
     copts = [
         "-DFLATBUFFERS_TRACK_VERIFIER_BUFFER_SIZE",
@@ -43,6 +43,7 @@
         ":monsterdata_test.golden",
         ":monsterdata_test.json",
         ":native_type_test.fbs",
+        ":optional_scalars.fbs",
         ":prototest/imported.proto",
         ":prototest/test.golden",
         ":prototest/test.proto",
@@ -54,7 +55,6 @@
         ":unicode_test.json",
         ":union_vector/union_vector.fbs",
         ":union_vector/union_vector.json",
-        ":optional_scalars.fbs",
     ],
     includes = [
         "",
diff --git a/third_party/gmp/BUILD b/third_party/gmp/BUILD
index 42c04d6..d4ce062 100644
--- a/third_party/gmp/BUILD
+++ b/third_party/gmp/BUILD
@@ -37,10 +37,11 @@
         "arm",
         "generic",
     ],
-    "@//tools:cpu_cortex_m4f_k22": [
-        "arm",
-        "generic",
-    ],
+    # TODO(phil): Support this properly.
+    #"@//tools:cpu_cortex_m4f_k22": [
+    #    "arm",
+    #    "generic",
+    #],
 }
 
 # gmp's tools leak memory on purpose. Just skip asan for them.
@@ -51,6 +52,7 @@
     srcs = file_from_architecture(architecture_paths, "gmp.h"),
     outs = ["gmp.h"],
     cmd = "cp $< $@",
+    target_compatible_with = ["@platforms//os:linux"],
 )
 
 genrule(
@@ -58,6 +60,7 @@
     srcs = file_from_architecture(architecture_paths, "config.m4"),
     outs = ["config.m4"],
     cmd = "cp $< $@",
+    target_compatible_with = ["@platforms//os:linux"],
 )
 
 copts_common = [
@@ -100,6 +103,7 @@
 
 cc_library(
     name = "bootstrap",
+    target_compatible_with = ["@platforms//os:linux"],
     textual_hdrs = [
         "bootstrap.c",
         "mini-gmp/mini-gmp.c",
@@ -112,6 +116,7 @@
     srcs = ["gen-fac.c"],
     copts = copts,
     features = tool_features,
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [":bootstrap"],
 )
 
@@ -126,6 +131,7 @@
     name = "fac_table_h",
     outs = ["fac_table.h"],
     cmd = "$(location :gen-fac) " + limb_bits + " " + nail_bits + " > $@",
+    target_compatible_with = ["@platforms//os:linux"],
     tools = [":gen-fac"],
 )
 
@@ -134,6 +140,7 @@
     srcs = ["gen-fib.c"],
     copts = copts,
     features = tool_features,
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [":bootstrap"],
 )
 
@@ -141,6 +148,7 @@
     name = "fib_table_h",
     outs = ["fib_table.h"],
     cmd = "$(location :gen-fib) header " + limb_bits + " " + nail_bits + " > $@",
+    target_compatible_with = ["@platforms//os:linux"],
     tools = [":gen-fib"],
 )
 
@@ -148,6 +156,7 @@
     name = "fib_table_c",
     outs = ["mpn/fib_table.c"],
     cmd = "$(location :gen-fib) table " + limb_bits + " " + nail_bits + " > $@",
+    target_compatible_with = ["@platforms//os:linux"],
     tools = [":gen-fib"],
 )
 
@@ -156,6 +165,7 @@
     srcs = ["gen-bases.c"],
     copts = copts,
     features = tool_features,
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [":bootstrap"],
 )
 
@@ -163,6 +173,7 @@
     name = "mp_bases_h",
     outs = ["mp_bases.h"],
     cmd = "$(location :gen-bases) header " + limb_bits + " " + nail_bits + " > $@",
+    target_compatible_with = ["@platforms//os:linux"],
     tools = [":gen-bases"],
 )
 
@@ -170,6 +181,7 @@
     name = "mp_bases_c",
     outs = ["mpn/mp_bases.c"],
     cmd = "$(location :gen-bases) table " + limb_bits + " " + nail_bits + " > $@",
+    target_compatible_with = ["@platforms//os:linux"],
     tools = [":gen-bases"],
 )
 
@@ -178,6 +190,7 @@
     srcs = ["gen-trialdivtab.c"],
     copts = copts,
     features = tool_features,
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [":bootstrap"],
 )
 
@@ -185,6 +198,7 @@
     name = "trialdivtab_h",
     outs = ["trialdivtab.h"],
     cmd = "$(location :gen-trialdivtab) " + limb_bits + " 8000 > $@",
+    target_compatible_with = ["@platforms//os:linux"],
     tools = [":gen-trialdivtab"],
 )
 
@@ -192,6 +206,7 @@
     name = "gen-jacobitab",
     srcs = ["gen-jacobitab.c"],
     copts = copts,
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [":bootstrap"],
 )
 
@@ -199,6 +214,7 @@
     name = "jacobitab_h",
     outs = ["mpn/jacobitab.h"],
     cmd = "$(location :gen-jacobitab) > $@",
+    target_compatible_with = ["@platforms//os:linux"],
     tools = [":gen-jacobitab"],
 )
 
@@ -206,6 +222,7 @@
     name = "gen-psqr",
     srcs = ["gen-psqr.c"],
     copts = copts,
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [":bootstrap"],
 )
 
@@ -213,6 +230,7 @@
     name = "perfsqr_h",
     outs = ["mpn/perfsqr.h"],
     cmd = "$(location :gen-psqr) " + limb_bits + " " + nail_bits + " > $@",
+    target_compatible_with = ["@platforms//os:linux"],
     tools = [":gen-psqr"],
 )
 
@@ -453,6 +471,7 @@
     mpn_m4_cc_library(
         name = x,
         architecture_paths = architecture_paths,
+        target_compatible_with = ["@platforms//os:linux"],
     )
     for x in gmp_mpn_functions
 ]
@@ -493,6 +512,7 @@
         "-Wno-unused-command-line-argument",
         "-Wa,--noexecstack",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
 )
 
 # TODO(austin): Can we run these through the mpn_m4_cc_library and get operation baked in without work?
@@ -502,6 +522,7 @@
         "mpn/fib_table.c",
     ],
     copts = copts,
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [":mpn_core"],
 )
 
@@ -511,11 +532,13 @@
         "mpn/mp_bases.c",
     ],
     copts = copts,
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [":mpn_core"],
 )
 
 cc_library(
     name = "mpn",
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":fib_table",
         ":mp_bases",
@@ -692,6 +715,7 @@
         "mpz/xor.c",
     ],
     copts = copts,
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":mpn",
     ],
@@ -734,6 +758,7 @@
         "mpq/swap.c",
     ],
     copts = copts,
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":mpn",
     ],
@@ -813,6 +838,7 @@
         "mpf/urandomb.c",
     ],
     copts = copts,
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":mpn",
     ],
@@ -844,6 +870,7 @@
         "printf/vsprintf.c",
     ],
     copts = copts,
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":mpn",
     ],
@@ -863,6 +890,7 @@
         "scanf/vsscanf.c",
     ],
     copts = copts,
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":mpn",
     ],
@@ -887,6 +915,7 @@
         "rand/randsdui.c",
     ],
     copts = copts,
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":mpn",
     ],
@@ -908,6 +937,7 @@
         "cxx/osmpz.cc",
     ],
     copts = ccopts,
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":mpn",
     ],
@@ -916,6 +946,7 @@
 cc_library(
     name = "gmp",
     includes = ["."],
+    target_compatible_with = ["@platforms//os:linux"],
     visibility = ["//visibility:public"],
     deps = [
         ":cxx",
@@ -941,6 +972,7 @@
               "amd64": "amd64call.asm",
           }) +
           " > $${ROOT}/$@",
+    target_compatible_with = ["@platforms//os:linux"],
     tools = [
         "@m4_v1.4.18//:bin",
         "@m4_v1.4.18//:lib",
@@ -977,6 +1009,7 @@
         ".",
         "tests",
     ] + ["mpn/" + p for p in architecture_paths],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [":gmp"],
 )
 
@@ -984,6 +1017,7 @@
     name = "tests/" + x,
     srcs = ["tests/" + x + ".c"],
     copts = copts,
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [":testlib"],
 ) for x in [
     "t-bswap",
@@ -1000,6 +1034,7 @@
     name = "tests/mpn/" + x,
     srcs = ["tests/mpn/" + x + ".c"],
     copts = copts,
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [":testlib"],
 ) for x in [
     "t-asmtype",
@@ -1058,6 +1093,7 @@
     name = "tests/mpz/" + x,
     srcs = ["tests/mpz/" + x + ".c"],
     copts = copts,
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [":testlib"],
 ) for x in [
     "reuse",
@@ -1130,6 +1166,7 @@
     name = "tests/mpq/" + x,
     srcs = ["tests/mpq/" + x + ".c"],
     copts = copts,
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [":testlib"],
 ) for x in [
     "t-aors",
@@ -1153,6 +1190,7 @@
     name = "tests/mpf/" + x,
     srcs = ["tests/mpf/" + x + ".c"],
     copts = copts,
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [":testlib"],
 ) for x in [
     "t-dm2exp",
@@ -1189,6 +1227,7 @@
     name = "tests/rand/" + x,
     srcs = ["tests/rand/" + x + ".c"],
     copts = copts,
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [":testlib"],
 ) for x in [
     "t-iset",
@@ -1204,6 +1243,7 @@
     name = "tests/misc/" + x,
     srcs = ["tests/misc/" + x + ".c"],
     copts = copts,
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [":testlib"],
 ) for x in [
     "t-printf",
@@ -1215,6 +1255,7 @@
     name = "tests/cxx/" + x,
     srcs = ["tests/cxx/" + x + ".cc"],
     copts = copts,
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [":testlib"],
 ) for x in [
     "t-binary",
diff --git a/third_party/gmp/mpn.bzl b/third_party/gmp/mpn.bzl
index 039725f..668df8d 100644
--- a/third_party/gmp/mpn.bzl
+++ b/third_party/gmp/mpn.bzl
@@ -56,7 +56,8 @@
         srcs,
         hdrs = [],
         copts = [],
-        deps = []):
+        deps = [],
+        target_compatible_with = None):
     native.cc_library(
         name = name,
         srcs = srcs,
@@ -70,6 +71,7 @@
             "-DOPERATION_" + name,
         ],
         deps = deps,
+        target_compatible_with = target_compatible_with,
     )
 
 def _m4_mpn_function_impl(ctx):
@@ -164,7 +166,7 @@
         result[key] = ["-I" + current_directory() + "/config/" + architecture_paths[key][0] + "/"]
     return select(result)
 
-def mpn_m4_cc_library(name, architecture_paths):
+def mpn_m4_cc_library(name, architecture_paths, target_compatible_with = None):
     # Search architecture_paths in order from 0 to N.
     # From there, search starting with the main name, then start looking at the alternatives.
     # And then look for .c or .asm
@@ -190,4 +192,5 @@
         operation = name,
         files = select(architecture_globs),
         deps = native.glob(["**/*.m4", "**/*.asm"]) + ["config.m4"],
+        target_compatible_with = target_compatible_with,
     )
diff --git a/third_party/google-benchmark/test/BUILD b/third_party/google-benchmark/test/BUILD
index 8d1ef8d..4ab8633 100644
--- a/third_party/google-benchmark/test/BUILD
+++ b/third_party/google-benchmark/test/BUILD
@@ -10,17 +10,17 @@
     "-fstrict-aliasing",
 ]
 
-PER_SRC_COPTS = ({
+PER_SRC_COPTS = {
     "cxx03_test.cc": ["-std=c++03"],
     # Some of the issues with DoNotOptimize only occur when optimization is enabled
     "donotoptimize_test.cc": ["-O3"],
-})
+}
 
 TEST_ARGS = ["--benchmark_min_time=0.01"]
 
-PER_SRC_TEST_ARGS = ({
+PER_SRC_TEST_ARGS = {
     "user_counters_tabular_test.cc": ["--benchmark_counters_tabular=true"],
-})
+}
 
 cc_library(
     name = "output_test_helper",
diff --git a/third_party/gperftools/BUILD b/third_party/gperftools/BUILD
index de30a96..7813282 100644
--- a/third_party/gperftools/BUILD
+++ b/third_party/gperftools/BUILD
@@ -142,6 +142,7 @@
         "-lpthread",
     ],
     nocopts = "-std=gnu\\+\\+1y",
+    target_compatible_with = ["@platforms//os:linux"],
     visibility = ["//visibility:public"],
     deps = [
         "//third_party/empty_config_h",
@@ -158,6 +159,7 @@
         "src/tests/testutil.h",
     ],
     copts = common_copts,
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":tcmalloc",
     ],
@@ -173,6 +175,7 @@
     defines = [
         "NO_TCMALLOC_SAMPLES",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":tcmalloc",
     ],
@@ -185,6 +188,7 @@
         "src/tests/atomicops_unittest.cc",
     ],
     copts = common_copts,
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":tcmalloc",
     ],
@@ -197,6 +201,7 @@
         "src/tests/stacktrace_unittest.cc",
     ],
     copts = common_copts,
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":tcmalloc",
     ],
@@ -213,6 +218,7 @@
         #Add this back in when we upgrade clang.
         #'-Wno-mismatched-new-delete',
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":tcmalloc",
         ":testutil",
@@ -228,6 +234,7 @@
     copts = common_copts + [
         "-fno-builtin",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":tcmalloc",
     ],
@@ -240,6 +247,7 @@
         "src/tests/addressmap_unittest.cc",
     ],
     copts = common_copts,
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":tcmalloc",
     ],
@@ -254,6 +262,7 @@
     copts = common_copts + [
         "-fno-builtin",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":tcmalloc",
     ],
@@ -266,6 +275,7 @@
         "src/tests/packed-cache_test.cc",
     ],
     copts = common_copts,
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":tcmalloc",
     ],
@@ -278,6 +288,7 @@
         "src/tests/frag_unittest.cc",
     ],
     copts = common_copts,
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":tcmalloc",
     ],
@@ -290,6 +301,7 @@
         "src/tests/markidle_unittest.cc",
     ]),
     copts = common_copts,
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":tcmalloc",
         ":testutil",
@@ -303,6 +315,7 @@
         "src/tests/current_allocated_bytes_test.cc",
     ],
     copts = common_copts,
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":tcmalloc",
     ],
@@ -320,6 +333,7 @@
         ],
         "clang": [],
     }),
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":tcmalloc",
         ":testutil",
@@ -333,6 +347,7 @@
         "src/tests/malloc_extension_test.cc",
     ]),
     copts = common_copts,
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":tcmalloc",
     ],
@@ -345,6 +360,7 @@
         "src/tests/malloc_extension_c_test.c",
     ]),
     copts = common_copts,
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":tcmalloc",
     ],
@@ -357,6 +373,7 @@
         "src/tests/memalign_unittest.cc",
     ]),
     copts = common_copts,
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":tcmalloc",
         ":testutil",
@@ -370,6 +387,7 @@
         "src/tests/page_heap_test.cc",
     ],
     copts = common_copts,
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":tcmalloc",
     ],
@@ -382,6 +400,7 @@
         "src/tests/pagemap_unittest.cc",
     ]),
     copts = common_copts,
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":tcmalloc",
     ],
@@ -394,6 +413,7 @@
         "src/tests/realloc_unittest.cc",
     ],
     copts = common_copts,
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":tcmalloc",
     ],
@@ -406,6 +426,7 @@
         "src/tests/stack_trace_table_test.cc",
     ],
     copts = common_copts,
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":tcmalloc",
     ],
@@ -418,6 +439,7 @@
         "src/tests/thread_dealloc_unittest.cc",
     ],
     copts = common_copts,
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":tcmalloc",
         ":testutil",
@@ -446,6 +468,7 @@
         "src/tests/large_heap_fragmentation_unittest.cc",
     ]),
     copts = common_copts,
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":tcmalloc",
     ],
@@ -458,6 +481,7 @@
         "src/tests/raw_printer_test.cc",
     ],
     copts = common_copts,
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":tcmalloc",
     ],
@@ -470,6 +494,7 @@
         "src/tests/getpc_test.cc",
     ]),
     copts = common_copts,
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":tcmalloc",
     ],
@@ -482,6 +507,7 @@
         "src/tests/profiledata_unittest.cc",
     ],
     copts = common_copts,
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":tcmalloc",
     ],
@@ -495,6 +521,7 @@
     ],
     copts = common_copts,
     flaky = True,
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":tcmalloc",
     ],
@@ -507,6 +534,7 @@
         "src/tests/heap-profiler_unittest.cc",
     ],
     copts = common_copts,
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":tcmalloc",
     ],
@@ -521,6 +549,7 @@
     copts = common_copts + [
         "-Wno-type-limits",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         ":tcmalloc",
     ],
diff --git a/third_party/hpipm/BUILD b/third_party/hpipm/BUILD
index f152d5a..adae276 100644
--- a/third_party/hpipm/BUILD
+++ b/third_party/hpipm/BUILD
@@ -66,7 +66,7 @@
         "-Wno-unused-parameter",
     ],
     includes = ["include"],
-    restricted_to = ["//tools:k8"],
+    target_compatible_with = ["@platforms//cpu:x86_64"],
     textual_hdrs = [
         "ocp_qp/x_ocp_qp_sol.c",
         "dense_qp/x_dense_qp.c",
diff --git a/third_party/jsont/BUILD b/third_party/jsont/BUILD
index dc1d03d..be9e94d 100644
--- a/third_party/jsont/BUILD
+++ b/third_party/jsont/BUILD
@@ -9,6 +9,7 @@
         "jsont.h",
     ],
     includes = ["."],
+    target_compatible_with = ["@platforms//os:linux"],
     visibility = ["//visibility:public"],
 )
 
@@ -24,5 +25,6 @@
         ],
         "//conditions:default": [],
     }),
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [":jsont"],
 )
diff --git a/third_party/libevent/BUILD b/third_party/libevent/BUILD
index 347ec0b..744a019 100644
--- a/third_party/libevent/BUILD
+++ b/third_party/libevent/BUILD
@@ -169,6 +169,7 @@
         ".",
         "include",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     textual_hdrs = [
         "arc4random.c",
     ],
diff --git a/third_party/libjpeg/BUILD b/third_party/libjpeg/BUILD
index f5b2d12..0b34cb7 100644
--- a/third_party/libjpeg/BUILD
+++ b/third_party/libjpeg/BUILD
@@ -77,5 +77,6 @@
         "//conditions:default": [],
     }),
     includes = ["src/main/c"],
+    target_compatible_with = ["@platforms//os:linux"],
     visibility = ["//visibility:public"],
 )
diff --git a/third_party/lksctp-tools/BUILD b/third_party/lksctp-tools/BUILD
index b127b77..f6edcb5 100644
--- a/third_party/lksctp-tools/BUILD
+++ b/third_party/lksctp-tools/BUILD
@@ -9,6 +9,7 @@
         "src/include/netinet/sctp.h",
     ],
     cmd = "cp $< $@",
+    target_compatible_with = ["@platforms//os:linux"],
 )
 
 cc_library(
@@ -31,5 +32,6 @@
     includes = [
         "src/include",
     ],
+    target_compatible_with = ["@platforms//os:linux"],
     visibility = ["//visibility:public"],
 )
diff --git a/third_party/matplotlib-cpp/BUILD b/third_party/matplotlib-cpp/BUILD
index 95f7192..4f1f004 100644
--- a/third_party/matplotlib-cpp/BUILD
+++ b/third_party/matplotlib-cpp/BUILD
@@ -9,7 +9,7 @@
         "@matplotlib_repo//:matplotlib3",
         "@python_repo//:all_files",
     ],
-    restricted_to = ["//tools:k8"],
+    target_compatible_with = ["@platforms//os:linux"],
     visibility = ["//visibility:public"],
     deps = [
         "@python_repo//:python3.5_lib",
@@ -21,7 +21,7 @@
     srcs = [
         "examples/basic.cpp",
     ],
-    restricted_to = ["//tools:k8"],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         "matplotlib-cpp",
     ],
@@ -32,7 +32,7 @@
     srcs = [
         "examples/animation.cpp",
     ],
-    restricted_to = ["//tools:k8"],
+    target_compatible_with = ["@platforms//os:linux"],
     deps = [
         "matplotlib-cpp",
     ],
diff --git a/third_party/protobuf/protobuf.bzl b/third_party/protobuf/protobuf.bzl
index a125606..ae3ea54 100644
--- a/third_party/protobuf/protobuf.bzl
+++ b/third_party/protobuf/protobuf.bzl
@@ -209,7 +209,7 @@
         internal_bootstrap_hack=False,
         use_grpc_plugin=False,
         default_runtime="@com_google_protobuf//:protobuf",
-        compatible_with = None,
+        target_compatible_with = None,
         copts = [],
         **kargs):
   """Bazel rule to create a C++ protobuf library from proto source files
@@ -277,7 +277,7 @@
       plugin_language="grpc",
       gen_cc=1,
       outs=outs,
-      compatible_with = compatible_with,
+      target_compatible_with = target_compatible_with,
       visibility=["//visibility:public"],
   )
 
@@ -293,7 +293,7 @@
       deps=cc_libs + deps,
       includes=includes,
       copts = COPTS + copts,
-      compatible_with = compatible_with,
+      target_compatible_with = target_compatible_with,
       **kargs)
 
 def internal_gen_well_known_protos_java(srcs):
diff --git a/third_party/pycrc/BUILD b/third_party/pycrc/BUILD
index 50a21e1..5c71234 100644
--- a/third_party/pycrc/BUILD
+++ b/third_party/pycrc/BUILD
@@ -9,6 +9,7 @@
         "pycrc_main.py",
     ],
     cmd = "cp $< $@",
+    target_compatible_with = ["@platforms//os:linux"],
 )
 
 py_binary(
@@ -21,5 +22,6 @@
     imports = ["."],
     legacy_create_init = False,
     main = "pycrc_main.py",
+    target_compatible_with = ["@platforms//os:linux"],
     visibility = ["//visibility:public"],
 )
diff --git a/third_party/seasocks/BUILD b/third_party/seasocks/BUILD
index e2b13eb..db37def 100644
--- a/third_party/seasocks/BUILD
+++ b/third_party/seasocks/BUILD
@@ -23,5 +23,6 @@
         "-Wno-unused-parameter",
     ],
     includes = ["src/main/c"],
+    target_compatible_with = ["@platforms//os:linux"],
     visibility = ["//visibility:public"],
 )