Skip to content

Commit 8b3496e

Browse files
Update the debugging playbook to add a section on prebuilt protoc issues.
PiperOrigin-RevId: 859182682
1 parent b2d23b5 commit 8b3496e

File tree

2 files changed

+51
-0
lines changed

2 files changed

+51
-0
lines changed

content/news/2026-01-16.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,11 @@ There are some use cases in which using the prebuilt protoc is not recommended:
3333
* You are making changes to protoc, itself, and want to ensure that those
3434
changes are tested.
3535

36+
### Troubleshooting
37+
38+
For information on troubleshooting the prebuilt protoc compiler configuration,
39+
see
40+
[Bazel: Resolving Issues with Prebuilt Protoc](/support/debugging-playbook#prebuilt-protoc)
41+
3642
For more information on other changes in Bazel 9 that affect Protocol Buffers,
3743
see https://bazel.build/about/roadmap.
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
+++
2+
title = "Debugging"
3+
weight = 915
4+
description = "Debugging common issues in Protocol Buffers."
5+
type = "docs"
6+
+++
7+
8+
Frequently asked questions and debugging scenarios encountered by protobuf
9+
users.
10+
11+
<!--*
12+
# Document freshness: For more information, see go/fresh-source.
13+
freshness: { owner: 'sangki' reviewed: '2025-02-11' }
14+
*-->
15+
16+
## Bazel: Resolving Issues with Prebuilt Protoc {#prebuilt-protoc}
17+
18+
As mentioned in [this news article](/news/2026-01-16),
19+
Bazel 7 and later support builds that use a prebuilt protoc. When everything is
20+
configured correctly, this can save a lot of time building, reduce logging
21+
volume, and eliminate the need for C++ toolchain in non-C++ implementations.
22+
23+
To prevent protoc compilation from source, add the following to your `.bazelrc`
24+
file:
25+
26+
```bazel
27+
common --per_file_copt=external/.*protobuf.*@--PROTOBUF_WAS_NOT_SUPPOSED_TO_BE_BUILT
28+
common --host_per_file_copt=external/.*protobuf.*@--PROTOBUF_WAS_NOT_SUPPOSED_TO_BE_BUILT
29+
common --per_file_copt=external/.*grpc.*@--GRPC_WAS_NOT_SUPPOSED_TO_BE_BUILT
30+
common --host_per_file_copt=external/.*grpc.*@--GRPC_WAS_NOT_SUPPOSED_TO_BE_BUILT
31+
```
32+
33+
When there are hard-coded references to `@com_google_protobuf//:protoc` that are
34+
reachable by the dependency graph, protoc will force it to be built for those
35+
cases, negating this benefit. To resolve this, you'll need to find where the
36+
dependencies are and request that those rulesets be updated.
37+
38+
To find where you depend on protoc, use the following command:
39+
40+
```none
41+
bazel cquery 'somepath("//...", "@com_google_protobuf//:all")'
42+
```
43+
44+
**Note:** Prebuilts are only available for our standard set of platforms. Anyone
45+
on a nonstandard platform will have to build protoc from source.

0 commit comments

Comments
 (0)