Skip to content

Commit 6fd83ea

Browse files
committed
opt-dist: change build_dir field to be an actual build dir
make it configurable so users can set build.build-dir option in bootstrap.toml
1 parent 1079c5e commit 6fd83ea

File tree

4 files changed

+13
-7
lines changed

4 files changed

+13
-7
lines changed

src/tools/opt-dist/src/environment.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ impl Environment {
4848
}
4949

5050
pub fn build_artifacts(&self) -> Utf8PathBuf {
51-
self.build_root().join("build").join(&self.host_tuple)
51+
self.build_root().join(&self.host_tuple)
5252
}
5353

5454
pub fn artifact_dir(&self) -> Utf8PathBuf {

src/tools/opt-dist/src/exec.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ pub struct Bootstrap {
9999

100100
impl Bootstrap {
101101
pub fn build(env: &Environment) -> Self {
102-
let metrics_path = env.build_root().join("build").join("metrics.json");
102+
let metrics_path = env.build_root().join("metrics.json");
103103
let cmd = cmd(&[
104104
env.python_binary(),
105105
env.checkout_path().join("x.py").as_str(),
@@ -119,7 +119,7 @@ impl Bootstrap {
119119
}
120120

121121
pub fn dist(env: &Environment, dist_args: &[String]) -> Self {
122-
let metrics_path = env.build_root().join("build").join("metrics.json");
122+
let metrics_path = env.build_root().join("metrics.json");
123123
let args = dist_args.iter().map(|arg| arg.as_str()).collect::<Vec<_>>();
124124
let cmd = cmd(&args).env("RUST_BACKTRACE", "full");
125125
let mut cmd = add_shared_x_flags(env, cmd);

src/tools/opt-dist/src/main.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,11 @@ enum EnvironmentCmd {
102102
/// Will be LLVM built during the run?
103103
#[arg(long, default_value_t = true, action(clap::ArgAction::Set))]
104104
build_llvm: bool,
105+
106+
/// Set build artifacts dir. Relative to `checkout_dir`, should point to the directory set
107+
/// in bootstrap.toml via `build.build-dir` option
108+
#[arg(long, default_value = "build")]
109+
build_dir: Utf8PathBuf,
105110
},
106111
/// Perform an optimized build on Linux CI, from inside Docker.
107112
LinuxCi {
@@ -138,14 +143,15 @@ fn create_environment(args: Args) -> anyhow::Result<(Environment, Vec<String>)>
138143
shared,
139144
run_tests,
140145
build_llvm,
146+
build_dir,
141147
} => {
142148
let env = EnvironmentBuilder::default()
143149
.host_tuple(target_triple)
144150
.python_binary(python)
145151
.checkout_dir(checkout_dir.clone())
146152
.host_llvm_dir(llvm_dir)
147153
.artifact_dir(artifact_dir)
148-
.build_dir(checkout_dir)
154+
.build_dir(checkout_dir.join(build_dir))
149155
.prebuilt_rustc_perf(rustc_perf_checkout_dir)
150156
.shared_llvm(llvm_shared)
151157
.use_bolt(use_bolt)
@@ -171,7 +177,7 @@ fn create_environment(args: Args) -> anyhow::Result<(Environment, Vec<String>)>
171177
.checkout_dir(checkout_dir.clone())
172178
.host_llvm_dir(Utf8PathBuf::from("/rustroot"))
173179
.artifact_dir(Utf8PathBuf::from("/tmp/tmp-multistage/opt-artifacts"))
174-
.build_dir(checkout_dir.join("obj"))
180+
.build_dir(checkout_dir.join("obj").join("build"))
175181
.shared_llvm(true)
176182
// FIXME: Enable bolt for aarch64 once it's fixed upstream. Broken as of December 2024.
177183
.use_bolt(!is_aarch64)
@@ -194,7 +200,7 @@ fn create_environment(args: Args) -> anyhow::Result<(Environment, Vec<String>)>
194200
.checkout_dir(checkout_dir.clone())
195201
.host_llvm_dir(checkout_dir.join("citools").join("clang-rust"))
196202
.artifact_dir(checkout_dir.join("opt-artifacts"))
197-
.build_dir(checkout_dir)
203+
.build_dir(checkout_dir.join("build"))
198204
.shared_llvm(false)
199205
.use_bolt(false)
200206
.skipped_tests(vec![])

src/tools/opt-dist/src/tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ pub fn run_tests(env: &Environment) -> anyhow::Result<()> {
1313
// and then use that extracted rustc as a stage0 compiler.
1414
// Then we run a subset of tests using that compiler, to have a basic smoke test which checks
1515
// whether the optimization pipeline hasn't broken something.
16-
let build_dir = env.build_root().join("build");
16+
let build_dir = env.build_root();
1717
let dist_dir = build_dir.join("dist");
1818
let unpacked_dist_dir = build_dir.join("unpacked-dist");
1919
std::fs::create_dir_all(&unpacked_dist_dir)?;

0 commit comments

Comments
 (0)