Skip to content

opt-dist: change build_dir field to be an actual build dir #144159

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 21, 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
2 changes: 1 addition & 1 deletion src/tools/opt-dist/src/environment.rs
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ impl Environment {
}

pub fn build_artifacts(&self) -> Utf8PathBuf {
self.build_root().join("build").join(&self.host_tuple)
self.build_root().join(&self.host_tuple)
}

pub fn artifact_dir(&self) -> Utf8PathBuf {
Expand Down
4 changes: 2 additions & 2 deletions src/tools/opt-dist/src/exec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ pub struct Bootstrap {

impl Bootstrap {
pub fn build(env: &Environment) -> Self {
let metrics_path = env.build_root().join("build").join("metrics.json");
let metrics_path = env.build_root().join("metrics.json");
let cmd = cmd(&[
env.python_binary(),
env.checkout_path().join("x.py").as_str(),
Expand All @@ -119,7 +119,7 @@ impl Bootstrap {
}

pub fn dist(env: &Environment, dist_args: &[String]) -> Self {
let metrics_path = env.build_root().join("build").join("metrics.json");
let metrics_path = env.build_root().join("metrics.json");
let args = dist_args.iter().map(|arg| arg.as_str()).collect::<Vec<_>>();
let cmd = cmd(&args).env("RUST_BACKTRACE", "full");
let mut cmd = add_shared_x_flags(env, cmd);
Expand Down
12 changes: 9 additions & 3 deletions src/tools/opt-dist/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,11 @@ enum EnvironmentCmd {
/// Will be LLVM built during the run?
#[arg(long, default_value_t = true, action(clap::ArgAction::Set))]
build_llvm: bool,

/// Set build artifacts dir. Relative to `checkout_dir`, should point to the directory set
/// in bootstrap.toml via `build.build-dir` option
#[arg(long, default_value = "build")]
build_dir: Utf8PathBuf,
},
/// Perform an optimized build on Linux CI, from inside Docker.
LinuxCi {
Expand Down Expand Up @@ -138,14 +143,15 @@ fn create_environment(args: Args) -> anyhow::Result<(Environment, Vec<String>)>
shared,
run_tests,
build_llvm,
build_dir,
} => {
let env = EnvironmentBuilder::default()
.host_tuple(target_triple)
.python_binary(python)
.checkout_dir(checkout_dir.clone())
.host_llvm_dir(llvm_dir)
.artifact_dir(artifact_dir)
.build_dir(checkout_dir)
.build_dir(checkout_dir.join(build_dir))
.prebuilt_rustc_perf(rustc_perf_checkout_dir)
.shared_llvm(llvm_shared)
.use_bolt(use_bolt)
Expand All @@ -171,7 +177,7 @@ fn create_environment(args: Args) -> anyhow::Result<(Environment, Vec<String>)>
.checkout_dir(checkout_dir.clone())
.host_llvm_dir(Utf8PathBuf::from("/rustroot"))
.artifact_dir(Utf8PathBuf::from("/tmp/tmp-multistage/opt-artifacts"))
.build_dir(checkout_dir.join("obj"))
.build_dir(checkout_dir.join("obj").join("build"))
.shared_llvm(true)
// FIXME: Enable bolt for aarch64 once it's fixed upstream. Broken as of December 2024.
.use_bolt(!is_aarch64)
Expand All @@ -194,7 +200,7 @@ fn create_environment(args: Args) -> anyhow::Result<(Environment, Vec<String>)>
.checkout_dir(checkout_dir.clone())
.host_llvm_dir(checkout_dir.join("citools").join("clang-rust"))
.artifact_dir(checkout_dir.join("opt-artifacts"))
.build_dir(checkout_dir)
.build_dir(checkout_dir.join("build"))
.shared_llvm(false)
.use_bolt(false)
.skipped_tests(vec![])
Expand Down
2 changes: 1 addition & 1 deletion src/tools/opt-dist/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ pub fn run_tests(env: &Environment) -> anyhow::Result<()> {
// and then use that extracted rustc as a stage0 compiler.
// Then we run a subset of tests using that compiler, to have a basic smoke test which checks
// whether the optimization pipeline hasn't broken something.
let build_dir = env.build_root().join("build");
let build_dir = env.build_root();
let dist_dir = build_dir.join("dist");
let unpacked_dist_dir = build_dir.join("unpacked-dist");
std::fs::create_dir_all(&unpacked_dist_dir)?;
Expand Down
Loading