about summary refs log tree commit diff
path: root/src/bootstrap
diff options
context:
space:
mode:
authormorine0122 <k0000.m000.job@gmail.com>2023-03-08 00:41:53 +0900
committermorine0122 <k0000.m000.job@gmail.com>2023-03-08 01:52:28 +0900
commit740d476bbf9122b27c3aac18b5e4d2c8162cb576 (patch)
treebb419f263716ec065dd7cc6480a53df81a0ccee1 /src/bootstrap
parent0d439f81815b7b2a13b6a30b9263f9a60d46a4d4 (diff)
downloadrust-740d476bbf9122b27c3aac18b5e4d2c8162cb576.tar.gz
rust-740d476bbf9122b27c3aac18b5e4d2c8162cb576.zip
Add force to use the stage 2 compiler in compiler_for when config.download_rustc is set
Diffstat (limited to 'src/bootstrap')
-rw-r--r--src/bootstrap/builder.rs6
-rw-r--r--src/bootstrap/lib.rs9
2 files changed, 13 insertions, 2 deletions
diff --git a/src/bootstrap/builder.rs b/src/bootstrap/builder.rs
index b33fc02f49c..3d48db8660a 100644
--- a/src/bootstrap/builder.rs
+++ b/src/bootstrap/builder.rs
@@ -910,14 +910,16 @@ impl<'a> Builder<'a> {
     /// new artifacts, it can't be used to rely on the presence of a particular
     /// sysroot.
     ///
-    /// See `force_use_stage1` for documentation on what each argument is.
+    /// See `force_use_stage1` and `force_use_stage2` for documentation on what each argument is.
     pub fn compiler_for(
         &self,
         stage: u32,
         host: TargetSelection,
         target: TargetSelection,
     ) -> Compiler {
-        if self.build.force_use_stage1(Compiler { stage, host }, target) {
+        if self.build.force_use_stage2() {
+            self.compiler(2, self.config.build)
+        } else if self.build.force_use_stage1(Compiler { stage, host }, target) {
             self.compiler(1, self.config.build)
         } else {
             self.compiler(stage, host)
diff --git a/src/bootstrap/lib.rs b/src/bootstrap/lib.rs
index f4abdf1cc57..ebd42bcf678 100644
--- a/src/bootstrap/lib.rs
+++ b/src/bootstrap/lib.rs
@@ -1209,6 +1209,15 @@ impl Build {
             && (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()
+    }
+
     /// Given `num` in the form "a.b.c" return a "release string" which
     /// describes the release version number.
     ///