From ba73788f2ce73fcb79376a7795f20d03a3829bca Mon Sep 17 00:00:00 2001 From: Etienne Perot Date: Wed, 30 Nov 2022 13:59:00 -0800 Subject: [PATCH] gvisor: Explicitly register C++ toolchains for cross-compilation. Bazel >= 5 seems to no longer implicitly recognize coral_crosstool's C++ toolchains when looking through the possible set of toolchains to use for compiling C++ (`@bazel_tools//tools/cpp:toolchain_type`). This change explicitly registers these toolchains within `WORKSPACE`. PiperOrigin-RevId: 492011138 --- BUILD | 22 ++++++++++++++++++++++ WORKSPACE | 1 + 2 files changed, 23 insertions(+) diff --git a/BUILD b/BUILD index fb4b4014b..f43350875 100644 --- a/BUILD +++ b/BUILD @@ -145,6 +145,28 @@ go_path( ], ) +# CC toolchain targets for cross-compilation. +# Required to be explicitly specified in bazel >= 5. +toolchain( + name = "cc_toolchain_k8", + target_compatible_with = [ + "@platforms//os:linux", + "@platforms//cpu:x86_64", + ], + toolchain = "@crosstool//:cc-compiler-k8", + toolchain_type = "@bazel_tools//tools/cpp:toolchain_type", +) + +toolchain( + name = "cc_toolchain_aarch64", + target_compatible_with = [ + "@platforms//os:linux", + "@platforms//cpu:aarch64", + ], + toolchain = "@crosstool//:cc-compiler-aarch64", + toolchain_type = "@bazel_tools//tools/cpp:toolchain_type", +) + # gazelle is a set of build tools. # # To update the WORKSPACE from go.mod, use: diff --git a/WORKSPACE b/WORKSPACE index 8b589dbe5..3819acea9 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -137,6 +137,7 @@ http_archive( load("@coral_crosstool//:configure.bzl", "cc_crosstool") cc_crosstool(name = "crosstool") +register_toolchains("//:cc_toolchain_k8", "//:cc_toolchain_aarch64") # Load protobuf dependencies. http_archive(