Prebuilt-protoc broken in 37.0-rc1

Open
#30,777 0 comments 0 reactions 1 assignee View on GitHub

Maintainers usually reply within 1 day

@haberman is already working on this.

Since Oct 20, 2026.

Assessment

Difficulty
4/5
Estimated time
3-5 days
Newbie friendliness
48/100
Issue type
Bug
Clarity
Mostly clear
Activity status
Active
Tech stack
cpp

Research direction

Start by reproducing the failure with the issue’s minimal MODULE.bazel, BUILD.bazel, and .bazelrc setup using bazel build //...; the poison-pill compile option shows that protobuf is being built despite the prebuilt-protoc settings. Read the Bazel toolchain-resolution and prebuilt-protoc flag configuration referenced in the .bazelrc, then compare behavior with protobuf 36.2. Done means the 37.0-rc1 build uses prebuilt protoc without compiling protobuf.

Written by the indexing model from the issue text.

Description

bazel bug packaging & distribution

What version of protobuf and what language are you using?

Version: 37.0-rc1

Language: Proto

What
supported operating system version
are you using (e.g. Linux, Windows) ?

Linux

What
supported runtime / compiler version
are you using (e.g. python version, gcc version)

bazel --version
bazel 9.3.0

I am not configuring a c++ or python toolchain in bazel explicitly. These are my host toolchains.

gcc --version
gcc (GCC) 16.2.1 20260819 (Red Hat 16.2.1-2)
Copyright (C) 2026 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
python --version
Python 3.14.8

What did you do?

Steps to reproduce the behavior:
You can reproduce this with a super simple repo.

.
├── .bazelrc
├── BUILD.bazel
├── foo.proto
├── MODULE.bazel
└── MODULE.bazel.lock

.bazelrc

# Force pre-built protoc
common --incompatible_enable_proto_toolchain_resolution
common --@protobuf//bazel/flags:allow_nonstandard_protoc=true
common --@protobuf//bazel/toolchains:prefer_prebuilt_protoc=true
common --@protobuf//bazel/flags:prefer_prebuilt_protoc=true

# Set toolchain to pre-built protoc
common --noincompatible_exclude_starlark_flags_from_exec_config
common --experimental_propagate_custom_flag=@protobuf//bazel/flags:prefer_prebuilt_protoc

# Poison pill that fails build if protoc is compiled
common --host_per_file_copt=external/.*protobuf.*@--PROTOBUF_WAS_NOT_SUPPOSED_TO_BE_BUILT

BUILD.bazel

load("@protobuf//bazel:proto_library.bzl", "proto_library")

proto_library(
    name = "foo",
    srcs = ["foo.proto"],
)

foo.proto

syntax = "proto3";

package foo;

MODULE.bazel

module(name = "test")

bazel_dep(name = "protobuf", version = "37.0-rc1")

You can trigger the poison pill by building all targets.

bazel build //...
INFO: Analyzed target //:foo (1 packages loaded, 5 targets configured).
ERROR: /home/my-user/.cache/bazel/_bazel_monolith/9e64523796ff1373614a9e266ee6e99b/external/protobuf+/third_party/utf8_range/BUILD.bazel:40:11: Compiling third_party/utf8_range/utf8_range.c [for tool] failed: (Exit 1): gcc failed: error executing CppCompile command (from cc_library rule target @@protobuf+//third_party/utf8_range:utf8_range) /usr/bin/gcc -U_FORTIFY_SOURCE -fstack-protector -Wall -Wunused-but-set-parameter -Wno-free-nonheap-object -fno-omit-frame-pointer -g0 -O2 '-D_FORTIFY_SOURCE=1' -DNDEBUG -ffunction-sections ... (remaining 21 arguments skipped)

Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging
gcc: error: unrecognized command-line option '--PROTOBUF_WAS_NOT_SUPPOSED_TO_BE_BUILT'
Target //:foo failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 0.237s, Critical Path: 0.06s
INFO: 54 processes: 54 internal.
ERROR: Build did NOT complete successfully

You can get this to build again by rolling back to 36.2.

sed -i s/37.0-rc1/36.2/ MODULE.bazel
bazel build //...
WARNING: Build option --flag_alias has changed, discarding analysis cache (this can be expensive, see https://bazel.build/advanced/performance/iteration-speed).
INFO: Analyzed target //:foo (95 packages loaded, 1402 targets configured).
INFO: Found 1 target...
Target //:foo up-to-date:
  bazel-bin/foo-descriptor-set.proto.bin
INFO: Elapsed time: 0.547s, Critical Path: 0.00s
INFO: 1 process: 2 action cache hit, 1 internal.
INFO: Build completed successfully, 1 total action

Anything else we should know about your project / environment

Dominant language
C++
Stars
72.2k
Forks
16.4k
Avg merge
1d 8h
Merged PRs (30d)
342

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from protocolbuffers/protobuf

All issues in protocolbuffers/protobuf

Similar issues

More C++ issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.