Skip to content

Commit 6435e25

Browse files
Auto merge of #144159 - ognevny:opt-dist-build-dir, r=<try>
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 <!-- homu-ignore:start --> <!-- If this PR is related to an unstable feature or an otherwise tracked effort, please link to the relevant tracking issue here. If you don't know of a related tracking issue or there are none, feel free to ignore this. This PR will get automatically assigned to a reviewer. In case you would like a specific user to review your work, you can assign it to them by using r? <reviewer name> --> <!-- homu-ignore:end --> r? Kobzol try-job: dist-x86_64-msvc try-job: dist-x86_64-linux
2 parents 81af9d4 + 2243454 commit 6435e25

File tree

4 files changed

+12
-7
lines changed

4 files changed

+12
-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: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,10 @@ 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. Must be the same as `build.build-dir` in bootstrap.toml
107+
#[arg(long, default_value = "build")]
108+
build_dir: Utf8PathBuf,
105109
},
106110
/// Perform an optimized build on Linux CI, from inside Docker.
107111
LinuxCi {
@@ -138,14 +142,15 @@ fn create_environment(args: Args) -> anyhow::Result<(Environment, Vec<String>)>
138142
shared,
139143
run_tests,
140144
build_llvm,
145+
build_dir,
141146
} => {
142147
let env = EnvironmentBuilder::default()
143148
.host_tuple(target_triple)
144149
.python_binary(python)
145150
.checkout_dir(checkout_dir.clone())
146151
.host_llvm_dir(llvm_dir)
147152
.artifact_dir(artifact_dir)
148-
.build_dir(checkout_dir)
153+
.build_dir(checkout_dir.join(build_dir))
149154
.prebuilt_rustc_perf(rustc_perf_checkout_dir)
150155
.shared_llvm(llvm_shared)
151156
.use_bolt(use_bolt)
@@ -171,7 +176,7 @@ fn create_environment(args: Args) -> anyhow::Result<(Environment, Vec<String>)>
171176
.checkout_dir(checkout_dir.clone())
172177
.host_llvm_dir(Utf8PathBuf::from("/rustroot"))
173178
.artifact_dir(Utf8PathBuf::from("/tmp/tmp-multistage/opt-artifacts"))
174-
.build_dir(checkout_dir.join("obj"))
179+
.build_dir(checkout_dir.join("obj").join("build"))
175180
.shared_llvm(true)
176181
// FIXME: Enable bolt for aarch64 once it's fixed upstream. Broken as of December 2024.
177182
.use_bolt(!is_aarch64)
@@ -194,7 +199,7 @@ fn create_environment(args: Args) -> anyhow::Result<(Environment, Vec<String>)>
194199
.checkout_dir(checkout_dir.clone())
195200
.host_llvm_dir(checkout_dir.join("citools").join("clang-rust"))
196201
.artifact_dir(checkout_dir.join("opt-artifacts"))
197-
.build_dir(checkout_dir)
202+
.build_dir(checkout_dir.join("build"))
198203
.shared_llvm(false)
199204
.use_bolt(false)
200205
.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)