Commit 11bf2d92de

Andrew Kelley <andrew@ziglang.org>
2024-11-26 22:56:12
diversify "unable to spawn" failure messages
to help understand where a spurious failure is occurring
1 parent 68b3f50
Changed files (6)
lib/std/Build/Step/Run.zig
@@ -1137,7 +1137,7 @@ fn runCommand(
             };
         }
 
-        return step.fail("unable to spawn {s}: {s}", .{ argv[0], @errorName(err) });
+        return step.fail("failed to spawn and capture stdio from {s}: {s}", .{ argv[0], @errorName(err) });
     };
 
     step.result_duration_ns = result.elapsed_ns;
lib/std/Build/Step.zig
@@ -339,7 +339,7 @@ pub fn captureChildProcess(
         .allocator = arena,
         .argv = argv,
         .progress_node = progress_node,
-    }) catch |err| return s.fail("unable to spawn {s}: {s}", .{ argv[0], @errorName(err) });
+    }) catch |err| return s.fail("failed to run {s}: {s}", .{ argv[0], @errorName(err) });
 
     if (result.stderr.len > 0) {
         try s.result_error_msgs.append(arena, result.stderr);
@@ -423,7 +423,7 @@ pub fn evalZigProcess(
     child.request_resource_usage_statistics = true;
     child.progress_node = prog_node;
 
-    child.spawn() catch |err| return s.fail("unable to spawn {s}: {s}", .{
+    child.spawn() catch |err| return s.fail("failed to spawn zig compiler {s}: {s}", .{
         argv[0], @errorName(err),
     });
 
src/link/Wasm.zig
@@ -3722,7 +3722,7 @@ fn linkWithLLD(wasm: *Wasm, arena: Allocator, tid: Zcu.PerThread.Id, prog_node:
                 child.stderr_behavior = .Inherit;
 
                 const term = child.spawnAndWait() catch |err| {
-                    log.err("unable to spawn {s}: {s}", .{ argv.items[0], @errorName(err) });
+                    log.err("failed to spawn (passthrough mode) LLD {s}: {s}", .{ argv.items[0], @errorName(err) });
                     return error.UnableToSpawnWasm;
                 };
                 switch (term) {
@@ -3743,7 +3743,7 @@ fn linkWithLLD(wasm: *Wasm, arena: Allocator, tid: Zcu.PerThread.Id, prog_node:
                 const stderr = try child.stderr.?.reader().readAllAlloc(arena, std.math.maxInt(usize));
 
                 const term = child.wait() catch |err| {
-                    log.err("unable to spawn {s}: {s}", .{ argv.items[0], @errorName(err) });
+                    log.err("failed to spawn LLD {s}: {s}", .{ argv.items[0], @errorName(err) });
                     return error.UnableToSpawnWasm;
                 };
 
src/Compilation.zig
@@ -4772,7 +4772,7 @@ fn updateCObject(comp: *Compilation, c_object: *CObject, c_obj_prog_node: std.Pr
                 child.stderr_behavior = .Inherit;
 
                 const term = child.spawnAndWait() catch |err| {
-                    return comp.failCObj(c_object, "unable to spawn {s}: {s}", .{ argv.items[0], @errorName(err) });
+                    return comp.failCObj(c_object, "failed to spawn zig clang (passthrough mode) {s}: {s}", .{ argv.items[0], @errorName(err) });
                 };
                 switch (term) {
                     .Exited => |code| {
@@ -4794,7 +4794,7 @@ fn updateCObject(comp: *Compilation, c_object: *CObject, c_obj_prog_node: std.Pr
                 const stderr = try child.stderr.?.reader().readAllAlloc(arena, std.math.maxInt(usize));
 
                 const term = child.wait() catch |err| {
-                    return comp.failCObj(c_object, "unable to spawn {s}: {s}", .{ argv.items[0], @errorName(err) });
+                    return comp.failCObj(c_object, "failed to spawn zig clang {s}: {s}", .{ argv.items[0], @errorName(err) });
                 };
 
                 switch (term) {
src/link.zig
@@ -1648,7 +1648,7 @@ pub fn spawnLld(
             },
             else => first_err,
         };
-        log.err("unable to spawn {s}: {s}", .{ argv[0], @errorName(err) });
+        log.err("unable to spawn LLD {s}: {s}", .{ argv[0], @errorName(err) });
         return error.UnableToSpawnSelf;
     };
 
src/main.zig
@@ -5244,7 +5244,7 @@ fn cmdBuild(gpa: Allocator, arena: Allocator, args: []const []const u8) !void {
                 std.debug.lockStdErr();
                 defer std.debug.unlockStdErr();
                 break :t child.spawnAndWait() catch |err| {
-                    fatal("unable to spawn {s}: {s}", .{ child_argv.items[0], @errorName(err) });
+                    fatal("failed to spawn build runner {s}: {s}", .{ child_argv.items[0], @errorName(err) });
                 };
             };