close
Skip to content

Explicitly request copying rustc-dev artifacts for rustfmt/clippy and add rustc libs path for rustc-private tools under download-rustc#156528

Open
jieyouxu wants to merge 3 commits into
rust-lang:mainfrom
jieyouxu:jieyouxu/fix/rustfmt-download-rustc
Open

Explicitly request copying rustc-dev artifacts for rustfmt/clippy and add rustc libs path for rustc-private tools under download-rustc#156528
jieyouxu wants to merge 3 commits into
rust-lang:mainfrom
jieyouxu:jieyouxu/fix/rustfmt-download-rustc

Conversation

@jieyouxu
Copy link
Copy Markdown
Member

@jieyouxu jieyouxu commented May 13, 2026

Summary

#t-infra/bootstrap > x run rustfmt works but x test rustfmt fails to compile reported that ./x test rustfmt --stage={1,2} no longer works with download-rustc.

  • This seems to be due to us removing some manual builder.ensure(Rustc)s around the times of stage 0 rejiggling.
  • Because compile::Sysroot::run has a quirky non-trivial behavior regarding rustc-dev artifact copying under download-rustc, tracing back to sysroot dep resolution troubles (cf. tests/ui/allocator/no_std-alloc-error-handler* fail when download-rustc is enabled #108767), we need to explicitly ensure(Rustc) to opt-in to rustc-dev artifact copying under download-rustc.
  • For the short-term, let's insert manual ensures to force rustc-dev artifact copying under download-rustc to unblock rustfmt/clippy contributors who want to use download-rustc (to avoid having to build the compiler).

Additionally, I needed to explicitly add rustc libs path for RustcPrivate tools, or else it seems like the ci-rustc sysroot is not always correctly set.

Testing

Use a dummy config: bootstrap.rustfmt.toml

profile = "tools"
change-id = "ignore"

[rust]
# Force download-rustc, needed because we modify bootstrap which makes
# `if-unchanged` ineligible.
download-rustc = true

Run:

  • ./x test rustfmt --config=bootstrap.rustfmt.toml --stage=1
  • ./x test rustfmt --config=bootstrap.rustfmt.toml --stage=2
  • ./x test clippy --config=bootstrap.rustfmt.toml --stage=1
  • ./x test clippy --config=bootstrap.rustfmt.toml --stage=2

When reviewing, also check that if you revert the commit / this PR, that invocations above fail (which is the case against main for me).

Tested also without download-rustc to make sure ./x test {rustfmt,clippy} --stage={1,2} still works.

Notes

This is by no means a proper fix, but it should unblock local tool profile workflows trying to use download-rustc with {rustfmt,clippy}. I don't think it's worth blocking over that.

Efforts for a more proper fix should be tracked by #156525, I left FIXMEs pointing to that.

@rustbot rustbot added A-testsuite Area: The testsuite used to check the correctness of rustc S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) labels May 13, 2026
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented May 13, 2026

r? @Mark-Simulacrum

rustbot has assigned @Mark-Simulacrum.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: bootstrap
  • bootstrap expanded to 6 candidates
  • Random selection from Mark-Simulacrum, clubby789

@jieyouxu jieyouxu added the A-download-rustc Area: The `rust.download-rustc` build option. label May 13, 2026
@ytmimi
Copy link
Copy Markdown
Contributor

ytmimi commented May 20, 2026

@jieyouxu I tested these changes locally and they mostly work. Testing is fine now, but running rustfmt is broken for stage 2. I also found it odd that it's not testing stage 1 when explicitly passing --stage=1. It always seems to test stage 2. Could that be because src/bootstrap/defaults/bootstrap.tools.toml sets test-stage = 2?

# These defaults are meant for contributors to tools which build on the
# compiler, but do not modify it directly.
[rust]
# This greatly increases the speed of rebuilds, especially when there are only minor changes. However, it makes the initial build slightly slower.
incremental = true
# Most commonly, tools contributors do not need to modify the compiler, so
# downloading a CI rustc is a good default for tools profile.
download-rustc = "if-unchanged"

[build]
# cargo and clippy tests don't pass on stage 1
test-stage = 2
# Document with the in-tree rustdoc by default, since `download-rustc` makes it quick to compile.
doc-stage = 2
# Contributors working on tools will probably expect compiler docs to be generated, so they can figure out how to use the API.
compiler-docs = true
# Contributors working on tools are the most likely to change non-rust programs.
tidy-extra-checks = "auto:js,auto:py,auto:cpp,auto:spellcheck"

[llvm]
# Will download LLVM from CI if available on your platform.
# If you intend to modify `src/llvm-project`, use `"if-unchanged"` or `false` instead.
download-ci-llvm = true
Terminal Output
./x test rustfmt --config=bootstrap.rustfmt.toml --stage=1
Building bootstrap
   Compiling bootstrap v0.0.0 (/Users/ytmimi/Documents/Projects/rust_projects/rust/src/bootstrap)
    Finished `dev` profile [unoptimized] target(s) in 3.86s
NOTE: detected 2 modifications that could affect a build of rustc
- src/bootstrap/src/core/build_steps/compile.rs
- src/bootstrap/src/core/build_steps/test.rs
downloading unconditionally due to `download-rustc = true`
downloading https://ci-artifacts.rust-lang.org/rustc-builds/c8c4c83d57d3b4cf72a7306cd77bb8b5c0f03434/rust-std-nightly-aarch64-apple-darwin.tar.xz
################################################################################################################# 100.0%
extracting /Users/ytmimi/Documents/Projects/rust_projects/rust/build/cache/c8c4c83d57d3b4cf72a7306cd77bb8b5c0f03434-false/rust-std-nightly-aarch64-apple-darwin.tar.xz to /Users/ytmimi/Documents/Projects/rust_projects/rust/build/aarch64-apple-darwin/ci-rustc
downloading https://ci-artifacts.rust-lang.org/rustc-builds/c8c4c83d57d3b4cf72a7306cd77bb8b5c0f03434/rustc-nightly-aarch64-apple-darwin.tar.xz
################################################################################################################# 100.0%
extracting /Users/ytmimi/Documents/Projects/rust_projects/rust/build/cache/c8c4c83d57d3b4cf72a7306cd77bb8b5c0f03434-false/rustc-nightly-aarch64-apple-darwin.tar.xz to /Users/ytmimi/Documents/Projects/rust_projects/rust/build/aarch64-apple-darwin/ci-rustc
downloading https://ci-artifacts.rust-lang.org/rustc-builds/c8c4c83d57d3b4cf72a7306cd77bb8b5c0f03434/rustc-dev-nightly-aarch64-apple-darwin.tar.xz
################################################################################################################# 100.0%
extracting /Users/ytmimi/Documents/Projects/rust_projects/rust/build/cache/c8c4c83d57d3b4cf72a7306cd77bb8b5c0f03434-false/rustc-dev-nightly-aarch64-apple-darwin.tar.xz to /Users/ytmimi/Documents/Projects/rust_projects/rust/build/aarch64-apple-darwin/ci-rustc
/Users/ytmimi/Documents/Projects/rust_projects/rust/build/aarch64-apple-darwin/ci-llvm/bin/llvm-strip does not exist; skipping copy
Creating a sysroot for stage1 compiler (use `rustup toolchain link 'name' build/host/stage1`)
/Users/ytmimi/Documents/Projects/rust_projects/rust/build/aarch64-apple-darwin/ci-llvm/bin/llvm-strip does not exist; skipping copy
Testing stage2 rustfmt (aarch64-apple-darwin)
   Compiling proc-macro2 v1.0.103
   Compiling quote v1.0.45
   Compiling unicode-ident v1.0.22
   Compiling serde_core v1.0.228
   Compiling memchr v2.8.0
   Compiling libc v0.2.183
   Compiling regex-syntax v0.8.8
   Compiling utf8parse v0.2.2
   Compiling crossbeam-utils v0.8.21
   Compiling once_cell v1.21.3
   Compiling anstyle v1.0.13
   Compiling serde v1.0.228
   Compiling is_terminal_polyfill v1.70.2
   Compiling colorchoice v1.0.4
   Compiling cfg-if v1.0.4
   Compiling anstyle-query v1.1.5
   Compiling log v0.4.28
   Compiling serde_json v1.0.145
   Compiling anstyle-parse v0.2.7
   Compiling strsim v0.11.1
   Compiling camino v1.2.1
   Compiling heck v0.5.0
   Compiling clap_lex v0.7.6
   Compiling thiserror v1.0.69
   Compiling tracing-core v0.1.34
   Compiling anstream v0.6.21
   Compiling winnow v1.0.0
   Compiling pin-project-lite v0.2.16
   Compiling lazy_static v1.5.0
   Compiling same-file v1.0.6
   Compiling option-ext v0.2.0
   Compiling aho-corasick v1.1.4
   Compiling clap_builder v4.5.54
   Compiling bstr v1.12.1
   Compiling itoa v1.0.15
   Compiling unicode-width v0.2.2
   Compiling ryu v1.0.20
   Compiling anyhow v1.0.100
   Compiling tracing-log v0.2.0
   Compiling tracing v0.1.41
   Compiling toml_parser v1.1.0+spec-1.1.0
   Compiling walkdir v2.5.0
   Compiling sharded-slab v0.1.7
   Compiling crossbeam-epoch v0.9.18
   Compiling thread_local v1.1.9
   Compiling rustfmt-nightly v1.9.0 (/Users/ytmimi/Documents/Projects/rust_projects/rust/src/tools/rustfmt)
   Compiling toml_writer v1.1.0+spec-1.1.0
   Compiling crossbeam-deque v0.8.6
   Compiling winnow v0.7.13
   Compiling nu-ansi-term v0.50.3
   Compiling regex-automata v0.4.13
   Compiling either v1.15.0
   Compiling smallvec v1.15.1
   Compiling getopts v0.2.24
   Compiling annotate-snippets v0.11.5
   Compiling itertools v0.12.1
   Compiling diff v0.1.13
   Compiling term v1.2.1
   Compiling syn v2.0.110
   Compiling bytecount v0.6.9
   Compiling unicode-properties v0.1.4
   Compiling unicode-width v0.1.14
   Compiling unicode-segmentation v1.12.0
   Compiling rustix v1.1.2
   Compiling getrandom v0.3.3
   Compiling bitflags v2.10.0
   Compiling dirs-sys v0.5.0
   Compiling errno v0.3.14
   Compiling dirs v6.0.0
   Compiling fastrand v2.3.0
   Compiling serde_spanned v1.1.0
   Compiling semver v1.0.27
   Compiling toml_datetime v0.7.3
   Compiling toml v0.9.8
   Compiling tempfile v3.23.0
   Compiling serde_derive v1.0.228
   Compiling thiserror-impl v1.0.69
   Compiling clap_derive v4.5.49
   Compiling rustfmt-config_proc_macro v0.3.0 (/Users/ytmimi/Documents/Projects/rust_projects/rust/src/tools/rustfmt/config_proc_macro)
   Compiling globset v0.4.18
   Compiling matchers v0.2.0
   Compiling regex v1.12.2
   Compiling tracing-subscriber v0.3.20
   Compiling ignore v0.4.25
   Compiling clap v4.5.54
   Compiling clap-cargo v0.12.0
   Compiling cargo-platform v0.1.9
   Compiling cargo_metadata v0.18.1
    Finished `release` profile [optimized] target(s) in 14.90s
     Running unittests src/lib.rs (build/aarch64-apple-darwin/stage2-tools/aarch64-apple-darwin/release/deps/rustfmt_nightly-a76a6e3c1d2fca9f)

running 232 tests
........................................................................................  88/232
........................................................................................ 176/232
.....................error: missing type for `static` item
 --> tests/parser/stashed-diag.rs:1:15
  |
1 | #![u={static N;}]
  |               ^
  |
help: provide a type for the item
  |
1 | #![u={static N: <type>;}]
  |               ++++++++

error: mismatched closing delimiter: `}`
 --> tests/parser/unclosed-delims/issue_4466.rs:3:17
  |
2 |     if true {
  |             - closing delimiter possibly meant for this
3 |         println!("answer: {}", a_func();
  |                 ^ unclosed delimiter
4 |     } else {
  |     ^ mismatched closing delimiter

......error: this file contains an unclosed delimiter
 --> tests/parser/stashed-diag2.rs:3:14
  |
1 | trait Trait<'1> { s> {}
  |                 - unclosed delimiter
2 |
3 | fn main() {}
  |             ^

.error: lifetimes cannot start with a number
 --> tests/parser/stashed-diag2.rs:1:13
  |
1 | trait Trait<'1> { s> {}
  |             ^^

error: unexpected closing delimiter: `}`
 --> tests/parser/issue_4418.rs:1:1
  |
1 | }
  | ^ unexpected closing delimiter

...error: this file contains an unclosed delimiter
 --> <stdin>:1:2
  |
1 | {
  | -^
  | |
  | unclosed delimiter

....error: unexpected closing delimiter: `}`
 --> <stdin>:1:1
  |
1 | }
  | ^ unexpected closing delimiter

error: unexpected `if` in the condition expression
 --> tests/parser/issue-4126/invalid.rs:2:14
  |
2 |     if bar && if !baz {
  |              ^^^^
  |
help: remove the `if`
  |
2 -     if bar && if !baz {
2 +     if bar && !baz {
  |

.....................

test result: ok. 232 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 652.19ms

     Running unittests src/cargo-fmt/main.rs (build/aarch64-apple-darwin/stage2-tools/aarch64-apple-darwin/release/deps/cargo_fmt-5864122e9eb1621e)

running 24 tests
........................

test result: ok. 24 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 65.39ms

     Running unittests src/git-rustfmt/main.rs (build/aarch64-apple-darwin/stage2-tools/aarch64-apple-darwin/release/deps/git_rustfmt-be84c7dfdeb5de14)

running 0 tests


test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 21.75µs

     Running unittests src/bin/main.rs (build/aarch64-apple-darwin/stage2-tools/aarch64-apple-darwin/release/deps/rustfmt-803543e58f39ad94)

running 16 tests
................

test result: ok. 16 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 3.30ms

     Running unittests src/format-diff/main.rs (build/aarch64-apple-darwin/stage2-tools/aarch64-apple-darwin/release/deps/rustfmt_format_diff-62583ea3b15c2b26)

running 7 tests
.......

test result: ok. 7 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 2.41ms

     Running tests/cargo-fmt/main.rs (build/aarch64-apple-darwin/stage2-tools/aarch64-apple-darwin/release/deps/cargo_fmt-b26eae58ab67f86a)

running 5 tests
iiiii

test result: ok. 0 passed; 0 failed; 5 ignored; 0 measured; 0 filtered out; finished in 40.42µs

     Running tests/rustfmt/main.rs (build/aarch64-apple-darwin/stage2-tools/aarch64-apple-darwin/release/deps/rustfmt-b463a72d35327109)

running 13 tests
ii...........

test result: ok. 11 passed; 0 failed; 2 ignored; 0 measured; 0 filtered out; finished in 100.48ms

   Doc-tests rustfmt_nightly

running 3 tests
i..

test result: ok. 2 passed; 0 failed; 1 ignored; 0 measured; 0 filtered out; finished in 96.71ms

	finished in 19.119 seconds
Build completed successfully in 0:00:51

Trying to run run rustfmt with --stage=1 works ✅:

Terminal Output
./x run rustfmt --config=bootstrap.rustfmt.toml --stage=1 
Building bootstrap
    Finished `dev` profile [unoptimized] target(s) in 0.07s
NOTE: detected 2 modifications that could affect a build of rustc
- src/bootstrap/src/core/build_steps/compile.rs
- src/bootstrap/src/core/build_steps/test.rs
downloading unconditionally due to `download-rustc = true`
/Users/ytmimi/Documents/Projects/rust_projects/rust/build/aarch64-apple-darwin/ci-llvm/bin/llvm-strip does not exist; skipping copy
Creating a sysroot for stage1 compiler (use `rustup toolchain link 'name' build/host/stage1`)
/Users/ytmimi/Documents/Projects/rust_projects/rust/build/aarch64-apple-darwin/ci-llvm/bin/llvm-strip does not exist; skipping copy
Building stage2 rustfmt (stage1 -> stage2, aarch64-apple-darwin)
   Compiling rustfmt-nightly v1.9.0 (/Users/ytmimi/Documents/Projects/rust_projects/rust/src/tools/rustfmt)
    Finished `release` profile [optimized] target(s) in 11.64s
    Finished `release` profile [optimized] target(s) in 0.07s
     Running `build/aarch64-apple-darwin/stage2-tools/aarch64-apple-darwin/release/rustfmt`
fn main() {
}

fn main() {}
Build completed successfully in 0:00:28

Trying to run run rustfmt with --stage=2 fails ❌ (issues finding the dylib for rustc_driver):

Terminal Output
./x run rustfmt --config=bootstrap.rustfmt.toml --stage=2
Building bootstrap
    Finished `dev` profile [unoptimized] target(s) in 0.07s
NOTE: detected 2 modifications that could affect a build of rustc
- src/bootstrap/src/core/build_steps/compile.rs
- src/bootstrap/src/core/build_steps/test.rs
downloading unconditionally due to `download-rustc = true`
/Users/ytmimi/Documents/Projects/rust_projects/rust/build/aarch64-apple-darwin/ci-llvm/bin/llvm-strip does not exist; skipping copy
/Users/ytmimi/Documents/Projects/rust_projects/rust/build/aarch64-apple-darwin/ci-llvm/bin/llvm-strip does not exist; skipping copy
Creating a sysroot for stage2 compiler (use `rustup toolchain link 'name' build/host/stage2`)
Building stage2 rustfmt (stage1 -> stage2, aarch64-apple-darwin)
   Compiling rustfmt-nightly v1.9.0 (/Users/ytmimi/Documents/Projects/rust_projects/rust/src/tools/rustfmt)
    Finished `release` profile [optimized] target(s) in 11.67s
    Finished `release` profile [optimized] target(s) in 0.07s
     Running `build/aarch64-apple-darwin/stage2-tools/aarch64-apple-darwin/release/rustfmt`
dyld[86770]: Library not loaded: @rpath/librustc_driver-5a10d13ef6d8a830.dylib
  Referenced from: <B1C6535C-C813-3C5C-ABE6-9F6459B9C581> /Users/ytmimi/Documents/Projects/rust_projects/rust/build/aarch64-apple-darwin/stage2-tools/aarch64-apple-darwin/release/rustfmt
  Reason: tried: '/Users/ytmimi/Documents/Projects/rust_projects/rust/build/aarch64-apple-darwin/stage2-tools/aarch64-apple-darwin/release/../lib/librustc_driver-5a10d13ef6d8a830.dylib' (no such file), '/Users/ytmimi/Documents/Projects/rust_projects/rust/build/aarch64-apple-darwin/stage2-tools/aarch64-apple-darwin/release/../lib/librustc_driver-5a10d13ef6d8a830.dylib' (no such file), '/Users/ytmimi/Documents/Projects/rust_projects/rust/build/aarch64-apple-darwin/stage2-tools/aarch64-apple-darwin/release/librustc_driver-5a10d13ef6d8a830.dylib' (no such file), '/Users/ytmimi/Documents/Projects/rust_projects/rust/build/aarch64-apple-darwin/stage2-tools/aarch64-apple-darwin/release/deps/librustc_driver-5a10d13ef6d8a830.dylib' (no such file), '/Users/ytmimi/Documents/Projects/rust_projects/rust/build/aarch64-apple-darwin/stage1/lib/rustlib/aarch64-apple-darwin/lib/librustc_driver-5a10d13ef6d8a830.dylib' (no such file), '/Users/ytmimi/lib/librustc_driver-5a10d13ef6d8a830.dylib' (no such file), '/usr/local/lib/librustc_driver-5a10d13ef6d8a830.dylib' (no such file), '/usr/lib/librustc_driver-5a10d13ef6d8a830.dylib' (no such file, not in dyld cache)
Command `/Users/ytmimi/Documents/Projects/rust_projects/rust/build/aarch64-apple-darwin/stage0/bin/cargo run -Zwarnings --target aarch64-apple-darwin -Zbinary-dep-depinfo -j 18 -Zroot-dir=/Users/ytmimi/Documents/Projects/rust_projects/rust --profile=release --manifest-path /Users/ytmimi/Documents/Projects/rust_projects/rust/src/tools/rustfmt/Cargo.toml --bin rustfmt -- [workdir=/Users/ytmimi/Documents/Projects/rust_projects/rust]` failed with exit code 1
Created at: src/bootstrap/src/core/build_steps/tool.rs:191:21
Executed at: src/bootstrap/src/core/build_steps/run.rs:526:28

Command has failed. Rerun with -v to see more details.
Build completed unsuccessfully in 0:00:20

@jieyouxu
Copy link
Copy Markdown
Member Author

jieyouxu commented May 20, 2026

Ugh, yeah, more staging problems. Thanks for the testing. I'll take a look after this week

@jieyouxu jieyouxu added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels May 22, 2026
jieyouxu added 3 commits May 24, 2026 14:25
`compile::Rustc`'s sysroot copying logic intentionally does not
implicitly copy `rustc-dev` artifacts unless explicitly requested
through `builder.ensure(compile::Rustc)`, due to a previous issue
RUST-108767:

```text
// NOTE(rust-lang#108767): We intentionally don't copy `rustc-dev` artifacts until they're
// requested with `builder.ensure(Rustc)`. This fixes an issue where we'd have multiple
// copies of libc in the sysroot with no way to tell which to load. There are a few
// quirks of bootstrap that interact to make this reliable:
// 1. The order `Step`s are run is hard-coded in `builder.rs` and not configurable. This
//    avoids e.g. reordering `test::UiFulldeps` before `test::Ui` and causing the latter
//    to fail because of duplicate metadata.
// 2. The sysroot is deleted and recreated between each invocation, so running `x test
//    ui-fulldeps && x test ui` can't cause failures.
```

So, for rustfmt/clippy, we insert intentionally explicit
`builder.ensure(compile::Rustc)` as a short-term band-aid, leaving
FIXMEs pointing to RUST-156525 to investigate if the multiple libc
copies is still a problem and if that can be fixed properly.

This is by no means a proper fix, but it should unblock local tool
profile workflows trying to use `download-rustc` with {rustfmt,clippy}.
Centrally in `tool::prepare_tool_cargo`.

So that `./x run rustfmt` + `download-rustc` can find the correct rustc
libs.
@jieyouxu jieyouxu force-pushed the jieyouxu/fix/rustfmt-download-rustc branch from 26a44dc to 71487e8 Compare May 24, 2026 12:30
@rustbot
Copy link
Copy Markdown
Collaborator

rustbot commented May 24, 2026

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@rustbot

This comment was marked as off-topic.

@jieyouxu
Copy link
Copy Markdown
Member Author

Not yet ready for proper review (I need to do more local testing). Note to self:

  • Fix PR title + description, this now covers a second case where the ./x run rustfmt flow previously AFAIK was also broken with download-rustc...?
  • Test download-rustc = false flows of {rustfmt,clippy}
  • Re-test ./x test flows for {rustfmt,clippy} with/without download-rustc
  • Add a step resolution snapshot test for the extra compile::Rustc under download-rustc flow + ./x test {rustfmt,clippy}.

@ytmimi could you try out this new set of changes locally to check if both ./x {test,run} rustfmt works for you with download-rustc when you have time?

@ytmimi
Copy link
Copy Markdown
Contributor

ytmimi commented May 26, 2026

@jieyouxu was able to test this again. ./x test rustfmt and ./x run rustfmt are now working! Still can't get it to test or run stage 1 rustfmt, but maybe that's just a tradeoff of using the CI artifacts?


⚠️ `./x test rustfmt --config=bootstrap.rustfmt.toml --stage=1` Works, but logs say "Testing stage2"
./x test rustfmt --config=bootstrap.rustfmt.toml --stage=1
Building bootstrap
    Finished `dev` profile [unoptimized] target(s) in 0.06s
NOTE: detected 4 modifications that could affect a build of rustc
- src/bootstrap/src/core/build_steps/compile.rs
- src/bootstrap/src/core/build_steps/run.rs
- src/bootstrap/src/core/build_steps/test.rs
- src/bootstrap/src/core/build_steps/tool.rs
downloading unconditionally due to `download-rustc = true`
/Users/ytmimi/Documents/Projects/rust_projects/rust/build/aarch64-apple-darwin/ci-llvm/bin/llvm-strip does not exist; skipping copy
Creating a sysroot for stage1 compiler (use `rustup toolchain link 'name' build/host/stage1`)
/Users/ytmimi/Documents/Projects/rust_projects/rust/build/aarch64-apple-darwin/ci-llvm/bin/llvm-strip does not exist; skipping copy
Testing stage2 rustfmt (aarch64-apple-darwin)
    Finished `release` profile [optimized] target(s) in 0.33s
     Running unittests src/lib.rs (build/aarch64-apple-darwin/stage2-tools/aarch64-apple-darwin/release/deps/rustfmt_nightly-70982026117283e7)

running 232 tests
........................................................................................  88/232
........................................................................................ 176/232
....................error: this file contains an unclosed delimiter
 --> tests/parser/stashed-diag2.rs:3:14
  |
1 | trait Trait<'1> { s> {}
  |                 - unclosed delimiter
2 |
3 | fn main() {}
  |             ^

error: missing type for `static` item
 --> tests/parser/stashed-diag.rs:1:15
  |
1 | #![u={static N;}]
  |               ^
  |
help: provide a type for the item
  |
1 | #![u={static N: <type>;}]
  |               ++++++++

error: mismatched closing delimiter: `}`
 --> tests/parser/unclosed-delims/issue_4466.rs:3:17
  |
2 |     if true {
  |             - closing delimiter possibly meant for this
3 |         println!("answer: {}", a_func();
  |                 ^ unclosed delimiter
4 |     } else {
  |     ^ mismatched closing delimiter

error: lifetimes cannot start with a number
 --> tests/parser/stashed-diag2.rs:1:13
  |
1 | trait Trait<'1> { s> {}
  |             ^^

....error: unexpected closing delimiter: `}`
 --> tests/parser/issue_4418.rs:1:1
  |
1 | }
  | ^ unexpected closing delimiter

.......error: this file contains an unclosed delimiter
 --> <stdin>:1:2
  |
1 | {
  | -^
  | |
  | unclosed delimiter

....error: unexpected `if` in the condition expression
 --> tests/parser/issue-4126/invalid.rs:2:14
  |
2 |     if bar && if !baz {
  |              ^^^^
  |
help: remove the `if`
  |
2 -     if bar && if !baz {
2 +     if bar && !baz {
  |

error: unexpected closing delimiter: `}`
 --> <stdin>:1:1
  |
1 | }
  | ^ unexpected closing delimiter

.....................

test result: ok. 232 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 613.32ms

     Running unittests src/cargo-fmt/main.rs (build/aarch64-apple-darwin/stage2-tools/aarch64-apple-darwin/release/deps/cargo_fmt-83b1aec189b5c4a9)

running 24 tests
........................

test result: ok. 24 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 52.28ms

     Running unittests src/git-rustfmt/main.rs (build/aarch64-apple-darwin/stage2-tools/aarch64-apple-darwin/release/deps/git_rustfmt-6509d6b3295aedc7)

running 0 tests


test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 114.46µs

     Running unittests src/bin/main.rs (build/aarch64-apple-darwin/stage2-tools/aarch64-apple-darwin/release/deps/rustfmt-de621ad4898279c8)

running 16 tests
................

test result: ok. 16 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 2.74ms

     Running unittests src/format-diff/main.rs (build/aarch64-apple-darwin/stage2-tools/aarch64-apple-darwin/release/deps/rustfmt_format_diff-8da153f3a9a9c11f)

running 7 tests
.......

test result: ok. 7 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 2.68ms

     Running tests/cargo-fmt/main.rs (build/aarch64-apple-darwin/stage2-tools/aarch64-apple-darwin/release/deps/cargo_fmt-62a2a86b13c256e5)

running 5 tests
iiiii

test result: ok. 0 passed; 0 failed; 5 ignored; 0 measured; 0 filtered out; finished in 27.67µs

     Running tests/rustfmt/main.rs (build/aarch64-apple-darwin/stage2-tools/aarch64-apple-darwin/release/deps/rustfmt-5379267e03963cb9)

running 13 tests
ii...........

test result: ok. 11 passed; 0 failed; 2 ignored; 0 measured; 0 filtered out; finished in 80.61ms

   Doc-tests rustfmt_nightly

running 3 tests
i..

test result: ok. 2 passed; 0 failed; 1 ignored; 0 measured; 0 filtered out; finished in 331.84ms

	finished in 11.325 seconds
Build completed successfully in 0:00:23

✅ `./x test rustfmt --config=bootstrap.rustfmt.toml --stage=2` Works
./x test rustfmt --config=bootstrap.rustfmt.toml --stage=2
Building bootstrap
    Finished `dev` profile [unoptimized] target(s) in 0.07s
NOTE: detected 4 modifications that could affect a build of rustc
- src/bootstrap/src/core/build_steps/compile.rs
- src/bootstrap/src/core/build_steps/run.rs
- src/bootstrap/src/core/build_steps/test.rs
- src/bootstrap/src/core/build_steps/tool.rs
downloading unconditionally due to `download-rustc = true`
/Users/ytmimi/Documents/Projects/rust_projects/rust/build/aarch64-apple-darwin/ci-llvm/bin/llvm-strip does not exist; skipping copy
/Users/ytmimi/Documents/Projects/rust_projects/rust/build/aarch64-apple-darwin/ci-llvm/bin/llvm-strip does not exist; skipping copy
Creating a sysroot for stage2 compiler (use `rustup toolchain link 'name' build/host/stage2`)
Testing stage2 rustfmt (aarch64-apple-darwin)
    Finished `release` profile [optimized] target(s) in 0.32s
     Running unittests src/lib.rs (build/aarch64-apple-darwin/stage2-tools/aarch64-apple-darwin/release/deps/rustfmt_nightly-70982026117283e7)

running 232 tests
........................................................................................  88/232
........................................................................................ 176/232
...................error: mismatched closing delimiter: `}`
 --> tests/parser/unclosed-delims/issue_4466.rs:3:17
  |
2 |     if true {
  |             - closing delimiter possibly meant for this
3 |         println!("answer: {}", a_func();
  |                 ^ unclosed delimiter
4 |     } else {
  |     ^ mismatched closing delimiter

error: this file contains an unclosed delimiter
 --> tests/parser/stashed-diag2.rs:3:14
  |
1 | trait Trait<'1> { s> {}
  |                 - unclosed delimiter
2 |
3 | fn main() {}
  |             ^

.error: missing type for `static` item
 --> tests/parser/stashed-diag.rs:1:15
  |
1 | #![u={static N;}]
  |               ^
  |
help: provide a type for the item
  |
1 | #![u={static N: <type>;}]
  |               ++++++++

.error: lifetimes cannot start with a number
 --> tests/parser/stashed-diag2.rs:1:13
  |
1 | trait Trait<'1> { s> {}
  |             ^^

......error: unexpected closing delimiter: `}`
 --> tests/parser/issue_4418.rs:1:1
  |
1 | }
  | ^ unexpected closing delimiter

...error: this file contains an unclosed delimiter
 --> <stdin>:1:2
  |
1 | {
  | -^
  | |
  | unclosed delimiter

....error: unexpected closing delimiter: `}`
 --> <stdin>:1:1
  |
1 | }
  | ^ unexpected closing delimiter

error: unexpected `if` in the condition expression
 --> tests/parser/issue-4126/invalid.rs:2:14
  |
2 |     if bar && if !baz {
  |              ^^^^
  |
help: remove the `if`
  |
2 -     if bar && if !baz {
2 +     if bar && !baz {
  |

......................

test result: ok. 232 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 610.72ms

     Running unittests src/cargo-fmt/main.rs (build/aarch64-apple-darwin/stage2-tools/aarch64-apple-darwin/release/deps/cargo_fmt-83b1aec189b5c4a9)

running 24 tests
........................

test result: ok. 24 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 50.63ms

     Running unittests src/git-rustfmt/main.rs (build/aarch64-apple-darwin/stage2-tools/aarch64-apple-darwin/release/deps/git_rustfmt-6509d6b3295aedc7)

running 0 tests


test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 130.67µs

     Running unittests src/bin/main.rs (build/aarch64-apple-darwin/stage2-tools/aarch64-apple-darwin/release/deps/rustfmt-de621ad4898279c8)

running 16 tests
................

test result: ok. 16 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 2.08ms

     Running unittests src/format-diff/main.rs (build/aarch64-apple-darwin/stage2-tools/aarch64-apple-darwin/release/deps/rustfmt_format_diff-8da153f3a9a9c11f)

running 7 tests
.......

test result: ok. 7 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 2.49ms

     Running tests/cargo-fmt/main.rs (build/aarch64-apple-darwin/stage2-tools/aarch64-apple-darwin/release/deps/cargo_fmt-62a2a86b13c256e5)

running 5 tests
iiiii

test result: ok. 0 passed; 0 failed; 5 ignored; 0 measured; 0 filtered out; finished in 31.88µs

     Running tests/rustfmt/main.rs (build/aarch64-apple-darwin/stage2-tools/aarch64-apple-darwin/release/deps/rustfmt-5379267e03963cb9)

running 13 tests
ii...........

test result: ok. 11 passed; 0 failed; 2 ignored; 0 measured; 0 filtered out; finished in 77.01ms

   Doc-tests rustfmt_nightly

running 3 tests
i..

test result: ok. 2 passed; 0 failed; 1 ignored; 0 measured; 0 filtered out; finished in 335.35ms

	finished in 11.425 seconds
Build completed successfully in 0:00:22

⚠️ `./x run rustfmt --config=bootstrap.rustfmt.toml --stage=1` Works, but it builds and runs stage2 rustfmt
./x run rustfmt --config=bootstrap.rustfmt.toml --stage=1 
Building bootstrap
    Finished `dev` profile [unoptimized] target(s) in 0.07s
NOTE: detected 4 modifications that could affect a build of rustc
- src/bootstrap/src/core/build_steps/compile.rs
- src/bootstrap/src/core/build_steps/run.rs
- src/bootstrap/src/core/build_steps/test.rs
- src/bootstrap/src/core/build_steps/tool.rs
downloading unconditionally due to `download-rustc = true`
/Users/ytmimi/Documents/Projects/rust_projects/rust/build/aarch64-apple-darwin/ci-llvm/bin/llvm-strip does not exist; skipping copy
Creating a sysroot for stage1 compiler (use `rustup toolchain link 'name' build/host/stage1`)
/Users/ytmimi/Documents/Projects/rust_projects/rust/build/aarch64-apple-darwin/ci-llvm/bin/llvm-strip does not exist; skipping copy
Building stage2 rustfmt (stage1 -> stage2, aarch64-apple-darwin)
   Compiling rustfmt-nightly v1.9.0 (/Users/ytmimi/Documents/Projects/rust_projects/rust/src/tools/rustfmt)
    Finished `release` profile [optimized] target(s) in 11.59s
    Finished `release` profile [optimized] target(s) in 0.08s
     Running `build/aarch64-apple-darwin/stage2-tools/aarch64-apple-darwin/release/rustfmt`
fn main() {}
fn main() {}
Build completed successfully in 0:00:29

✅ `./x run rustfmt --config=bootstrap.rustfmt.toml --stage=2` Works
./x run rustfmt --config=bootstrap.rustfmt.toml --stage=2 
Building bootstrap
    Finished `dev` profile [unoptimized] target(s) in 0.07s

NOTE: detected 4 modifications that could affect a build of rustc
- src/bootstrap/src/core/build_steps/compile.rs
- src/bootstrap/src/core/build_steps/run.rs
- src/bootstrap/src/core/build_steps/test.rs
- src/bootstrap/src/core/build_steps/tool.rs
downloading unconditionally due to `download-rustc = true`
/Users/ytmimi/Documents/Projects/rust_projects/rust/build/aarch64-apple-darwin/ci-llvm/bin/llvm-strip does not exist; skipping copy
/Users/ytmimi/Documents/Projects/rust_projects/rust/build/aarch64-apple-darwin/ci-llvm/bin/llvm-strip does not exist; skipping copy
Creating a sysroot for stage2 compiler (use `rustup toolchain link 'name' build/host/stage2`)
Building stage2 rustfmt (stage1 -> stage2, aarch64-apple-darwin)
   Compiling rustfmt-nightly v1.9.0 (/Users/ytmimi/Documents/Projects/rust_projects/rust/src/tools/rustfmt)
    Finished `release` profile [optimized] target(s) in 11.45s
    Finished `release` profile [optimized] target(s) in 0.07s
     Running `build/aarch64-apple-darwin/stage2-tools/aarch64-apple-darwin/release/rustfmt`
fn main() {}
fn main() {}
Build completed successfully in 0:00:24

@jieyouxu
Copy link
Copy Markdown
Member Author

jieyouxu commented May 27, 2026

Still can't get it to test or run stage 1 rustfmt, but maybe that's just a tradeoff of using the CI artifacts?

This is expected (albeit somewhat confusing yes) from using ci rustc -- since when using download rustc we are trying to avoid building a rustc, the downloaded rustc is treated as a stage 2 compiler (for --stage >= 1) (hm, maybe a step log stage is off-by-one somewhere).

@jieyouxu jieyouxu changed the title bootstrap: explicitly request copying rustc-dev artifacts for rustfmt/clippy under download-rustc bootstrap: explicitly request copying rustc-dev artifacts for rustfmt/clippy and add rustc libs path for rustc-private tools under download-rustc May 27, 2026
@jieyouxu jieyouxu changed the title bootstrap: explicitly request copying rustc-dev artifacts for rustfmt/clippy and add rustc libs path for rustc-private tools under download-rustc Explicitly request copying rustc-dev artifacts for rustfmt/clippy and add rustc libs path for rustc-private tools under download-rustc May 27, 2026
@jieyouxu
Copy link
Copy Markdown
Member Author

Retested:

  • ./x test rustfmt --stage={1,2} (download-rustc=false)
  • ./x test rustdoc --stage=1

I did look at a step resolution shapshot test, but it turns out the way we implement download-rustc makes it "not show up" materially different in terms of steps versus non-download-rustc. Oh well.

@rustbot review

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels May 27, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-download-rustc Area: The `rust.download-rustc` build option. A-testsuite Area: The testsuite used to check the correctness of rustc S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants