Delete platform_mappings and switch to platform suffixes

As far as I can tell, we only stuck with the `--cpu` legacy mechanism
to get different output bases for each platform. This can be achieved
with `--platform_suffix` as well.

I want folks (especially students) to move away from thinking about
compiling for specific CPUs. Instead the students should think of
target platforms. Along the lines of "I want to build for the Pi"
instead of "I want to build for an armv7 machine". The renaming of
config options will happen in a future patch. This patch just changes
everything over to use equivalent config options.

Sample paths for Linux-based targets:

    $ for config in k8 roborio armv7 arm64 cortex-m4f rp2040; do bazel cquery //build_tests:tcmalloc_build_test_binary --output=starlark --starlark:expr='providers(target)["FilesToRunProvider"].executable.path' --config=${config} 2>/dev/null; done
    bazel-out/k8-fastbuild/bin/build_tests/tcmalloc_build_test_binary
    bazel-out/k8-fastbuild-roborio/bin/build_tests/tcmalloc_build_test_binary
    bazel-out/k8-fastbuild-armv7/bin/build_tests/tcmalloc_build_test_binary
    bazel-out/k8-fastbuild-arm64/bin/build_tests/tcmalloc_build_test_binary

Sample paths for embedded targets:

    $ for config in k8 roborio armv7 arm64 cortex-m4f rp2040; do bazel cquery //motors:simple_receiver.elf --output=starlark --starlark:expr='providers(target)["FilesToRunProvider"].executable.path' --config=${config} 2>/dev/null; done
    bazel-out/k8-fastbuild-cortex-m4f/bin/motors/simple_receiver.elf

It's unfortunate that all the names start with `k8-fastbuild`, but I
don't see a way around this.

In our own code the `--cpu` option appears to be used in a meaningful
way only in abseil. I patched one `config_setting` that was checking
for `--cpu=k8` and replaced it with a check for the
`@platforms//cpu:x86_64` constraint. Other than that, it doesn't look
like anything's making use of it.

    $ git grep '"cpu":' -- '*BUILD*' '*bzl'
    third_party/abseil/absl/BUILD.bazel:        "cpu": "ppc",
    third_party/abseil/absl/BUILD.bazel:        "cpu": "wasm32",
    third_party/abseil/absl/copts/configure_copts.bzl:            values = {"cpu": cpu},
    third_party/bazel-toolchain/bazel_tools_changes/tools/cpp/unix_cc_toolchain_config.bzl:        "cpu": attr.string(mandatory = True),
    third_party/gflags/BUILD:    values = {"cpu": "x64_windows"},
    third_party/google-benchmark/BUILD.bazel:        "cpu": "x64_windows",
    tools/cpp/toolchain_config.bzl:        "cpu": attr.string(mandatory = True, values = ["cortex-m4f", "cortex-m4f-k22", "roborio", "rp2040"]),

I looked through our external dependencies to see if any of them need
to be fixed up, but it doesn't look like it.

    $ bazel fetch //...
    $ grep -rnI --include='*BUILD*' --include='*.bzl' '"cpu":' -- '*BUILD*' '*bzl' external/
    grep: *BUILD*: No such file or directory
    grep: *bzl: No such file or directory
    external/rules_python/python/BUILD:77:#         values = {"cpu": "arm"},
    external/boringssl/src/util/BUILD.toplevel:39:    values = {"cpu": "k8"},
    external/boringssl/src/util/BUILD.toplevel:44:    values = {"cpu": "ppc"},
    external/boringssl/src/util/BUILD.toplevel:49:    values = {"cpu": "darwin"},
    external/boringssl/src/util/BUILD.toplevel:54:    values = {"cpu": "x64_windows"},
    external/boringssl/BUILD:56:    values = {"cpu": "ppc"},
    external/boringssl/BUILD:61:    values = {"cpu": "darwin"},
    external/boringssl/BUILD:66:    values = {"cpu": "x64_windows"},
    external/com_github_bazelbuild_buildtools/BUILD.bazel:11:    values = {"cpu": "x64_windows"},
    external/rules_cc/cc/private/toolchain/unix_cc_toolchain_config.bzl:1180:        "cpu": attr.string(mandatory = True),
    external/rules_cc/cc/private/toolchain/cc_toolchain_config.bzl:1486:        "cpu": attr.string(mandatory = True),
    external/rules_cc/cc/private/toolchain/windows_cc_toolchain_config.bzl:1321:        "cpu": attr.string(mandatory = True),
    external/rules_cc/cc/private/toolchain/freebsd_cc_toolchain_config.bzl:303:        "cpu": attr.string(mandatory = True),
    external/io_bazel_rules_go/tests/legacy/examples/cgo/cc_dependency/BUILD.bazel:3:    values = {"cpu": "darwin"},

I also added an OBJCOPY make variable that supports platforms. The
`@bazel_tools//tools/cpp:current_cc_toolchain` target that we were
using doesn't seem to work with platforms.

Change-Id: I7a3dff63a55e6bc5d637dd700473f4fd1351bdbd
Signed-off-by: Philipp Schrader <philipp.schrader@gmail.com>
diff --git a/tools/cpp/toolchain_make_variables.bzl b/tools/cpp/toolchain_make_variables.bzl
new file mode 100644
index 0000000..7c06e1d
--- /dev/null
+++ b/tools/cpp/toolchain_make_variables.bzl
@@ -0,0 +1,39 @@
+load("@bazel_tools//tools/cpp:toolchain_utils.bzl", "find_cpp_toolchain")
+
+def _cc_toolchain_make_variables_impl(ctx):
+    """Supports make variables for toolchains in a platforms setup.
+
+    The upstream @bazel_tools//tools/cpp:current_cc_toolchain target on its own
+    doesn't appear to work with platforms. It only works when using --cpu.
+    """
+    toolchain = find_cpp_toolchain(ctx)
+
+    feature_configuration = cc_common.configure_features(
+        ctx = ctx,
+        cc_toolchain = toolchain,
+        requested_features = ctx.features,
+        unsupported_features = ctx.disabled_features,
+    )
+    objcopy = cc_common.get_tool_for_action(
+        feature_configuration = feature_configuration,
+        action_name = "objcopy_embed_data",
+    )
+
+    return [
+        platform_common.TemplateVariableInfo({
+            "OBJCOPY": objcopy,
+        }),
+        DefaultInfo(files = toolchain.all_files),
+    ]
+
+cc_toolchain_make_variables = rule(
+    implementation = _cc_toolchain_make_variables_impl,
+    attrs = {
+        # This is a dependency of find_cpp_toolchain().
+        "_toolchain": attr.label(
+            default = Label("@bazel_tools//tools/cpp:current_cc_toolchain"),
+        ),
+    },
+    fragments = ["cpp"],
+    toolchains = ["@bazel_tools//tools/cpp:toolchain_type"],
+)