authorgravatar for jacobly@ziglang.orgJacob Young <jacobly@ziglang.org> 2026-02-13 12:28:03-05:00
committergravatar for jacobly@ziglang.orgJacob Young <jacobly@ziglang.org> 2026-02-13 12:29:40-05:00
log0eb1e0c30a4f143dfcb15b4c6a01ec9c566dc39f
tree5b95c582d2e3d7bc726b8a494318440a3d29fe7d
parent2fa1a784914c536e45fdfaba9e357d0ef4f4f133

crash_report: finish reverting panic changes better

I missed that the types were `pub`.

2 files changed, 25 insertions(+), 11 deletions(-)

src/crash_report.zig+23-5
...@@ -1,13 +1,18 @@...@@ -1,13 +1,18 @@
1pub const enabled = switch (build_options.io_mode) {
2 .threaded => build_options.enable_debug_extensions,
3 .evented => false, // would use threadlocals in a way incompatible with evented
4};
5
1/// We override the panic implementation to our own one, so we can print our own information before6/// We override the panic implementation to our own one, so we can print our own information before
2/// calling the default panic handler. This declaration must be re-exposed from `@import("root")`.7/// calling the default panic handler. This declaration must be re-exposed from `@import("root")`.
3pub const panic = std.debug.FullPanic(panicImpl);8pub const panic = std.debug.FullPanic(if (enabled) panicImpl else std.debug.defaultPanic);
49
5/// We let std install its segfault handler, but we override the target-agnostic handler it calls,10/// We let std install its segfault handler, but we override the target-agnostic handler it calls,
6/// so we can print our own information before calling the default segfault logic. This declaration11/// so we can print our own information before calling the default segfault logic. This declaration
7/// must be re-exposed from `@import("root")`.12/// must be re-exposed from `@import("root")`.
8pub const debug = struct {13pub const debug = if (enabled) struct {
9 pub const handleSegfault = handleSegfaultImpl;14 pub const handleSegfault = handleSegfaultImpl;
10};15} else struct {};
1116
12/// Printed in panic messages when suggesting a command to run, allowing copy-pasting the command.17/// Printed in panic messages when suggesting a command to run, allowing copy-pasting the command.
13/// Set by `main` as soon as arguments are known. The value here is a default in case we somehow18/// Set by `main` as soon as arguments are known. The value here is a default in case we somehow
...@@ -25,7 +30,7 @@ fn panicImpl(msg: []const u8, first_trace_addr: ?usize) noreturn {...@@ -25,7 +30,7 @@ fn panicImpl(msg: []const u8, first_trace_addr: ?usize) noreturn {
25 std.debug.defaultPanic(msg, first_trace_addr orelse @returnAddress());30 std.debug.defaultPanic(msg, first_trace_addr orelse @returnAddress());
26}31}
2732
28pub const AnalyzeBody = struct {33pub const AnalyzeBody = if (enabled) struct {
29 parent: ?*AnalyzeBody,34 parent: ?*AnalyzeBody,
30 sema: *Sema,35 sema: *Sema,
31 block: *Sema.Block,36 block: *Sema.Block,
...@@ -52,9 +57,15 @@ pub const AnalyzeBody = struct {...@@ -52,9 +57,15 @@ pub const AnalyzeBody = struct {
52 std.debug.assert(current.? == ab); // `Sema.analyzeBodyInner` did not match push/pop calls57 std.debug.assert(current.? == ab); // `Sema.analyzeBodyInner` did not match push/pop calls
53 current = ab.parent;58 current = ab.parent;
54 }59 }
60} else struct {
61 const current: ?noreturn = null;
62 // Dummy implementation, with functions marked `inline` to avoid interfering with tail calls.
63 pub inline fn push(_: AnalyzeBody, _: *Sema, _: *Sema.Block, _: []const Zir.Inst.Index) void {}
64 pub inline fn pop(_: AnalyzeBody) void {}
65 pub inline fn setBodyIndex(_: @This(), _: usize) void {}
55};66};
5667
57pub const CodegenFunc = struct {68pub const CodegenFunc = if (enabled) struct {
58 zcu: *const Zcu,69 zcu: *const Zcu,
59 func_index: InternPool.Index,70 func_index: InternPool.Index,
60 threadlocal var current: ?CodegenFunc = null;71 threadlocal var current: ?CodegenFunc = null;
...@@ -66,6 +77,11 @@ pub const CodegenFunc = struct {...@@ -66,6 +77,11 @@ pub const CodegenFunc = struct {
66 std.debug.assert(current.?.func_index == func_index);77 std.debug.assert(current.?.func_index == func_index);
67 current = null;78 current = null;
68 }79 }
80} else struct {
81 const current: ?noreturn = null;
82 // Dummy implementation
83 pub fn start(_: *const Zcu, _: InternPool.Index) void {}
84 pub fn stop(_: InternPool.Index) void {}
69};85};
7086
71fn dumpCrashContext() Io.Writer.Error!void {87fn dumpCrashContext() Io.Writer.Error!void {
...@@ -172,3 +188,5 @@ const Zcu = @import("Zcu.zig");...@@ -172,3 +188,5 @@ const Zcu = @import("Zcu.zig");
172const InternPool = @import("InternPool.zig");188const InternPool = @import("InternPool.zig");
173const dev = @import("dev.zig");189const dev = @import("dev.zig");
174const print_zir = @import("print_zir.zig");190const print_zir = @import("print_zir.zig");
191
192const build_options = @import("build_options");
src/main.zig+2-6
...@@ -52,12 +52,8 @@ pub const std_options: std.Options = .{...@@ -52,12 +52,8 @@ pub const std_options: std.Options = .{
52};52};
53pub const std_options_cwd = if (native_os == .wasi) wasi_cwd else null;53pub const std_options_cwd = if (native_os == .wasi) wasi_cwd else null;
5454
55const crash_report_enabled = switch (build_options.io_mode) {55pub const panic = crash_report.panic;
56 .threaded => build_options.enable_debug_extensions,56pub const debug = crash_report.debug;
57 .evented => false, // would use threadlocals in a way incompatible with evented
58};
59pub const panic = if (crash_report_enabled) crash_report.panic else std.debug.FullPanic(std.debug.defaultPanic);
60pub const debug = if (crash_report_enabled) crash_report.debug else struct {};
6157
62var preopens: std.process.Preopens = .empty;58var preopens: std.process.Preopens = .empty;
63pub fn wasi_cwd() Io.Dir {59pub fn wasi_cwd() Io.Dir {