Skip to content

Commit

Permalink
Revert "Drop conditionally applied cargo -Zon-broken-pipe=kill flags"
Browse files Browse the repository at this point in the history
This reverts commit 5a7058c.

In [rust-lang#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.

[rust-lang#131059]: rust-lang#131059
[1]: rust-lang#131059 (comment)
  • Loading branch information
jieyouxu committed Oct 1, 2024
1 parent 07f08ff commit 1c7e824
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
4 changes: 4 additions & 0 deletions src/bootstrap/src/core/build_steps/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1053,6 +1053,10 @@ pub fn rustc_cargo(

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

// If the rustc output is piped to e.g. `head -n1` we want the process to be
// killed, rather than having an error bubble up and cause a panic.
cargo.rustflag("-Zon-broken-pipe=kill");

if builder.config.llvm_enzyme {
cargo.rustflag("-l").rustflag("Enzyme-19");
}
Expand Down
11 changes: 7 additions & 4 deletions src/bootstrap/src/core/build_steps/tool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,10 +200,6 @@ pub fn prepare_tool_cargo(
cargo.arg("--features").arg(features.join(", "));
}

// Warning: be very careful with RUSTFLAGS or command-line options, as conditionally applied
// RUSTFLAGS or cli flags can lead to hard-to-diagnose rebuilds due to flag differences, causing
// previous tool build artifacts to get invalidated.

// Enable internal lints for clippy and rustdoc
// NOTE: this doesn't enable lints for any other tools unless they explicitly add `#![warn(rustc::internal)]`
// See https://github.com/rust-lang/rust/pull/80573#issuecomment-754010776
Expand All @@ -213,6 +209,13 @@ pub fn prepare_tool_cargo(
// See https://github.com/rust-lang/rust/issues/116538
cargo.rustflag("-Zunstable-options");

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

cargo
}

Expand Down

0 comments on commit 1c7e824

Please sign in to comment.