Bazel: Split protobuf Bazel module across language boundaries
Maintainers usually reply within 1 day
@esrauchg is already working on this.
Since Oct 20, 2026.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 15/100
- Issue type
- Refactor
- Clarity
- Mostly clear
- Activity status
- Active
- Domain
- build-system
Research direction
The payload points to the Rust runtime BUILD file at rust/BUILD and the procedural macro BUILD file at rust/protobuf_macros/BUILD, which pull in paste, linkme, quote and syn. Reproduce the cost by running bazelisk mod deps --lockfile_mode=update on a Java-only consumer and checking which Rust tooling downloads. Done would mean a proposed module layout that keeps Rust and multilanguage consumers working, which needs maintainer agreement on the design first.
Written by the indexing model from the issue text.
Description
Request
Provide separate Bazel modules for Protobuf's language integrations, so
Java consumers can use Java support without provisioning Rust tooling.
For example, using proposed module names:
# Java applications
bazel_dep(name = "protobuf_java", version = "36.2")
# Rust applications
bazel_dep(name = "protobuf_rust", version = "36.2")
Each language module would depend on shared compiler/core infrastructure.
The shared module would not depend on every language integration.
Measured cost
Gerrit Code Review uses Protobuf's Java support. With Protobuf 36.2 and
Bazel 9.3.0 on macOS x86_64, running:
bazelisk mod deps --lockfile_mode=update
provisions Rust tooling and processes Protobuf's Cargo workspace.
A repeat with a fresh Bazel output directory and empty download cache
confirmed these downloads:
| Download | MB |
|---|---|
| cargo-bazel 0.69.0 | 15.87 |
| rustc 1.93.1 | 77.40 |
| Cargo 1.93.1 | 9.16 |
| Clippy 1.93.1 | 3.21 |
| LLVM tools 1.93.1 | 49.15 |
| Rust standard library 1.93.1 | 28.51 |
| Rustfmt nightly | 1.73 |
| Total | 185.03 |
Bazel's profile records 194.61 seconds evaluating the Rust crate
extension. Separately, the extracted Rust host tools contain 1.05 GB
of files, excluding cargo-bazel and cached archives.
These measurements come from one cold-cache run. Repository-rule logs and
downloaded files establish the payload sizes; the total excludes metadata
and network overhead. Warm caches can avoid repeat downloads.
Why our workaround is limited
Our Gerrit patch
marks rules_rust and the crate extension as dev_dependency = True.
This works for Java-only usage, but removes dependencies required by
downstream Rust consumers.
The extension includes test tooling such as googletest, but also
production dependencies: paste and linkme in the
Rust runtime,
and quote and syn in its
procedural macros.
It cannot all be treated as test-only.
Expected behavior
- Java builds and lockfile maintenance work without unused Rust tooling.
- Rust and multilanguage consumers retain supported configurations.
- Existing consumers have a documented migration path.
- Required shared compiler dependencies remain available, including C++
dependencies when building protoc from source.
A smaller fix that preserves downstream Rust support would also be
welcome; resolving the download bug need not wait for a module split.
Related discussion
Bazel considered optional module dependencies in
bazelbuild/bazel#25214,
now closed as not planned. It explicitly discusses splitting Protobuf
into core and language-specific modules. Its optional-dependency proposal
means activation when another dependency introduces the module, rather
than selection based on a build target's language.
This request concerns Protobuf's module design; it does not require a new
Bazel optional-dependency attribute.
Related: #30684 — Java-only consumers inherit Rust compiler downloads.
- Dominant language
- C++
- Stars
- 72.2k
- Forks
- 16.4k
- Avg merge
- 1d 8h
- Merged PRs (30d)
- 342
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from protocolbuffers/protobuf
-
Difficulty 2/5 1-3 hours Newbie friendliness 77/100
protocolbuffers/protobuf#31768 ·
Maintainers usually reply within 1 day
-
feature request packaging & distribution python
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
protocolbuffers/protobuf#31654 ·
Maintainers usually reply within 1 day
-
google-protobuf 0.36.2-release fails to compile for ARMv7: @progbits rejected in global_asm!Possibly taken @farisbasha claimed this 1 day ago. Openbug help wanted rust
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
protocolbuffers/protobuf#31619 · 3 comments ·
Maintainers usually reply within 1 day
-
Null pointer passed to memcpy in lupb_decode() when the second argument is nilPossibly taken A pull request linked to this issue is open or already merged. Openbug help wanted lua
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
protocolbuffers/protobuf#31392 · 1 comment ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
protocolbuffers/protobuf#31032 ·
Maintainers usually reply within 1 day
All issues in protocolbuffers/protobuf
Similar issues
-
agent:Windows bug in progress pri:medium sev:low testing windows
Difficulty 1/5 Under an hour Newbie friendliness 91/100
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
godotengine/godot#125651 ·
Maintainers usually reply within 1 day
-
Android: with view recycling on, a recycled View keeps its nextFocusLeftPossibly taken A pull request linked to this issue is open or already merged. OpenNeeds: Triage :mag: Platform: Android
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
react/react-native#60167 ·
Maintainers usually reply within 2 days
-
documentation
Difficulty 2/5 1-3 hours Newbie friendliness 63/100
-
Difficulty 1/5 1-3 hours Newbie friendliness 88/100
Maintainers usually reply within 2 days