Repository navigation
Share the compiler repository with rustfmt of the same release - #4443
Open
TrapsterDK wants to merge 1 commit into
Open
TrapsterDK wants to merge 1 commit into
TrapsterDK wants to merge 1 commit into
Conversation
`rustfmt_toolchain_tools_repository` downloaded and unpacked its own `rustc` (about 400 MB unpacked) because rustfmt loads `librustc_driver` relative to its own path. When `rustfmt_version` is the release the Rust toolchains of the same execution platform compile with by default, that compiler is already in their `<name>__<channel>__rustc` repository. `rust_register_toolchains` now passes that repository as `rustc_anchor`, and the rustfmt repository links its `lib/` beside `rustfmt` (as the Clippy repository does) instead of downloading `rustc`. `rustc_lib` names the links, so remote executors get the libraries where rustfmt looks for them. The compiler repository of a non-default channel is not shared, since it also holds its standard library and llvm-tools and is otherwise only fetched with `--@rules_rust//rust/toolchain/channel`. `rust_repository_set` now gets `compact_windows_names` from `rust_register_toolchains`, so the shared repository names computed for rustfmt match the ones the set declares. The new `test/integration/rustfmt_shared_compiler` module sets `rustfmt_version` to its only version, runs a `rustfmt_test`, and checks that the rustfmt toolchain's `rustc` comes from the compiler repository and its `rustc_lib` from rustfmt's own. The rustfmt repository there is 7 MB with no `rustc` of its own. Assisted-by: Claude
This branch has not been deployed
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.
Closes #4441.
Since #1769,
rustfmt_toolchain_tools_repositorydownloads and unpacks therustccomponent next to rustfmt, because rustfmt loadslibrustc_driverrelative to its own path. That's about 400 MB per execution platform. Whenrustfmt_versionis the release the Rust toolchains compile with by default, the samerustcis already in the shared<name>__<channel>__rustcrepository from #4397, so a build that runs rustfmt holds two copies.This change:
rust_register_toolchainspasses that compiler repository to the rustfmt repository as a newrustc_anchorattribute. It only does this whenrustfmt_versionis one ofversionsand is the default channel's release (stable, or the only version given). A nightly rustfmt in a stable build still downloads its ownrustc, because the nightly compiler repository also holds its standard library and llvm-tools.rustc_anchorset, the rustfmt repository links the compiler'slib/besiderustfmt, the way the Clippy repository already does, and skips therustcdownload.rustc_libnames the links, so remote executors get the libraries where rustfmt looks for them. The toolchain'srustcpoints at the compiler repository.rust_repository_setnow getscompact_windows_namesfromrust_register_toolchains, so the shared repository names computed for rustfmt match the ones the set declares. The name logic moved into_shared_repository_nameso both places use it.Without an anchor, the behaviour is the same as before.
Test: a new integration module,
test/integration/rustfmt_shared_compiler, setsrustfmt_versionto its only version. It runs arustfmt_test, plus an analysis test that checks the rustfmt toolchain'srustccomes from the compiler repository and itsrustc_libfrom rustfmt's own. It runs as apost_shell_commandsstep of the existingrustfmt_failuretask, because presubmit is already at BazelCI's limit of 128 tasks.bazel test //...passes (2/2), and the rustfmt repository is 7 MB with norustcof its own.bazel test //test/rustfmt/...at the root still passes (20/20).Related: #1768.
Assisted by Claude.