Skip to content

Commit

Permalink
Rollup merge of rust-lang#109295 - ozkanonur:issue-109286, r=ozkanonur
Browse files Browse the repository at this point in the history
refactor `fn bootstrap::builder::Builder::compiler_for` logic

- check compiler stage before forcing for stage2.
- check if download_rustc is not set before forcing for stage1.

resolves rust-lang#109286
  • Loading branch information
matthiaskrgr committed Mar 21, 2023
2 parents 7ce2aab + 2ec7f6c commit 69d989b
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
4 changes: 2 additions & 2 deletions src/bootstrap/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -919,9 +919,9 @@ impl<'a> Builder<'a> {
host: TargetSelection,
target: TargetSelection,
) -> Compiler {
if self.build.force_use_stage2() {
if self.build.force_use_stage2(stage) {
self.compiler(2, self.config.build)
} else if self.build.force_use_stage1(Compiler { stage, host }, target) {
} else if self.build.force_use_stage1(stage, target) {
self.compiler(1, self.config.build)
} else {
self.compiler(stage, host)
Expand Down
13 changes: 7 additions & 6 deletions src/bootstrap/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1204,19 +1204,20 @@ impl Build {
///
/// When all of these conditions are met the build will lift artifacts from
/// the previous stage forward.
fn force_use_stage1(&self, compiler: Compiler, target: TargetSelection) -> bool {
fn force_use_stage1(&self, stage: u32, target: TargetSelection) -> bool {
!self.config.full_bootstrap
&& compiler.stage >= 2
&& !self.config.download_rustc()
&& stage >= 2
&& (self.hosts.iter().any(|h| *h == target) || target == self.build)
}

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

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

0 comments on commit 69d989b

Please sign in to comment.