//build/toolchain/musl-host-gcc: implement

This is a cc_toolchain which runs on x86 systems with Linux/gcc and
targets Smalltown via static musl builds.

It is currently unused, but can be tested by trying to build any
cc_binary with
--crosstool_top=//build/toolchain/musl-host-gcc:musl_host_cc_suite .

Test Plan: This has been tested manually by running it against a simple cc_binary. Another revision on top of this will attempt to build mkfs.xfs with it.

X-Origin-Diff: phab/D623
GitOrigin-RevId: ebdf51ee76d9d5a7fd94725c66ef53783f787df7
diff --git a/build/toolchain/musl-host-gcc/BUILD b/build/toolchain/musl-host-gcc/BUILD
new file mode 100644
index 0000000..95a59f6
--- /dev/null
+++ b/build/toolchain/musl-host-gcc/BUILD
@@ -0,0 +1,45 @@
+load("//build/toolchain:cc_toolchain_config.bzl", "host_cc_toolchain_config")
+
+# This file defines //build/toolchain/musl-host-gcc:musl_host_cc_suite.
+#
+# This is a C++ toolchain that uses GCC from the host at hardcoded paths, with
+# a pre-built sysroot tarball that targets Smalltown with musl and Linux headers.
+# It's a superset of //build/toolchain:host_cc_suite.
+# For more information, see README.md.
+
+cc_toolchain_suite(
+    name = "musl_host_cc_suite",
+    toolchains = {
+        "k8": ":musl_host_cc_k8_toolchain",
+    },
+    visibility = ["//visibility:public"],
+)
+
+cc_toolchain(
+    name = "musl_host_cc_k8_toolchain",
+    all_files = ":musl_toolchain_files",
+    compiler_files = ":musl_toolchain_files",
+    dwp_files = ":musl_toolchain_files",
+    linker_files = ":musl_toolchain_files",
+    objcopy_files = ":musl_toolchain_files",
+    strip_files = ":musl_toolchain_files",
+    supports_param_files = 0,
+    toolchain_config = ":musl_host_cc_k8_toolchain_config",
+    toolchain_identifier = "host-musl-k8-toolchain",
+)
+
+host_cc_toolchain_config(
+    name = "musl_host_cc_k8_toolchain_config",
+    gcc = "gcc-wrapper.sh",
+    host_includes = [],
+    sysroot = "external/musl_sysroot",
+)
+
+filegroup(
+    name = "musl_toolchain_files",
+    srcs = [
+        ":gcc-wrapper.sh",
+        ":musl.spec",
+        "@musl_sysroot//:all",
+    ],
+)