authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2026-05-27 13:04:19-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2026-05-27 13:04:19-07:00
logba634c44ba7b75ac4397df3a0c3c5f11093553f0
treead83040ce80b7ab310a95c85d6fcff52783107e8
parentea044a4b829a03861823bac7bbef8e28e4c54af6

Maker.Step.Run: fix not printing failed command

regressed in 349053e32239fb718b446c4f6a4c92387d6bb1b5 I added comments to help prevent this regression in the future.

2 files changed, 12 insertions(+), 1 deletions(-)

lib/compiler/Maker/PkgConfig.zig+1
......@@ -104,6 +104,7 @@ fn getPkgs(
104104 else => |e| return e,
105105 };
106106
107 step.clearFailedCommand(maker.gpa);
107108 pc.pkgs = result;
108109 return result;
109110}
lib/compiler/Maker/Step/Run.zig+11-1
......@@ -332,6 +332,12 @@ pub fn make(
332332
333333 try populateGeneratedStdIo(maker, &conf_run, cache_root, &digest);
334334 try populateGeneratedPaths(maker, output_placeholders.items, cache_root, &digest);
335
336 // The utility functions that spawn the child process must unconditionally allocate
337 // the failed command because at that point it is not known whether the step will
338 // pass or fail based on the process termination. Here we free the memory since
339 // the step has succeeded.
340 step.clearFailedCommand(gpa);
335341}
336342
337343/// Reads stdout of a Zig test process until a termination condition is reached:
......@@ -2148,7 +2154,11 @@ fn spawnChildAndCollect(
21482154 .dir => unreachable,
21492155 .inherit => null,
21502156 };
2151 errdefer step.setFailedCommand(gpa, argv, .{
2157 // We have to set the failed command here regardless of whether this
2158 // function returns an error because only after this function returns
2159 // does the logic determine whether the child process termination was
2160 // success or failure.
2161 step.setFailedCommand(gpa, argv, .{
21522162 .cwd = cwd_string,
21532163 .child_env = environ_map,
21542164 .parent_env = &graph.environ_map,