From 2e017f42c469cc4aa2dcaded22014a52c68d4423 Mon Sep 17 00:00:00 2001 From: onur-ozkan Date: Tue, 25 Jun 2024 11:36:50 +0300 Subject: [PATCH] set `on-broken-pipe` in `prepare_cargo_tool` 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. Signed-off-by: onur-ozkan --- src/bootstrap/src/core/build_steps/tool.rs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/bootstrap/src/core/build_steps/tool.rs b/src/bootstrap/src/core/build_steps/tool.rs index 850c8bfe2f8b9..03dfc86ba3066 100644 --- a/src/bootstrap/src/core/build_steps/tool.rs +++ b/src/bootstrap/src/core/build_steps/tool.rs @@ -211,6 +211,10 @@ pub fn prepare_tool_cargo( // See https://github.com/rust-lang/rust/issues/116538 cargo.rustflag("-Zunstable-options"); + // 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 } @@ -575,7 +579,8 @@ impl Step for Rustdoc { features.push("jemalloc".to_string()); } - let mut cargo = prepare_tool_cargo( + // NOTE: Never modify the rustflags here, it breaks the build cache for other tools! + let cargo = prepare_tool_cargo( builder, build_compiler, Mode::ToolRustc, @@ -586,11 +591,6 @@ impl Step for Rustdoc { features.as_slice(), ); - // If the rustdoc 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"); - let _guard = builder.msg_tool( Kind::Build, Mode::ToolRustc,