Skip to content

Commit 1c7e824

Browse files
committed
Revert "Drop conditionally applied cargo -Zon-broken-pipe=kill flags"
This reverts commit 5a7058c. In [#131059] we found out that `-Zon-broken-pipe=kill` is actually **load-bearing** [1] for (at least) `rustc` and `rustdoc` to have the kill-process-on-broken-pipe behavior, e.g. `rustc --print=sysroot | false` will ICE and `rustdoc --print=sysroot | false` will panic on a broken pipe. [#131059]: #131059 [1]: #131059 (comment)
1 parent 07f08ff commit 1c7e824

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

src/bootstrap/src/core/build_steps/compile.rs

+4
Original file line numberDiff line numberDiff line change
@@ -1053,6 +1053,10 @@ pub fn rustc_cargo(
10531053

10541054
cargo.rustdocflag("-Zcrate-attr=warn(rust_2018_idioms)");
10551055

1056+
// If the rustc output is piped to e.g. `head -n1` we want the process to be
1057+
// killed, rather than having an error bubble up and cause a panic.
1058+
cargo.rustflag("-Zon-broken-pipe=kill");
1059+
10561060
if builder.config.llvm_enzyme {
10571061
cargo.rustflag("-l").rustflag("Enzyme-19");
10581062
}

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

+7-4
Original file line numberDiff line numberDiff line change
@@ -200,10 +200,6 @@ pub fn prepare_tool_cargo(
200200
cargo.arg("--features").arg(features.join(", "));
201201
}
202202

203-
// Warning: be very careful with RUSTFLAGS or command-line options, as conditionally applied
204-
// RUSTFLAGS or cli flags can lead to hard-to-diagnose rebuilds due to flag differences, causing
205-
// previous tool build artifacts to get invalidated.
206-
207203
// Enable internal lints for clippy and rustdoc
208204
// NOTE: this doesn't enable lints for any other tools unless they explicitly add `#![warn(rustc::internal)]`
209205
// See https://github.com/rust-lang/rust/pull/80573#issuecomment-754010776
@@ -213,6 +209,13 @@ pub fn prepare_tool_cargo(
213209
// See https://github.com/rust-lang/rust/issues/116538
214210
cargo.rustflag("-Zunstable-options");
215211

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

0 commit comments

Comments
 (0)