Skip to content

handle forced compiler and revert #137476 #138039

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

Merged
merged 4 commits into from
Mar 6, 2025
Merged
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
59 changes: 47 additions & 12 deletions src/bootstrap/src/core/build_steps/dist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,11 @@ impl Step for Rustc {

if let Some(ra_proc_macro_srv) = builder.ensure_if_default(
tool::RustAnalyzerProcMacroSrv {
compiler: builder.compiler(compiler.stage, builder.config.build),
compiler: builder.compiler_for(
compiler.stage,
builder.config.build,
compiler.host,
),
target: compiler.host,
},
builder.kind,
Expand Down Expand Up @@ -771,7 +775,11 @@ impl Step for Analysis {
// Find the actual compiler (handling the full bootstrap option) which
// produced the save-analysis data because that data isn't copied
// through the sysroot uplifting.
compiler: run.builder.compiler(run.builder.top_stage, run.builder.config.build),
compiler: run.builder.compiler_for(
run.builder.top_stage,
run.builder.config.build,
run.target,
),
target: run.target,
});
}
Expand Down Expand Up @@ -1116,7 +1124,11 @@ impl Step for Cargo {

fn make_run(run: RunConfig<'_>) {
run.builder.ensure(Cargo {
compiler: run.builder.compiler(run.builder.top_stage, run.builder.config.build),
compiler: run.builder.compiler_for(
run.builder.top_stage,
run.builder.config.build,
run.target,
),
target: run.target,
});
}
Expand Down Expand Up @@ -1161,7 +1173,11 @@ impl Step for Rls {

fn make_run(run: RunConfig<'_>) {
run.builder.ensure(Rls {
compiler: run.builder.compiler(run.builder.top_stage, run.builder.config.build),
compiler: run.builder.compiler_for(
run.builder.top_stage,
run.builder.config.build,
run.target,
),
target: run.target,
});
}
Expand Down Expand Up @@ -1199,7 +1215,11 @@ impl Step for RustAnalyzer {

fn make_run(run: RunConfig<'_>) {
run.builder.ensure(RustAnalyzer {
compiler: run.builder.compiler(run.builder.top_stage, run.builder.config.build),
compiler: run.builder.compiler_for(
run.builder.top_stage,
run.builder.config.build,
run.target,
),
target: run.target,
});
}
Expand Down Expand Up @@ -1237,7 +1257,11 @@ impl Step for Clippy {

fn make_run(run: RunConfig<'_>) {
run.builder.ensure(Clippy {
compiler: run.builder.compiler(run.builder.top_stage, run.builder.config.build),
compiler: run.builder.compiler_for(
run.builder.top_stage,
run.builder.config.build,
run.target,
),
target: run.target,
});
}
Expand Down Expand Up @@ -1280,7 +1304,11 @@ impl Step for Miri {

fn make_run(run: RunConfig<'_>) {
run.builder.ensure(Miri {
compiler: run.builder.compiler(run.builder.top_stage, run.builder.config.build),
compiler: run.builder.compiler_for(
run.builder.top_stage,
run.builder.config.build,
run.target,
),
target: run.target,
});
}
Expand Down Expand Up @@ -1414,7 +1442,11 @@ impl Step for Rustfmt {

fn make_run(run: RunConfig<'_>) {
run.builder.ensure(Rustfmt {
compiler: run.builder.compiler(run.builder.top_stage, run.builder.config.build),
compiler: run.builder.compiler_for(
run.builder.top_stage,
run.builder.config.build,
run.target,
),
target: run.target,
});
}
Expand Down Expand Up @@ -1464,7 +1496,7 @@ impl Step for Extended {
fn run(self, builder: &Builder<'_>) {
let target = self.target;
let stage = self.stage;
let compiler = builder.compiler(self.stage, self.host);
let compiler = builder.compiler_for(self.stage, self.host, self.target);

builder.info(&format!("Dist extended stage{} ({})", compiler.stage, target));

Expand Down Expand Up @@ -2112,8 +2144,7 @@ pub fn maybe_install_llvm_target(builder: &Builder<'_>, target: TargetSelection,
),
)]
pub fn maybe_install_llvm_runtime(builder: &Builder<'_>, target: TargetSelection, sysroot: &Path) {
let dst_libdir =
sysroot.join(builder.sysroot_libdir_relative(Compiler { stage: 1, host: target }));
let dst_libdir = sysroot.join(builder.sysroot_libdir_relative(Compiler::new(1, target)));
// We do not need to copy LLVM files into the sysroot if it is not
// dynamically linked; it is already included into librustc_llvm
// statically.
Expand Down Expand Up @@ -2228,7 +2259,11 @@ impl Step for LlvmBitcodeLinker {

fn make_run(run: RunConfig<'_>) {
run.builder.ensure(LlvmBitcodeLinker {
compiler: run.builder.compiler(run.builder.top_stage, run.builder.config.build),
compiler: run.builder.compiler_for(
run.builder.top_stage,
run.builder.config.build,
run.target,
),
target: run.target,
});
}
Expand Down
2 changes: 2 additions & 0 deletions src/bootstrap/src/core/build_steps/tool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,8 @@ pub(crate) fn get_tool_rustc_compiler(
if builder.download_rustc() && target_compiler.stage == 1 {
// We already have the stage 1 compiler, we don't need to cut the stage.
builder.compiler(target_compiler.stage, builder.config.build)
} else if target_compiler.is_forced_compiler() {
target_compiler
} else {
// Similar to `compile::Assemble`, build with the previous stage's compiler. Otherwise
// we'd have stageN/bin/rustc and stageN/bin/$rustc_tool be effectively different stage
Expand Down
9 changes: 7 additions & 2 deletions src/bootstrap/src/core/builder/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1234,7 +1234,7 @@ impl<'a> Builder<'a> {
),
)]
pub fn compiler(&self, stage: u32, host: TargetSelection) -> Compiler {
self.ensure(compile::Assemble { target_compiler: Compiler { stage, host } })
self.ensure(compile::Assemble { target_compiler: Compiler::new(stage, host) })
}

/// Similar to `compiler`, except handles the full-bootstrap option to
Expand Down Expand Up @@ -1272,7 +1272,7 @@ impl<'a> Builder<'a> {
target: TargetSelection,
) -> Compiler {
#![allow(clippy::let_and_return)]
let resolved_compiler = if self.build.force_use_stage2(stage) {
let mut resolved_compiler = if self.build.force_use_stage2(stage) {
trace!(target: "COMPILER_FOR", ?stage, "force_use_stage2");
self.compiler(2, self.config.build)
} else if self.build.force_use_stage1(stage, target) {
Expand All @@ -1282,6 +1282,11 @@ impl<'a> Builder<'a> {
trace!(target: "COMPILER_FOR", ?stage, ?host, "no force, fallback to `compiler()`");
self.compiler(stage, host)
};

if stage != resolved_compiler.stage {
resolved_compiler.forced_compiler(true);
}

trace!(target: "COMPILER_FOR", ?resolved_compiler);
resolved_compiler
}
Expand Down
Loading
Loading