diff --git a/lib/compiler/reduce.zig b/lib/compiler/reduce.zig index abdd9f84362292f50dc1c67d04cbc707d2e30888..b5051d2905106b6b4c627ef1be92ab0369f0d3ba 100644 --- a/lib/compiler/reduce.zig +++ b/lib/compiler/reduce.zig @@ -291,7 +291,11 @@ fn termToInteresting(term: std.process.Child.Term) Interestingness { std.debug.print("interestingness check terminated with signal {t}\n", .{sig}); return .boring; }, - else => { + .stopped => |sig| { + std.debug.print("interestingness check stopped with signal {d}\n", .{sig}); + return .boring; + }, + .unknown => { std.debug.print("interestingness check aborted unexpectedly\n", .{}); return .boring; }, diff --git a/lib/compiler/std-docs.zig b/lib/compiler/std-docs.zig index 5660e6e56dbf4c5b60aab76305a22f1de730f64b..69595726f48d3f658468bb35c98f6bc629413b68 100644 --- a/lib/compiler/std-docs.zig +++ b/lib/compiler/std-docs.zig @@ -423,7 +423,14 @@ fn buildWasmBinary( ); return error.WasmCompilationFailed; }, - .stopped, .unknown => { + .stopped => |sig| { + std.log.err( + "the following command stopped unexpectedly with signal {d}:\n{s}", + .{ sig, try std.Build.Step.allocPrintCmd(arena, .inherit, null, argv.items) }, + ); + return error.WasmCompilationFailed; + }, + .unknown => { std.log.err( "the following command terminated unexpectedly:\n{s}", .{try std.Build.Step.allocPrintCmd(arena, .inherit, null, argv.items)}, diff --git a/lib/std/Build/Step.zig b/lib/std/Build/Step.zig index 5876614099b38b9608006650b464978a87443b6f..03aac38e20a20510fda9e4ba131994224ca8fe09 100644 --- a/lib/std/Build/Step.zig +++ b/lib/std/Build/Step.zig @@ -725,19 +725,12 @@ pub inline fn handleChildProcUnsupported(s: *Step) error{ OutOfMemory, MakeFaile /// Asserts that the caller has already populated `s.result_failed_command`. pub fn handleChildProcessTerm(s: *Step, term: std.process.Child.Term) error{ MakeFailed, OutOfMemory }!void { assert(s.result_failed_command != null); - switch (term) { - .exited => |code| { - if (code != 0) { - return s.fail("process exited with error code {d}", .{code}); - } - }, - .signal => |sig| { - return s.fail("process terminated with signal {t}", .{sig}); - }, - .stopped, .unknown => { - return s.fail("process terminated unexpectedly", .{}); - }, - } + return switch (term) { + .exited => |code| if (code != 0) s.fail("process exited with error code {d}", .{code}), + .signal => |sig| s.fail("process terminated with signal {t}", .{sig}), + .stopped => |sig| s.fail("process stopped with signal {d}", .{sig}), + .unknown => s.fail("process terminated unexpectedly", .{}), + }; } pub fn allocPrintCmd( diff --git a/lib/std/Build/WebServer.zig b/lib/std/Build/WebServer.zig index 02778dec7a685dde4f39eae3f74b184cdcd00606..ff21739fa364b9cb9526e87bcbebc79e3c4fbce2 100644 --- a/lib/std/Build/WebServer.zig +++ b/lib/std/Build/WebServer.zig @@ -681,7 +681,14 @@ fn buildClientWasm(ws: *WebServer, arena: Allocator, optimize: std.builtin.Optim ); return error.WasmCompilationFailed; }, - .stopped, .unknown => { + .stopped => |sig| { + log.err( + "the following command stopped unexpectedly with signal {d}:\n{s}", + .{ sig, try Build.Step.allocPrintCmd(arena, .inherit, null, argv.items) }, + ); + return error.WasmCompilationFailed; + }, + .unknown => { log.err( "the following command terminated unexpectedly:\n{s}", .{try Build.Step.allocPrintCmd(arena, .inherit, null, argv.items)}, diff --git a/lib/std/zig/system.zig b/lib/std/zig/system.zig index 524c5e29afc5407036069264a16c9ea698e8c794..788ece9d6df6881f254c9eec403d1e7309e0f242 100644 --- a/lib/std/zig/system.zig +++ b/lib/std/zig/system.zig @@ -1185,11 +1185,25 @@ fn detectAndroidApiLevel(io: Io) !u32 { return error.ApiLevelQueryFailed; }; - const term = try child.wait(io); - if (term != .exited or term.exited != 0) { - std.log.err("getprop terminated abnormally: {}", .{term}); - return error.ApiLevelQueryFailed; + switch (try child.wait(io)) { + .exited => |code| if (code != 0) { + std.log.err("getprop terminated abnormally with exit code: {d}", .{code}); + return error.ApiLevelQueryFailed; + }, + .signal => |sig| { + std.log.err("getprop terminated abnormally with signal: {t}", .{sig}); + return error.ApiLevelQueryFailed; + }, + .stopped => |sig| { + std.log.err("getprop stopped abnormally with signal: {d}", .{sig}); + return error.ApiLevelQueryFailed; + }, + .unknown => { + std.log.err("getprop terminated abnormally", .{}); + return error.ApiLevelQueryFailed; + }, } + return api_level; } diff --git a/src/Compilation.zig b/src/Compilation.zig index fb0e5cc83f02513600cd0fc0fe92032c20fa3337..9164f889af793e0fbd6531af6fe7fb860b6ea1a2 100644 --- a/src/Compilation.zig +++ b/src/Compilation.zig @@ -5870,7 +5870,11 @@ fn updateCObject(comp: *Compilation, c_object: *CObject, c_obj_prog_node: std.Pr log.err("clang failed with stderr: {s}", .{stderr}); return comp.failCObj(c_object, "clang terminated with signal {t}", .{sig}); }, - else => { + .stopped => |sig| { + log.err("clang failed with stderr: {s}", .{stderr}); + return comp.failCObj(c_object, "clang stopped with signal {d}", .{sig}); + }, + .unknown => { log.err("clang terminated with stderr: {s}", .{stderr}); return comp.failCObj(c_object, "clang terminated unexpectedly", .{}); }, @@ -6297,7 +6301,11 @@ fn spawnZigRc( log.err("zig rc signaled {t} with stderr:\n{s}", .{ sig, stderr }); return comp.failWin32Resource(win32_resource, "zig rc terminated unexpectedly", .{}); }, - else => { + .stopped => |sig| { + log.err("zig rc stopped {d} with stderr:\n{s}", .{ sig, stderr }); + return comp.failWin32Resource(win32_resource, "zig rc terminated unexpectedly", .{}); + }, + .unknown => { log.err("zig rc terminated with stderr:\n{s}", .{stderr}); return comp.failWin32Resource(win32_resource, "zig rc terminated unexpectedly", .{}); }, diff --git a/src/main.zig b/src/main.zig index 4a69edfe82d9b2a11e0247691e13c4a9482ec9e8..f8286432e45653566b977db8b559546869636cfc 100644 --- a/src/main.zig +++ b/src/main.zig @@ -4580,7 +4580,11 @@ fn runOrTest( const cmd = try std.mem.join(arena, " ", argv.items); fatal("the following command terminated with signal {t}:\n{s}", .{ sig, cmd }); }, - else => { + .stopped => |sig| { + const cmd = try std.mem.join(arena, " ", argv.items); + fatal("the following command stopped with signal {d}:\n{s}", .{ sig, cmd }); + }, + .unknown => { process.exit(1); }, } @@ -5631,7 +5635,11 @@ fn cmdBuild(gpa: Allocator, arena: Allocator, io: Io, args: []const []const u8, const cmd = try std.mem.join(arena, " ", child_argv.items); fatal("the following build command terminated with signal {t}:\n{s}", .{ sig, cmd }); }, - else => { + .stopped => |sig| { + const cmd = try std.mem.join(arena, " ", child_argv.items); + fatal("the following build command stopped with signal {d}:\n{s}", .{ sig, cmd }); + }, + .unknown => { const cmd = try std.mem.join(arena, " ", child_argv.items); fatal("the following build command crashed:\n{s}", .{cmd}); }, @@ -5933,7 +5941,11 @@ fn jitCmdInner( const cmd = try std.mem.join(arena, " ", child_argv.items); fatal("the following build command terminated with signal {t}:\n{s}", .{ sig, cmd }); }, - else => { + .stopped => |sig| { + const cmd = try std.mem.join(arena, " ", child_argv.items); + fatal("the following build command stopped with signal {d}:\n{s}", .{ sig, cmd }); + }, + .unknown => { const cmd = try std.mem.join(arena, " ", child_argv.items); fatal("the following build command crashed:\n{s}", .{cmd}); }, diff --git a/tools/doctest.zig b/tools/doctest.zig index 0e29b2b983f6f5915fae5f9ae0fc759ba1abcdfa..50b1a747b0343482805f405be34681f483ce5fff 100644 --- a/tools/doctest.zig +++ b/tools/doctest.zig @@ -1141,7 +1141,12 @@ fn run( dumpArgs(args); return error.ChildCrashed; }, - else => { + .stopped => |sig| { + std.debug.print("{s}\nThe following command stopped with signal {d}:\n", .{ result.stderr, sig }); + dumpArgs(args); + return error.ChildCrashed; + }, + .unknown => { std.debug.print("{s}\nThe following command crashed:\n", .{result.stderr}); dumpArgs(args); return error.ChildCrashed; diff --git a/tools/incr-check.zig b/tools/incr-check.zig index 453139609c4a663e7681cc5846b44050cbbd6789..b825c0fdbf315966abe8981c2e59832087981d22 100644 --- a/tools/incr-check.zig +++ b/tools/incr-check.zig @@ -568,7 +568,10 @@ const Eval = struct { .signal => |sig| { eval.fatal("generated executable '{s}' terminated with signal {t}", .{ binary_path, sig }); }, - .stopped, .unknown => { + .stopped => |sig| { + eval.fatal("generated executable '{s}' stopped with signal {d}", .{ binary_path, sig }); + }, + .unknown => { eval.fatal("generated executable '{s}' terminated unexpectedly", .{binary_path}); }, } @@ -627,19 +630,17 @@ const Eval = struct { }) catch |err| { eval.fatal("failed to spawn zig cc for '{s}': {t}", .{ c_path, err }); }; + + if (result.term == .exited and result.term.exited == 0) return; + + if (result.stderr.len != 0) { + std.log.err("zig cc stderr:\n{s}", .{result.stderr}); + } switch (result.term) { - .exited => |code| if (code != 0) { - if (result.stderr.len != 0) { - std.log.err("zig cc stderr:\n{s}", .{result.stderr}); - } - eval.fatal("zig cc for '{s}' failed with code {d}", .{ c_path, code }); - }, - .signal, .stopped, .unknown => { - if (result.stderr.len != 0) { - std.log.err("zig cc stderr:\n{s}", .{result.stderr}); - } - eval.fatal("zig cc for '{s}' terminated unexpectedly", .{c_path}); - }, + .exited => |code| eval.fatal("zig cc for '{s}' failed with code {d}", .{ c_path, code }), + .signal => |sig| eval.fatal("zig cc for '{s}' terminated unexpectedly with signal {t}", .{ c_path, sig }), + .stopped => |sig| eval.fatal("zig cc for '{s}' stopped unexpectedly with signal {d}", .{ c_path, sig }), + .unknown => eval.fatal("zig cc for '{s}' terminated unexpectedly", .{c_path}), } } @@ -918,7 +919,8 @@ fn waitChild(child: *std.process.Child, eval: *Eval) void { switch (term) { .exited => |code| if (code != 0) eval.fatal("compiler failed with code {d}", .{code}), .signal => |sig| eval.fatal("compiler terminated with signal {t}", .{sig}), - .stopped, .unknown => eval.fatal("compiler terminated unexpectedly", .{}), + .stopped => |sig| eval.fatal("compiler stopped unexpectedly with signal {d}", .{sig}), + .unknown => eval.fatal("compiler terminated unexpectedly", .{}), } } diff --git a/tools/update_clang_options.zig b/tools/update_clang_options.zig index b2661ac181f1a2f3405ffc19a8da1e48d811647b..de3da1b6f4f57016ed29359f25d21e9d9b18dddf 100644 --- a/tools/update_clang_options.zig +++ b/tools/update_clang_options.zig @@ -688,7 +688,16 @@ pub fn main(init: std.process.Init) !void { const json_text = switch (child_result.term) { .exited => |code| if (code == 0) child_result.stdout else { - fatal("llvm-tblgen exited with code {d}", .{code}); + fatal("llvm-tblgen exited with code {d}\n", .{code}); + }, + .signal => |sig| { + fatal("llvm-tblgen terminated with signal {t}\n", .{sig}); + }, + .stopped => |sig| { + fatal("llvm-tblgen stopped with signal {d}\n", .{sig}); + }, + .unknown => { + fatal("llvm-tblgen crashed\n", .{}); }, else => fatal("llvm-tblgen crashed", .{}), }; diff --git a/tools/update_cpu_features.zig b/tools/update_cpu_features.zig index 636f45fa86f98513e45f6c212f389f56ec442281..e42c533b5120c8459be312adf8a561d1e2aeda3f 100644 --- a/tools/update_cpu_features.zig +++ b/tools/update_cpu_features.zig @@ -2012,7 +2012,15 @@ fn processOneTarget(io: Io, job: Job) void { std.debug.print("llvm-tblgen exited with code {d}\n", .{code}); std.process.exit(1); }, - else => { + .signal => |sig| { + std.debug.print("llvm-tblgen terminated with signal {t}\n", .{sig}); + std.process.exit(1); + }, + .stopped => |sig| { + std.debug.print("llvm-tblgen stopped with signal {d}\n", .{sig}); + std.process.exit(1); + }, + .unknown => { std.debug.print("llvm-tblgen crashed\n", .{}); std.process.exit(1); },