authorgravatar for kcbanner@gmail.comCasey Banner <kcbanner@gmail.com> 2023-07-26 01:26:26-04:00
committergravatar for kcbanner@gmail.comCasey Banner <kcbanner@gmail.com> 2023-07-26 20:58:29-04:00
log661028a907a66ad94b6c052286a59da3bcd6f287
tree867d916f3cc0158f19a847a0258cd42697506b0a
parentf2aab12a8627b3afd1a4d9c38157968b2f012e0c

target: emit unwind tables if the platform supports unwinding


3 files changed, 20 insertions(+), 9 deletions(-)

lib/std/dwarf.zig+1-1
......@@ -1656,7 +1656,7 @@ pub const DwarfInfo = struct {
16561656 /// `explicit_fde_offset` is for cases where the FDE offset is known, such as when __unwind_info
16571657 /// defers unwinding to DWARF. This is an offset into the `.eh_frame` section.
16581658 pub fn unwindFrame(di: *const DwarfInfo, context: *UnwindContext, explicit_fde_offset: ?usize) !usize {
1659 if (!comptime abi.isSupportedArch(builtin.target.cpu.arch)) return error.UnsupportedCpuArchitecture;
1659 if (!comptime abi.supportsUnwinding(builtin.target)) return error.UnsupportedCpuArchitecture;
16601660 if (context.pc == 0) return 0;
16611661
16621662 // Find the FDE and CIE
lib/std/dwarf/abi.zig+18-7
......@@ -3,13 +3,24 @@ const std = @import("../std.zig");
33const os = std.os;
44const mem = std.mem;
55
6pub fn isSupportedArch(arch: std.Target.Cpu.Arch) bool {
7 return switch (arch) {
8 .x86,
9 .x86_64,
10 .arm,
11 .aarch64,
12 => true,
6pub fn supportsUnwinding(target: std.Target) bool {
7 return switch (target.cpu.arch) {
8 .x86 => switch (target.os.tag) {
9 .linux, .netbsd, .solaris => true,
10 else => false,
11 },
12 .x86_64 => switch (target.os.tag) {
13 .linux, .netbsd, .freebsd, .openbsd, .macos, .solaris => true,
14 else => false,
15 },
16 .arm => switch (target.os.tag) {
17 .linux => true,
18 else => false,
19 },
20 .aarch64 => switch (target.os.tag) {
21 .linux, .netbsd, .freebsd, .macos => true,
22 else => false,
23 },
1324 else => false,
1425 };
1526}
src/target.zig+1-1
......@@ -510,7 +510,7 @@ pub fn clangAssemblerSupportsMcpuArg(target: std.Target) bool {
510510}
511511
512512pub fn needUnwindTables(target: std.Target) bool {
513 return target.os.tag == .windows or target.isDarwin();
513 return target.os.tag == .windows or target.isDarwin() or std.dwarf.abi.supportsUnwinding(target);
514514}
515515
516516pub fn defaultAddressSpace(