about summary refs log tree commit diff
path: root/src/bootstrap
diff options
context:
space:
mode:
authoronur-ozkan <work@onurozkan.dev>2024-06-25 11:36:50 +0300
committeronur-ozkan <work@onurozkan.dev>2024-06-26 08:03:55 +0300
commitb3fb67e050e763ff80b90121f2b60f10d86204f5 (patch)
tree162cc156e66f43d990226c3c8136a347d353c234 /src/bootstrap
parent164e1297e1bce47a241e4d93a9f044452b288715 (diff)
downloadrust-b3fb67e050e763ff80b90121f2b60f10d86204f5.tar.gz
rust-b3fb67e050e763ff80b90121f2b60f10d86204f5.zip
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 <work@onurozkan.dev>
Diffstat (limited to 'src/bootstrap')
-rw-r--r--src/bootstrap/src/core/build_steps/tool.rs15
1 files changed, 9 insertions, 6 deletions
diff --git a/src/bootstrap/src/core/build_steps/tool.rs b/src/bootstrap/src/core/build_steps/tool.rs
index 850c8bfe2f8..7411d0ba2be 100644
--- a/src/bootstrap/src/core/build_steps/tool.rs
+++ b/src/bootstrap/src/core/build_steps/tool.rs
@@ -211,6 +211,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
 }
 
@@ -575,7 +582,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 +594,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,