diff options
| author | 许杰友 Jieyou Xu (Joe) <jieyouxu@outlook.com> | 2024-10-01 18:35:26 +0000 |
|---|---|---|
| committer | 许杰友 Jieyou Xu (Joe) <jieyouxu@outlook.com> | 2024-10-01 18:35:26 +0000 |
| commit | 1c7e8246d53da3b68589c9fe2aa2c830fae3f164 (patch) | |
| tree | 9889966bd244f2f0a92d47dd438eaf427e5520a2 | |
| parent | 07f08ffb2dbc864d2127abedf7a5917b965c0a4b (diff) | |
| download | rust-1c7e8246d53da3b68589c9fe2aa2c830fae3f164.tar.gz rust-1c7e8246d53da3b68589c9fe2aa2c830fae3f164.zip | |
Revert "Drop conditionally applied cargo `-Zon-broken-pipe=kill` flags"
This reverts commit 5a7058c5a542ec42d1fa9b524f7b4f7d6845d1e9. 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]: https://github.com/rust-lang/rust/issues/131059 [1]: https://github.com/rust-lang/rust/issues/131059#issuecomment-2385822033
| -rw-r--r-- | src/bootstrap/src/core/build_steps/compile.rs | 4 | ||||
| -rw-r--r-- | src/bootstrap/src/core/build_steps/tool.rs | 11 |
2 files changed, 11 insertions, 4 deletions
diff --git a/src/bootstrap/src/core/build_steps/compile.rs b/src/bootstrap/src/core/build_steps/compile.rs index bb1d8d27928..eaa982d4e2b 100644 --- a/src/bootstrap/src/core/build_steps/compile.rs +++ b/src/bootstrap/src/core/build_steps/compile.rs @@ -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"); } diff --git a/src/bootstrap/src/core/build_steps/tool.rs b/src/bootstrap/src/core/build_steps/tool.rs index fa2c1b8360f..64dfe054d9c 100644 --- a/src/bootstrap/src/core/build_steps/tool.rs +++ b/src/bootstrap/src/core/build_steps/tool.rs @@ -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 @@ -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 } |
