You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
proposal: allow stack traces to be disabled even when not stripping debug info #18387
enhancementSolving this issue will likely involve adding new logic or components to the codebase.standard libraryThis issue involves writing Zig code for the standard library.
stderr.print("Unable to dump stack trace: debug info stripped\n", .{}) catchreturn;
return;
}
in most cases this is fine, its extremely convenient to just run your program and get stack traces on panics, errors, crashes, etc. its like your program is a debugger itself. but this isnt always the best, in embedded applications for example. you have to use ReleaseSmall but if you want to keep debug info it compiles in an insane amount of code for something you dont want or need. in cases this like its quite trivial to separate the debug info manually with e.g. objcopy and now you have the best of both worlds, tiny binary and stack traces by using a debugger.
i did a simple test on a program that only consisted of a blank panic in main and the binary sizes were the following
Config
Size
ReleaseSmall (stripped)
8.0K
ReleaseSmall (-fno-strip)
1.2M
ReleaseSmall (-fno-strip) + strip -s
130K
ReleaseSmall (-fno-strip, no stack traces)
526K
ReleaseSmall (-fno-strip, no stack traces) + strip -s
8K
im thinking this could be something in std_options then the checks in debug.zig can just be changed to something like if (!std.options.keep_stack_traces or builtin.strip_debug_info)
In general, the concept of using "is stripped" as a setting for things to include in the binary is misleading, whether the binary will be stripped is not comptime-known.
Resolved by b64535e with this new field in std.Options:
/// Whether to allow capturing and writing stack traces. This affects the following functions:/// * `debug.captureCurrentStackTrace`/// * `debug.writeCurrentStackTrace`/// * `debug.dumpCurrentStackTrace`/// * `debug.writeStackTrace`/// * `debug.dumpStackTrace`////// Stack traces can generally be collected and printed when debug info is stripped, but are/// often less useful since they usually cannot be mapped to source locations and/or have bad/// source locations. The stack tracing logic can also be quite large, which may be undesirable,/// particularly in ReleaseSmall.////// If this is `false`, then captured stack traces will always be empty, and attempts to write/// stack traces will just print an error to the relevant `Io.Writer` and return.allow_stack_tracing: bool=!@import("builtin").strip_debug_info,
enhancementSolving this issue will likely involve adding new logic or components to the codebase.standard libraryThis issue involves writing Zig code for the standard library.
Activity
cn-cn-cn commentedon Dec 31, 2023
In general, the concept of using "is stripped" as a setting for things to include in the binary is misleading, whether the binary will be stripped is not comptime-known.
mlugg commentedon Oct 1, 2025
Resolved by b64535e with this new field in
std.Options: