Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stabilize stage management for rustc tools #137215

Merged
merged 16 commits into from
Feb 23, 2025

Conversation

onur-ozkan
Copy link
Member

@onur-ozkan onur-ozkan commented Feb 18, 2025

#135990 got out of control due to excessive complexity. This PR aims to achieve the same goal with a simpler approach, likely through multiple smaller PRs. I will keep the other one read-only and open as a reference for future work.

This work stabilizes the staging logic for ToolRustc programs, so you no longer need to handle build and target compilers separately in steps. Previously, most tools didn't do this correctly, which was causing the compiler to be built twice (e.g., x test cargo --stage 1 would compile the stage 2 compiler before, but now it only compiles the stage 1 compiler).

I also tried to document how we should write ToolRustc steps as they are quite different and require more attention than other tools.

Next goal is to stabilize how stages are handled for the rustc itself. Currently, x build --stage 1 builds the stage 1 compiler which is fine, but x build compiler --stage 1 builds stage 2 compiler.

for now, r? ghost

@rustbot rustbot added 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 Feb 18, 2025
@jieyouxu
Copy link
Member

jieyouxu commented Feb 18, 2025

Feel free to r/? me if you want help with testing / becomes ready for review.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rustbot rustbot added the A-testsuite Area: The testsuite used to check the correctness of rustc label Feb 18, 2025
@onur-ozkan onur-ozkan force-pushed the rustc-tool-build-stages branch 2 times, most recently from 90a651c to 23999ef Compare February 18, 2025 12:21
Signed-off-by: onur-ozkan <work@onurozkan.dev>
Signed-off-by: onur-ozkan <work@onurozkan.dev>
Signed-off-by: onur-ozkan <work@onurozkan.dev>
Signed-off-by: onur-ozkan <work@onurozkan.dev>
Signed-off-by: onur-ozkan <work@onurozkan.dev>
Signed-off-by: onur-ozkan <work@onurozkan.dev>
@onur-ozkan onur-ozkan force-pushed the rustc-tool-build-stages branch from 23999ef to a338439 Compare February 18, 2025 12:35
Signed-off-by: onur-ozkan <work@onurozkan.dev>
Signed-off-by: onur-ozkan <work@onurozkan.dev>
Signed-off-by: onur-ozkan <work@onurozkan.dev>
Signed-off-by: onur-ozkan <work@onurozkan.dev>
Signed-off-by: onur-ozkan <work@onurozkan.dev>
Signed-off-by: onur-ozkan <work@onurozkan.dev>
Signed-off-by: onur-ozkan <work@onurozkan.dev>
@rustbot rustbot added the A-rustc-dev-guide Area: rustc-dev-guide label Feb 19, 2025
@rustbot
Copy link
Collaborator

rustbot commented Feb 19, 2025

The rustc-dev-guide subtree was changed. If this PR only touches the dev guide consider submitting a PR directly to rust-lang/rustc-dev-guide otherwise thank you for updating the dev guide with your changes.

cc @BoxyUwU, @jieyouxu, @Kobzol

@rustbot

This comment was marked as off-topic.

@onur-ozkan
Copy link
Member Author

r? jieyouxu

@rustbot ready

just in case @bors rollup=never

@onur-ozkan
Copy link
Member Author

p.s.: Sorry for the dirty commit history. It was being painful to work on this change.

@jieyouxu
Copy link
Member

p.s.: Sorry for the dirty commit history. It was being painful to work on this change.

No worries, making this less confusing is way more important

@onur-ozkan
Copy link
Member Author

I get it but it was buggy even for cargo and clippy that's what I'm saying. When you pass the stage flag it never works as expected (it always compiles rustc and cargo for stage +1).

@Kobzol
Copy link
Contributor

Kobzol commented Feb 21, 2025

Right, so if I understand it correctly:

Before:
./x test src/tools/cargo => correct
./x test src/tools/cargo --stage=N => incorrect

After:
./x test src/tools/cargo => incorrect, warns
./x test src/tools/cargo --stage=N => correct

And I propose:

./x test src/tools/cargo => correct (automatically selects the lowest supported stage)
./x test src/tools/cargo --stage=N => correct

@onur-ozkan
Copy link
Member Author

Yeah, we could do that. It's not hard — we just need to add a check for whether the stage was explicitly set. I can send a follow-up PR after this.

bors added a commit to rust-lang-ci/rust that referenced this pull request Feb 21, 2025
Compile run-make-support and run-make tests with the bootstrap compiler

It does not seem necessary to have to recompile run-make-support on changes to the local compiler/stdlib. This PR simplifies the implementation of a few tools, then switches rms to stage0 and also makes the handling of environment variables in run-make tests simpler.

Best reviewed commit-by-commit. I can split it into multiple PRs if you want.

Based on: rust-lang#137215

r? `@jieyouxu`

try-job: x86_64-apple-1
try-job: x86_64-apple-2
try-job: aarch64-apple
try-job: x86_64-msvc-1
try-job: x86_64-msvc-2
try-job: x86_64-mingw-1
try-job: x86_64-mingw-2
bors added a commit to rust-lang-ci/rust that referenced this pull request Feb 21, 2025
Compile run-make-support and run-make tests with the bootstrap compiler

It does not seem necessary to have to recompile run-make-support on changes to the local compiler/stdlib. This PR simplifies the implementation of a few tools, then switches rms to stage0 and also makes the handling of environment variables in run-make tests simpler.

Best reviewed commit-by-commit. I can split it into multiple PRs if you want.

Based on: rust-lang#137215

r? `@jieyouxu`

try-job: x86_64-apple-1
try-job: x86_64-apple-2
try-job: aarch64-apple
try-job: x86_64-msvc-1
try-job: x86_64-msvc-2
try-job: x86_64-mingw-1
try-job: x86_64-mingw-2
@BoxyUwU
Copy link
Member

BoxyUwU commented Feb 22, 2025

Sorry for the drive by comment, but does this PR make x test tests/ui build a stage2 rustc? That would be really bad for contributors, I can't see how that wouldn't more than double the time it takes to get to UI tests whenever you make a change to the compiler 😦

Very sympathetic to the fact that generally setting stages for various x commands does inconsistent or confusing things though and its good to see work happen here :3

@bors
Copy link
Contributor

bors commented Feb 23, 2025

⌛ Testing commit 76063a6 with merge bb2cc59...

@onur-ozkan
Copy link
Member Author

Sorry for the drive by comment, but does this PR make x test tests/ui build a stage2 rustc?

No, it doesn't. This PR either reduces compilation or keeps it the same as before. It doesn't add any extra compilation on any invocation.

@bors
Copy link
Contributor

bors commented Feb 23, 2025

☀️ Test successful - checks-actions
Approved by: jieyouxu,Kobzol
Pushing bb2cc59 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Feb 23, 2025
@bors bors merged commit bb2cc59 into rust-lang:master Feb 23, 2025
7 checks passed
@rustbot rustbot added this to the 1.87.0 milestone Feb 23, 2025
@onur-ozkan onur-ozkan deleted the rustc-tool-build-stages branch February 23, 2025 08:07
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (bb2cc59): comparison URL.

Overall result: ✅ improvements - no action needed

@rustbot label: -perf-regression

Instruction count

This is the most reliable metric that we have; it was used to determine the overall result at the top of this comment. However, even this metric can sometimes exhibit noise.

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

Max RSS (memory usage)

Results (primary -7.9%)

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

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

Cycles

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

Binary size

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

Bootstrap: 770.304s -> 770.69s (0.05%)
Artifact size: 359.67 MiB -> 359.83 MiB (0.04%)

Noratrieb added a commit to Noratrieb/rust that referenced this pull request Feb 23, 2025
…stages, r=jieyouxu,Kobzol"

This reverts commit bb2cc59, reversing
changes made to bca5f37.

This PR made rustc tools no longer work after dist.
fmease added a commit to fmease/rust that referenced this pull request Feb 25, 2025
…bzol

use stage 2 on cargo and clippy tests when possible

Follow-up for rust-lang#137215.

For more context, read the discussion starting from rust-lang#137215 (comment).

r? Kobzol (Feel free to re-r if you are not available).
fmease added a commit to fmease/rust that referenced this pull request Feb 25, 2025
…bzol

use stage 2 on cargo and clippy tests when possible

Follow-up for rust-lang#137215.

For more context, read the discussion starting from rust-lang#137215 (comment).

r? Kobzol (Feel free to re-r if you are not available).
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Feb 25, 2025
Rollup merge of rust-lang#137522 - onur-ozkan:137215-follow-ups, r=Kobzol

use stage 2 on cargo and clippy tests when possible

Follow-up for rust-lang#137215.

For more context, read the discussion starting from rust-lang#137215 (comment).

r? Kobzol (Feel free to re-r if you are not available).
@@ -8,6 +8,8 @@ incremental = true
download-rustc = "if-unchanged"

[build]
# cargo and clippy tests don't pass on stage 1
test-stage = 2
Copy link
Member

Choose a reason for hiding this comment

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

I don't think this is a good default -- it should be considered a bug if the tests do not work in stage 1. Certainly, they do work for Miri, so this can lead to Miri contributors waiting unnecessarily long for their builds to finish.

Copy link
Member Author

Choose a reason for hiding this comment

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

#137522 should be enough for the stage1 problems happen on clippy and cargo tests, so this should be revertable.

Copy link
Member

Choose a reason for hiding this comment

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

So what that does is just bump the stage to 2? I guess that hides the bugs with those tools...

I have #78717 somewhere in my TODO list, so I'll have to remember to revert that then. I don't know why cargo needs stage 2.

Copy link
Member Author

Choose a reason for hiding this comment

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

I didn't get how #78717 is being related to test-stage = 2 in the config file.

So what that does is just bump the stage to 2? I guess that hides the bugs with those tools...

Actually I don't know if it's a bug or not. All other tools work fine but cargo and clippy fail on stage 1 tests.

Copy link
Member

Choose a reason for hiding this comment

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

#78717 tracks the bug that you need stage 2 for clippy. Once that is fixed, clippy can be tested on stage 1.

Copy link
Member

Choose a reason for hiding this comment

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

Actually I don't know if it's a bug or not.

I am arguing that we should consider it a bug. We should have the expectation that tools can be tested in stage 1 (except when they really need the bootstrap loop to have completed, which is quite rare).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-rustc-dev-guide Area: rustc-dev-guide 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.

9 participants