Skip to content

Commit b85cb3c

Browse files
authored
Unrolled build for rust-lang#136157
Rollup merge of rust-lang#136157 - onur-ozkan:override-release-profile, r=Kobzol override build profile for bootstrap tests Using the release profile for bootstrap self tests puts too much load on the CPU and makes it quite hot on `x test bootstrap` invocation for no good reason. It also makes the compilation take longer than usual (see rust-lang#136048 (comment)). This change turns off the release flag for bootstrap self tests.
2 parents a730edc + 869bc2f commit b85cb3c

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
}
@@ -3106,6 +3107,8 @@ impl Step for Bootstrap {
31063107
&[],
31073108
);
31083109

3110+
cargo.release_build(false);
3111+
31093112
cargo
31103113
.rustflag("-Cdebuginfo=2")
31113114
.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

@@ -342,6 +348,12 @@ impl Cargo {
342348

343349
impl From<Cargo> for BootstrapCommand {
344350
fn from(mut cargo: Cargo) -> BootstrapCommand {
351+
if cargo.release_build {
352+
cargo.args.insert(0, "--release".into());
353+
}
354+
355+
cargo.command.args(cargo.args);
356+
345357
let rustflags = &cargo.rustflags.0;
346358
if !rustflags.is_empty() {
347359
cargo.command.env("RUSTFLAGS", rustflags);
@@ -360,6 +372,7 @@ impl From<Cargo> for BootstrapCommand {
360372
if !cargo.allow_features.is_empty() {
361373
cargo.command.env("RUSTC_ALLOW_FEATURES", cargo.allow_features);
362374
}
375+
363376
cargo.command
364377
}
365378
}
@@ -429,13 +442,6 @@ impl Builder<'_> {
429442
assert_eq!(target, compiler.host);
430443
}
431444

432-
if self.config.rust_optimize.is_release() &&
433-
// cargo bench/install do not accept `--release` and miri doesn't want it
434-
!matches!(cmd_kind, Kind::Bench | Kind::Install | Kind::Miri | Kind::MiriSetup | Kind::MiriTest)
435-
{
436-
cargo.arg("--release");
437-
}
438-
439445
// Remove make-related flags to ensure Cargo can correctly set things up
440446
cargo.env_remove("MAKEFLAGS");
441447
cargo.env_remove("MFLAGS");
@@ -1218,14 +1224,20 @@ impl Builder<'_> {
12181224
rustflags.arg("-Zmir_strip_debuginfo=locals-in-tiny-functions");
12191225
}
12201226

1227+
let release_build = self.config.rust_optimize.is_release() &&
1228+
// cargo bench/install do not accept `--release` and miri doesn't want it
1229+
!matches!(cmd_kind, Kind::Bench | Kind::Install | Kind::Miri | Kind::MiriSetup | Kind::MiriTest);
1230+
12211231
Cargo {
12221232
command: cargo,
1233+
args: vec![],
12231234
compiler,
12241235
target,
12251236
rustflags,
12261237
rustdocflags,
12271238
hostflags,
12281239
allow_features,
1240+
release_build,
12291241
}
12301242
}
12311243
}

0 commit comments

Comments
 (0)