Skip to content

Commit 869bc2f

Browse files
committed
override build profile for bootstrap tests
Signed-off-by: onur-ozkan <work@onurozkan.dev>
1 parent 6365178 commit 869bc2f

File tree

2 files changed

+23
-8
lines changed

2 files changed

+23
-8
lines changed

src/bootstrap/src/core/build_steps/test.rs

+3
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ impl Step for CrateBootstrap {
8686
SourceType::InTree,
8787
&[],
8888
);
89+
8990
let crate_name = path.rsplit_once('/').unwrap().1;
9091
run_cargo_test(cargo, &[], &[], crate_name, crate_name, bootstrap_host, builder);
9192
}
@@ -3099,6 +3100,8 @@ impl Step for Bootstrap {
30993100
&[],
31003101
);
31013102

3103+
cargo.release_build(false);
3104+
31023105
cargo
31033106
.rustflag("-Cdebuginfo=2")
31043107
.env("CARGO_TARGET_DIR", builder.out.join("bootstrap"))

src/bootstrap/src/core/builder/cargo.rs

+20-8
Original file line numberDiff line numberDiff line change
@@ -88,12 +88,14 @@ impl HostFlags {
8888
#[derive(Debug)]
8989
pub struct Cargo {
9090
command: BootstrapCommand,
91+
args: Vec<OsString>,
9192
compiler: Compiler,
9293
target: TargetSelection,
9394
rustflags: Rustflags,
9495
rustdocflags: Rustflags,
9596
hostflags: HostFlags,
9697
allow_features: String,
98+
release_build: bool,
9799
}
98100

99101
impl Cargo {
@@ -121,6 +123,10 @@ impl Cargo {
121123
cargo
122124
}
123125

126+
pub fn release_build(&mut self, release_build: bool) {
127+
self.release_build = release_build;
128+
}
129+
124130
pub fn compiler(&self) -> Compiler {
125131
self.compiler
126132
}
@@ -153,7 +159,7 @@ impl Cargo {
153159
}
154160

155161
pub fn arg(&mut self, arg: impl AsRef<OsStr>) -> &mut Cargo {
156-
self.command.arg(arg.as_ref());
162+
self.args.push(arg.as_ref().into());
157163
self
158164
}
159165

@@ -335,6 +341,12 @@ impl Cargo {
335341

336342
impl From<Cargo> for BootstrapCommand {
337343
fn from(mut cargo: Cargo) -> BootstrapCommand {
344+
if cargo.release_build {
345+
cargo.args.insert(0, "--release".into());
346+
}
347+
348+
cargo.command.args(cargo.args);
349+
338350
let rustflags = &cargo.rustflags.0;
339351
if !rustflags.is_empty() {
340352
cargo.command.env("RUSTFLAGS", rustflags);
@@ -353,6 +365,7 @@ impl From<Cargo> for BootstrapCommand {
353365
if !cargo.allow_features.is_empty() {
354366
cargo.command.env("RUSTC_ALLOW_FEATURES", cargo.allow_features);
355367
}
368+
356369
cargo.command
357370
}
358371
}
@@ -422,13 +435,6 @@ impl Builder<'_> {
422435
assert_eq!(target, compiler.host);
423436
}
424437

425-
if self.config.rust_optimize.is_release() &&
426-
// cargo bench/install do not accept `--release` and miri doesn't want it
427-
!matches!(cmd_kind, Kind::Bench | Kind::Install | Kind::Miri | Kind::MiriSetup | Kind::MiriTest)
428-
{
429-
cargo.arg("--release");
430-
}
431-
432438
// Remove make-related flags to ensure Cargo can correctly set things up
433439
cargo.env_remove("MAKEFLAGS");
434440
cargo.env_remove("MFLAGS");
@@ -1214,14 +1220,20 @@ impl Builder<'_> {
12141220
rustflags.arg("-Zmir_strip_debuginfo=locals-in-tiny-functions");
12151221
}
12161222

1223+
let release_build = self.config.rust_optimize.is_release() &&
1224+
// cargo bench/install do not accept `--release` and miri doesn't want it
1225+
!matches!(cmd_kind, Kind::Bench | Kind::Install | Kind::Miri | Kind::MiriSetup | Kind::MiriTest);
1226+
12171227
Cargo {
12181228
command: cargo,
1229+
args: vec![],
12191230
compiler,
12201231
target,
12211232
rustflags,
12221233
rustdocflags,
12231234
hostflags,
12241235
allow_features,
1236+
release_build,
12251237
}
12261238
}
12271239
}

0 commit comments

Comments
 (0)