From ba634c44ba7b75ac4397df3a0c3c5f11093553f0 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Wed, 27 May 2026 13:04:19 -0700 Subject: [PATCH] Maker.Step.Run: fix not printing failed command regressed in 349053e32239fb718b446c4f6a4c92387d6bb1b5 I added comments to help prevent this regression in the future. --- lib/compiler/Maker/PkgConfig.zig | 1 + lib/compiler/Maker/Step/Run.zig | 12 +++++++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/compiler/Maker/PkgConfig.zig b/lib/compiler/Maker/PkgConfig.zig index 56bf8f08d721aee1cfd0e678cc8f320e3b540d98..5ef34a8fbce44001dc822d37d55f11fd1a636e48 100644 --- a/lib/compiler/Maker/PkgConfig.zig +++ b/lib/compiler/Maker/PkgConfig.zig @@ -104,6 +104,7 @@ fn getPkgs( else => |e| return e, }; + step.clearFailedCommand(maker.gpa); pc.pkgs = result; return result; } diff --git a/lib/compiler/Maker/Step/Run.zig b/lib/compiler/Maker/Step/Run.zig index 326048b4a1a9d5c8b7203f7c6256d67899247ed4..8b30753ecacc8b25c016286f6b110c13ed6f318c 100644 --- a/lib/compiler/Maker/Step/Run.zig +++ b/lib/compiler/Maker/Step/Run.zig @@ -332,6 +332,12 @@ pub fn make( try populateGeneratedStdIo(maker, &conf_run, cache_root, &digest); try populateGeneratedPaths(maker, output_placeholders.items, cache_root, &digest); + + // The utility functions that spawn the child process must unconditionally allocate + // the failed command because at that point it is not known whether the step will + // pass or fail based on the process termination. Here we free the memory since + // the step has succeeded. + step.clearFailedCommand(gpa); } /// Reads stdout of a Zig test process until a termination condition is reached: @@ -2148,7 +2154,11 @@ fn spawnChildAndCollect( .dir => unreachable, .inherit => null, }; - errdefer step.setFailedCommand(gpa, argv, .{ + // We have to set the failed command here regardless of whether this + // function returns an error because only after this function returns + // does the logic determine whether the child process termination was + // success or failure. + step.setFailedCommand(gpa, argv, .{ .cwd = cwd_string, .child_env = environ_map, .parent_env = &graph.environ_map, -- 2.54.0