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(...@@ -104,6 +104,7 @@ fn getPkgs(
104 else => |e| return e,104 else => |e| return e,
105 };105 };
106106
107 step.clearFailedCommand(maker.gpa);
107 pc.pkgs = result;108 pc.pkgs = result;
108 return result;109 return result;
109}110}
lib/compiler/Maker/Step/Run.zig+11-1
...@@ -332,6 +332,12 @@ pub fn make(...@@ -332,6 +332,12 @@ pub fn make(
332332
333 try populateGeneratedStdIo(maker, &conf_run, cache_root, &digest);333 try populateGeneratedStdIo(maker, &conf_run, cache_root, &digest);
334 try populateGeneratedPaths(maker, output_placeholders.items, cache_root, &digest);334 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);
335}341}
336342
337/// Reads stdout of a Zig test process until a termination condition is reached:343/// Reads stdout of a Zig test process until a termination condition is reached:
...@@ -2148,7 +2154,11 @@ fn spawnChildAndCollect(...@@ -2148,7 +2154,11 @@ fn spawnChildAndCollect(
2148 .dir => unreachable,2154 .dir => unreachable,
2149 .inherit => null,2155 .inherit => null,
2150 };2156 };
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, .{
2152 .cwd = cwd_string,2162 .cwd = cwd_string,
2153 .child_env = environ_map,2163 .child_env = environ_map,
2154 .parent_env = &graph.environ_map,2164 .parent_env = &graph.environ_map,