From 72e6e948d30dec9dec60d78efef4eeda5b764a8f Mon Sep 17 00:00:00 2001 From: kshyanashree <109167932+kshyanashree@users.noreply.github.com> Date: Fri, 4 Nov 2022 12:06:24 -0700 Subject: [PATCH] [cc] Add cc toolchain to starlark cc_proto_library (#16661) Fixes https://github.com/bazelbuild/bazel/issues/16577 Closes #16585. PiperOrigin-RevId: 485600476 Change-Id: I3c2985731ff800a2c6136f401ed3c7e5e89518ad Co-authored-by: Yannic --- .../common/cc/cc_proto_library.bzl | 1 + .../shell/bazel/bazel_proto_library_test.sh | 29 +++++++++++++++++++ 2 files changed, 30 insertions(+) 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 <