Skip to content

Commit bae813a

Browse files
committedJun 26, 2024
Auto merge of #126934 - onur-ozkan:broken-build-cache, r=Kobzol
fix broken build cache caused by rustdoc builds Currently rustdoc breaks the build cache (due to having different rustflags) when building rustdoc before building another tool (e.g., `x test miri && x test rustdoc && x test miri`). This change fixes that by moving `on-broken-pipe` into `prepare_cargo_tool` so it is set for all tools. cc `@RalfJung` Fixes #123177
2 parents 7731802 + b3fb67e commit bae813a

File tree

1 file changed

+9
-6
lines changed
  • src/bootstrap/src/core/build_steps

1 file changed

+9
-6
lines changed
 

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

+9-6
Original file line numberDiff line numberDiff line change
@@ -211,6 +211,13 @@ pub fn prepare_tool_cargo(
211211
// See https://github.com/rust-lang/rust/issues/116538
212212
cargo.rustflag("-Zunstable-options");
213213

214+
// `-Zon-broken-pipe=kill` breaks cargo tests
215+
if !path.ends_with("cargo") {
216+
// If the output is piped to e.g. `head -n1` we want the process to be killed,
217+
// rather than having an error bubble up and cause a panic.
218+
cargo.rustflag("-Zon-broken-pipe=kill");
219+
}
220+
214221
cargo
215222
}
216223

@@ -575,7 +582,8 @@ impl Step for Rustdoc {
575582
features.push("jemalloc".to_string());
576583
}
577584

578-
let mut cargo = prepare_tool_cargo(
585+
// NOTE: Never modify the rustflags here, it breaks the build cache for other tools!
586+
let cargo = prepare_tool_cargo(
579587
builder,
580588
build_compiler,
581589
Mode::ToolRustc,
@@ -586,11 +594,6 @@ impl Step for Rustdoc {
586594
features.as_slice(),
587595
);
588596

589-
// If the rustdoc output is piped to e.g. `head -n1` we want the process
590-
// to be killed, rather than having an error bubble up and cause a
591-
// panic.
592-
cargo.rustflag("-Zon-broken-pipe=kill");
593-
594597
let _guard = builder.msg_tool(
595598
Kind::Build,
596599
Mode::ToolRustc,

0 commit comments

Comments
 (0)
Please sign in to comment.