diff --git a/src/main/starlark/builtins_bzl/common/cc/cc_proto_library.bzl b/src/main/starlark/builtins_bzl/common/cc/cc_proto_library.bzl index 042ee384ab1341..4d2efef8d21624 100644 --- a/src/main/starlark/builtins_bzl/common/cc/cc_proto_library.bzl +++ b/src/main/starlark/builtins_bzl/common/cc/cc_proto_library.bzl @@ -267,6 +267,7 @@ _cc_proto_aspect = aspect( ), "_cc_toolchain": attr.label(default = "@bazel_tools//tools/cpp:current_cc_toolchain"), }, + toolchains = cc_helper.use_cpp_toolchain(), ) def _impl(ctx): diff --git a/src/test/shell/bazel/bazel_proto_library_test.sh b/src/test/shell/bazel/bazel_proto_library_test.sh index c41b4e1e678c13..17c064aac38c90 100755 --- a/src/test/shell/bazel/bazel_proto_library_test.sh +++ b/src/test/shell/bazel/bazel_proto_library_test.sh @@ -565,6 +565,35 @@ EOF bazel build //a:c || fail "build failed" } +function test_cc_proto_library_with_toolchain_resolution() { + write_workspace "" + mkdir -p a + cat > a/BUILD < a/p.proto < a/c.cc <