authorgravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2025-09-08 12:52:00+01:00
committergravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2025-09-30 13:44:51+01:00
log202aeacc05a2fc53762c49d18daeefdf0fa5fbec
tree838955ffcb20ba01523ba1f997f7f23b94708ec6
parentf1215adedab23535024a28367375a62909de6395
signaturelock-open Commit is signed but in an unrecognized format.

std: fixes


6 files changed, 19 insertions(+), 37 deletions(-)

lib/std/Build/Step.zig+2-14
......@@ -275,18 +275,6 @@ pub fn dependOn(step: *Step, other: *Step) void {
275275 step.dependencies.append(other) catch @panic("OOM");
276276}
277277
278pub fn getStackTrace(s: *Step) ?std.builtin.StackTrace {
279 var len: usize = 0;
280 while (len < s.debug_stack_trace.len and s.debug_stack_trace[len] != 0) {
281 len += 1;
282 }
283
284 return if (len == 0) null else .{
285 .instruction_addresses = s.debug_stack_trace,
286 .index = len,
287 };
288}
289
290278fn makeNoOp(step: *Step, options: MakeOptions) anyerror!void {
291279 _ = options;
292280
......@@ -308,9 +296,9 @@ pub fn cast(step: *Step, comptime T: type) ?*T {
308296
309297/// For debugging purposes, prints identifying information about this Step.
310298pub fn dump(step: *Step, w: *std.Io.Writer, tty_config: std.Io.tty.Config) void {
311 if (step.getStackTrace()) |stack_trace| {
299 if (step.debug_stack_trace.instruction_addresses.len > 0) {
312300 w.print("name: '{s}'. creation stack trace:\n", .{step.name}) catch {};
313 std.debug.writeStackTrace(stack_trace, w, tty_config) catch {};
301 std.debug.writeStackTrace(&step.debug_stack_trace, w, tty_config) catch {};
314302 } else {
315303 const field = "debug_stack_frames_count";
316304 comptime assert(@hasField(Build, field));
lib/std/Build/Step/CheckObject.zig+12-18
......@@ -1098,15 +1098,9 @@ const MachODumper = struct {
10981098 for (ctx.symtab.items) |sym| {
10991099 const sym_name = ctx.getString(sym.n_strx);
11001100 if (sym.n_type.bits.is_stab != 0) {
1101 const tt = switch (sym.n_type) {
1102 macho.N_SO => "SO",
1103 macho.N_OSO => "OSO",
1104 macho.N_BNSYM => "BNSYM",
1105 macho.N_ENSYM => "ENSYM",
1106 macho.N_FUN => "FUN",
1107 macho.N_GSYM => "GSYM",
1108 macho.N_STSYM => "STSYM",
1109 else => "UNKNOWN STAB",
1101 const tt = switch (sym.n_type.stab) {
1102 _ => "UNKNOWN STAB",
1103 else => @tagName(sym.n_type.stab),
11101104 };
11111105 try writer.print("{x}", .{sym.n_value});
11121106 if (sym.n_sect > 0) {
......@@ -1114,27 +1108,27 @@ const MachODumper = struct {
11141108 try writer.print(" ({s},{s})", .{ sect.segName(), sect.sectName() });
11151109 }
11161110 try writer.print(" {s} (stab) {s}\n", .{ tt, sym_name });
1117 } else if (sym.n_type.type == .sect) {
1111 } else if (sym.n_type.bits.type == .sect) {
11181112 const sect = ctx.sections.items[sym.n_sect - 1];
11191113 try writer.print("{x} ({s},{s})", .{
11201114 sym.n_value,
11211115 sect.segName(),
11221116 sect.sectName(),
11231117 });
1124 if (sym.n_desc & macho.REFERENCED_DYNAMICALLY != 0) try writer.writeAll(" [referenced dynamically]");
1118 if (sym.n_desc.referenced_dynamically) try writer.writeAll(" [referenced dynamically]");
11251119 if (sym.n_desc.weak_def_or_ref_to_weak) try writer.writeAll(" weak");
11261120 if (sym.n_desc.weak_ref) try writer.writeAll(" weakref");
1127 if (sym.ext()) {
1128 if (sym.pext()) try writer.writeAll(" private");
1121 if (sym.n_type.bits.ext) {
1122 if (sym.n_type.bits.pext) try writer.writeAll(" private");
11291123 try writer.writeAll(" external");
1130 } else if (sym.pext()) try writer.writeAll(" (was private external)");
1124 } else if (sym.n_type.bits.pext) try writer.writeAll(" (was private external)");
11311125 try writer.print(" {s}\n", .{sym_name});
11321126 } else if (sym.tentative()) {
1133 const alignment = (sym.n_desc >> 8) & 0x0F;
1127 const alignment = (@as(u16, @bitCast(sym.n_desc)) >> 8) & 0x0F;
11341128 try writer.print(" 0x{x:0>16} (common) (alignment 2^{d})", .{ sym.n_value, alignment });
1135 if (sym.ext()) try writer.writeAll(" external");
1129 if (sym.n_type.bits.ext) try writer.writeAll(" external");
11361130 try writer.print(" {s}\n", .{sym_name});
1137 } else if (sym.n_type.type == .undf) {
1131 } else if (sym.n_type.bits.type == .undf) {
11381132 const ordinal = @divFloor(@as(i16, @bitCast(sym.n_desc)), macho.N_SYMBOL_RESOLVER);
11391133 const import_name = blk: {
11401134 if (ordinal <= 0) {
......@@ -1154,7 +1148,7 @@ const MachODumper = struct {
11541148 };
11551149 try writer.writeAll("(undefined)");
11561150 if (sym.n_desc.weak_ref) try writer.writeAll(" weakref");
1157 if (sym.ext()) try writer.writeAll(" external");
1151 if (sym.n_type.bits.ext) try writer.writeAll(" external");
11581152 try writer.print(" {s} (from {s})\n", .{
11591153 sym_name,
11601154 import_name,
lib/std/Thread.zig+1-1
......@@ -530,7 +530,7 @@ fn callFn(comptime f: anytype, args: anytype) switch (Impl) {
530530 @call(.auto, f, args) catch |err| {
531531 std.debug.print("error: {s}\n", .{@errorName(err)});
532532 if (@errorReturnTrace()) |trace| {
533 std.debug.dumpStackTrace(trace.*);
533 std.debug.dumpStackTrace(trace);
534534 }
535535 };
536536
lib/std/debug.zig+1-1
......@@ -1443,7 +1443,7 @@ pub fn ConfigurableTrace(comptime size: usize, comptime stack_frame_count: usize
14431443 .index = frames.len,
14441444 .instruction_addresses = frames,
14451445 };
1446 writeStackTrace(stack_trace, stderr, tty_config) catch return;
1446 writeStackTrace(&stack_trace, stderr, tty_config) catch return;
14471447 }
14481448 if (t.index > end) {
14491449 stderr.print("{d} more traces not shown; consider increasing trace size\n", .{
lib/std/macho.zig+2-2
......@@ -892,7 +892,7 @@ pub const nlist_64 = extern struct {
892892 n_desc: packed struct(u16) {
893893 _pad0: u3 = 0,
894894 arm_thumb_def: bool,
895 _pad1: u1 = 0,
895 referenced_dynamically: bool,
896896 /// The meaning of this bit is contextual.
897897 /// See `N_DESC_DISCARDED` and `N_NO_DEAD_STRIP`.
898898 discarded_or_no_dead_strip: bool,
......@@ -907,7 +907,7 @@ pub const nlist_64 = extern struct {
907907 n_value: u64,
908908
909909 pub fn tentative(sym: nlist_64) bool {
910 return sym.n_type.type == .undf and sym.n_value != 0;
910 return sym.n_type.bits.type == .undf and sym.n_value != 0;
911911 }
912912};
913913
lib/std/start.zig+1-1
......@@ -636,7 +636,7 @@ pub inline fn callMain() u8 {
636636 }
637637 std.log.err("{s}", .{@errorName(err)});
638638 if (@errorReturnTrace()) |trace| {
639 std.debug.dumpStackTrace(trace.*);
639 std.debug.dumpStackTrace(trace);
640640 }
641641 return 1;
642642 };