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 {...@@ -275,18 +275,6 @@ pub fn dependOn(step: *Step, other: *Step) void {
275 step.dependencies.append(other) catch @panic("OOM");275 step.dependencies.append(other) catch @panic("OOM");
276}276}
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
290fn makeNoOp(step: *Step, options: MakeOptions) anyerror!void {278fn makeNoOp(step: *Step, options: MakeOptions) anyerror!void {
291 _ = options;279 _ = options;
292280
...@@ -308,9 +296,9 @@ pub fn cast(step: *Step, comptime T: type) ?*T {...@@ -308,9 +296,9 @@ pub fn cast(step: *Step, comptime T: type) ?*T {
308296
309/// For debugging purposes, prints identifying information about this Step.297/// For debugging purposes, prints identifying information about this Step.
310pub fn dump(step: *Step, w: *std.Io.Writer, tty_config: std.Io.tty.Config) void {298pub 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) {
312 w.print("name: '{s}'. creation stack trace:\n", .{step.name}) catch {};300 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 {};
314 } else {302 } else {
315 const field = "debug_stack_frames_count";303 const field = "debug_stack_frames_count";
316 comptime assert(@hasField(Build, field));304 comptime assert(@hasField(Build, field));
lib/std/Build/Step/CheckObject.zig+12-18
...@@ -1098,15 +1098,9 @@ const MachODumper = struct {...@@ -1098,15 +1098,9 @@ const MachODumper = struct {
1098 for (ctx.symtab.items) |sym| {1098 for (ctx.symtab.items) |sym| {
1099 const sym_name = ctx.getString(sym.n_strx);1099 const sym_name = ctx.getString(sym.n_strx);
1100 if (sym.n_type.bits.is_stab != 0) {1100 if (sym.n_type.bits.is_stab != 0) {
1101 const tt = switch (sym.n_type) {1101 const tt = switch (sym.n_type.stab) {
1102 macho.N_SO => "SO",1102 _ => "UNKNOWN STAB",
1103 macho.N_OSO => "OSO",1103 else => @tagName(sym.n_type.stab),
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",
1110 };1104 };
1111 try writer.print("{x}", .{sym.n_value});1105 try writer.print("{x}", .{sym.n_value});
1112 if (sym.n_sect > 0) {1106 if (sym.n_sect > 0) {
...@@ -1114,27 +1108,27 @@ const MachODumper = struct {...@@ -1114,27 +1108,27 @@ const MachODumper = struct {
1114 try writer.print(" ({s},{s})", .{ sect.segName(), sect.sectName() });1108 try writer.print(" ({s},{s})", .{ sect.segName(), sect.sectName() });
1115 }1109 }
1116 try writer.print(" {s} (stab) {s}\n", .{ tt, sym_name });1110 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) {
1118 const sect = ctx.sections.items[sym.n_sect - 1];1112 const sect = ctx.sections.items[sym.n_sect - 1];
1119 try writer.print("{x} ({s},{s})", .{1113 try writer.print("{x} ({s},{s})", .{
1120 sym.n_value,1114 sym.n_value,
1121 sect.segName(),1115 sect.segName(),
1122 sect.sectName(),1116 sect.sectName(),
1123 });1117 });
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]");
1125 if (sym.n_desc.weak_def_or_ref_to_weak) try writer.writeAll(" weak");1119 if (sym.n_desc.weak_def_or_ref_to_weak) try writer.writeAll(" weak");
1126 if (sym.n_desc.weak_ref) try writer.writeAll(" weakref");1120 if (sym.n_desc.weak_ref) try writer.writeAll(" weakref");
1127 if (sym.ext()) {1121 if (sym.n_type.bits.ext) {
1128 if (sym.pext()) try writer.writeAll(" private");1122 if (sym.n_type.bits.pext) try writer.writeAll(" private");
1129 try writer.writeAll(" external");1123 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)");
1131 try writer.print(" {s}\n", .{sym_name});1125 try writer.print(" {s}\n", .{sym_name});
1132 } else if (sym.tentative()) {1126 } else if (sym.tentative()) {
1133 const alignment = (sym.n_desc >> 8) & 0x0F;1127 const alignment = (@as(u16, @bitCast(sym.n_desc)) >> 8) & 0x0F;
1134 try writer.print(" 0x{x:0>16} (common) (alignment 2^{d})", .{ sym.n_value, alignment });1128 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");
1136 try writer.print(" {s}\n", .{sym_name});1130 try writer.print(" {s}\n", .{sym_name});
1137 } else if (sym.n_type.type == .undf) {1131 } else if (sym.n_type.bits.type == .undf) {
1138 const ordinal = @divFloor(@as(i16, @bitCast(sym.n_desc)), macho.N_SYMBOL_RESOLVER);1132 const ordinal = @divFloor(@as(i16, @bitCast(sym.n_desc)), macho.N_SYMBOL_RESOLVER);
1139 const import_name = blk: {1133 const import_name = blk: {
1140 if (ordinal <= 0) {1134 if (ordinal <= 0) {
...@@ -1154,7 +1148,7 @@ const MachODumper = struct {...@@ -1154,7 +1148,7 @@ const MachODumper = struct {
1154 };1148 };
1155 try writer.writeAll("(undefined)");1149 try writer.writeAll("(undefined)");
1156 if (sym.n_desc.weak_ref) try writer.writeAll(" weakref");1150 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");
1158 try writer.print(" {s} (from {s})\n", .{1152 try writer.print(" {s} (from {s})\n", .{
1159 sym_name,1153 sym_name,
1160 import_name,1154 import_name,
lib/std/Thread.zig+1-1
...@@ -530,7 +530,7 @@ fn callFn(comptime f: anytype, args: anytype) switch (Impl) {...@@ -530,7 +530,7 @@ fn callFn(comptime f: anytype, args: anytype) switch (Impl) {
530 @call(.auto, f, args) catch |err| {530 @call(.auto, f, args) catch |err| {
531 std.debug.print("error: {s}\n", .{@errorName(err)});531 std.debug.print("error: {s}\n", .{@errorName(err)});
532 if (@errorReturnTrace()) |trace| {532 if (@errorReturnTrace()) |trace| {
533 std.debug.dumpStackTrace(trace.*);533 std.debug.dumpStackTrace(trace);
534 }534 }
535 };535 };
536536
lib/std/debug.zig+1-1
...@@ -1443,7 +1443,7 @@ pub fn ConfigurableTrace(comptime size: usize, comptime stack_frame_count: usize...@@ -1443,7 +1443,7 @@ pub fn ConfigurableTrace(comptime size: usize, comptime stack_frame_count: usize
1443 .index = frames.len,1443 .index = frames.len,
1444 .instruction_addresses = frames,1444 .instruction_addresses = frames,
1445 };1445 };
1446 writeStackTrace(stack_trace, stderr, tty_config) catch return;1446 writeStackTrace(&stack_trace, stderr, tty_config) catch return;
1447 }1447 }
1448 if (t.index > end) {1448 if (t.index > end) {
1449 stderr.print("{d} more traces not shown; consider increasing trace size\n", .{1449 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 {...@@ -892,7 +892,7 @@ pub const nlist_64 = extern struct {
892 n_desc: packed struct(u16) {892 n_desc: packed struct(u16) {
893 _pad0: u3 = 0,893 _pad0: u3 = 0,
894 arm_thumb_def: bool,894 arm_thumb_def: bool,
895 _pad1: u1 = 0,895 referenced_dynamically: bool,
896 /// The meaning of this bit is contextual.896 /// The meaning of this bit is contextual.
897 /// See `N_DESC_DISCARDED` and `N_NO_DEAD_STRIP`.897 /// See `N_DESC_DISCARDED` and `N_NO_DEAD_STRIP`.
898 discarded_or_no_dead_strip: bool,898 discarded_or_no_dead_strip: bool,
...@@ -907,7 +907,7 @@ pub const nlist_64 = extern struct {...@@ -907,7 +907,7 @@ pub const nlist_64 = extern struct {
907 n_value: u64,907 n_value: u64,
908908
909 pub fn tentative(sym: nlist_64) bool {909 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;
911 }911 }
912};912};
913913
lib/std/start.zig+1-1
...@@ -636,7 +636,7 @@ pub inline fn callMain() u8 {...@@ -636,7 +636,7 @@ pub inline fn callMain() u8 {
636 }636 }
637 std.log.err("{s}", .{@errorName(err)});637 std.log.err("{s}", .{@errorName(err)});
638 if (@errorReturnTrace()) |trace| {638 if (@errorReturnTrace()) |trace| {
639 std.debug.dumpStackTrace(trace.*);639 std.debug.dumpStackTrace(trace);
640 }640 }
641 return 1;641 return 1;
642 };642 };