File tree 3 files changed +13
-6
lines changed
3 files changed +13
-6
lines changed Original file line number Diff line number Diff line change @@ -137,6 +137,10 @@ fn main() {
137
137
cmd. args ( lint_flags. split_whitespace ( ) ) ;
138
138
}
139
139
140
+ if let Ok ( flags) = env:: var ( "UNTRACKED_BROKEN_PIPE_FLAG" ) {
141
+ cmd. args ( flags. split_whitespace ( ) ) ;
142
+ }
143
+
140
144
if target. is_some ( ) {
141
145
// The stage0 compiler has a special sysroot distinct from what we
142
146
// actually downloaded, so we just always pass the `--sysroot` option,
Original file line number Diff line number Diff line change @@ -1053,8 +1053,10 @@ pub fn rustc_cargo(
1053
1053
1054
1054
cargo. rustdocflag ( "-Zcrate-attr=warn(rust_2018_idioms)" ) ;
1055
1055
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.
1056
+ // If the rustc output is piped to e.g. `head -n1` we want the process to be killed, rather than
1057
+ // having an error bubble up and cause a panic.
1058
+ // NOTE(jieyouxu): this flag is load-bearing for rustc to not ICE on broken pipes.
1059
+ // See <https://github.com/rust-lang/rust/issues/131059> for details.
1058
1060
cargo. rustflag ( "-Zon-broken-pipe=kill" ) ;
1059
1061
1060
1062
if builder. config . llvm_enzyme {
Original file line number Diff line number Diff line change @@ -209,11 +209,12 @@ pub fn prepare_tool_cargo(
209
209
// See https://github.com/rust-lang/rust/issues/116538
210
210
cargo. rustflag ( "-Zunstable-options" ) ;
211
211
212
- // `-Zon-broken-pipe=kill` breaks cargo tests
212
+ // cargo explicitly does not want `-Zon-broken-pipe=kill` semantics, and thankfully cargo tests
213
+ // will break if we do set the flag. We use a special env var here that is not part of
214
+ // `RUSTFLAGS` tracked by cargo as that can cause unnecessary tool rebuilds due to tool build
215
+ // cache invalidation.
213
216
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
+ cargo. env ( "UNTRACKED_BROKEN_PIPE_FLAG" , "-Zon-broken-pipe=kill" ) ;
217
218
}
218
219
219
220
cargo
You can’t perform that action at this time.
0 commit comments