bazel: switch to hermetic_cc_toolchain#3216
Open
mgeisler wants to merge 1 commit into
Open
Conversation
I've seen spurious out of disk space build failures in CI and I believe they are caused by the huge (5+ GB) LLVM toolchain I introduced in #3204. We've already disabled the Bazel repository cache (#3210), but builds are still failing. It turns out that Uber maintains a 40 MB toolchain for Bazel. It's based on Zig, which apparently knows how to compile C/C++ as well. I'm torn on this since it feels a bit experimental to start using Zig to compile C/C++ code... but from a quick test, it seems to work, so maybe I'm overthinking this? Originally, the LLVM toolchain was introduced to fix > warning: the gold linker is deprecated and has known bugs with Rust warnings emitted during the build. We can also fix those warnigns by [telling `rustc` to use its own linker (`rust-lld`)](https://bazelbuild.github.io/rules_rust/rust_settings.html#toolchain_linker_preference)). However, I believe this would not be a complete solution as but there are crates in our dependency tree which links with C code. One example is `aws-lc-sys`: ``` % cargo tree -i -p cc cc v1.2.51 └── cmake v0.1.57 [build-dependencies] └── aws-lc-sys v0.35.0 └── aws-lc-rs v1.15.2 └── rustls v0.23.31 └── hyper-rustls v0.27.7 └── reqwest v0.13.4 └── sync-exercises v0.1.0 (src/concurrency/sync-exercises) ``` Hence, I figured it was better to configure a CC toolchain for the entire Bazel build instead of just telling `rustc` to do the linking. Using the toolchain here would continue this path, but with a much smaller toolchain. Since I don't think we want to rely on any particular behavior of our C/C++ compilers, I think this should be fine for us going forward. Googlers will of course have to let me know if this is broken internally... and/or if there is a better way to go about this!
71ed270 to
f3b1a2f
Compare
Collaborator
Author
|
Oh well, this seems incompatible with the macOS build: So this specific toolchain is probably a non-starter. |
This was referenced Jun 20, 2026
mgeisler
added a commit
that referenced
this pull request
Jun 23, 2026
This reverts #3204 due to repeated build failures in CI. The LLVM toolchain is huge, taking up 11 GB in the Bazel repository cache: ``` % cd $(bazel info repository_cache)/contents/f7d96c1d09ac1778314f1a73179da702edd9e75e8ef9231c06fa7ef6229cf47d % du -hs . 11G . ``` This is way too large for the GitHub CI runners, which are [documentated to have 14 GB of free disk space](https://docs.github.com/en/actions/reference/runners/github-hosted-runners). The result is seemingly random build failures where we run out of disk space. See [run 27773830289](https://github.com/google/comprehensive-rust/actions/runs/27773830289) which had several failed translation builds. The result of this is that we fall back on non-hermetic builds for the time being. This is the status quo from before adopting Bazel. We should look for another way to fix the > warning: the gold linker is deprecated and has known bugs with Rust warnigns. Perhaps more targeted by uninstalling `gold` and making sure another linker is picked up in CI? Universally instructing `rustc` to use `rust-lld` does not work (#3219) and using the small `hermetic_cc_toolchain` (Zig-based) also failed (#3216).
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.
I've seen spurious out of disk space build failures in CI and I believe they are caused by the huge (5+ GB) LLVM toolchain I introduced in #3204. We've already disabled the Bazel repository cache (#3210), but builds are still failing.
It turns out that Uber maintains a 40 MB toolchain for Bazel. It's based on Zig, which apparently knows how to compile C/C++ as well.
I'm torn on this since it feels a bit experimental to start using Zig to compile C/C++ code... but from a quick test, it seems to work, so maybe I'm overthinking this?
Originally, the LLVM toolchain was introduced to fix
warnings emitted during the build. We can also fix those warnigns by telling
rustcto use its ownlinker (
rust-lld)).However, I believe this would not be a complete solution as but there are crates in our dependency tree which links with C code. One example is
aws-lc-sys:Hence, I figured it was better to configure a CC toolchain for the entire Bazel build instead of just telling
rustcto do the linking.Using the toolchain here would continue this path, but with a much smaller toolchain. Since I don't think we want to rely on any particular behavior of our C/C++ compilers, I think this should be fine for us going forward.
Googlers will of course have to let me know if this is broken internally... and/or if there is a better way to go about this!