zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit dcdb562c154c950ed06a23a3a267fa8cdc172dda (tree)
parent 492efd4c06541ca8add4147dfc2d766c1ba54693
Author: Mason Remaley <mason@gamesbymason.com>
Date:   Thu,  9 Apr 2026 17:27:12 -0700

Adds support for running the trace tests through darling, fixes compilation errors in MachO due to interface change

Diffstat:
Mlib/std/debug/SelfInfo/MachO.zig | 39+++++++++++++++++++++++++++------------
Mtest/tests.zig | 6++++++
2 files changed, 33 insertions(+), 12 deletions(-)

diff --git a/lib/std/debug/SelfInfo/MachO.zig b/lib/std/debug/SelfInfo/MachO.zig @@ -22,12 +22,26 @@ pub fn deinit(si: *SelfInfo, io: Io) void { si.modules.deinit(gpa); } -pub fn getSymbol(si: *SelfInfo, io: Io, address: usize) Error!std.debug.Symbol { +pub const SymbolIterator = struct { + curr: ?Error!std.debug.Symbol, + + pub fn deinit(self: *SymbolIterator, _: Io) void { + self.* = undefined; + } + + pub fn next(self: *SymbolIterator) ?Error!std.debug.Symbol { + const result = self.curr; + self.curr = null; + return result; + } +}; + +pub fn getSymbols(si: *SelfInfo, io: Io, address: usize) SymbolIterator { const gpa = std.debug.getDebugInfoAllocator(); - const module = try si.findModule(gpa, io, address); + const module = si.findModule(gpa, io, address) catch |err| return .{ .curr = err }; defer si.mutex.unlock(io); - const file = try module.getFile(gpa, io); + const file = module.getFile(gpa, io) catch |err| return .{ .curr = err }; // This is not necessarily the same as the vmaddr_slide that dyld would report. This is // because the segments in the file on disk might differ from the ones in memory. Normally @@ -43,25 +57,26 @@ pub fn getSymbol(si: *SelfInfo, io: Io, address: usize) Error!std.debug.Symbol { const ofile_dwarf, const ofile_vaddr = file.getDwarfForAddress(gpa, io, vaddr) catch { // Return at least the symbol name if available. - return .{ - .name = try file.lookupSymbolName(vaddr), + return .{ .curr = .{ + .name = file.lookupSymbolName(vaddr) catch |err| return .{ .curr = err }, .compile_unit_name = null, .source_location = null, - }; + } }; }; const compile_unit = ofile_dwarf.findCompileUnit(native_endian, ofile_vaddr) catch { // Return at least the symbol name if available. - return .{ - .name = try file.lookupSymbolName(vaddr), + return .{ .curr = .{ + .name = file.lookupSymbolName(vaddr) catch |err| return .{ .curr = err }, .compile_unit_name = null, .source_location = null, - }; + } }; }; - return .{ + return .{ .curr = .{ .name = ofile_dwarf.getSymbolName(ofile_vaddr) orelse - try file.lookupSymbolName(vaddr), + file.lookupSymbolName(vaddr) catch |err| + return .{ .curr = err }, .compile_unit_name = compile_unit.die.getAttrString( ofile_dwarf, native_endian, @@ -77,7 +92,7 @@ pub fn getSymbol(si: *SelfInfo, io: Io, address: usize) Error!std.debug.Symbol { compile_unit, ofile_vaddr, ) catch null, - }; + } }; } pub fn getModuleName(si: *SelfInfo, io: Io, address: usize) Error![]const u8 { _ = si; diff --git a/test/tests.zig b/test/tests.zig @@ -2033,6 +2033,12 @@ fn nativeAndCompatible32bit(b: *std.Build, skip_non_native: bool) []const std.Bu .os_tag = .windows, })) catch @panic("OOM"); } + if (b.enable_darling and b.graph.host.result.os.tag != .macos) { + targets.append(b.graph.arena, b.resolveTargetQuery(.{ + .cpu_arch = host.cpu.arch, + .os_tag = .macos, + })) catch @panic("OOM"); + } return targets.toOwnedSlice(b.graph.arena) catch @panic("OOM"); }