rust-lang / rust-lang/rust

`x.py check; x.py test` builds compiler twice

Open
#143,815 3 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

C-bug S-needs-repro T-bootstrap
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

repro:
git clone https://github.com/rust-lang/rust --depth=10 ; cd rust ; ./x.py check

downloading https://static.rust-lang.org/dist/2025-06-24/rust-std-beta-x86_64-unknown-linux-gnu.tar.xz
##################################################################################################################################################################################################################################################################################################################### 100.0%
downloading https://static.rust-lang.org/dist/2025-06-24/rustc-beta-x86_64-unknown-linux-gnu.tar.xz
##################################################################################################################################################################################################################################################################################################################### 100.0%
downloading https://static.rust-lang.org/dist/2025-06-24/cargo-beta-x86_64-unknown-linux-gnu.tar.xz
##################################################################################################################################################################################################################################################################################################################### 100.0%
extracting /tmp/rust/build/cache/2025-06-24/rust-std-beta-x86_64-unknown-linux-gnu.tar.xz
extracting /tmp/rust/build/cache/2025-06-24/rustc-beta-x86_64-unknown-linux-gnu.tar.xz
extracting /tmp/rust/build/cache/2025-06-24/cargo-beta-x86_64-unknown-linux-gnu.tar.xz
Building bootstrap
...
    Finished `dev` profile [unoptimized] target(s) in 25.10s
downloading https://static.rust-lang.org/dist/2025-06-24/rustfmt-nightly-x86_64-unknown-linux-gnu.tar.xz
##################################################################################################################################################################################################################################################################################################################### 100.0%
extracting /tmp/rust/build/cache/2025-06-24/rustfmt-nightly-x86_64-unknown-linux-gnu.tar.xz to /tmp/rust/build/x86_64-unknown-linux-gnu/rustfmt
downloading https://static.rust-lang.org/dist/2025-06-24/rustc-nightly-x86_64-unknown-linux-gnu.tar.xz
##################################################################################################################################################################################################################################################################################################################### 100.0%
extracting /tmp/rust/build/cache/2025-06-24/rustc-nightly-x86_64-unknown-linux-gnu.tar.xz to /tmp/rust/build/x86_64-unknown-linux-gnu/rustfmt
WARNING: you have not made a `bootstrap.toml`
HELP: consider running `./x.py setup` or copying `bootstrap.example.toml` by running `cp bootstrap.example.toml bootstrap.toml`
Updating submodule library/backtrace
Submodule 'library/backtrace' (https://github.com/rust-lang/backtrace-rs.git) registered for path 'library/backtrace'
Cloning into '/tmp/rust/library/backtrace'...
remote: Enumerating objects: 147, done.
remote: Counting objects: 100% (147/147), done.
remote: Compressing objects: 100% (113/113), done.
remote: Total 147 (delta 6), reused 95 (delta 4), pack-reused 0 (from 0)
Receiving objects: 100% (147/147), 119.85 KiB | 4.13 MiB/s, done.
Resolving deltas: 100% (6/6), done.
Submodule path 'library/backtrace': checked out 'b65ab935fb2e0d59dba8966ffca09c9cc5a5f57c'
Updating submodule library/backtrace
downloading https://ci-artifacts.rust-lang.org/rustc-builds/32cd9114712a24010b0583624dc52ac302194128/rust-dev-nightly-x86_64-unknown-linux-gnu.tar.xz
##################################################################################################################################################################################################################################################################################################################### 100.0%
extracting /tmp/rust/build/cache/llvm-32cd9114712a24010b0583624dc52ac302194128-false/rust-dev-nightly-x86_64-unknown-linux-gnu.tar.xz to /tmp/rust/build/x86_64-unknown-linux-gnu/ci-llvm
Checking stage1 compiler artifacts {rustc-main, rustc_abi, rustc_arena, rustc_ast, rustc_ast_ir, rustc_ast_lowering, rustc_ast_passes, rustc_ast_pretty, rustc_attr_data_structures, rustc_attr_parsing, rustc_baked_icu_data, rustc_borrowck, rustc_builtin_macros, rustc_codegen_llvm, rustc_codegen_ssa, rustc_const_eval, rustc_data_structures, rustc_driver, rustc_driver_impl, rustc_error_codes, rustc_error_messages, rustc_errors, rustc_expand, rustc_feature, rustc_fluent_macro, rustc_fs_util, rustc_graphviz, rustc_hashes, rustc_hir, rustc_hir_analysis, rustc_hir_pretty, rustc_hir_typeck, rustc_incremental, rustc_index, rustc_index_macros, rustc_infer, rustc_interface, rustc_lexer, rustc_lint, rustc_lint_defs, rustc_llvm, rustc_log, rustc_macros, rustc_metadata, rustc_middle, rustc_mir_build, rustc_mir_dataflow, rustc_mir_transform, rustc_monomorphize, rustc_next_trait_solver, rustc_parse, rustc_parse_format, rustc_passes, rustc_pattern_analysis, rustc_privacy, rustc_proc_macro, rustc_query_impl, rustc_query_system, rustc_resolve, rustc_sanitizers, rustc_serialize, rustc_session, rustc_smir, rustc_span, rustc_symbol_mangling, rustc_target, rustc_thread_pool, rustc_trait_selection, rustc_traits, rustc_transmute, rustc_ty_utils, rustc_type_ir, rustc_type_ir_macros, stable_mir} (x86_64-unknown-linux-gnu)
....
    Finished `release` profile [optimized] target(s) in 1m 05s
Checking tool rustdoc (stage0 -> stage1, x86_64-unknown-linux-gnu)
...
    Finished `release` profile [optimized] target(s) in 18.21s
Checking stage1 rustc_codegen_cranelift (x86_64-unknown-linux-gnu)
...
    Finished `release` profile [optimized] target(s) in 19.81s
Checking stage1 rustc_codegen_gcc (x86_64-unknown-linux-gnu)
...
Checking tool clippy (stage0 -> stage1, x86_64-unknown-linux-gnu)
    Checking memchr v2.7.5
...
    Finished `release` profile [optimized] target(s) in 22.68s
Checking tool miri (stage0 -> stage1, x86_64-unknown-linux-gnu)
...
    Finished `release` profile [optimized] target(s) in 1m 01s
Checking tool cargo-miri (stage0 -> stage1, x86_64-unknown-linux-gnu)
...
    Finished `release` profile [optimized] target(s) in 6.38s
Checking stage1 tool miropt-test-tools (x86_64-unknown-linux-gnu)
    Checking miropt-test-tools v0.1.0 (/tmp/rust/src/tools/miropt-test-tools)
    Finished `release` profile [optimized] target(s) in 0.30s
Checking tool rustfmt (stage0 -> stage1, x86_64-unknown-linux-gnu)
...
    Finished `release` profile [optimized] target(s) in 11.68s
Checking stage1 rust-analyzer artifacts (x86_64-unknown-linux-gnu)
...
    Finished `release` profile [optimized] target(s) in 50.14s
/tmp/rust/build/x86_64-unknown-linux-gnu/ci-llvm/bin/llvm-strip does not exist; skipping copy
Building compiler artifacts (stage0 -> stage1, x86_64-unknown-linux-gnu) ///                         <<<---- !!!
...
    Finished `release` profile [optimized] target(s) in 5m 51s
Creating a sysroot for stage1 compiler (use `rustup toolchain link 'name' build/host/stage1`)
Building stage1 library artifacts (x86_64-unknown-linux-gnu)
...
    Finished `release` profile [optimized] target(s) in 25.27s
Checking stage2 tool test-float-parse (x86_64-unknown-linux-gnu)
...
    Finished `release` profile [optimized] target(s) in 5.27s
Checking stage1 tool features-status-dump (x86_64-unknown-linux-gnu)
...
    Finished `release` profile [optimized] target(s) in 10.73s
Checking stage1 library artifacts {alloc, compiler_builtins, core, panic_abort, panic_unwind, proc_macro, std, sysroot, test, unwind} (x86_64-unknown-linux-gnu)
...
Checking stage1 library test/bench/example targets (x86_64-unknown-linux-gnu)
    Finished `release` profile [optimized] target(s) in 0.02s
WARNING: you have not made a `bootstrap.toml`
HELP: consider running `./x.py setup` or copying `bootstrap.example.toml` by running `cp bootstrap.example.toml bootstrap.toml`
NOTE: this message was printed twice to make it more likely to be seen
Build completed successfully in 0:12:44

now, when I do a x.py test we build the compiler again, although we just did that!
As if something in the build process had touched the rustc sources or we are now running with a different cfg somehow?

x.py test ui

Building bootstrap
    Finished `dev` profile [unoptimized] target(s) in 0.04s
WARNING: you have not made a `bootstrap.toml`
HELP: consider running `./x.py setup` or copying `bootstrap.example.toml` by running `cp bootstrap.example.toml bootstrap.toml`
/tmp/rust/build/x86_64-unknown-linux-gnu/ci-llvm/bin/llvm-strip does not exist; skipping copy
Building compiler artifacts (stage0 -> stage1, x86_64-unknown-linux-gnu) /// not again :((
   Compiling rustc_data_structures v0.0.0 (/tmp/rust/compiler/rustc_data_structures)
   Compiling unic-langid-impl v0.9.6
   Compiling yoke v0.7.5
   Compiling serde_json v1.0.140
   Compiling fluent-syntax v0.12.0
   Compiling gsgdt v0.1.2
   Compiling tracing-subscriber v0.3.18
....

Is it possible to avoid that?

Operating system

6.14.6-2-MANJARO

HEAD

cdac44e60

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the issue with ./x.py check followed by ./x.py test ui, then start at the x.py check and test entry points and the bootstrap build output. Compare the build state after each command to identify why compiler artifacts are rebuilt; done means the second command reuses the compiler built by the first without changing test behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
build-system, compilers
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.