Skip to content

Commit 9f4f916

Browse files
authored
Unrolled build for #143681
Rollup merge of #143681 - RalfJung:bootstrap-miri-rebuilds, r=Kobzol bootstrap/miri: avoid rebuilds for test builds When building Miri in its own repo, we always build with `--all-targets`: https://github.com/rust-lang/rust/blob/a00961269107703772c4e8f071f0accbe0f1a7e5/src/tools/miri/miri-script/src/util.rs#L167-L174 This saves a bunch of time since some of Miri's dependencies get more features enabled by some of Miri's dev-dependencies, and they all get built twice otherwise if you do `cargo build && cargo test` (which is typically what you end up doing inside `./miri test` and also inside `./x test miri`). This applies the same approach to bootstrap, drastically reducing the edit-compile cycle for Miri work here. :)
2 parents 64b185e + b703451 commit 9f4f916

File tree

1 file changed

+8
-2
lines changed
  • src/bootstrap/src/core/build_steps

1 file changed

+8
-2
lines changed

src/bootstrap/src/core/build_steps/tool.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1140,6 +1140,7 @@ macro_rules! tool_extended {
11401140
stable: $stable:expr
11411141
$( , add_bins_to_sysroot: $add_bins_to_sysroot:expr )?
11421142
$( , add_features: $add_features:expr )?
1143+
$( , cargo_args: $cargo_args:expr )?
11431144
$( , )?
11441145
}
11451146
) => {
@@ -1180,6 +1181,7 @@ macro_rules! tool_extended {
11801181
$path,
11811182
None $( .or(Some(&$add_bins_to_sysroot)) )?,
11821183
None $( .or(Some($add_features)) )?,
1184+
None $( .or(Some($cargo_args)) )?,
11831185
)
11841186
}
11851187

@@ -1219,6 +1221,7 @@ fn should_run_tool_build_step<'a>(
12191221
)
12201222
}
12211223

1224+
#[expect(clippy::too_many_arguments)] // silence overeager clippy lint
12221225
fn run_tool_build_step(
12231226
builder: &Builder<'_>,
12241227
compiler: Compiler,
@@ -1227,6 +1230,7 @@ fn run_tool_build_step(
12271230
path: &'static str,
12281231
add_bins_to_sysroot: Option<&[&str]>,
12291232
add_features: Option<fn(&Builder<'_>, TargetSelection, &mut Vec<String>)>,
1233+
cargo_args: Option<&[&'static str]>,
12301234
) -> ToolBuildResult {
12311235
let mut extra_features = Vec::new();
12321236
if let Some(func) = add_features {
@@ -1243,7 +1247,7 @@ fn run_tool_build_step(
12431247
extra_features,
12441248
source_type: SourceType::InTree,
12451249
allow_features: "",
1246-
cargo_args: vec![],
1250+
cargo_args: cargo_args.unwrap_or_default().iter().map(|s| String::from(*s)).collect(),
12471251
artifact_kind: ToolArtifactKind::Binary,
12481252
});
12491253

@@ -1294,7 +1298,9 @@ tool_extended!(Miri {
12941298
path: "src/tools/miri",
12951299
tool_name: "miri",
12961300
stable: false,
1297-
add_bins_to_sysroot: ["miri"]
1301+
add_bins_to_sysroot: ["miri"],
1302+
// Always compile also tests when building miri. Otherwise feature unification can cause rebuilds between building and testing miri.
1303+
cargo_args: &["--all-targets"],
12981304
});
12991305
tool_extended!(CargoMiri {
13001306
path: "src/tools/miri/cargo-miri",

0 commit comments

Comments
 (0)