about summary refs log tree commit diff
diff options
context:
space:
mode:
authorMaksim Bondarenkov <maksapple2306@gmail.com>2025-07-21 15:58:38 +0300
committerMaksim Bondarenkov <maksapple2306@gmail.com>2025-07-21 15:58:38 +0300
commitfa924641d67a510a1101b79bbc2cea4f5360135e (patch)
tree1a1fed8ecc5872e46e632217b300868289f1dd58
parent67819923ac8ea353aaa775303f4c3aacbf41d010 (diff)
downloadrust-fa924641d67a510a1101b79bbc2cea4f5360135e.tar.gz
rust-fa924641d67a510a1101b79bbc2cea4f5360135e.zip
opt-dist: add an option for setting path to stage0 root
in MSYS2 we have problems with stage0 for *-gnullvm hosts because prebuilt dist tarballs will be
available starting from 1.90.0-beta. also this change helps to match bootstrap.toml config
-rw-r--r--src/tools/opt-dist/src/environment.rs16
-rw-r--r--src/tools/opt-dist/src/main.rs6
2 files changed, 14 insertions, 8 deletions
diff --git a/src/tools/opt-dist/src/environment.rs b/src/tools/opt-dist/src/environment.rs
index e6e4c711c0c..2cae0785f33 100644
--- a/src/tools/opt-dist/src/environment.rs
+++ b/src/tools/opt-dist/src/environment.rs
@@ -28,6 +28,8 @@ pub struct Environment {
     run_tests: bool,
     fast_try_build: bool,
     build_llvm: bool,
+    #[builder(default)]
+    stage0_root: Option<Utf8PathBuf>,
 }
 
 impl Environment {
@@ -56,17 +58,11 @@ impl Environment {
     }
 
     pub fn cargo_stage_0(&self) -> Utf8PathBuf {
-        self.build_artifacts()
-            .join("stage0")
-            .join("bin")
-            .join(format!("cargo{}", executable_extension()))
+        self.stage0().join("bin").join(format!("cargo{}", executable_extension()))
     }
 
     pub fn rustc_stage_0(&self) -> Utf8PathBuf {
-        self.build_artifacts()
-            .join("stage0")
-            .join("bin")
-            .join(format!("rustc{}", executable_extension()))
+        self.stage0().join("bin").join(format!("rustc{}", executable_extension()))
     }
 
     pub fn rustc_stage_2(&self) -> Utf8PathBuf {
@@ -116,6 +112,10 @@ impl Environment {
     pub fn build_llvm(&self) -> bool {
         self.build_llvm
     }
+
+    pub fn stage0(&self) -> Utf8PathBuf {
+        self.stage0_root.clone().unwrap_or_else(|| self.build_artifacts().join("stage0"))
+    }
 }
 
 /// What is the extension of binary executables on this platform?
diff --git a/src/tools/opt-dist/src/main.rs b/src/tools/opt-dist/src/main.rs
index d0e6badede6..f46a86f507c 100644
--- a/src/tools/opt-dist/src/main.rs
+++ b/src/tools/opt-dist/src/main.rs
@@ -107,6 +107,10 @@ enum EnvironmentCmd {
         /// in bootstrap.toml via `build.build-dir` option
         #[arg(long, default_value = "build")]
         build_dir: Utf8PathBuf,
+
+        /// Path to custom stage0 root
+        #[arg(long)]
+        stage0_root: Option<Utf8PathBuf>,
     },
     /// Perform an optimized build on Linux CI, from inside Docker.
     LinuxCi {
@@ -144,6 +148,7 @@ fn create_environment(args: Args) -> anyhow::Result<(Environment, Vec<String>)>
             run_tests,
             build_llvm,
             build_dir,
+            stage0_root,
         } => {
             let env = EnvironmentBuilder::default()
                 .host_tuple(target_triple)
@@ -160,6 +165,7 @@ fn create_environment(args: Args) -> anyhow::Result<(Environment, Vec<String>)>
                 .run_tests(run_tests)
                 .fast_try_build(is_fast_try_build)
                 .build_llvm(build_llvm)
+                .stage0_root(stage0_root)
                 .build()?;
 
             (env, shared.build_args)