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/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",
],