Skip to content

Commit 2ec7f6c

Browse files
committedMar 18, 2023
refactor fn bootstrap::builder::Builder::compiler_for
- check compiler stage before forcing for stage2. - check if download_rustc is not set before forcing for stage1. Signed-off-by: ozkanonur <work@onurozkan.dev>
1 parent 0058748 commit 2ec7f6c

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed
 

‎src/bootstrap/builder.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -919,9 +919,9 @@ impl<'a> Builder<'a> {
919919
host: TargetSelection,
920920
target: TargetSelection,
921921
) -> Compiler {
922-
if self.build.force_use_stage2() {
922+
if self.build.force_use_stage2(stage) {
923923
self.compiler(2, self.config.build)
924-
} else if self.build.force_use_stage1(Compiler { stage, host }, target) {
924+
} else if self.build.force_use_stage1(stage, target) {
925925
self.compiler(1, self.config.build)
926926
} else {
927927
self.compiler(stage, host)

‎src/bootstrap/lib.rs

+7-6
Original file line numberDiff line numberDiff line change
@@ -1198,19 +1198,20 @@ impl Build {
11981198
///
11991199
/// When all of these conditions are met the build will lift artifacts from
12001200
/// the previous stage forward.
1201-
fn force_use_stage1(&self, compiler: Compiler, target: TargetSelection) -> bool {
1201+
fn force_use_stage1(&self, stage: u32, target: TargetSelection) -> bool {
12021202
!self.config.full_bootstrap
1203-
&& compiler.stage >= 2
1203+
&& !self.config.download_rustc()
1204+
&& stage >= 2
12041205
&& (self.hosts.iter().any(|h| *h == target) || target == self.build)
12051206
}
12061207

12071208
/// Checks whether the `compiler` compiling for `target` should be forced to
12081209
/// use a stage2 compiler instead.
12091210
///
1210-
/// When we download the pre-compiled version of rustc it should be forced to
1211-
/// use a stage2 compiler.
1212-
fn force_use_stage2(&self) -> bool {
1213-
self.config.download_rustc()
1211+
/// When we download the pre-compiled version of rustc and compiler stage is >= 2,
1212+
/// it should be forced to use a stage2 compiler.
1213+
fn force_use_stage2(&self, stage: u32) -> bool {
1214+
self.config.download_rustc() && stage >= 2
12141215
}
12151216

12161217
/// Given `num` in the form "a.b.c" return a "release string" which

0 commit comments

Comments
 (0)
Please sign in to comment.