aboutsummaryrefslogtreecommitdiff
path: root/lib/compiler_rt/common.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2024-09-28 15:58:41 -0700
committerGitHub <noreply@github.com>2024-09-28 15:58:41 -0700
commit0cdec976e4eaf96e1735ff417b222ab1463727e8 (patch)
tree1b47bb75eb6f29f9da11c93ac7ea924a8bfb326a /lib/compiler_rt/common.zig
parent085cc54aadb327b9910be2c72b31ea046e7e8f52 (diff)
parent2857ca1edc1c3fa83298d2e8f6d505a3776f1ae3 (diff)
downloadzig-0cdec976e4eaf96e1735ff417b222ab1463727e8.tar.gz
zig-0cdec976e4eaf96e1735ff417b222ab1463727e8.zip
Merge pull request #21520 from ziglang/no-formatted-panics
formalize the panic interface closes #17969 closes #20240
Diffstat (limited to 'lib/compiler_rt/common.zig')
-rw-r--r--lib/compiler_rt/common.zig13
1 files changed, 7 insertions, 6 deletions
diff --git a/lib/compiler_rt/common.zig b/lib/compiler_rt/common.zig
index a6fd953379..db2a55445e 100644
--- a/lib/compiler_rt/common.zig
+++ b/lib/compiler_rt/common.zig
@@ -75,13 +75,14 @@ pub const gnu_f16_abi = switch (builtin.cpu.arch) {
pub const want_sparc_abi = builtin.cpu.arch.isSPARC();
-// Avoid dragging in the runtime safety mechanisms into this .o file,
-// unless we're trying to test compiler-rt.
-pub fn panic(msg: []const u8, error_return_trace: ?*std.builtin.StackTrace, _: ?usize) noreturn {
- _ = error_return_trace;
+// Avoid dragging in the runtime safety mechanisms into this .o file, unless
+// we're trying to test compiler-rt.
+pub const Panic = if (builtin.is_test) std.debug.FormattedPanic else struct {};
+
+/// To be deleted after zig1.wasm is updated.
+pub fn panic(msg: []const u8, error_return_trace: ?*std.builtin.StackTrace, ret_addr: ?usize) noreturn {
if (builtin.is_test) {
- @branchHint(.cold);
- std.debug.panic("{s}", .{msg});
+ std.debug.defaultPanic(msg, error_return_trace, ret_addr orelse @returnAddress());
} else {
unreachable;
}