Skip to content

Commit 85c286a

Browse files
committed
Clarify get_tool_target_compiler
1 parent 205587b commit 85c286a

File tree

1 file changed

+9
-3
lines changed
  • src/bootstrap/src/core/build_steps

1 file changed

+9
-3
lines changed

src/bootstrap/src/core/build_steps/tool.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -381,20 +381,26 @@ pub(crate) fn get_tool_target_compiler(
381381
builder: &Builder<'_>,
382382
mode: ToolTargetBuildMode,
383383
) -> Compiler {
384-
let (target, min_build_compiler_stage) = match mode {
384+
let (target, build_compiler_stage) = match mode {
385385
ToolTargetBuildMode::Build(target) => {
386386
assert!(builder.top_stage > 0);
387+
// If we want to build a stage N tool, we need to compile it with stage N-1 rustc
387388
(target, builder.top_stage - 1)
388389
}
389390
ToolTargetBuildMode::Dist(target_compiler) => {
390391
assert!(target_compiler.stage > 0);
392+
// If we want to dist a stage N rustc, we want to attach stage N tool to it.
393+
// And to build that tool, we need to compile it with stage N-1 rustc
391394
(target_compiler.host, target_compiler.stage - 1)
392395
}
393396
};
397+
394398
let compiler = if builder.host_target == target {
395-
builder.compiler(min_build_compiler_stage, builder.host_target)
399+
builder.compiler(build_compiler_stage, builder.host_target)
396400
} else {
397-
builder.compiler(min_build_compiler_stage.max(1), builder.host_target)
401+
// If we are cross-compiling a stage 1 tool, we cannot do that with a stage 0 compiler,
402+
// so we auto-bump the tool's stage to 2.
403+
builder.compiler(build_compiler_stage.max(1), builder.host_target)
398404
};
399405
builder.std(compiler, target);
400406
compiler

0 commit comments

Comments
 (0)