aboutsummaryrefslogtreecommitdiff
path: root/lib/std/debug.zig
diff options
context:
space:
mode:
authormlugg <mlugg@mlugg.co.uk>2025-09-18 15:52:02 +0100
committermlugg <mlugg@mlugg.co.uk>2025-09-30 13:44:55 +0100
commit084e92879a1732374fac5f1a05a27f42b9306d22 (patch)
tree59d416eec4b409c74aa2c0b95781e418d5cd2c7a /lib/std/debug.zig
parentdae703d3c028eab3bf98d89d2bca1abc75f864fa (diff)
downloadzig-084e92879a1732374fac5f1a05a27f42b9306d22.tar.gz
zig-084e92879a1732374fac5f1a05a27f42b9306d22.zip
std: don't get CPU context when using CBE targeting MSVC
Calling `current` here causes compilation failures as the C backend currently does not emit valid MSVC inline assembly. This change means that when building for MSVC with the self-hosted C backend, only FP unwinding can be used.
Diffstat (limited to 'lib/std/debug.zig')
-rw-r--r--lib/std/debug.zig8
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/std/debug.zig b/lib/std/debug.zig
index 23d134f84c..3d8bc565e7 100644
--- a/lib/std/debug.zig
+++ b/lib/std/debug.zig
@@ -756,7 +756,13 @@ const StackIterator = union(enum) {
// Use `di_first` here so we report the PC in the context before unwinding any further.
return .{ .di_first = .init(context_ptr) };
}
- if (SelfInfo.supports_unwinding and cpu_context.Native != noreturn) {
+ // Workaround the C backend being unable to use inline assembly on MSVC by disabling the
+ // call to `current`. This effectively constrains stack trace collection and dumping to FP
+ // unwinding when building with CBE for MSVC.
+ if (!(builtin.zig_backend == .stage2_c and builtin.target.abi == .msvc) and
+ SelfInfo.supports_unwinding and
+ cpu_context.Native != noreturn)
+ {
// We don't need `di_first` here, because our PC is in `std.debug`; we're only interested
// in our caller's frame and above.
return .{ .di = .init(&.current()) };