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

Fix spurious error when running build --stage 2 compiler/rustc #96859

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion src/bootstrap/builder/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,10 @@ mod dist {
std!(A => C, stage = 2),
]
);
assert_eq!(builder.cache.all::<compile::Assemble>().len(), 5);
// Theoretically this should be 5, the same as `compile::Rustc`.
// Unfortunately, the sysroot for the stage 3 compiler is broken; see #90244.
// Instead we only generate the sysroot for non-stage2 build compilers.
assert_eq!(builder.cache.all::<compile::Assemble>().len(), 3);
assert_eq!(
first(builder.cache.all::<compile::Rustc>()),
&[
Expand Down
27 changes: 24 additions & 3 deletions src/bootstrap/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1104,9 +1104,30 @@ impl Step for Assemble {
}

fn make_run(run: RunConfig<'_>) {
run.builder.ensure(Assemble {
target_compiler: run.builder.compiler(run.builder.top_stage + 1, run.target),
});
// Trying to actually create the sysroot for stage 2 is tricky, because everywhere in
// bootstrap that touches self.rustc or self.cargo_out suddenly needs to know whether those
// artifacts actually exist or whether we're reusing the ones from stage 1. Instead, just
// build the artifacts, like we used to do before `compiler/rustc` implied assembling the
// compiler.
//
// When using full-bootstrap, we never reuse the artifacts from stage 1, so we don't have
// any issues.
//
// NOTE: Anywhere in bootstrap that calls `builder.compiler` has the side effect of running
// `Assemble`. In those cases, this workaround in `make_run` doesn't help, we'll still hit a
// panic (see #90224). In practice, that's probably ok: nothing currently uses the stage 2
// sysroot.
Copy link
Member

Choose a reason for hiding this comment

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

I'm a little confused why we put this in make_run, rather than in the main body of the Assemble step. That would seem to prevent this FIXME from being necessary.

if run.builder.top_stage >= 2 && !run.builder.config.full_bootstrap {
let build_compiler = run.builder.compiler(run.builder.top_stage, run.builder.config.build);
run.builder.ensure(Rustc {
compiler: build_compiler,
target: run.target,
crates: Default::default(),
});
return;
}
let target_compiler = Compiler { stage: run.builder.top_stage + 1, host: run.target };
run.builder.ensure(Assemble { target_compiler });
}

/// Prepare a new compiler from the artifacts in `stage`
Expand Down