Skip to content

Conversation

@Zalathar
Copy link
Member


One of the confusing things about bootstrap's Step::should_run is that it combines two loosely-related but non-overlapping responsibilities:

  • Registering paths/aliases to decide whether a step should be run in response to paths/aliases passed as explicit command-line arguments
    • When the user invokes ./x test compiler, this allows bootstrap to know what steps “compiler” should translate into
  • Deciding whether a step marked DEFAULT = true should actually run or not, when no paths/aliases are explicitly specified
    • When the user invokes ./x test, this allows bootstrap to know which steps to run by default

This PR therefore splits out the latter of those responsibilities into a dedicated is_default_step associated function, which also replaces the existing DEFAULT associated constant.

A small number of steps were using ShouldRun::lazy_default_condition to specify a condition that should not be run repeatedly if possible, e.g. because it queries external tools. Those steps now perform memoization via fields in Builder instead.

r? jieyouxu

@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 Nov 16, 2025
@Zalathar
Copy link
Member Author

Ignoring the new snapshot tests, the actual git diff --shortstat is more like +511, -307.

Copy link
Member

@Kobzol Kobzol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great cleanup! To go further, I think that we could eventually rethink/rename all the important Step functions (not in this PR).

Something like:

should_run => `define_cli_paths`
is_default_step => `should_run_by_default`, `should_run_with_no_path` or just `is_default`
make_run => `run_from_cli`

I would suggest making fn is_default_step { true } the default implementation. IMO everything should be enabled by default, so that we don't miss steps by accident, and only specific steps should return false. This reduces then need to think about the right default impl for the is_default_step function. Most/more of the impls in this PR return true anyway.

View changes since this review

fn check_if_tidy_is_installed(builder: &Builder<'_>) -> bool {
command("tidy").allow_failure().arg("--version").run_capture_stdout(builder).is_success()
*builder.html_tidy_is_available_memo.get_or_init(|| {
command("tidy").allow_failure().arg("--version").run_capture_stdout(builder).is_success()
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rather than caching this in the builder, you can just make the command cached (.cached()). That's IMO much simpler.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Caching the command output is a bit less powerful, since it doesn't cache the subsequent processing steps.

But if running the command repeatedly is the thing we're worried about, then that's fine.

Ideally I would want to not perform these probes here at all, and instead require opt-in config for these tools. But that's well beyond the scope of this PR.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tbh I think that even without any caching it would be fine. But if anything, I'd expect the command invocation to take more time than the processing.

Copy link
Member

@jieyouxu jieyouxu Nov 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally I would want to not perform these probes here at all, and instead require opt-in config for these tools. But that's well beyond the scope of this PR.

This is also my preference (if I were to redesign this setup from scratch), but I can appreciate it being annoying for existing usages.

@Zalathar
Copy link
Member Author

Great cleanup! To go further, I think that we could eventually rethink/rename all the important Step functions (not in this PR).

Something like:

should_run => `define_cli_paths`
is_default_step => `should_run_by_default`, `should_run_with_no_path` or just `is_default`
make_run => `run_from_cli`

I would suggest making fn is_default_step { true } the default implementation. IMO everything should be enabled by default, so that we don't miss steps by accident, and only specific steps should return false. This reduces then need to think about the right default impl for the is_default_step function. Most/more of the impls in this PR return true anyway.

I've written some of my thoughts about this on Zulip, since it's a bit of a pain to have an actual discussion on GitHub.

@jieyouxu
Copy link
Member

Holding off on reviewing this to wait for the discussion to settle down first.
@rustbot label: -S-waiting-on-review +S-waiting-on-t-bootstrap

@rustbot rustbot added S-waiting-on-t-bootstrap Status: Awaiting decision from T-bootstrap. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Nov 17, 2025
@bors
Copy link
Collaborator

bors commented Nov 17, 2025

☔ The latest upstream changes (presumably #148763) made this pull request unmergeable. Please resolve the merge conflicts.

@bors bors added the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Nov 17, 2025
@rustbot

This comment has been minimized.

@jieyouxu jieyouxu 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. S-waiting-on-t-bootstrap Status: Awaiting decision from T-bootstrap. labels Nov 24, 2025
Copy link
Member

@jieyouxu jieyouxu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, handing review back to Jakub in case they had more feedback

View changes since this review

@jieyouxu
Copy link
Member

r? @Kobzol

@rustbot rustbot assigned Kobzol and unassigned jieyouxu Nov 26, 2025
@rustbot
Copy link
Collaborator

rustbot commented Nov 26, 2025

Kobzol is not on the review rotation at the moment.
They may take a while to respond.

@jieyouxu
Copy link
Member

Right. r? me

In that case, I think let's merge this as-is. If we wanted to make run-by-default the default (hah), we can still do that in a follow-up.

@bors r+ rollup=never

@bors
Copy link
Collaborator

bors commented Nov 26, 2025

📌 Commit 231c789 has been approved by jieyouxu

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Nov 26, 2025
@rust-log-analyzer

This comment has been minimized.

@rustbot
Copy link
Collaborator

rustbot commented Nov 26, 2025

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.

@Zalathar
Copy link
Member Author

Rebased to fix a trivial soft-conflict with the new step added by #149071.

@jieyouxu
Copy link
Member

r=me once PR CI is green enough

@Kobzol
Copy link
Member

Kobzol commented Nov 26, 2025

Fine by me to this as-is 👍

@Zalathar
Copy link
Member Author

@bors r=jieyouxu

@bors
Copy link
Collaborator

bors commented Nov 26, 2025

📌 Commit df8a851 has been approved by jieyouxu

It is now in the queue for this repository.

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Nov 26, 2025
bors added a commit that referenced this pull request Nov 27, 2025
bootstrap: Replace `Step::DEFAULT` and `default_condition` with `is_default_step`

- Revised and expanded version of #148965

---

One of the confusing things about bootstrap's `Step::should_run` is that it combines two loosely-related but non-overlapping responsibilities:
- Registering paths/aliases to decide whether a step should be run in response to paths/aliases passed as explicit command-line arguments
  - When the user invokes `./x test compiler`, this allows bootstrap to know what steps “compiler” should translate into
- Deciding whether a step marked `DEFAULT = true` should actually run or not, when no paths/aliases are explicitly specified
  - When the user invokes `./x test`, this allows bootstrap to know which steps to run by default

This PR therefore splits out the latter of those responsibilities into a dedicated `is_default_step` associated function, which also replaces the existing `DEFAULT` associated constant.

A small number of steps were using `ShouldRun::lazy_default_condition` to specify a condition that should not be run repeatedly if possible, e.g. because it queries external tools. Those steps now perform memoization via fields in `Builder` instead.

r? jieyouxu
@bors
Copy link
Collaborator

bors commented Nov 27, 2025

⌛ Testing commit df8a851 with merge c4d75ac...

@bors
Copy link
Collaborator

bors commented Nov 27, 2025

💔 Test failed - checks-actions

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Nov 27, 2025
@jieyouxu
Copy link
Member

The hosted runner lost communication with the server.

Tragic. @bors retry

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Nov 27, 2025
@bors
Copy link
Collaborator

bors commented Nov 27, 2025

⌛ Testing commit df8a851 with merge cf8a955...

@bors
Copy link
Collaborator

bors commented Nov 27, 2025

☀️ Test successful - checks-actions
Approved by: jieyouxu
Pushing cf8a955 to main...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Nov 27, 2025
@bors bors merged commit cf8a955 into rust-lang:main Nov 27, 2025
12 checks passed
@rustbot rustbot added this to the 1.93.0 milestone Nov 27, 2025
@github-actions
Copy link
Contributor

What is this? This is an experimental post-merge analysis report that shows differences in test outcomes between the merged PR and its parent PR.

Comparing 7b9905e (parent) -> cf8a955 (this PR)

Test differences

Show 13 test diffs

Stage 0

  • core::builder::cli_paths::tests::x_bench: [missing] -> pass (J0)
  • core::builder::cli_paths::tests::x_clean: [missing] -> pass (J0)
  • core::builder::cli_paths::tests::x_clippy: [missing] -> pass (J0)
  • core::builder::cli_paths::tests::x_doc: [missing] -> pass (J0)
  • core::builder::cli_paths::tests::x_fix: [missing] -> pass (J0)
  • core::builder::cli_paths::tests::x_fmt: [missing] -> pass (J0)
  • core::builder::cli_paths::tests::x_install: [missing] -> pass (J0)
  • core::builder::cli_paths::tests::x_miri: [missing] -> pass (J0)
  • core::builder::cli_paths::tests::x_run: [missing] -> pass (J0)
  • core::builder::cli_paths::tests::x_setup: [missing] -> pass (J0)
  • core::builder::cli_paths::tests::x_vendor: [missing] -> pass (J0)

Additionally, 2 doctest diffs were found. These are ignored, as they are noisy.

Job group index

Test dashboard

Run

cargo run --manifest-path src/ci/citool/Cargo.toml -- \
    test-dashboard cf8a95590a1b768b7711f2631d5b5e3ead464de7 --output-dir test-dashboard

And then open test-dashboard/index.html in your browser to see an overview of all executed tests.

Job duration changes

  1. dist-x86_64-apple: 9564.5s -> 6734.7s (-29.6%)
  2. dist-apple-various: 3384.3s -> 3892.2s (+15.0%)
  3. dist-aarch64-apple: 7384.5s -> 6425.7s (-13.0%)
  4. x86_64-gnu-miri: 4555.3s -> 4091.8s (-10.2%)
  5. aarch64-gnu-llvm-20-1: 3366.3s -> 3687.7s (+9.5%)
  6. dist-i586-gnu-i586-i686-musl: 5366.8s -> 4896.1s (-8.8%)
  7. aarch64-gnu-llvm-20-2: 2181.2s -> 2362.0s (+8.3%)
  8. dist-i686-msvc: 7766.6s -> 8359.5s (+7.6%)
  9. dist-sparcv9-solaris: 5305.7s -> 4910.7s (-7.4%)
  10. x86_64-msvc-1: 9078.6s -> 9740.5s (+7.3%)
How to interpret the job duration changes?

Job durations can vary a lot, based on the actual runner instance
that executed the job, system noise, invalidated caches, etc. The table above is provided
mostly for t-infra members, for simpler debugging of potential CI slow-downs.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (cf8a955): comparison URL.

Overall result: no relevant changes - no action needed

@rustbot label: -perf-regression

Instruction count

This benchmark run did not return any relevant results for this metric.

Max RSS (memory usage)

Results (secondary 4.2%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
4.2% [4.2%, 4.2%] 1
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) - - 0

Cycles

Results (primary 0.3%, secondary 0.9%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

mean range count
Regressions ❌
(primary)
2.3% [2.3%, 2.3%] 1
Regressions ❌
(secondary)
4.4% [4.4%, 4.4%] 1
Improvements ✅
(primary)
-1.6% [-1.6%, -1.6%] 1
Improvements ✅
(secondary)
-2.5% [-2.5%, -2.5%] 1
All ❌✅ (primary) 0.3% [-1.6%, 2.3%] 2

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 470.06s -> 470.335s (0.06%)
Artifact size: 386.96 MiB -> 386.93 MiB (-0.01%)

@Zalathar Zalathar deleted the is-default branch November 27, 2025 22:45
makai410 pushed a commit to makai410/rust that referenced this pull request Dec 10, 2025
bootstrap: Replace `Step::DEFAULT` and `default_condition` with `is_default_step`

- Revised and expanded version of rust-lang#148965

---

One of the confusing things about bootstrap's `Step::should_run` is that it combines two loosely-related but non-overlapping responsibilities:
- Registering paths/aliases to decide whether a step should be run in response to paths/aliases passed as explicit command-line arguments
  - When the user invokes `./x test compiler`, this allows bootstrap to know what steps “compiler” should translate into
- Deciding whether a step marked `DEFAULT = true` should actually run or not, when no paths/aliases are explicitly specified
  - When the user invokes `./x test`, this allows bootstrap to know which steps to run by default

This PR therefore splits out the latter of those responsibilities into a dedicated `is_default_step` associated function, which also replaces the existing `DEFAULT` associated constant.

A small number of steps were using `ShouldRun::lazy_default_condition` to specify a condition that should not be run repeatedly if possible, e.g. because it queries external tools. Those steps now perform memoization via fields in `Builder` instead.

r? jieyouxu
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-testsuite Area: The testsuite used to check the correctness of rustc merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. 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.

7 participants