Cargo build of rs_bindings_from_cc (using Bazel C++ dependencies). - #1876
Draft
anforowicz wants to merge 1 commit into
Draft
Cargo build of rs_bindings_from_cc (using Bazel C++ dependencies).#1876anforowicz wants to merge 1 commit into
rs_bindings_from_cc (using Bazel C++ dependencies).#1876anforowicz wants to merge 1 commit into
Conversation
anforowicz
force-pushed
the
cargo-bazel-take2
branch
from
August 26, 2026 23:10
e05c461 to
231b067
Compare
This commit enables building the `rs_bindings_from_cc` binary using
Cargo by reusing Bazel-built static libraries and generated headers
for Abseil, LLVM/Clang, and Protobuf.
Changes:
1. **Environment Setup & Protobuf Scripts**:
- Adds `cargo/build/generate_proto_headers.py` to pre-generate
C++ Protobuf headers into a shared directory upfront, avoiding
race conditions during concurrent Cargo builds across environments
(Crubit OSS, Chromium, Android).
- `cargo/build/setup_bazel_env.py`: Queries Bazel for prebuilt C++
dependencies, merges static archives using `llvm-ar`, pre-generates
Protobuf headers, detects the hermetic Clang toolchain, and emits
`target/bazel_outputs/bazel-env.sh`.
2. **C++ Header Discovery & Robustness (`cargo/build/`)**:
- Adds `paths::collect_static_libs` and `paths::get_env_paths` to
validate environment variables, directory existence, and
non-empty library archives with clean diagnostics.
- Adds `-DLLVM_ON_UNIX` to C++ compilation flags in `flags.rs`.
3. **Protobuf Compatibility (`rust/BUILD`)**:
- Adds placeholder `//rust:use_upb_kernel` config_setting in
`rust/BUILD` to work around a known Bzlmod `rules_rust` bug in
Protobuf where relative labels resolve against the root workspace.
4. **Documentation & CI Integration**:
- Documents the Cargo build workflow and environment variable
specification in `docs/overview/cargo_build.md`.
- Adds CI steps in `.github/workflows/rust.yml` to verify
`cargo build` of `rs_bindings_from_cc` in GitHub Actions.
anforowicz
force-pushed
the
cargo-bazel-take2
branch
from
August 27, 2026 03:40
231b067 to
d926604
Compare
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.
No description provided.