Repository navigation
chore(bazel): replace toolchains_protoc with protobuf's prebuilt protoc - #12163
Merged
Merged
Conversation
toolchains_protoc is archived: its prebuilt protoc toolchain was upstreamed into protobuf 33.4, and its last release only knows protoc up to v33.0, which kept protobuf pinned to 33.0 (protobuf 33.4's ProtocAuthenticityCheck requires protoc and the module to have the same version). Upgrade protobuf to 33.4, which Bazel 9.3.2's bazel_tools requires anyway, drop the single_version_override and toolchains_protoc, and turn on protobuf's own prebuilt protoc toolchains with --@protobuf//bazel/toolchains:prefer_prebuilt_protoc. --incompatible_enable_proto_toolchain_resolution is dropped: it's the default since Bazel 9. //bazel:protoc, which prost/tonic build scripts, generators and generated-file checks run, is now a small rule that returns the protoc of the resolved proto toolchain, and fails rather than return a protoc compiled from C++ source. Co-Authored-By: Claude Opus 5.5 <[email protected]>
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues remain for the migration to protobuf’s toolchain-selected prebuilt protoc.
No open issues 🎉
What changed in this PR
Replaces the archived toolchains_protoc dependency with protobuf’s own prebuilt protoc, aligning Rust code-generation tools with the compiler selected by the proto toolchain.
Changes:
- Upgrades protobuf from 33.0 to 33.4 and removes
toolchains_protocand the protobuf version override. - Adds a toolchain-backed
//bazel:protocrule that rejects a compiler built from source. - Enables prebuilt protoc selection while retaining linker settings needed by protobuf’s Python runtime.
| File | Description |
|---|---|
MODULE.bazel |
Upgrades protobuf and removes the old protoc dependency and registration. |
bazel/protoc.bzl |
Exposes the resolved toolchain’s protoc with a prebuilt-file check. |
bazel/conf/.bazelrc.build |
Enables prebuilt protoc and clarifies why bootstrap linker settings remain. |
bazel/BUILD.bazel |
Replaces the platform-selecting alias with current_protoc. |
Review effort: Balanced
rzakrzyk
approved these changes
Nov 18, 2026
basvandijk
added a commit
that referenced
this pull request
Nov 18, 2026
#12163 (replace toolchains_protoc with protobuf's prebuilt protoc), which this PR was stacked on, has landed in master as a squash commit, so this PR now targets master. Git sees #12163's changes twice, once from master's squash commit and once from this branch's copies of #12163's commits, and this PR edits some of the same lines. That makes MODULE.bazel, bazel/BUILD.bazel, bazel/conf/.bazelrc.build and bazel/protoc.bzl conflict in a plain merge. The resolution merges with #12163's final head (b624233) as the merge base, which merges cleanly. The resulting diff against master is identical to this PR's own changes on top of #12163 (same patch-id). Co-Authored-By: Claude Opus 5.5 <[email protected]>
AleDema
pushed a commit
to AleDema/ic
that referenced
this pull request
Nov 18, 2026
Upgrades `protobuf` from 33.4 to [36.2](https://github.com/protocolbuffers/protobuf/releases/tag/v36.2), its latest release (37.0 is still a release candidate). This PR was stacked on dfinity#12163, which has landed. dfinity#12163 moved the proto toolchain and `//bazel:protoc` to protobuf's own prebuilt protoc. This PR now targets master, with master merged in. The unstamped release artifacts are byte-identical to dfinity#12163's, which match master. ## Changes - **`MODULE.bazel`**: - `protobuf` 33.4 → 36.2. - A `single_version_override` that applies `bazel/protobuf_crate_dev_dependency.patch` to protobuf's `MODULE.bazel` (see "`bazel mod`" below). It sets `version = "36.2"` because the patch only fits that version: without it, Bazel also tries to patch the module files of the older protobuf versions it discovers (27.0 via `rules_cc`, 29.0 via `rules_go`, ...) and fails. MVS selects 36.2 without the override too, so the pin doesn't change the resolution. It would also silently win over a higher protobuf version that another module requires. The comment says so and points to `bazel mod all_paths protobuf --verbose --include_builtin`, which shows each module's request (today at most 33.4, from `bazel_tools`, i.e. Bazel 9.3.2 itself, and from `rules_android`). `bazel mod explain protobuf --verbose` shows only 7 of these 12 modules: `bazel_tools` needs `--include_builtin`, and it leaves out `rules_android`, `rules_proto`, `bazel_worker_api` and `bazel_worker_java`, which `all_paths` shows as `(cycle)` edges below protobuf. - The comment above the `bazel_dep` now says that the prebuilt protoc is protobuf's default, and that the pip `protobuf` package must not be older than this release's Python version (see "Python gencode" below). - **`bazel/protobuf_crate_dev_dependency.patch`** (new): adds `dev_dependency = True` to protobuf's `use_extension` of rules_rust's `crate` extension. It applies to the 36.2 archive with no fuzz or offset. - **`bazel/conf/.bazelrc.build`**: - Adds `common --repo_env=ANDROID_HOME=`, so that no build depends on an Android SDK in the environment (see "`ANDROID_HOME`" below). - Removes `build --@protobuf//bazel/toolchains:prefer_prebuilt_protoc`. Since 34.0 the flag is `@protobuf//bazel/flags:prefer_prebuilt_protoc` (the old label is an alias for it) and defaults to true. That default also applies in the exec configuration, where the build scripts' `tools` resolve `//bazel:protoc`. 35.0 also gave the flag `scope = "universal"`, but that only matters with `--incompatible_exclude_starlark_flags_from_exec_config`, which Bazel 9.3.2 leaves off: it carries all Starlark flags into the exec configuration. - Removes `build:linux --host_linkopt=-Wl,-z,nostart-stop-gc`. It kept the `__start_`/`__stop_` linker arrays of upb's bootstrap tools, which protobuf 33's Python runtime built from source for `//ci/githubstats`. With 36.2 nothing in `//...` builds upb (see "Python runtime" below). `common --enable_platform_specific_config` stays, next to the `build:linux` glibc lines that need it. - **`bazel/protoc.bzl`**, **`bazel/BUILD.bazel`**: `current_protoc`'s failure message and a comment refer to the flag by its new label. - **`requirements.in`**, **`requirements.txt`**: the pip `protobuf` package goes from 6.33.5 to 7.36.2 (`bazel run //:python-requirements.update -- --upgrade-package protobuf`; no other package changes, and the 8 hashes match PyPI's). Its lower bound goes from 5.29.0 to 7.36.2. dfinity#12164 (Python 3.15) re-locks `requirements.txt` for Python 3.15 and keeps `protobuf` at 6.33.5. Whichever of the two lands second has to regenerate the lock with `protobuf` 7.36.2. ## Upstream changes that touch our setup From the release notes of [33.5](https://github.com/protocolbuffers/protobuf/releases/tag/v33.5), [33.6](https://github.com/protocolbuffers/protobuf/releases/tag/v33.6), [34.0](https://github.com/protocolbuffers/protobuf/releases/tag/v34.0), [34.1](https://github.com/protocolbuffers/protobuf/releases/tag/v34.1), [34.2](https://github.com/protocolbuffers/protobuf/releases/tag/v34.2), [35.0](https://github.com/protocolbuffers/protobuf/releases/tag/v35.0), [35.1](https://github.com/protocolbuffers/protobuf/releases/tag/v35.1), [36.0](https://github.com/protocolbuffers/protobuf/releases/tag/v36.0), [36.1](https://github.com/protocolbuffers/protobuf/releases/tag/v36.1) and 36.2, and a diff of the 33.4 and 36.2 release archives (`MODULE.bazel`, `bazel/`, `python/`, `editions/` and the well-known types): - **The prebuilt protoc is the default** ([protocolbuffers/protobuf@84a30b5](protocolbuffers/protobuf@84a30b5), 34.0), see above. `current_protoc` still guards against the from-source toolchain: with `--@protobuf//bazel/flags:prefer_prebuilt_protoc=false` it fails analysis. - **Python runtime**: it no longer compiles protoc ([protocolbuffers/protobuf@41ad19a](protocolbuffers/protobuf@41ad19a), 34.0). `@protobuf//python:protobuf_python`, which `py_proto_library` adds as a dependency, generates its well-known-type modules with the toolchain's protoc instead of `@protobuf//:protoc` compiled from C++. - So `//ci/githubstats` no longer builds protoc, its code generators or upb's bootstrap tools. The protobuf C++ targets in `deps(//...)` go from 127 (49 of them upb) to 39 (no upb), and `somepath(//..., @protobuf//:protoc)` is empty. - What remains is `protoc_minimal` (protoc without code generators), which the runtime still compiles for its `python_edition_defaults`. It doesn't link upb. libprotobuf's one linker array of its own (`pb_defaults`) has an entry that is referenced directly, so it survives section GC anyway. `protoc_minimal` and its output are byte-identical with and without `-z nostart-stop-gc`. - **Python gencode**: 34.0 moved the Python package to 7.x, and 36.2's protoc generates code for [7.36.2](https://github.com/protocolbuffers/protobuf/blob/v36.2/version.json). The generated `_pb2.py` modules check at import time that the runtime isn't older than that ([`ValidateProtobufRuntimeVersion`](https://github.com/protocolbuffers/protobuf/blob/v36.2/python/google/protobuf/runtime_version.py#L54-L105)). They don't require the same major version: protobuf [supports](https://protobuf.dev/support/cross-version-runtime-guarantee/#python) Python code generated since 3.20.0 on runtimes up to at least 8.x, so `requirements.in` only sets a lower bound. - `//ci/githubstats:query` imports `google.protobuf` from the pip package (with its upb backend), not from protobuf's own runtime (checked with `PYTHONVERBOSE=1`). With pip's 6.33.5, `//ci/githubstats:query_test` fails: `VersionError: Detected incompatible Protobuf Gencode/Runtime versions when loading proto/target.proto: gencode 7.36.2 runtime 6.33.5. Runtime version cannot be older than the linked gencode version.` Hence the bump to 7.36.2. - The 7.x breaking changes (removed `FieldDescriptor.label`, `float_precision` and `float_format`, errors on bool-to-int assignment, ...) don't affect `query.py`. It only builds two messages, sets string fields, and calls `SerializeToString`, `ParseFromString` and `HasField`. - **`bazel mod` and rules_rust's `crate` extension** (35.0): protobuf's `MODULE.bazel` uses the `crate` extension (through the deprecated `crate_universe:extension.bzl`) as a non-dev dependency. Up to 34.2 it was a dev dependency. Every release so far calls `crate.from_specs()` without a lockfile, which rules_rust 0.71.1 and later (we're on 0.75.0) reject in a non-root module ([protocolbuffers/protobuf#29866](protocolbuffers/protobuf#29866)). - Builds never evaluate that extension. Its repositories hold the crates of protobuf's own Rust runtime (`@protobuf//rust`), which we don't use. - But `bazel mod graph`, `deps`, `explain`, `show_repo`, `show_extension` and `tidy` evaluate all extensions. Without the patch they exit 2 with ``crate_universe extension call `crates` is in a non-root module but has no lockfile``. - The patch restores the `dev_dependency = True` of 34.2 and earlier. protobuf's main branch and 37.0-rc3 pass a lockfile instead, so the patch and the override can go with the upgrade to 37.0. - **Transitive modules**: protobuf 36.2 drops its `rules_apple` dependency and requires `rules_kotlin` 2.3.20 instead of 1.9.6, which in turn requires `rules_android` 0.7.1 instead of the empty 0.1.1. - In the resolved graph: `rules_kotlin` 1.9.6 → 2.3.20, `rules_android` 0.1.1 → 0.7.1, `rules_jvm_external` 6.7 → 6.9 and `jsoncpp` 1.9.6 → 1.9.6.bcr.2. `abseil-py`, `bazel_worker_api`, `bazel_worker_java` and `rules_robolectric` are added; `rules_apple`, `rules_swift`, `swift_argument_parser` and `nlohmann_json` drop out. - None of them is a direct dependency of ours, and `bazel mod graph --depth=1` only changes for `protobuf`. - rules_android 0.7.1 adds a Go 1.22.4 SDK and its own `go.mod` to rules_go's and gazelle's extensions. We build no Go code of our own, and gazelle is still built with rules_go's `go_default_sdk`. - **`ANDROID_HOME`**: rules_android 0.7.1 registers toolchains from its `@androidsdk` repository as a non-dev dependency ([`MODULE.bazel`](https://github.com/bazelbuild/rules_android/blob/v0.7.1/MODULE.bazel#L199-L202)). Bazel fetches that repository whenever it resolves toolchains: in every build, test, run, cquery and aquery. Its repository rule reads `ANDROID_HOME` ([`rule.bzl`](https://github.com/bazelbuild/rules_android/blob/v0.7.1/rules/android_sdk_repository/rule.bzl#L93-L142)). When the variable is unset or empty, the rule writes a stub `BUILD` file. Otherwise it links that SDK, and fails if the SDK has no `platforms/android-*` or its newest build-tools are older than 35.0.0. The analysis then fails, even for unrelated targets like `//rs/types/base_types`. Neither `ci/container/Dockerfile` nor `.github/` sets `ANDROID_HOME`, but the arm64 jobs run Bazel directly on Namespace runners, and a developer machine may point it at any Android SDK. `common --repo_env=ANDROID_HOME=` makes every build use the stub, which is all we need: we build no Android code. `--repo_env` is not part of the build configuration, so the line changes no action (see Verification). Builds still fetch rules_android and the stub. - **protoc output**: 35.0 strips empty options from descriptors ([protocolbuffers/protobuf@d5d6d4c](protocolbuffers/protobuf@d5d6d4c)), and 36.0 no longer maps option sub-locations in `SourceCodeInfo` ([protocolbuffers/protobuf@1d8a656](protocolbuffers/protobuf@1d8a656)). That changes descriptor sets, but none of our build scripts writes one, and the code that prost and tonic generate is unchanged (see Verification). 35.0 also refuses generator output paths that escape the output directory ([protocolbuffers/protobuf@3bf2b07](protocolbuffers/protobuf@3bf2b07)); prost gets a descriptor set from protoc, not generated files. - **Well-known types**: 36.2's `descriptor.proto` adds `EDITION_2026`, an extension range (990–998) reserved for protobuf's own options and `FieldOptions.FeatureSupport.removal_error`. `any.proto`, `struct.proto`, `timestamp.proto` and `field_mask.proto` only change comments. prost maps the well-known types to `prost-types` instead of compiling them, and `//rs/types/base_types`, which extends `MessageOptions` and `FieldOptions`, generates the same code. - **Removed Bazel APIs** (34.0): `ProtoInfo.transitive_imports` and the native `--proto_toolchain_for*` flags. We use neither (`rules_buf` only provides the `buf` binary). 34.0 also drops Bazel 7; we're on 9.3.2. - **BCR**: 36.0 is yanked (macOS prebuilt protoc integrity mismatch), and 36.1 shipped an empty integrity table (patched in 36.1.bcr.1). 36.2's `tool_integrity.bzl` lists all 10 protoc archives, and the Linux and macOS hashes match the digests GitHub reports for the release assets. BCR has no patches for 36.2, and its `MODULE.bazel` is identical to the release archive's. ## Verification In the dev container: - **Module resolution**: as listed above. `bazel mod graph` (full and `--depth=1`), `bazel mod explain`, `bazel mod all_paths` and `bazel mod show_repo` exit 0. There's no new warning; the only one is the existing `rules_qemu` `use_repo` warning. `bazel mod all_paths protobuf --verbose --include_builtin` shows the request of each of the 12 modules that depend on protobuf as `(was <version>, cause single_version_override)`, from 3.19.6 (`gazelle`) to 33.4 (`bazel_tools` and `rules_android`). These are the same 12 edges into protobuf as in `bazel mod graph --verbose --include_builtin`. `bazel mod explain protobuf --verbose` shows 7 of them, up to 32.1 (`rules_java`), and 8 with `--include_builtin`. - **Analysis**: `bazel build //... --nobuild` analyzes all 3387 targets, without warnings (also at the head commit). - **After merging master**: dfinity#12163 landed as a squash commit, so a plain merge of master conflicts on the lines this PR changes on top of dfinity#12163. I merged with dfinity#12163's final head as the merge base. The resulting diff against master is identical to this PR's change on top of dfinity#12163. Against master, `bazel mod graph` shows exactly the module changes listed above, with only the existing `rules_qemu` warning; `bazel build //... --nobuild` analyzes all 3389 targets; `bazel run //:buildifier` changes nothing. Nothing on master has touched `requirements.txt` since this PR was locked. - **`ANDROID_HOME`**, with fake SDK directories in the container and `bazel build --nobuild //rs/types/base_types`: - `ANDROID_HOME` at an SDK with `platforms/android-34` and `build-tools/34.0.0`, with the new line overridden on the command line (`--repo_env=ANDROID_HOME=<that SDK>`, which is what the repository rule saw before the line existed): `ERROR: Analysis of target '//rs/types/base_types:base_types' failed; build aborted: Bazel requires Android build tools version 35.0.0 or newer, 34.0.0 was provided`. - The same with an SDK that has `build-tools/35.0.0` but no `platforms/`: `No Android SDK apis found in the Android SDK at /tmp/partial-android-sdk. Please install APIs from the Android SDK Manager.` - With the line in effect, both builds pass. The repository's marker file records an empty `ANDROID_HOME`, and `@androidsdk` holds the stub `BUILD` file. - With `ANDROID_HOME` at the old SDK and the line in effect, `bazel build //... --nobuild` analyzes all 3387 targets. `bazel aquery 'deps(//ic-os/guestos/envs/prod:bundle-update)'` lists the same 19,395 actions, with the same action keys and outputs, as without the line. The release-artifact rebuild below also ran with `ANDROID_HOME` at the old SDK. - Without the line, CI's `Bazel Test arm64-linux` and `Bazel Test arm64-darwin` jobs passed on the PR's first commit. - **Which protoc runs**: `//bazel:protoc` resolves to `@@protobuf++protoc+prebuilt_protoc.linux_x86_64//:bin/protoc` (`libprotoc 36.2`) in every configuration it's used in, including the exec configuration of the build scripts' `tools`. Under `//ci/githubstats:query`, all 24 `GenProto`, `GenProtoDescriptorSet` and `ProtoCompile` actions run that binary, and only `ProtobufCompileEditionDefaults` runs `protoc_minimal`. `ProtocAuthenticityCheck` outputs `libprotoc 36.2` and passes. - **No protobuf C++ behind `//bazel:protoc`**: with the `--per_file_copt`/`--host_per_file_copt` probe from dfinity#12163 (any protobuf C++ compile fails), `//bazel:protoc`, the 6 build scripts, `@crate_index//:pprof`, the 18 `check_generated_files` tests and the 18 `protobuf_generator` binaries build. - **Generated code**: the `OUT_DIR`s of the 5 first-party prost/tonic build scripts are byte-identical to dfinity#12163's. The 12 BuildBuddy `_pb2.py` modules of `//ci/githubstats` only change in their version lines (6.33.4 → 7.36.2). - **Tests**: these 32 pass: - the 18 `check_generated_files` tests: protoc 36.2 and prost regenerate every checked-in file identically. - `//ci/githubstats:query_test` and `:query_help_test`, which import the generated modules with pip's `protobuf` 7.36.2. - `//:python-requirements.test`. - 11 tests that build on the prost/tonic-generated crates (`//rs/https_outcalls/...`, `//rs/ic_os/guest_upgrade/...` and 4 `//rs/replica_tests` tests). They were cache hits: their inputs are unchanged. - After the `ANDROID_HOME` line, `//ci/githubstats:query_test`, `:query_help_test` and `//:python-requirements.test` ran again, as cache hits. - **CI linter parity**, before and after the `ANDROID_HOME` line, and again after the `MODULE.bazel` comment corrections: `shfmt-check`, `ruff-check`, `buf-check`, `DFINITY-capitalization-check`, `do-not-merge-check`, `buildifier-check`, `gazelle-check` and `buf-breaking-check` pass. `buildifier-fix`, `shfmt-fix`, `ruff-fix` and `//:gazelle` change nothing. - **Release artifacts are byte-identical** to dfinity#12163's, which match master (133 files): the unstamped IC-OS bundles that `ci/container/build-ic.sh --icos` builds (GuestOS prod disk and update, GuestOS recovery update, HostOS update, SetupOS), `//publish/binaries:bundle` and `//publish/canisters:bundle`. Their build runs protoc 36.2 in the prost build scripts, and links without `-z nostart-stop-gc`. - Rebuilt with the `ANDROID_HOME` line: identical again. Of the 15,666 actions, all but 26 were cache hits (`1194 action cache hit, 12136 disk cache hit, 3504 internal, 26 local`). The 26 are IC-OS partition, image and tar actions, which are tagged `no-cache`. - Dropping the linkopt has a one-time cache cost: this build ran 6,576 actions (dfinity#12163's: 62). In the release artifacts' graph, 898 actions carry the exec link flags (690 `Rustc`, 202 `CargoBuildScriptRun`, 6 `CppLink`), and rules_foreign_cc's builds of exec tools (e2fsprogs, dosfstools, mtools) get them through their generated build scripts. Also, the `ST-<hash>` output directories of Starlark-transitioned configurations depend on the exec configuration's `--linkopt`: in the GuestOS update image's graph alone, about 30 of them get new names, so the actions in them run again. - The outputs don't change: besides the artifacts above, 24 exec binaries (the `serde_derive` and `thiserror-impl` proc-macros, 21 crate build scripts and `//rs/bitcoin/service`'s) and `protoc_minimal` are byte-identical with and without the flag. - **Not verified locally**: macOS and Linux aarch64, where protobuf's prebuilt toolchains cover `osx-aarch_64`, `osx-x86_64` and `linux-aarch_64` as with 33.4 (`-z nostart-stop-gc` was Linux-only). CI covers those, the full build and test suite and the system tests. 🤖 Generated with [Claude Code](https://claude.com/claude-code) --------- Co-authored-by: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Removes the
toolchains_protocmodule in favour of the prebuilt protoc thatprotobufitself provides since 33.4, and upgradesprotobuffrom 33.0 to 33.4 for that. Upgradingprotobufbeyond 33.4 is left to a follow-up.Is
toolchains_protocstill needed? No--@protobuf//bazel/toolchains:prefer_prebuilt_protoc(And prior to Bazel 9, also set--incompatible_enable_proto_toolchain_resolution)". Its last release, 0.6.1, only knows protoc releases up to v33.0.register_toolchains("@toolchains_protoc_hub//:all")), used byproto_libraryandpy_proto_library. Our only such targets are//ci/githubstats's BuildBuddy protos.bin/protocfiles behind//bazel:protoc. They are run by the prost/tonic build scripts (5 first-party ones, pluspprofthrough its crate annotation), the 18check_generated_filestests and the 18protobuf_generatorbinaries.prebuilt_protocmodule extension downloads the same kind of archive (protoc-33.4-<platform>.zipfrom protobuf's GitHub release, sha256-pinned in protobuf'sprebuilt_tool_integrity.bzl) and registers one proto toolchain per platform. Those toolchains are used once--@protobuf//bazel/toolchains:prefer_prebuilt_protocis set (protocolbuffers/protobuf@aeaede0).toolchains_protocwas also what keptprotobufon 33.0. protobuf 33.4 gives everyproto_libraryaProtocAuthenticityCheckvalidation that fails unless protoc reports the module's version. So with toolchains_protoc's newest protoc (v33.0),protobufhad to be pinned to 33.0 with asingle_version_override, below the 33.4 that Bazel 9.3.2'sbazel_toolsrequires.Changes
MODULE.bazel: removestoolchains_protoc(itsbazel_dep, itsprotocextension withuse_repo, andregister_toolchains) and thesingle_version_overrideofprotobuf.protobufgoes from 33.0 to 33.4, the versionbazel_toolsrequires, so it resolves to 33.4 without an override.bazel/conf/.bazelrc.build:build --@protobuf//bazel/toolchains:prefer_prebuilt_protoc.common --incompatible_enable_proto_toolchain_resolution, which is the default since Bazel 9.0.0. We're on 9.3.2.--host_linkopt=-Wl,-z,nostart-stop-gcfor upb's bootstrap tools. Its comment now says why they are still built: see the Python runtime item below.bazel/protoc.bzl(new) andbazel/BUILD.bazel://bazel:protocwas analiasthat picked toolchains_protoc'sbin/protocwith aselect()on the platform. It's now acurrent_protocrule that resolves the proto toolchain and returns its protoc, so//bazel:protocandproto_libraryalways run the same binary.ProtoLangToolchainInfo.proto_compiler. Both are the same in protobuf 36.2. It doesn't use the names of protobuf's internalprebuilt_protoc.<platform>repositories, whose extension moved frombazel/private/tobazel/private/oss/toolchains/prebuilt/by 36.2.//bazel:protoccan't silently start compiling protoc from C++.//bazel:protoc(bazel/prost.bzl, 5BUILD.bazelfiles, thepprofannotation inbazel/rust.MODULE.bazel) don't change, and neither doesCargo.Bazel.json.lock.Upstream changes that touch our setup
From the release notes of 33.1, 33.2, 33.3 (yanked on BCR) and 33.4, plus a diff of the 33.0 and 33.4 sources:
bool_flag. On Bazel 9.3.2 it still carries over into the exec configuration, where the build scripts'toolsresolve//bazel:protoc(checked with cquery below). Bazel 10 pre-releases turn on--incompatible_exclude_starlark_flags_from_exec_config, which stops that (protocolbuffers/protobuf#25561).current_protocwould then fail analysis instead of compiling protoc. protobuf 35.0 and later declare the flag withscope = "universal", which keeps it propagating.ProtocAuthenticityCheck(33.4):proto_librarygets a validation action that runsprotoc --versionand requireslibprotoc 33.4. It passes with the prebuilt protoc.//:protocin language runtimes (protocolbuffers/protobuf@453cfb2), but only for Java and Kotlin. protobuf 33's Python runtime (@protobuf//python:protobuf_python, whichpy_proto_libraryadds as a dependency) still generates its well-known-type_pb2modules with@protobuf//:protocbuilt from source. That build also compilesprotoc_minimaland upb's bootstrap tools.//ci/githubstatsstill compiles protoc from C++ in the exec configuration, exactly as on master: the same 127 protobuf C++ targets are in the graph, and//ci/githubstats:queryhas the same 1405CppCompileactions. That is why-z nostart-stop-gcstays.protoc_minimalfrom source for itspython_edition_defaults.descriptor.proto(33.2) gainsEDITION_UNSTABLEand a reserved extension declaration, and protoc's fixes in 33.1–33.4 are about editions and custom features. Our protos are proto2/proto3, and the generated code doesn't change (see below).Verification
In the dev container:
bazel mod graph, the only changes areprotobuf33.0 → 33.4 and the removal oftoolchains_protoc. No other module's resolved version changes;rules_protostays at 7.1.0, still required byprotobuf,rules_bufandrules_go. There's no new warning (only the existingrules_qemuuse_repoone).bazel mod explain protobuf: every dependent gets 33.4.bazel build //... --nobuildanalyzes all 3387 targets.//bazel:protocresolves to@@protobuf++protoc+prebuilt_protoc.linux_x86_64//:bin/protocin every configuration it's used in, including the exec configuration of the build scripts'tools.proto_library'sGenProtoDescriptorSetandGenProtoactions run the same binary (aquery).//bazel:protoc: I built 44 targets with--per_file_coptand--host_per_file_coptset toexternal/.*protobuf.*@--PROTOBUF_WAS_NOT_SUPPOSED_TO_BE_BUILT(toolchains_protoc's README trick, which makes any protobuf C++ compile fail). They are//bazel:protoc, the 6 build scripts,@crate_index//:pprof, the 18check_generated_filestests and the 18protobuf_generatorbinaries, and the build succeeds.//...: the protobuf C++ targets are the same 127 exec-configuration targets as on master. Thesomepathfrom//...to@protobuf//:protoc, toprotoc_minimaland toprotoc-gen-upb_stage0goes through//ci/githubstats's Python runtime, anddeps(//... except //ci/githubstats/...)contains no protobuf C++ target.OUT_DIRcontents are byte-identical to master's for all 5 first-party build scripts (rs/bitcoin/service,rs/https_outcalls/service,rs/ic_os/guest_upgrade/shared,rs/ic_os/remote_attestation/shared,rs/monitoring/adapter_metrics/service).pprof's build script only runs protoc when its proto no longer matches its pregenerated code, and itsOUT_DIRis empty both before and after.bazel testpasses 31 tests:check_generated_filestests: protoc 33.4 and prost regenerate every checked-in*.rsidentically, withPROTOC_INCLUDEpointing at protobuf 33.4's sources.//ci/githubstats:query_testand:query_help_test:proto_library+py_proto_librarywith the prebuilt protoc.//rs/ic_os/guest_upgrade/shared:shared_test,//rs/ic_os/guest_upgrade/tests:guest_upgrade_tests, and 4//rs/replica_testsintegration tests.@buildbuddy_proto//:buildbuddy_protowith--output_groups=+_validationsucceeds, and the output ofProtocAuthenticityCheckislibprotoc 33.4.//bazel:protoc --versionprints the same.shfmt-check,ruff-check,buf-check,DFINITY-capitalization-check,do-not-merge-check,buildifier-check,gazelle-checkandbuf-breaking-checkpass. The autofixesbuildifier-fix,shfmt-fix,ruff-fixand//:gazellechange nothing.//publish/binaries:bundleand//publish/canisters:bundle(133 files) match a build of master.osx-aarch_64,osx-x86_64andlinux-aarch_64, as toolchains_protoc did, and CI's arm64-linux and arm64-darwin jobs buildpocket-ic,ic-adminandsnsthere. CI also covers the full build and test suite.🤖 Generated with Claude Code