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 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!