Add system_sysroot to rust_toolchain for pre-installed toolchains#3920
Closed
rejuvenile wants to merge 1 commit intobazelbuild:mainfrom
Closed
Add system_sysroot to rust_toolchain for pre-installed toolchains#3920rejuvenile wants to merge 1 commit intobazelbuild:mainfrom
rejuvenile wants to merge 1 commit intobazelbuild:mainfrom
Conversation
When using remote execution with a locally-installed Rust toolchain, the entire sysroot (~670MB) is transferred per action. This adds a `system_sysroot` attribute to `rust_toolchain` that tells rules_rust the sysroot is pre-installed on workers, avoiding the transfer. When `system_sysroot` is set: - Rust toolchain files are excluded from action inputs - RUSTC, RUSTDOC, CARGO paths point to system-installed binaries - Make variable expansion uses system paths - CC toolchain and custom linker inputs are preserved
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
UebelAndre
requested changes
Mar 24, 2026
Collaborator
UebelAndre
left a comment
There was a problem hiding this comment.
Thanks! Could this be a repository rule instead? Much like @rules_cc//cc/private/toolchain/cc_configure.bzl%cc_configure?
Author
|
@UebelAndre I screwed up this PR slightly, so recreated it at #3928. I'll make those changes there. Thanks for the quick response! |
4 tasks
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.
Summary
system_sysrootattribute torust_toolchainthat specifies an absolute path to a pre-installed Rust toolchain on build workersMotivation
When using remote execution (or local builds with
--disk_cache), every Rustc action packages the entire Rust sysroot as inputs. For a typical nightly toolchain this is ~670MB of files that must be uploaded, hashed, and transferred per action. If the remote workers already have the toolchain installed (e.g. via container image or system package), this transfer is pure overhead.Setting
system_sysroot = "/path/to/toolchain"onrust_toolchaintells rules_rust to use the pre-installed toolchain directly, eliminating the transfer cost.Test plan
system_sysrootset to a valid rustup toolchain pathsystem_sysrootset (default behavior unchanged)🤖 Generated with Claude Code