Skip to content

opt-dist: add an option for setting path to stage0 root #144164

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions src/tools/opt-dist/src/environment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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?
Expand Down
6 changes: 6 additions & 0 deletions src/tools/opt-dist/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down
Loading