Skip to content

Enforce in bootstrap that doc must have stage at least 1 #145011

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

Open
wants to merge 10 commits into
base: master
Choose a base branch
from

Conversation

Kobzol
Copy link
Member

@Kobzol Kobzol commented Aug 6, 2025

Following with the bootstrap cleanups, this time around doc steps. Should be pretty straightforward, because the supporting infrastructure was already there.

The only thing I found a bit fishy is using Mode::ToolBootstrap as a "catch-all" mode for non-rustc-private steps in tool_doc!, but I don't think that we need to distinguish the tools in some special way when documenting them, apart from supporting rustc_private.

Before, x doc more or less defaulted to what we call stage 2 now. Now it is properly stage 1, so e.g. x doc compiler documents the compiler using the stage0/beta rust(do)c.

r? @jieyouxu

@rustbot rustbot added A-CI Area: Our Github Actions CI A-testsuite Area: The testsuite used to check the correctness of rustc S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-infra Relevant to the infrastructure team, which will review and decide on the PR/issue. labels Aug 6, 2025
@bors
Copy link
Collaborator

bors commented Aug 7, 2025

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

@Kobzol Kobzol marked this pull request as ready for review August 8, 2025 06:17
@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 Aug 8, 2025
@rustbot
Copy link
Collaborator

rustbot commented Aug 8, 2025

This PR modifies src/bootstrap/src/core/config.

If appropriate, please update CONFIG_CHANGE_HISTORY in src/bootstrap/src/utils/change_tracker.rs.

@Kobzol
Copy link
Member Author

Kobzol commented Aug 8, 2025

Rebased over the two merged PRs, should be ready now.

@rustbot ready

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.

Thanks for working on this! The changes look good in the general sense that it does feel more self-consistent. I do have some questions though that occurred to me when looking at the changes.

@@ -1076,11 +1076,15 @@ impl Config {
// Now check that the selected stage makes sense, and if not, print a warning and end
match (config.stage, &config.cmd) {
(0, Subcommand::Build) => {
eprintln!("WARNING: cannot build anything on stage 0. Use at least stage 1.");
eprintln!("ERROR: cannot build anything on stage 0. Use at least 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.

Remark: lol I didn't notice this

Comment on lines +760 to +764
fn prepare_doc_compiler(builder: &Builder<'_>, target: TargetSelection, stage: u32) -> Compiler {
let build_compiler = builder.compiler(stage - 1, builder.host_target);
builder.std(build_compiler, target);
build_compiler
}
Copy link
Member

Choose a reason for hiding this comment

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

Question: maybe overkill, should this assert that the passed in stage is at least one?

Comment on lines 1744 to +1748
#[test]
#[should_panic]
fn doc_compiler_stage_0() {
let ctx = TestCtx::new();
insta::assert_snapshot!(
ctx.config("doc")
.path("compiler")
.stage(0)
.render_steps(), @r"
[build] rustdoc 0 <host>
[build] llvm <host>
[doc] rustc 0 <host>
");
ctx.config("doc").path("compiler").stage(0).run();
Copy link
Member

Choose a reason for hiding this comment

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

Question: hm, would we regress any actual use cases of documenting the stage 0 compiler?

Comment on lines +1291 to +1292
/// It is always done using a stage 1+ compiler, because it references in-tree compiler/stdlib
/// concepts.
Copy link
Member

Choose a reason for hiding this comment

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

Nit: "It is always done" -> "It must always be done" (stronger emphasis)?

Comment on lines +1309 to +1318
// Bump the stage to 2, because the reference requires an in-tree compiler.
// At the same time, since this step is enabled by default, we don't want `x doc` to fail
// in stage 1.
// FIXME: create a shared method on builder for auto-bumping, and print some warning when
// it happens.
let stage = if run.builder.config.is_explicit_stage() || run.builder.top_stage >= 2 {
run.builder.top_stage
} else {
2
};
Copy link
Member

Choose a reason for hiding this comment

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

Remark: hmm, auto-bumping stages always feel a bit sad (because it can be quite surprising to the user), but I suppose this makes sense. Good call on the warning when it will happen.

Comment on lines +979 to +980
// Build rustc docs so that we generate relative links.
run.builder.ensure(Rustc::from_build_compiler(run.builder, compilers.build_compiler(), target));
Copy link
Member

Choose a reason for hiding this comment

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

Remark: hah, this is not super obvious...

Comment on lines 1796 to 1797
[build] rustdoc 0 <host>
[doc] rustc 0 <host> -> Compiletest 1 <host>
Copy link
Member

Choose a reason for hiding this comment

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

Question: hm, to clarify, the staging in ./x doc $thing --stage=N corresponds to "what gets built"

Comment on lines +1178 to +1179
[doc] rustc 2 <host> -> std 2 <host> crates=[]
[doc] rustc 2 <host> -> std 2 <target1> crates=[]
Copy link
Member

Choose a reason for hiding this comment

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

Remark: hm, this is always a bit funny, when we run a std doc step with

crates=[alloc,compiler_builtins,core,panic_abort,panic_unwind,proc_macro,rustc-std-workspace-core,std,std_detect,sysroot,test,unwind]

but then again later with

crates=[]

then I think we rely on the fact that they can unify to not have this invalidate the previous build cache (?)

Comment on lines +1207 to +1212
[doc] book (book) <host>
[doc] book/first-edition (book) <host>
[doc] book/second-edition (book) <host>
[doc] book/2018-edition (book) <host>
[build] rustdoc 1 <host>
[doc] rustc 1 <host> -> standalone 2 <host>
Copy link
Member

Choose a reason for hiding this comment

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

Question: wait, are we building less than we should be? I.e. there are two hosts, $\text{host}_{1} := \text{"host"}$ and $\text{host}_{1} := \text{"TEST-TRIPLE-1"}$. Or is this an instance where the "host" is actually the build platform and not actually the host platform? I.e. under the scenario where bootstrap is ran on a different platform than where the stage 1 compiler would be ran (?)

Hm... or taking a step back, what does the "hosts" config actually mean in bootstrap?

@jieyouxu
Copy link
Member

@rustbot author

@rustbot rustbot 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 Aug 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-CI Area: Our Github Actions CI A-testsuite Area: The testsuite used to check the correctness of rustc S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) T-infra Relevant to the infrastructure team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants