Skip to content

Commit e6e4792

Browse files
committed
std.debug: completely disable FP-based unwinding on mips
1 parent 30f5258 commit e6e4792

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

lib/std/debug.zig

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -855,6 +855,18 @@ const StackIterator = union(enum) {
855855
}
856856
}
857857

858+
/// Some architectures make FP unwinding too impractical. For example, due to its very silly ABI
859+
/// design decisions, it's not possible to do generic FP unwinding on MIPS; we would need to do
860+
/// a complicated code scanning algorithm instead. At that point, we may as well just use DWARF.
861+
const fp_unwind_is_impossible = switch (builtin.cpu.arch) {
862+
.mips,
863+
.mipsel,
864+
.mips64,
865+
.mips64el,
866+
=> true,
867+
else => false,
868+
};
869+
858870
/// <https://developer.apple.com/documentation/xcode/writing-arm64-code-for-apple-platforms#Respect-the-purpose-of-specific-CPU-registers>
859871
const fp_unwind_is_safe = builtin.cpu.arch == .aarch64 and builtin.os.tag.isDarwin();
860872

@@ -879,7 +891,14 @@ const StackIterator = union(enum) {
879891
// immediately regardless of anything. But FPs could also be omitted from a different
880892
// linked object, so it's not guaranteed to be safe, unless the target specifically
881893
// requires it.
882-
.fp => abi_requires_backchain or (!builtin.omit_frame_pointer and (fp_unwind_is_safe or allow_unsafe)),
894+
.fp => s: {
895+
if (fp_unwind_is_impossible) break :s false;
896+
if (abi_requires_backchain) break :s true;
897+
if (builtin.omit_frame_pointer) break :s false;
898+
if (fp_unwind_is_safe) break :s true;
899+
if (allow_unsafe) break :s true;
900+
break :s false;
901+
},
883902
};
884903
}
885904

0 commit comments

Comments
 (0)