authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2025-07-02 14:05:28-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2025-07-07 22:43:52-07:00
logd5c97fded5d31114f8fc684938a2de22af929949
treeb54ce623de1c4a43165db4cff8a9e5f7e921ac47
parent3afc6fbac63b31fd250b6cbc4451758e50f85b24

compiler: fix a bunch of format strings


22 files changed, 127 insertions(+), 151 deletions(-)

lib/compiler/aro/aro/Diagnostics.zig+5-6
...@@ -328,8 +328,8 @@ pub fn render(comp: *Compilation, config: std.io.tty.Config) void {...@@ -328,8 +328,8 @@ pub fn render(comp: *Compilation, config: std.io.tty.Config) void {
328 defer m.deinit();328 defer m.deinit();
329 renderMessages(comp, &m);329 renderMessages(comp, &m);
330}330}
331pub fn defaultMsgWriter(config: std.io.tty.Config) MsgWriter {331pub fn defaultMsgWriter(config: std.io.tty.Config, buffer: []u8) MsgWriter {
332 return MsgWriter.init(config);332 return MsgWriter.init(config, buffer);
333}333}
334334
335pub fn renderMessages(comp: *Compilation, m: anytype) void {335pub fn renderMessages(comp: *Compilation, m: anytype) void {
...@@ -529,16 +529,15 @@ const MsgWriter = struct {...@@ -529,16 +529,15 @@ const MsgWriter = struct {
529 config: std.io.tty.Config,529 config: std.io.tty.Config,
530530
531 fn init(config: std.io.tty.Config, buffer: []u8) MsgWriter {531 fn init(config: std.io.tty.Config, buffer: []u8) MsgWriter {
532 std.debug.lockStdErr();
533 return .{532 return .{
534 .w = std.fs.stderr().writer(buffer),533 .w = std.debug.lockStderrWriter(buffer),
535 .config = config,534 .config = config,
536 };535 };
537 }536 }
538537
539 pub fn deinit(m: *MsgWriter) void {538 pub fn deinit(m: *MsgWriter) void {
540 m.w.flush() catch {};539 std.debug.unlockStderrWriter();
541 std.debug.unlockStdErr();540 m.* = undefined;
542 }541 }
543542
544 pub fn print(m: *MsgWriter, comptime fmt: []const u8, args: anytype) void {543 pub fn print(m: *MsgWriter, comptime fmt: []const u8, args: anytype) void {
lib/compiler/aro/aro/Value.zig+1-1
...@@ -961,7 +961,7 @@ pub fn print(v: Value, ty: Type, comp: *const Compilation, w: anytype) @TypeOf(w...@@ -961,7 +961,7 @@ pub fn print(v: Value, ty: Type, comp: *const Compilation, w: anytype) @TypeOf(w
961 switch (key) {961 switch (key) {
962 .null => return w.writeAll("nullptr_t"),962 .null => return w.writeAll("nullptr_t"),
963 .int => |repr| switch (repr) {963 .int => |repr| switch (repr) {
964 inline else => |x| return w.print("{d}", .{x}),964 inline else => |x| return w.print("{fd}", .{x}),
965 },965 },
966 .float => |repr| switch (repr) {966 .float => |repr| switch (repr) {
967 .f16 => |x| return w.print("{d}", .{@round(@as(f64, @floatCast(x)) * 1000) / 1000}),967 .f16 => |x| return w.print("{d}", .{@round(@as(f64, @floatCast(x)) * 1000) / 1000}),
lib/std/io/Writer.zig+9-24
...@@ -1981,21 +1981,15 @@ pub fn Hashed(comptime Hasher: type) type {...@@ -1981,21 +1981,15 @@ pub fn Hashed(comptime Hasher: type) type {
1981 .hasher = hasher,1981 .hasher = hasher,
1982 .writer = .{1982 .writer = .{
1983 .buffer = buffer,1983 .buffer = buffer,
1984 .vtable = &.{@This().drain},1984 .vtable = &.{ .drain = @This().drain },
1985 },1985 },
1986 };1986 };
1987 }1987 }
19881988
1989 fn drain(w: *Writer, data: []const []const u8, splat: usize) Error!usize {1989 fn drain(w: *Writer, data: []const []const u8, splat: usize) Error!usize {
1990 const this: *@This() = @alignCast(@fieldParentPtr("writer", w));1990 const this: *@This() = @alignCast(@fieldParentPtr("writer", w));
1991 if (data.len == 0) {1991 const aux = w.buffered();
1992 const buf = w.buffered();1992 const aux_n = try this.out.writeSplatHeader(aux, data, splat);
1993 try this.out.writeAll(buf);
1994 this.hasher.update(buf);
1995 w.end = 0;
1996 return buf.len;
1997 }
1998 const aux_n = try this.out.writeSplatAux(w.buffered(), data, splat);
1999 if (aux_n < w.end) {1993 if (aux_n < w.end) {
2000 this.hasher.update(w.buffer[0..aux_n]);1994 this.hasher.update(w.buffer[0..aux_n]);
2001 const remaining = w.buffer[aux_n..w.end];1995 const remaining = w.buffer[aux_n..w.end];
...@@ -2003,29 +1997,20 @@ pub fn Hashed(comptime Hasher: type) type {...@@ -2003,29 +1997,20 @@ pub fn Hashed(comptime Hasher: type) type {
2003 w.end = remaining.len;1997 w.end = remaining.len;
2004 return 0;1998 return 0;
2005 }1999 }
2006 this.hasher.update(w.buffered());2000 this.hasher.update(aux);
2007 const n = aux_n - w.end;2001 const n = aux_n - w.end;
2008 w.end = 0;2002 w.end = 0;
2009 var remaining: usize = n;2003 var remaining: usize = n;
2010 const short_data = data[0 .. data.len - @intFromBool(splat == 0)];2004 for (data[0 .. data.len - 1]) |slice| {
2011 for (short_data) |slice| {2005 if (remaining <= slice.len) {
2012 if (remaining < slice.len) {
2013 this.hasher.update(slice[0..remaining]);2006 this.hasher.update(slice[0..remaining]);
2014 return n;2007 return n;
2015 } else {
2016 remaining -= slice.len;
2017 this.hasher.update(slice);
2018 }2008 }
2009 remaining -= slice.len;
2010 this.hasher.update(slice);
2019 }2011 }
2020 const remaining_splat = switch (splat) {
2021 0, 1 => {
2022 assert(remaining == 0);
2023 return n;
2024 },
2025 else => splat - 1,
2026 };
2027 const pattern = data[data.len - 1];2012 const pattern = data[data.len - 1];
2028 assert(remaining == remaining_splat * pattern.len);2013 assert(remaining == splat * pattern.len);
2029 switch (pattern.len) {2014 switch (pattern.len) {
2030 0 => {2015 0 => {
2031 assert(remaining == 0);2016 assert(remaining == 0);
lib/std/zig/llvm/Builder.zig+1-1
...@@ -1262,7 +1262,7 @@ pub const Attribute = union(Kind) {...@@ -1262,7 +1262,7 @@ pub const Attribute = union(Kind) {
1262 try w.writeByte(')');1262 try w.writeByte(')');
1263 },1263 },
1264 .alignstack => |alignment| {1264 .alignstack => |alignment| {
1265 try w.print(" {s}", .{attribute});1265 try w.print(" {f}", .{attribute});
1266 const alignment_bytes = alignment.toByteUnits() orelse return;1266 const alignment_bytes = alignment.toByteUnits() orelse return;
1267 switch (data.mode) {1267 switch (data.mode) {
1268 .pound => try w.print("({d})", .{alignment_bytes}),1268 .pound => try w.print("({d})", .{alignment_bytes}),
src/Builtin.zig+1-1
...@@ -317,7 +317,7 @@ pub fn updateFileOnDisk(file: *File, comp: *Compilation) !void {...@@ -317,7 +317,7 @@ pub fn updateFileOnDisk(file: *File, comp: *Compilation) !void {
317 if (root_dir.statFile(sub_path)) |stat| {317 if (root_dir.statFile(sub_path)) |stat| {
318 if (stat.size != file.source.?.len) {318 if (stat.size != file.source.?.len) {
319 std.log.warn(319 std.log.warn(
320 "the cached file '{f}{s}' had the wrong size. Expected {d}, found {d}. " ++320 "the cached file '{f}' had the wrong size. Expected {d}, found {d}. " ++
321 "Overwriting with correct file contents now",321 "Overwriting with correct file contents now",
322 .{ file.path.fmt(comp), file.source.?.len, stat.size },322 .{ file.path.fmt(comp), file.source.?.len, stat.size },
323 );323 );
src/Compilation.zig+4-3
...@@ -399,9 +399,8 @@ pub const Path = struct {...@@ -399,9 +399,8 @@ pub const Path = struct {
399 const Formatter = struct {399 const Formatter = struct {
400 p: Path,400 p: Path,
401 comp: *Compilation,401 comp: *Compilation,
402 pub fn format(f: Formatter, comptime unused_fmt: []const u8, options: std.fmt.FormatOptions, w: anytype) !void {402 pub fn format(f: Formatter, w: *std.io.Writer, comptime unused_fmt: []const u8) std.io.Writer.Error!void {
403 comptime assert(unused_fmt.len == 0);403 comptime assert(unused_fmt.len == 0);
404 _ = options;
405 const root_path: []const u8 = switch (f.p.root) {404 const root_path: []const u8 = switch (f.p.root) {
406 .zig_lib => f.comp.dirs.zig_lib.path orelse ".",405 .zig_lib => f.comp.dirs.zig_lib.path orelse ".",
407 .global_cache => f.comp.dirs.global_cache.path orelse ".",406 .global_cache => f.comp.dirs.global_cache.path orelse ".",
...@@ -6034,7 +6033,9 @@ fn updateWin32Resource(comp: *Compilation, win32_resource: *Win32Resource, win32...@@ -6034,7 +6033,9 @@ fn updateWin32Resource(comp: *Compilation, win32_resource: *Win32Resource, win32
6034 // 24 is RT_MANIFEST6033 // 24 is RT_MANIFEST
6035 const resource_type = 24;6034 const resource_type = 24;
60366035
6037 const input = try std.fmt.allocPrint(arena, "{} {} \"{s}\"", .{ resource_id, resource_type, fmtRcEscape(src_path) });6036 const input = try std.fmt.allocPrint(arena, "{} {} \"{f}\"", .{
6037 resource_id, resource_type, fmtRcEscape(src_path),
6038 });
60386039
6039 try o_dir.writeFile(.{ .sub_path = rc_basename, .data = input });6040 try o_dir.writeFile(.{ .sub_path = rc_basename, .data = input });
60406041
src/Package/Fetch.zig+2-2
...@@ -1079,13 +1079,13 @@ fn initResource(f: *Fetch, uri: std.Uri, server_header_buffer: []u8) RunError!Re...@@ -1079,13 +1079,13 @@ fn initResource(f: *Fetch, uri: std.Uri, server_header_buffer: []u8) RunError!Re
1079 });1079 });
1080 const notes_start = try eb.reserveNotes(notes_len);1080 const notes_start = try eb.reserveNotes(notes_len);
1081 eb.extra.items[notes_start] = @intFromEnum(try eb.addErrorMessage(.{1081 eb.extra.items[notes_start] = @intFromEnum(try eb.addErrorMessage(.{
1082 .msg = try eb.printString("try .url = \"{;+/}#{}\",", .{ uri, want_oid }),1082 .msg = try eb.printString("try .url = \"{f;+/}#{f}\",", .{ uri, want_oid }),
1083 }));1083 }));
1084 return error.FetchFailed;1084 return error.FetchFailed;
1085 }1085 }
10861086
1087 var want_oid_buf: [git.Oid.max_formatted_length]u8 = undefined;1087 var want_oid_buf: [git.Oid.max_formatted_length]u8 = undefined;
1088 _ = std.fmt.bufPrint(&want_oid_buf, "{}", .{want_oid}) catch unreachable;1088 _ = std.fmt.bufPrint(&want_oid_buf, "{f}", .{want_oid}) catch unreachable;
1089 var fetch_stream = session.fetch(&.{&want_oid_buf}, server_header_buffer) catch |err| {1089 var fetch_stream = session.fetch(&.{&want_oid_buf}, server_header_buffer) catch |err| {
1090 return f.fail(f.location_tok, try eb.printString(1090 return f.fail(f.location_tok, try eb.printString(
1091 "unable to create fetch stream: {s}",1091 "unable to create fetch stream: {s}",
src/Package/Fetch/git.zig+10-16
...@@ -119,14 +119,8 @@ pub const Oid = union(Format) {...@@ -119,14 +119,8 @@ pub const Oid = union(Format) {
119 } else error.InvalidOid;119 } else error.InvalidOid;
120 }120 }
121121
122 pub fn format(122 pub fn format(oid: Oid, writer: *std.io.Writer, comptime fmt: []const u8) std.io.Writer.Error!void {
123 oid: Oid,123 comptime assert(fmt.len == 0);
124 comptime fmt: []const u8,
125 options: std.fmt.FormatOptions,
126 writer: anytype,
127 ) @TypeOf(writer).Error!void {
128 _ = fmt;
129 _ = options;
130 try writer.print("{x}", .{oid.slice()});124 try writer.print("{x}", .{oid.slice()});
131 }125 }
132126
...@@ -669,13 +663,13 @@ pub const Session = struct {...@@ -669,13 +663,13 @@ pub const Session = struct {
669 fn init(allocator: Allocator, uri: std.Uri) !Location {663 fn init(allocator: Allocator, uri: std.Uri) !Location {
670 const scheme = try allocator.dupe(u8, uri.scheme);664 const scheme = try allocator.dupe(u8, uri.scheme);
671 errdefer allocator.free(scheme);665 errdefer allocator.free(scheme);
672 const user = if (uri.user) |user| try std.fmt.allocPrint(allocator, "{user}", .{user}) else null;666 const user = if (uri.user) |user| try std.fmt.allocPrint(allocator, "{fuser}", .{user}) else null;
673 errdefer if (user) |s| allocator.free(s);667 errdefer if (user) |s| allocator.free(s);
674 const password = if (uri.password) |password| try std.fmt.allocPrint(allocator, "{password}", .{password}) else null;668 const password = if (uri.password) |password| try std.fmt.allocPrint(allocator, "{fpassword}", .{password}) else null;
675 errdefer if (password) |s| allocator.free(s);669 errdefer if (password) |s| allocator.free(s);
676 const host = if (uri.host) |host| try std.fmt.allocPrint(allocator, "{host}", .{host}) else null;670 const host = if (uri.host) |host| try std.fmt.allocPrint(allocator, "{fhost}", .{host}) else null;
677 errdefer if (host) |s| allocator.free(s);671 errdefer if (host) |s| allocator.free(s);
678 const path = try std.fmt.allocPrint(allocator, "{path}", .{uri.path});672 const path = try std.fmt.allocPrint(allocator, "{fpath}", .{uri.path});
679 errdefer allocator.free(path);673 errdefer allocator.free(path);
680 // The query and fragment are not used as part of the base server URI.674 // The query and fragment are not used as part of the base server URI.
681 return .{675 return .{
...@@ -706,7 +700,7 @@ pub const Session = struct {...@@ -706,7 +700,7 @@ pub const Session = struct {
706 fn getCapabilities(session: *Session, http_headers_buffer: []u8) !CapabilityIterator {700 fn getCapabilities(session: *Session, http_headers_buffer: []u8) !CapabilityIterator {
707 var info_refs_uri = session.location.uri;701 var info_refs_uri = session.location.uri;
708 {702 {
709 const session_uri_path = try std.fmt.allocPrint(session.allocator, "{path}", .{session.location.uri.path});703 const session_uri_path = try std.fmt.allocPrint(session.allocator, "{fpath}", .{session.location.uri.path});
710 defer session.allocator.free(session_uri_path);704 defer session.allocator.free(session_uri_path);
711 info_refs_uri.path = .{ .percent_encoded = try std.fs.path.resolvePosix(session.allocator, &.{ "/", session_uri_path, "info/refs" }) };705 info_refs_uri.path = .{ .percent_encoded = try std.fs.path.resolvePosix(session.allocator, &.{ "/", session_uri_path, "info/refs" }) };
712 }706 }
...@@ -730,7 +724,7 @@ pub const Session = struct {...@@ -730,7 +724,7 @@ pub const Session = struct {
730 if (request.response.status != .ok) return error.ProtocolError;724 if (request.response.status != .ok) return error.ProtocolError;
731 const any_redirects_occurred = request.redirect_behavior.remaining() < max_redirects;725 const any_redirects_occurred = request.redirect_behavior.remaining() < max_redirects;
732 if (any_redirects_occurred) {726 if (any_redirects_occurred) {
733 const request_uri_path = try std.fmt.allocPrint(session.allocator, "{path}", .{request.uri.path});727 const request_uri_path = try std.fmt.allocPrint(session.allocator, "{fpath}", .{request.uri.path});
734 defer session.allocator.free(request_uri_path);728 defer session.allocator.free(request_uri_path);
735 if (!mem.endsWith(u8, request_uri_path, "/info/refs")) return error.UnparseableRedirect;729 if (!mem.endsWith(u8, request_uri_path, "/info/refs")) return error.UnparseableRedirect;
736 var new_uri = request.uri;730 var new_uri = request.uri;
...@@ -817,7 +811,7 @@ pub const Session = struct {...@@ -817,7 +811,7 @@ pub const Session = struct {
817 pub fn listRefs(session: Session, options: ListRefsOptions) !RefIterator {811 pub fn listRefs(session: Session, options: ListRefsOptions) !RefIterator {
818 var upload_pack_uri = session.location.uri;812 var upload_pack_uri = session.location.uri;
819 {813 {
820 const session_uri_path = try std.fmt.allocPrint(session.allocator, "{path}", .{session.location.uri.path});814 const session_uri_path = try std.fmt.allocPrint(session.allocator, "{fpath}", .{session.location.uri.path});
821 defer session.allocator.free(session_uri_path);815 defer session.allocator.free(session_uri_path);
822 upload_pack_uri.path = .{ .percent_encoded = try std.fs.path.resolvePosix(session.allocator, &.{ "/", session_uri_path, "git-upload-pack" }) };816 upload_pack_uri.path = .{ .percent_encoded = try std.fs.path.resolvePosix(session.allocator, &.{ "/", session_uri_path, "git-upload-pack" }) };
823 }817 }
...@@ -932,7 +926,7 @@ pub const Session = struct {...@@ -932,7 +926,7 @@ pub const Session = struct {
932 ) !FetchStream {926 ) !FetchStream {
933 var upload_pack_uri = session.location.uri;927 var upload_pack_uri = session.location.uri;
934 {928 {
935 const session_uri_path = try std.fmt.allocPrint(session.allocator, "{path}", .{session.location.uri.path});929 const session_uri_path = try std.fmt.allocPrint(session.allocator, "{fpath}", .{session.location.uri.path});
936 defer session.allocator.free(session_uri_path);930 defer session.allocator.free(session_uri_path);
937 upload_pack_uri.path = .{ .percent_encoded = try std.fs.path.resolvePosix(session.allocator, &.{ "/", session_uri_path, "git-upload-pack" }) };931 upload_pack_uri.path = .{ .percent_encoded = try std.fs.path.resolvePosix(session.allocator, &.{ "/", session_uri_path, "git-upload-pack" }) };
938 }932 }
src/codegen/c.zig+26-26
...@@ -1563,7 +1563,7 @@ pub const DeclGen = struct {...@@ -1563,7 +1563,7 @@ pub const DeclGen = struct {
1563 .payload => {1563 .payload => {
1564 try writer.writeByte('{');1564 try writer.writeByte('{');
1565 if (field_ty.hasRuntimeBits(zcu)) {1565 if (field_ty.hasRuntimeBits(zcu)) {
1566 try writer.print(" .{ } = ", .{fmtIdentSolo(field_name.toSlice(ip))});1566 try writer.print(" .{f} = ", .{fmtIdentSolo(field_name.toSlice(ip))});
1567 try dg.renderValue(1567 try dg.renderValue(
1568 writer,1568 writer,
1569 Value.fromInterned(un.val),1569 Value.fromInterned(un.val),
...@@ -1667,7 +1667,7 @@ pub const DeclGen = struct {...@@ -1667,7 +1667,7 @@ pub const DeclGen = struct {
1667 try writer.writeAll("{(");1667 try writer.writeAll("{(");
1668 const ptr_ty = ty.slicePtrFieldType(zcu);1668 const ptr_ty = ty.slicePtrFieldType(zcu);
1669 try dg.renderType(writer, ptr_ty);1669 try dg.renderType(writer, ptr_ty);
1670 return writer.print("){f}, {0x}}}", .{1670 return writer.print("){f}, {0fx}}}", .{
1671 try dg.fmtIntLiteralHex(.undef_usize, .Other),1671 try dg.fmtIntLiteralHex(.undef_usize, .Other),
1672 });1672 });
1673 },1673 },
...@@ -1972,17 +1972,17 @@ pub const DeclGen = struct {...@@ -1972,17 +1972,17 @@ pub const DeclGen = struct {
1972 const is_mangled = isMangledIdent(extern_name, true);1972 const is_mangled = isMangledIdent(extern_name, true);
1973 const is_export = @"export".extern_name != @"export".main_name;1973 const is_export = @"export".extern_name != @"export".main_name;
1974 if (is_mangled and is_export) {1974 if (is_mangled and is_export) {
1975 try w.print(" zig_mangled_export({ }, {s}, {s})", .{1975 try w.print(" zig_mangled_export({f}, {f}, {f})", .{
1976 fmtIdentSolo(extern_name),1976 fmtIdentSolo(extern_name),
1977 fmtStringLiteral(extern_name, null),1977 fmtStringLiteral(extern_name, null),
1978 fmtStringLiteral(@"export".main_name.toSlice(ip), null),1978 fmtStringLiteral(@"export".main_name.toSlice(ip), null),
1979 });1979 });
1980 } else if (is_mangled) {1980 } else if (is_mangled) {
1981 try w.print(" zig_mangled({ }, {s})", .{1981 try w.print(" zig_mangled({f}, {f})", .{
1982 fmtIdentSolo(extern_name), fmtStringLiteral(extern_name, null),1982 fmtIdentSolo(extern_name), fmtStringLiteral(extern_name, null),
1983 });1983 });
1984 } else if (is_export) {1984 } else if (is_export) {
1985 try w.print(" zig_export({s}, {s})", .{1985 try w.print(" zig_export({f}, {f})", .{
1986 fmtStringLiteral(@"export".main_name.toSlice(ip), null),1986 fmtStringLiteral(@"export".main_name.toSlice(ip), null),
1987 fmtStringLiteral(extern_name, null),1987 fmtStringLiteral(extern_name, null),
1988 });1988 });
...@@ -2210,7 +2210,7 @@ pub const DeclGen = struct {...@@ -2210,7 +2210,7 @@ pub const DeclGen = struct {
2210 .new_local, .local => |i| try w.print("t{d}", .{i}),2210 .new_local, .local => |i| try w.print("t{d}", .{i}),
2211 .constant => |uav| try renderUavName(w, uav),2211 .constant => |uav| try renderUavName(w, uav),
2212 .nav => |nav| try dg.renderNavName(w, nav),2212 .nav => |nav| try dg.renderNavName(w, nav),
2213 .identifier => |ident| try w.print("{ }", .{fmtIdentSolo(ident)}),2213 .identifier => |ident| try w.print("{f}", .{fmtIdentSolo(ident)}),
2214 else => unreachable,2214 else => unreachable,
2215 }2215 }
2216 }2216 }
...@@ -2227,8 +2227,8 @@ pub const DeclGen = struct {...@@ -2227,8 +2227,8 @@ pub const DeclGen = struct {
2227 try dg.renderNavName(w, nav);2227 try dg.renderNavName(w, nav);
2228 },2228 },
2229 .undef => |ty| try dg.renderUndefValue(w, ty, .Other),2229 .undef => |ty| try dg.renderUndefValue(w, ty, .Other),
2230 .identifier => |ident| try w.print("{ }", .{fmtIdentSolo(ident)}),2230 .identifier => |ident| try w.print("{f}", .{fmtIdentSolo(ident)}),
2231 .payload_identifier => |ident| try w.print("{ }.{ }", .{2231 .payload_identifier => |ident| try w.print("{f}.{f}", .{
2232 fmtIdentSolo("payload"),2232 fmtIdentSolo("payload"),
2233 fmtIdentSolo(ident),2233 fmtIdentSolo(ident),
2234 }),2234 }),
...@@ -2257,8 +2257,8 @@ pub const DeclGen = struct {...@@ -2257,8 +2257,8 @@ pub const DeclGen = struct {
2257 },2257 },
2258 .nav_ref => |nav| try dg.renderNavName(w, nav),2258 .nav_ref => |nav| try dg.renderNavName(w, nav),
2259 .undef => unreachable,2259 .undef => unreachable,
2260 .identifier => |ident| try w.print("(*{ })", .{fmtIdentSolo(ident)}),2260 .identifier => |ident| try w.print("(*{f})", .{fmtIdentSolo(ident)}),
2261 .payload_identifier => |ident| try w.print("(*{ }.{ })", .{2261 .payload_identifier => |ident| try w.print("(*{f}.{f})", .{
2262 fmtIdentSolo("payload"),2262 fmtIdentSolo("payload"),
2263 fmtIdentSolo(ident),2263 fmtIdentSolo(ident),
2264 }),2264 }),
...@@ -2345,7 +2345,7 @@ pub const DeclGen = struct {...@@ -2345,7 +2345,7 @@ pub const DeclGen = struct {
2345 const ip = &zcu.intern_pool;2345 const ip = &zcu.intern_pool;
2346 const nav = ip.getNav(nav_index);2346 const nav = ip.getNav(nav_index);
2347 if (nav.getExtern(ip)) |@"extern"| {2347 if (nav.getExtern(ip)) |@"extern"| {
2348 try writer.print("{ }", .{2348 try writer.print("{f}", .{
2349 fmtIdentSolo(ip.getNav(@"extern".owner_nav).name.toSlice(ip)),2349 fmtIdentSolo(ip.getNav(@"extern".owner_nav).name.toSlice(ip)),
2350 });2350 });
2351 } else {2351 } else {
...@@ -2790,7 +2790,7 @@ pub fn genTypeDecl(...@@ -2790,7 +2790,7 @@ pub fn genTypeDecl(
27902790
2791pub fn genGlobalAsm(zcu: *Zcu, writer: anytype) !void {2791pub fn genGlobalAsm(zcu: *Zcu, writer: anytype) !void {
2792 for (zcu.global_assembly.values()) |asm_source| {2792 for (zcu.global_assembly.values()) |asm_source| {
2793 try writer.print("__asm({s});\n", .{fmtStringLiteral(asm_source, null)});2793 try writer.print("__asm({f});\n", .{fmtStringLiteral(asm_source, null)});
2794 }2794 }
2795}2795}
27962796
...@@ -3063,7 +3063,7 @@ fn genFunc(f: *Function) !void {...@@ -3063,7 +3063,7 @@ fn genFunc(f: *Function) !void {
3063 try fwd.writeAll(";\n");3063 try fwd.writeAll(";\n");
30643064
3065 if (nav.status.fully_resolved.@"linksection".toSlice(ip)) |s|3065 if (nav.status.fully_resolved.@"linksection".toSlice(ip)) |s|
3066 try o.writer().print("zig_linksection_fn({s}) ", .{fmtStringLiteral(s, null)});3066 try o.writer().print("zig_linksection_fn({f}) ", .{fmtStringLiteral(s, null)});
3067 try o.dg.renderFunctionSignature(3067 try o.dg.renderFunctionSignature(
3068 o.writer(),3068 o.writer(),
3069 nav_val,3069 nav_val,
...@@ -3176,7 +3176,7 @@ pub fn genDecl(o: *Object) !void {...@@ -3176,7 +3176,7 @@ pub fn genDecl(o: *Object) !void {
3176 const w = o.writer();3176 const w = o.writer();
3177 if (variable.is_threadlocal and !o.dg.mod.single_threaded) try w.writeAll("zig_threadlocal ");3177 if (variable.is_threadlocal and !o.dg.mod.single_threaded) try w.writeAll("zig_threadlocal ");
3178 if (nav.status.fully_resolved.@"linksection".toSlice(&zcu.intern_pool)) |s|3178 if (nav.status.fully_resolved.@"linksection".toSlice(&zcu.intern_pool)) |s|
3179 try w.print("zig_linksection({s}) ", .{fmtStringLiteral(s, null)});3179 try w.print("zig_linksection({f}) ", .{fmtStringLiteral(s, null)});
3180 try o.dg.renderTypeAndName(3180 try o.dg.renderTypeAndName(
3181 w,3181 w,
3182 nav_ty,3182 nav_ty,
...@@ -3217,7 +3217,7 @@ pub fn genDeclValue(...@@ -3217,7 +3217,7 @@ pub fn genDeclValue(
32173217
3218 const w = o.writer();3218 const w = o.writer();
3219 if (@"linksection".toSlice(&zcu.intern_pool)) |s|3219 if (@"linksection".toSlice(&zcu.intern_pool)) |s|
3220 try w.print("zig_linksection({s}) ", .{fmtStringLiteral(s, null)});3220 try w.print("zig_linksection({f}) ", .{fmtStringLiteral(s, null)});
3221 try o.dg.renderTypeAndName(w, ty, decl_c_value, Const, alignment, .complete);3221 try o.dg.renderTypeAndName(w, ty, decl_c_value, Const, alignment, .complete);
3222 try w.writeAll(" = ");3222 try w.writeAll(" = ");
3223 try o.dg.renderValue(w, val, .StaticInitializer);3223 try o.dg.renderValue(w, val, .StaticInitializer);
...@@ -3236,7 +3236,7 @@ pub fn genExports(dg: *DeclGen, exported: Zcu.Exported, export_indices: []const...@@ -3236,7 +3236,7 @@ pub fn genExports(dg: *DeclGen, exported: Zcu.Exported, export_indices: []const
3236 .uav => |uav| try DeclGen.renderUavName(fwd, Value.fromInterned(uav)),3236 .uav => |uav| try DeclGen.renderUavName(fwd, Value.fromInterned(uav)),
3237 }3237 }
3238 try fwd.writeByte(' ');3238 try fwd.writeByte(' ');
3239 try fwd.print("{ }", .{fmtIdentSolo(main_name.toSlice(ip))});3239 try fwd.print("{f}", .{fmtIdentSolo(main_name.toSlice(ip))});
3240 try fwd.writeByte('\n');3240 try fwd.writeByte('\n');
32413241
3242 const exported_val = exported.getValue(zcu);3242 const exported_val = exported.getValue(zcu);
...@@ -3266,7 +3266,7 @@ pub fn genExports(dg: *DeclGen, exported: Zcu.Exported, export_indices: []const...@@ -3266,7 +3266,7 @@ pub fn genExports(dg: *DeclGen, exported: Zcu.Exported, export_indices: []const
3266 const @"export" = export_index.ptr(zcu);3266 const @"export" = export_index.ptr(zcu);
3267 try fwd.writeAll("zig_extern ");3267 try fwd.writeAll("zig_extern ");
3268 if (@"export".opts.linkage == .weak) try fwd.writeAll("zig_weak_linkage ");3268 if (@"export".opts.linkage == .weak) try fwd.writeAll("zig_weak_linkage ");
3269 if (@"export".opts.section.toSlice(ip)) |s| try fwd.print("zig_linksection({s}) ", .{3269 if (@"export".opts.section.toSlice(ip)) |s| try fwd.print("zig_linksection({f}) ", .{
3270 fmtStringLiteral(s, null),3270 fmtStringLiteral(s, null),
3271 });3271 });
3272 const extern_name = @"export".opts.name.toSlice(ip);3272 const extern_name = @"export".opts.name.toSlice(ip);
...@@ -3281,17 +3281,17 @@ pub fn genExports(dg: *DeclGen, exported: Zcu.Exported, export_indices: []const...@@ -3281,17 +3281,17 @@ pub fn genExports(dg: *DeclGen, exported: Zcu.Exported, export_indices: []const
3281 .complete,3281 .complete,
3282 );3282 );
3283 if (is_mangled and is_export) {3283 if (is_mangled and is_export) {
3284 try fwd.print(" zig_mangled_export({ }, {s}, {s})", .{3284 try fwd.print(" zig_mangled_export({f}, {f}, {f})", .{
3285 fmtIdentSolo(extern_name),3285 fmtIdentSolo(extern_name),
3286 fmtStringLiteral(extern_name, null),3286 fmtStringLiteral(extern_name, null),
3287 fmtStringLiteral(main_name.toSlice(ip), null),3287 fmtStringLiteral(main_name.toSlice(ip), null),
3288 });3288 });
3289 } else if (is_mangled) {3289 } else if (is_mangled) {
3290 try fwd.print(" zig_mangled({ }, {s})", .{3290 try fwd.print(" zig_mangled({f}, {f})", .{
3291 fmtIdentSolo(extern_name), fmtStringLiteral(extern_name, null),3291 fmtIdentSolo(extern_name), fmtStringLiteral(extern_name, null),
3292 });3292 });
3293 } else if (is_export) {3293 } else if (is_export) {
3294 try fwd.print(" zig_export({s}, {s})", .{3294 try fwd.print(" zig_export({f}, {f})", .{
3295 fmtStringLiteral(main_name.toSlice(ip), null),3295 fmtStringLiteral(main_name.toSlice(ip), null),
3296 fmtStringLiteral(extern_name, null),3296 fmtStringLiteral(extern_name, null),
3297 });3297 });
...@@ -4570,7 +4570,7 @@ fn airCmpLtErrorsLen(f: *Function, inst: Air.Inst.Index) !CValue {...@@ -4570,7 +4570,7 @@ fn airCmpLtErrorsLen(f: *Function, inst: Air.Inst.Index) !CValue {
4570 try f.writeCValue(writer, local, .Other);4570 try f.writeCValue(writer, local, .Other);
4571 try writer.writeAll(" = ");4571 try writer.writeAll(" = ");
4572 try f.writeCValue(writer, operand, .Other);4572 try f.writeCValue(writer, operand, .Other);
4573 try writer.print(" < sizeof({ }) / sizeof(*{0 });\n", .{fmtIdentSolo("zig_errorName")});4573 try writer.print(" < sizeof({f}) / sizeof(*{0f});\n", .{fmtIdentSolo("zig_errorName")});
4574 return local;4574 return local;
4575}4575}
45764576
...@@ -5644,7 +5644,7 @@ fn airAsm(f: *Function, inst: Air.Inst.Index) !CValue {...@@ -5644,7 +5644,7 @@ fn airAsm(f: *Function, inst: Air.Inst.Index) !CValue {
56445644
5645 try writer.writeAll("__asm");5645 try writer.writeAll("__asm");
5646 if (is_volatile) try writer.writeAll(" volatile");5646 if (is_volatile) try writer.writeAll(" volatile");
5647 try writer.print("({s}", .{fmtStringLiteral(fixed_asm_source[0..dst_i], null)});5647 try writer.print("({f}", .{fmtStringLiteral(fixed_asm_source[0..dst_i], null)});
5648 }5648 }
56495649
5650 extra_i = constraints_extra_begin;5650 extra_i = constraints_extra_begin;
...@@ -5662,7 +5662,7 @@ fn airAsm(f: *Function, inst: Air.Inst.Index) !CValue {...@@ -5662,7 +5662,7 @@ fn airAsm(f: *Function, inst: Air.Inst.Index) !CValue {
5662 try writer.writeByte(' ');5662 try writer.writeByte(' ');
5663 if (!mem.eql(u8, name, "_")) try writer.print("[{s}]", .{name});5663 if (!mem.eql(u8, name, "_")) try writer.print("[{s}]", .{name});
5664 const is_reg = constraint[1] == '{';5664 const is_reg = constraint[1] == '{';
5665 try writer.print("{s}(", .{fmtStringLiteral(if (is_reg) "=r" else constraint, null)});5665 try writer.print("{f}(", .{fmtStringLiteral(if (is_reg) "=r" else constraint, null)});
5666 if (is_reg) {5666 if (is_reg) {
5667 try f.writeCValue(writer, .{ .local = locals_index }, .Other);5667 try f.writeCValue(writer, .{ .local = locals_index }, .Other);
5668 locals_index += 1;5668 locals_index += 1;
...@@ -5688,7 +5688,7 @@ fn airAsm(f: *Function, inst: Air.Inst.Index) !CValue {...@@ -5688,7 +5688,7 @@ fn airAsm(f: *Function, inst: Air.Inst.Index) !CValue {
56885688
5689 const is_reg = constraint[0] == '{';5689 const is_reg = constraint[0] == '{';
5690 const input_val = try f.resolveInst(input);5690 const input_val = try f.resolveInst(input);
5691 try writer.print("{s}(", .{fmtStringLiteral(if (is_reg) "r" else constraint, null)});5691 try writer.print("{f}(", .{fmtStringLiteral(if (is_reg) "r" else constraint, null)});
5692 try f.writeCValue(writer, if (asmInputNeedsLocal(f, constraint, input_val)) local: {5692 try f.writeCValue(writer, if (asmInputNeedsLocal(f, constraint, input_val)) local: {
5693 const input_local_idx = locals_index;5693 const input_local_idx = locals_index;
5694 locals_index += 1;5694 locals_index += 1;
...@@ -5706,7 +5706,7 @@ fn airAsm(f: *Function, inst: Air.Inst.Index) !CValue {...@@ -5706,7 +5706,7 @@ fn airAsm(f: *Function, inst: Air.Inst.Index) !CValue {
5706 if (clobber.len == 0) continue;5706 if (clobber.len == 0) continue;
57075707
5708 if (clobber_i > 0) try writer.writeByte(',');5708 if (clobber_i > 0) try writer.writeByte(',');
5709 try writer.print(" {s}", .{fmtStringLiteral(clobber, null)});5709 try writer.print(" {f}", .{fmtStringLiteral(clobber, null)});
5710 }5710 }
5711 try writer.writeAll(");\n");5711 try writer.writeAll(");\n");
57125712
...@@ -8160,7 +8160,7 @@ fn StringLiteral(comptime WriterType: type) type {...@@ -8160,7 +8160,7 @@ fn StringLiteral(comptime WriterType: type) type {
8160 cur_len: u64 = 0,8160 cur_len: u64 = 0,
8161 counting_writer: std.io.CountingWriter(WriterType),8161 counting_writer: std.io.CountingWriter(WriterType),
81628162
8163 pub const Error = WriterType.Error;8163 pub const Error = if (WriterType == *std.io.Writer) error{WriteFailed} else WriterType.Error;
81648164
8165 const Self = @This();8165 const Self = @This();
81668166
src/link.zig+9-9
...@@ -838,7 +838,7 @@ pub const File = struct {...@@ -838,7 +838,7 @@ pub const File = struct {
838 const cached_pp_file_path = the_key.status.success.object_path;838 const cached_pp_file_path = the_key.status.success.object_path;
839 cached_pp_file_path.root_dir.handle.copyFile(cached_pp_file_path.sub_path, emit.root_dir.handle, emit.sub_path, .{}) catch |err| {839 cached_pp_file_path.root_dir.handle.copyFile(cached_pp_file_path.sub_path, emit.root_dir.handle, emit.sub_path, .{}) catch |err| {
840 const diags = &base.comp.link_diags;840 const diags = &base.comp.link_diags;
841 return diags.fail("failed to copy '{'}' to '{'}': {s}", .{841 return diags.fail("failed to copy '{f'}' to '{f'}': {s}", .{
842 @as(Path, cached_pp_file_path), @as(Path, emit), @errorName(err),842 @as(Path, cached_pp_file_path), @as(Path, emit), @errorName(err),
843 });843 });
844 };844 };
...@@ -2086,13 +2086,13 @@ fn resolvePathInputLib(...@@ -2086,13 +2086,13 @@ fn resolvePathInputLib(
2086 }) {2086 }) {
2087 var file = test_path.root_dir.handle.openFile(test_path.sub_path, .{}) catch |err| switch (err) {2087 var file = test_path.root_dir.handle.openFile(test_path.sub_path, .{}) catch |err| switch (err) {
2088 error.FileNotFound => return .no_match,2088 error.FileNotFound => return .no_match,
2089 else => |e| fatal("unable to search for {s} library '{'}': {s}", .{2089 else => |e| fatal("unable to search for {s} library '{f'}': {s}", .{
2090 @tagName(link_mode), test_path, @errorName(e),2090 @tagName(link_mode), test_path, @errorName(e),
2091 }),2091 }),
2092 };2092 };
2093 errdefer file.close();2093 errdefer file.close();
2094 try ld_script_bytes.resize(gpa, @max(std.elf.MAGIC.len, std.elf.ARMAG.len));2094 try ld_script_bytes.resize(gpa, @max(std.elf.MAGIC.len, std.elf.ARMAG.len));
2095 const n = file.preadAll(ld_script_bytes.items, 0) catch |err| fatal("failed to read '{'}': {s}", .{2095 const n = file.preadAll(ld_script_bytes.items, 0) catch |err| fatal("failed to read '{f'}': {s}", .{
2096 test_path, @errorName(err),2096 test_path, @errorName(err),
2097 });2097 });
2098 const buf = ld_script_bytes.items[0..n];2098 const buf = ld_script_bytes.items[0..n];
...@@ -2101,14 +2101,14 @@ fn resolvePathInputLib(...@@ -2101,14 +2101,14 @@ fn resolvePathInputLib(
2101 return finishResolveLibInput(resolved_inputs, test_path, file, link_mode, pq.query);2101 return finishResolveLibInput(resolved_inputs, test_path, file, link_mode, pq.query);
2102 }2102 }
2103 const stat = file.stat() catch |err|2103 const stat = file.stat() catch |err|
2104 fatal("failed to stat {}: {s}", .{ test_path, @errorName(err) });2104 fatal("failed to stat {f}: {s}", .{ test_path, @errorName(err) });
2105 const size = std.math.cast(u32, stat.size) orelse2105 const size = std.math.cast(u32, stat.size) orelse
2106 fatal("{}: linker script too big", .{test_path});2106 fatal("{f}: linker script too big", .{test_path});
2107 try ld_script_bytes.resize(gpa, size);2107 try ld_script_bytes.resize(gpa, size);
2108 const buf2 = ld_script_bytes.items[n..];2108 const buf2 = ld_script_bytes.items[n..];
2109 const n2 = file.preadAll(buf2, n) catch |err|2109 const n2 = file.preadAll(buf2, n) catch |err|
2110 fatal("failed to read {}: {s}", .{ test_path, @errorName(err) });2110 fatal("failed to read {f}: {s}", .{ test_path, @errorName(err) });
2111 if (n2 != buf2.len) fatal("failed to read {}: unexpected end of file", .{test_path});2111 if (n2 != buf2.len) fatal("failed to read {f}: unexpected end of file", .{test_path});
2112 var diags = Diags.init(gpa);2112 var diags = Diags.init(gpa);
2113 defer diags.deinit();2113 defer diags.deinit();
2114 const ld_script_result = LdScript.parse(gpa, &diags, test_path, ld_script_bytes.items);2114 const ld_script_result = LdScript.parse(gpa, &diags, test_path, ld_script_bytes.items);
...@@ -2128,7 +2128,7 @@ fn resolvePathInputLib(...@@ -2128,7 +2128,7 @@ fn resolvePathInputLib(
2128 }2128 }
21292129
2130 var ld_script = ld_script_result catch |err|2130 var ld_script = ld_script_result catch |err|
2131 fatal("{}: failed to parse linker script: {s}", .{ test_path, @errorName(err) });2131 fatal("{f}: failed to parse linker script: {s}", .{ test_path, @errorName(err) });
2132 defer ld_script.deinit(gpa);2132 defer ld_script.deinit(gpa);
21332133
2134 try unresolved_inputs.ensureUnusedCapacity(gpa, ld_script.args.len);2134 try unresolved_inputs.ensureUnusedCapacity(gpa, ld_script.args.len);
...@@ -2159,7 +2159,7 @@ fn resolvePathInputLib(...@@ -2159,7 +2159,7 @@ fn resolvePathInputLib(
21592159
2160 var file = test_path.root_dir.handle.openFile(test_path.sub_path, .{}) catch |err| switch (err) {2160 var file = test_path.root_dir.handle.openFile(test_path.sub_path, .{}) catch |err| switch (err) {
2161 error.FileNotFound => return .no_match,2161 error.FileNotFound => return .no_match,
2162 else => |e| fatal("unable to search for {s} library {}: {s}", .{2162 else => |e| fatal("unable to search for {s} library {f}: {s}", .{
2163 @tagName(link_mode), test_path, @errorName(e),2163 @tagName(link_mode), test_path, @errorName(e),
2164 }),2164 }),
2165 };2165 };
src/link/C.zig+1-1
...@@ -493,7 +493,7 @@ pub fn flush(self: *C, arena: Allocator, tid: Zcu.PerThread.Id, prog_node: std.P...@@ -493,7 +493,7 @@ pub fn flush(self: *C, arena: Allocator, tid: Zcu.PerThread.Id, prog_node: std.P
493493
494 const file = self.base.file.?;494 const file = self.base.file.?;
495 file.setEndPos(f.file_size) catch |err| return diags.fail("failed to allocate file: {s}", .{@errorName(err)});495 file.setEndPos(f.file_size) catch |err| return diags.fail("failed to allocate file: {s}", .{@errorName(err)});
496 file.pwritevAll(f.all_buffers.items, 0) catch |err| return diags.fail("failed to write to '{'}': {s}", .{496 file.pwritevAll(f.all_buffers.items, 0) catch |err| return diags.fail("failed to write to '{f'}': {s}", .{
497 self.base.emit, @errorName(err),497 self.base.emit, @errorName(err),
498 });498 });
499}499}
src/link/Coff.zig+1-1
...@@ -2588,7 +2588,7 @@ fn logSymtab(coff: *Coff) void {...@@ -2588,7 +2588,7 @@ fn logSymtab(coff: *Coff) void {
2588 .DEBUG => unreachable, // TODO2588 .DEBUG => unreachable, // TODO
2589 else => @intFromEnum(sym.section_number),2589 else => @intFromEnum(sym.section_number),
2590 };2590 };
2591 log.debug(" %{d}: {?s} @{x} in {s}({d}), {s}", .{2591 log.debug(" %{d}: {s} @{x} in {s}({d}), {s}", .{
2592 sym_id,2592 sym_id,
2593 coff.getSymbolName(.{ .sym_index = @as(u32, @intCast(sym_id)), .file = null }),2593 coff.getSymbolName(.{ .sym_index = @as(u32, @intCast(sym_id)), .file = null }),
2594 sym.value,2594 sym.value,
src/link/Elf.zig+8-8
...@@ -3544,7 +3544,7 @@ pub fn addRelaDyn(self: *Elf, opts: RelaDyn) !void {...@@ -3544,7 +3544,7 @@ pub fn addRelaDyn(self: *Elf, opts: RelaDyn) !void {
3544}3544}
35453545
3546pub fn addRelaDynAssumeCapacity(self: *Elf, opts: RelaDyn) void {3546pub fn addRelaDynAssumeCapacity(self: *Elf, opts: RelaDyn) void {
3547 relocs_log.debug(" {s}: [{x} => {d}({s})] + {x}", .{3547 relocs_log.debug(" {f}: [{x} => {d}({s})] + {x}", .{
3548 relocation.fmtRelocType(opts.type, self.getTarget().cpu.arch),3548 relocation.fmtRelocType(opts.type, self.getTarget().cpu.arch),
3549 opts.offset,3549 opts.offset,
3550 opts.sym,3550 opts.sym,
...@@ -3791,7 +3791,7 @@ fn reportUndefinedSymbols(self: *Elf, undefs: anytype) !void {...@@ -3791,7 +3791,7 @@ fn reportUndefinedSymbols(self: *Elf, undefs: anytype) !void {
3791 for (refs.items[0..nrefs]) |ref| {3791 for (refs.items[0..nrefs]) |ref| {
3792 const atom_ptr = self.atom(ref).?;3792 const atom_ptr = self.atom(ref).?;
3793 const file_ptr = atom_ptr.file(self).?;3793 const file_ptr = atom_ptr.file(self).?;
3794 err.addNote("referenced by {s}:{s}", .{ file_ptr.fmtPath(), atom_ptr.name(self) });3794 err.addNote("referenced by {f}:{s}", .{ file_ptr.fmtPath(), atom_ptr.name(self) });
3795 }3795 }
37963796
3797 if (refs.items.len > max_notes) {3797 if (refs.items.len > max_notes) {
...@@ -4020,19 +4020,19 @@ fn fmtDumpState(self: *Elf, writer: *std.io.Writer) std.io.Writer.Error!void {...@@ -4020,19 +4020,19 @@ fn fmtDumpState(self: *Elf, writer: *std.io.Writer) std.io.Writer.Error!void {
4020 {4020 {
4021 try writer.writeAll("atom lists\n");4021 try writer.writeAll("atom lists\n");
4022 for (slice.items(.shdr), slice.items(.atom_list_2), 0..) |shdr, atom_list, shndx| {4022 for (slice.items(.shdr), slice.items(.atom_list_2), 0..) |shdr, atom_list, shndx| {
4023 try writer.print("shdr({d}) : {s} : {}\n", .{ shndx, self.getShString(shdr.sh_name), atom_list.fmt(self) });4023 try writer.print("shdr({d}) : {s} : {f}\n", .{ shndx, self.getShString(shdr.sh_name), atom_list.fmt(self) });
4024 }4024 }
4025 }4025 }
40264026
4027 if (self.requiresThunks()) {4027 if (self.requiresThunks()) {
4028 try writer.writeAll("thunks\n");4028 try writer.writeAll("thunks\n");
4029 for (self.thunks.items, 0..) |th, index| {4029 for (self.thunks.items, 0..) |th, index| {
4030 try writer.print("thunk({d}) : {}\n", .{ index, th.fmt(self) });4030 try writer.print("thunk({d}) : {f}\n", .{ index, th.fmt(self) });
4031 }4031 }
4032 }4032 }
40334033
4034 try writer.print("{}\n", .{self.got.fmt(self)});4034 try writer.print("{f}\n", .{self.got.fmt(self)});
4035 try writer.print("{}\n", .{self.plt.fmt(self)});4035 try writer.print("{f}\n", .{self.plt.fmt(self)});
40364036
4037 try writer.writeAll("Output groups\n");4037 try writer.writeAll("Output groups\n");
4038 for (self.group_sections.items) |cg| {4038 for (self.group_sections.items) |cg| {
...@@ -4041,7 +4041,7 @@ fn fmtDumpState(self: *Elf, writer: *std.io.Writer) std.io.Writer.Error!void {...@@ -4041,7 +4041,7 @@ fn fmtDumpState(self: *Elf, writer: *std.io.Writer) std.io.Writer.Error!void {
40414041
4042 try writer.writeAll("\nOutput merge sections\n");4042 try writer.writeAll("\nOutput merge sections\n");
4043 for (self.merge_sections.items) |msec| {4043 for (self.merge_sections.items) |msec| {
4044 try writer.print(" shdr({d}) : {}\n", .{ msec.output_section_index, msec.fmt(self) });4044 try writer.print(" shdr({d}) : {f}\n", .{ msec.output_section_index, msec.fmt(self) });
4045 }4045 }
40464046
4047 try writer.writeAll("\nOutput shdrs\n");4047 try writer.writeAll("\nOutput shdrs\n");
...@@ -4424,7 +4424,7 @@ fn createThunks(elf_file: *Elf, atom_list: *AtomList) !void {...@@ -4424,7 +4424,7 @@ fn createThunks(elf_file: *Elf, atom_list: *AtomList) !void {
44244424
4425 thunk_ptr.value = try advance(atom_list, thunk_ptr.size(elf_file), Atom.Alignment.fromNonzeroByteUnits(2));4425 thunk_ptr.value = try advance(atom_list, thunk_ptr.size(elf_file), Atom.Alignment.fromNonzeroByteUnits(2));
44264426
4427 log.debug("thunk({d}) : {}", .{ thunk_index, thunk_ptr.fmt(elf_file) });4427 log.debug("thunk({d}) : {f}", .{ thunk_index, thunk_ptr.fmt(elf_file) });
4428 }4428 }
4429}4429}
44304430
src/link/Elf/Atom.zig+2-2
...@@ -243,7 +243,7 @@ pub fn writeRelocs(self: Atom, elf_file: *Elf, out_relocs: *std.ArrayList(elf.El...@@ -243,7 +243,7 @@ pub fn writeRelocs(self: Atom, elf_file: *Elf, out_relocs: *std.ArrayList(elf.El
243 },243 },
244 }244 }
245245
246 relocs_log.debug(" {s}: [{x} => {d}({s})] + {x}", .{246 relocs_log.debug(" {f}: [{x} => {d}({s})] + {x}", .{
247 relocation.fmtRelocType(rel.r_type(), cpu_arch),247 relocation.fmtRelocType(rel.r_type(), cpu_arch),
248 r_offset,248 r_offset,
249 r_sym,249 r_sym,
...@@ -652,7 +652,7 @@ pub fn resolveRelocsAlloc(self: Atom, elf_file: *Elf, code: []u8) RelocError!voi...@@ -652,7 +652,7 @@ pub fn resolveRelocsAlloc(self: Atom, elf_file: *Elf, code: []u8) RelocError!voi
652 // Address of the dynamic thread pointer.652 // Address of the dynamic thread pointer.
653 const DTP = elf_file.dtpAddress();653 const DTP = elf_file.dtpAddress();
654654
655 relocs_log.debug(" {s}: {x}: [{x} => {x}] GOT({x}) ({s})", .{655 relocs_log.debug(" {f}: {x}: [{x} => {x}] GOT({x}) ({s})", .{
656 relocation.fmtRelocType(rel.r_type(), cpu_arch),656 relocation.fmtRelocType(rel.r_type(), cpu_arch),
657 r_offset,657 r_offset,
658 P,658 P,
src/link/Elf/Object.zig+7-10
...@@ -488,10 +488,7 @@ fn parseEhFrame(...@@ -488,10 +488,7 @@ fn parseEhFrame(
488 if (cie.offset == cie_ptr) break @as(u32, @intCast(cie_index));488 if (cie.offset == cie_ptr) break @as(u32, @intCast(cie_index));
489 } else {489 } else {
490 // TODO convert into an error490 // TODO convert into an error
491 log.debug("{s}: no matching CIE found for FDE at offset {x}", .{491 log.debug("{f}: no matching CIE found for FDE at offset {x}", .{ self.fmtPath(), fde.offset });
492 self.fmtPath(),
493 fde.offset,
494 });
495 continue;492 continue;
496 };493 };
497 fde.cie_index = cie_index;494 fde.cie_index = cie_index;
...@@ -582,7 +579,7 @@ pub fn scanRelocs(self: *Object, elf_file: *Elf, undefs: anytype) !void {...@@ -582,7 +579,7 @@ pub fn scanRelocs(self: *Object, elf_file: *Elf, undefs: anytype) !void {
582 if (sym.flags.import) {579 if (sym.flags.import) {
583 if (sym.type(elf_file) != elf.STT_FUNC)580 if (sym.type(elf_file) != elf.STT_FUNC)
584 // TODO convert into an error581 // TODO convert into an error
585 log.debug("{s}: {s}: CIE referencing external data reference", .{582 log.debug("{f}: {s}: CIE referencing external data reference", .{
586 self.fmtPath(), sym.name(elf_file),583 self.fmtPath(), sym.name(elf_file),
587 });584 });
588 sym.flags.needs_plt = true;585 sym.flags.needs_plt = true;
...@@ -1448,14 +1445,14 @@ const Format = struct {...@@ -1448,14 +1445,14 @@ const Format = struct {
1448 const elf_file = f.elf_file;1445 const elf_file = f.elf_file;
1449 try writer.writeAll(" locals\n");1446 try writer.writeAll(" locals\n");
1450 for (object.locals()) |sym| {1447 for (object.locals()) |sym| {
1451 try writer.print(" {}\n", .{sym.fmt(elf_file)});1448 try writer.print(" {f}\n", .{sym.fmt(elf_file)});
1452 }1449 }
1453 try writer.writeAll(" globals\n");1450 try writer.writeAll(" globals\n");
1454 for (object.globals(), 0..) |sym, i| {1451 for (object.globals(), 0..) |sym, i| {
1455 const first_global = object.first_global.?;1452 const first_global = object.first_global.?;
1456 const ref = object.resolveSymbol(@intCast(i + first_global), elf_file);1453 const ref = object.resolveSymbol(@intCast(i + first_global), elf_file);
1457 if (elf_file.symbol(ref)) |ref_sym| {1454 if (elf_file.symbol(ref)) |ref_sym| {
1458 try writer.print(" {}\n", .{ref_sym.fmt(elf_file)});1455 try writer.print(" {f}\n", .{ref_sym.fmt(elf_file)});
1459 } else {1456 } else {
1460 try writer.print(" {s} : unclaimed\n", .{sym.name(elf_file)});1457 try writer.print(" {s} : unclaimed\n", .{sym.name(elf_file)});
1461 }1458 }
...@@ -1467,7 +1464,7 @@ const Format = struct {...@@ -1467,7 +1464,7 @@ const Format = struct {
1467 try writer.writeAll(" atoms\n");1464 try writer.writeAll(" atoms\n");
1468 for (object.atoms_indexes.items) |atom_index| {1465 for (object.atoms_indexes.items) |atom_index| {
1469 const atom_ptr = object.atom(atom_index) orelse continue;1466 const atom_ptr = object.atom(atom_index) orelse continue;
1470 try writer.print(" {}\n", .{atom_ptr.fmt(f.elf_file)});1467 try writer.print(" {f}\n", .{atom_ptr.fmt(f.elf_file)});
1471 }1468 }
1472 }1469 }
14731470
...@@ -1475,7 +1472,7 @@ const Format = struct {...@@ -1475,7 +1472,7 @@ const Format = struct {
1475 const object = f.object;1472 const object = f.object;
1476 try writer.writeAll(" cies\n");1473 try writer.writeAll(" cies\n");
1477 for (object.cies.items, 0..) |cie, i| {1474 for (object.cies.items, 0..) |cie, i| {
1478 try writer.print(" cie({d}) : {}\n", .{ i, cie.fmt(f.elf_file) });1475 try writer.print(" cie({d}) : {f}\n", .{ i, cie.fmt(f.elf_file) });
1479 }1476 }
1480 }1477 }
14811478
...@@ -1483,7 +1480,7 @@ const Format = struct {...@@ -1483,7 +1480,7 @@ const Format = struct {
1483 const object = f.object;1480 const object = f.object;
1484 try writer.writeAll(" fdes\n");1481 try writer.writeAll(" fdes\n");
1485 for (object.fdes.items, 0..) |fde, i| {1482 for (object.fdes.items, 0..) |fde, i| {
1486 try writer.print(" fde({d}) : {}\n", .{ i, fde.fmt(f.elf_file) });1483 try writer.print(" fde({d}) : {f}\n", .{ i, fde.fmt(f.elf_file) });
1487 }1484 }
1488 }1485 }
14891486
src/link/Elf/ZigObject.zig+14-14
...@@ -925,7 +925,7 @@ pub fn getNavVAddr(...@@ -925,7 +925,7 @@ pub fn getNavVAddr(
925 const zcu = pt.zcu;925 const zcu = pt.zcu;
926 const ip = &zcu.intern_pool;926 const ip = &zcu.intern_pool;
927 const nav = ip.getNav(nav_index);927 const nav = ip.getNav(nav_index);
928 log.debug("getNavVAddr {}({d})", .{ nav.fqn.fmt(ip), nav_index });928 log.debug("getNavVAddr {f}({d})", .{ nav.fqn.fmt(ip), nav_index });
929 const this_sym_index = if (nav.getExtern(ip)) |@"extern"| try self.getGlobalSymbol(929 const this_sym_index = if (nav.getExtern(ip)) |@"extern"| try self.getGlobalSymbol(
930 elf_file,930 elf_file,
931 nav.name.toSlice(ip),931 nav.name.toSlice(ip),
...@@ -1268,7 +1268,7 @@ fn updateNavCode(...@@ -1268,7 +1268,7 @@ fn updateNavCode(
1268 const ip = &zcu.intern_pool;1268 const ip = &zcu.intern_pool;
1269 const nav = ip.getNav(nav_index);1269 const nav = ip.getNav(nav_index);
12701270
1271 log.debug("updateNavCode {}({d})", .{ nav.fqn.fmt(ip), nav_index });1271 log.debug("updateNavCode {f}({d})", .{ nav.fqn.fmt(ip), nav_index });
12721272
1273 const target = &zcu.navFileScope(nav_index).mod.?.resolved_target.result;1273 const target = &zcu.navFileScope(nav_index).mod.?.resolved_target.result;
1274 const required_alignment = switch (pt.navAlignment(nav_index)) {1274 const required_alignment = switch (pt.navAlignment(nav_index)) {
...@@ -1302,7 +1302,7 @@ fn updateNavCode(...@@ -1302,7 +1302,7 @@ fn updateNavCode(
1302 self.allocateAtom(atom_ptr, true, elf_file) catch |err|1302 self.allocateAtom(atom_ptr, true, elf_file) catch |err|
1303 return elf_file.base.cgFail(nav_index, "failed to allocate atom: {s}", .{@errorName(err)});1303 return elf_file.base.cgFail(nav_index, "failed to allocate atom: {s}", .{@errorName(err)});
13041304
1305 log.debug("growing {} from 0x{x} to 0x{x}", .{ nav.fqn.fmt(ip), old_vaddr, atom_ptr.value });1305 log.debug("growing {f} from 0x{x} to 0x{x}", .{ nav.fqn.fmt(ip), old_vaddr, atom_ptr.value });
1306 if (old_vaddr != atom_ptr.value) {1306 if (old_vaddr != atom_ptr.value) {
1307 sym.value = 0;1307 sym.value = 0;
1308 esym.st_value = 0;1308 esym.st_value = 0;
...@@ -1347,7 +1347,7 @@ fn updateNavCode(...@@ -1347,7 +1347,7 @@ fn updateNavCode(
1347 const file_offset = atom_ptr.offset(elf_file);1347 const file_offset = atom_ptr.offset(elf_file);
1348 elf_file.base.file.?.pwriteAll(code, file_offset) catch |err|1348 elf_file.base.file.?.pwriteAll(code, file_offset) catch |err|
1349 return elf_file.base.cgFail(nav_index, "failed to write to output file: {s}", .{@errorName(err)});1349 return elf_file.base.cgFail(nav_index, "failed to write to output file: {s}", .{@errorName(err)});
1350 log.debug("writing {} from 0x{x} to 0x{x}", .{ nav.fqn.fmt(ip), file_offset, file_offset + code.len });1350 log.debug("writing {f} from 0x{x} to 0x{x}", .{ nav.fqn.fmt(ip), file_offset, file_offset + code.len });
1351 }1351 }
1352}1352}
13531353
...@@ -1365,7 +1365,7 @@ fn updateTlv(...@@ -1365,7 +1365,7 @@ fn updateTlv(
1365 const gpa = zcu.gpa;1365 const gpa = zcu.gpa;
1366 const nav = ip.getNav(nav_index);1366 const nav = ip.getNav(nav_index);
13671367
1368 log.debug("updateTlv {}({d})", .{ nav.fqn.fmt(ip), nav_index });1368 log.debug("updateTlv {f}({d})", .{ nav.fqn.fmt(ip), nav_index });
13691369
1370 const required_alignment = pt.navAlignment(nav_index);1370 const required_alignment = pt.navAlignment(nav_index);
13711371
...@@ -1424,7 +1424,7 @@ pub fn updateFunc(...@@ -1424,7 +1424,7 @@ pub fn updateFunc(
1424 const gpa = elf_file.base.comp.gpa;1424 const gpa = elf_file.base.comp.gpa;
1425 const func = zcu.funcInfo(func_index);1425 const func = zcu.funcInfo(func_index);
14261426
1427 log.debug("updateFunc {}({d})", .{ ip.getNav(func.owner_nav).fqn.fmt(ip), func.owner_nav });1427 log.debug("updateFunc {f}({d})", .{ ip.getNav(func.owner_nav).fqn.fmt(ip), func.owner_nav });
14281428
1429 const sym_index = try self.getOrCreateMetadataForNav(zcu, func.owner_nav);1429 const sym_index = try self.getOrCreateMetadataForNav(zcu, func.owner_nav);
1430 self.atom(self.symbol(sym_index).ref.index).?.freeRelocs(self);1430 self.atom(self.symbol(sym_index).ref.index).?.freeRelocs(self);
...@@ -1447,7 +1447,7 @@ pub fn updateFunc(...@@ -1447,7 +1447,7 @@ pub fn updateFunc(
1447 const code = code_buffer.items;1447 const code = code_buffer.items;
14481448
1449 const shndx = try self.getNavShdrIndex(elf_file, zcu, func.owner_nav, sym_index, code);1449 const shndx = try self.getNavShdrIndex(elf_file, zcu, func.owner_nav, sym_index, code);
1450 log.debug("setting shdr({x},{s}) for {}", .{1450 log.debug("setting shdr({x},{s}) for {f}", .{
1451 shndx,1451 shndx,
1452 elf_file.getShString(elf_file.sections.items(.shdr)[shndx].sh_name),1452 elf_file.getShString(elf_file.sections.items(.shdr)[shndx].sh_name),
1453 ip.getNav(func.owner_nav).fqn.fmt(ip),1453 ip.getNav(func.owner_nav).fqn.fmt(ip),
...@@ -1529,7 +1529,7 @@ pub fn updateNav(...@@ -1529,7 +1529,7 @@ pub fn updateNav(
1529 const ip = &zcu.intern_pool;1529 const ip = &zcu.intern_pool;
1530 const nav = ip.getNav(nav_index);1530 const nav = ip.getNav(nav_index);
15311531
1532 log.debug("updateNav {}({d})", .{ nav.fqn.fmt(ip), nav_index });1532 log.debug("updateNav {f}({d})", .{ nav.fqn.fmt(ip), nav_index });
15331533
1534 const nav_init = switch (ip.indexToKey(nav.status.fully_resolved.val)) {1534 const nav_init = switch (ip.indexToKey(nav.status.fully_resolved.val)) {
1535 .func => .none,1535 .func => .none,
...@@ -1576,7 +1576,7 @@ pub fn updateNav(...@@ -1576,7 +1576,7 @@ pub fn updateNav(
1576 const code = code_buffer.items;1576 const code = code_buffer.items;
15771577
1578 const shndx = try self.getNavShdrIndex(elf_file, zcu, nav_index, sym_index, code);1578 const shndx = try self.getNavShdrIndex(elf_file, zcu, nav_index, sym_index, code);
1579 log.debug("setting shdr({x},{s}) for {}", .{1579 log.debug("setting shdr({x},{s}) for {f}", .{
1580 shndx,1580 shndx,
1581 elf_file.getShString(elf_file.sections.items(.shdr)[shndx].sh_name),1581 elf_file.getShString(elf_file.sections.items(.shdr)[shndx].sh_name),
1582 nav.fqn.fmt(ip),1582 nav.fqn.fmt(ip),
...@@ -1622,7 +1622,7 @@ fn updateLazySymbol(...@@ -1622,7 +1622,7 @@ fn updateLazySymbol(
1622 defer code_buffer.deinit(gpa);1622 defer code_buffer.deinit(gpa);
16231623
1624 const name_str_index = blk: {1624 const name_str_index = blk: {
1625 const name = try std.fmt.allocPrint(gpa, "__lazy_{s}_{}", .{1625 const name = try std.fmt.allocPrint(gpa, "__lazy_{s}_{f}", .{
1626 @tagName(sym.kind),1626 @tagName(sym.kind),
1627 Type.fromInterned(sym.ty).fmt(pt),1627 Type.fromInterned(sym.ty).fmt(pt),
1628 });1628 });
...@@ -1941,7 +1941,7 @@ pub fn allocateAtom(self: *ZigObject, atom_ptr: *Atom, requires_padding: bool, e...@@ -1941,7 +1941,7 @@ pub fn allocateAtom(self: *ZigObject, atom_ptr: *Atom, requires_padding: bool, e
1941 .requires_padding = requires_padding,1941 .requires_padding = requires_padding,
1942 });1942 });
1943 atom_ptr.value = @intCast(alloc_res.value);1943 atom_ptr.value = @intCast(alloc_res.value);
1944 log.debug("allocated {s} at {x}\n placement {?}", .{1944 log.debug("allocated {s} at {x}\n placement {f}", .{
1945 atom_ptr.name(elf_file),1945 atom_ptr.name(elf_file),
1946 atom_ptr.offset(elf_file),1946 atom_ptr.offset(elf_file),
1947 alloc_res.placement,1947 alloc_res.placement,
...@@ -1986,7 +1986,7 @@ pub fn allocateAtom(self: *ZigObject, atom_ptr: *Atom, requires_padding: bool, e...@@ -1986,7 +1986,7 @@ pub fn allocateAtom(self: *ZigObject, atom_ptr: *Atom, requires_padding: bool, e
1986 atom_ptr.next_atom_ref = .{ .index = 0, .file = 0 };1986 atom_ptr.next_atom_ref = .{ .index = 0, .file = 0 };
1987 }1987 }
19881988
1989 log.debug(" prev {?}, next {?}", .{ atom_ptr.prev_atom_ref, atom_ptr.next_atom_ref });1989 log.debug(" prev {f}, next {f}", .{ atom_ptr.prev_atom_ref, atom_ptr.next_atom_ref });
1990}1990}
19911991
1992pub fn resetShdrIndexes(self: *ZigObject, backlinks: []const u32) void {1992pub fn resetShdrIndexes(self: *ZigObject, backlinks: []const u32) void {
...@@ -2271,7 +2271,7 @@ fn checkNavAllocated(pt: Zcu.PerThread, index: InternPool.Nav.Index, meta: AvMet...@@ -2271,7 +2271,7 @@ fn checkNavAllocated(pt: Zcu.PerThread, index: InternPool.Nav.Index, meta: AvMet
2271 const zcu = pt.zcu;2271 const zcu = pt.zcu;
2272 const ip = &zcu.intern_pool;2272 const ip = &zcu.intern_pool;
2273 const nav = ip.getNav(index);2273 const nav = ip.getNav(index);
2274 log.err("NAV {}({d}) assigned symbol {d} but not allocated!", .{2274 log.err("NAV {f}({d}) assigned symbol {d} but not allocated!", .{
2275 nav.fqn.fmt(ip),2275 nav.fqn.fmt(ip),
2276 index,2276 index,
2277 meta.symbol_index,2277 meta.symbol_index,
...@@ -2284,7 +2284,7 @@ fn checkUavAllocated(pt: Zcu.PerThread, index: InternPool.Index, meta: AvMetadat...@@ -2284,7 +2284,7 @@ fn checkUavAllocated(pt: Zcu.PerThread, index: InternPool.Index, meta: AvMetadat
2284 const zcu = pt.zcu;2284 const zcu = pt.zcu;
2285 const uav = Value.fromInterned(index);2285 const uav = Value.fromInterned(index);
2286 const ty = uav.typeOf(zcu);2286 const ty = uav.typeOf(zcu);
2287 log.err("UAV {}({d}) assigned symbol {d} but not allocated!", .{2287 log.err("UAV {f}({d}) assigned symbol {d} but not allocated!", .{
2288 ty.fmt(pt),2288 ty.fmt(pt),
2289 index,2289 index,
2290 meta.symbol_index,2290 meta.symbol_index,
src/link/Elf/eh_frame.zig+2-2
...@@ -276,7 +276,7 @@ fn resolveReloc(rec: anytype, sym: *const Symbol, rel: elf.Elf64_Rela, elf_file:...@@ -276,7 +276,7 @@ fn resolveReloc(rec: anytype, sym: *const Symbol, rel: elf.Elf64_Rela, elf_file:
276 const S = math.cast(i64, sym.address(.{}, elf_file)) orelse return error.Overflow;276 const S = math.cast(i64, sym.address(.{}, elf_file)) orelse return error.Overflow;
277 const A = rel.r_addend;277 const A = rel.r_addend;
278278
279 relocs_log.debug(" {s}: {x}: [{x} => {x}] ({s})", .{279 relocs_log.debug(" {f}: {x}: [{x} => {x}] ({s})", .{
280 relocation.fmtRelocType(rel.r_type(), cpu_arch),280 relocation.fmtRelocType(rel.r_type(), cpu_arch),
281 offset,281 offset,
282 P,282 P,
...@@ -398,7 +398,7 @@ fn emitReloc(elf_file: *Elf, r_offset: u64, sym: *const Symbol, rel: elf.Elf64_R...@@ -398,7 +398,7 @@ fn emitReloc(elf_file: *Elf, r_offset: u64, sym: *const Symbol, rel: elf.Elf64_R
398 },398 },
399 }399 }
400400
401 relocs_log.debug(" {s}: [{x} => {d}({s})] + {x}", .{401 relocs_log.debug(" {f}: [{x} => {d}({s})] + {x}", .{
402 relocation.fmtRelocType(r_type, cpu_arch),402 relocation.fmtRelocType(r_type, cpu_arch),
403 r_offset,403 r_offset,
404 r_sym,404 r_sym,
src/link/Elf/synthetic_sections.zig+1-1
...@@ -696,7 +696,7 @@ pub const PltSection = struct {...@@ -696,7 +696,7 @@ pub const PltSection = struct {
696 const r_sym: u64 = extra.dynamic;696 const r_sym: u64 = extra.dynamic;
697 const r_type = relocation.encode(.jump_slot, cpu_arch);697 const r_type = relocation.encode(.jump_slot, cpu_arch);
698698
699 relocs_log.debug(" {s}: [{x} => {d}({s})] + 0", .{699 relocs_log.debug(" {f}: [{x} => {d}({s})] + 0", .{
700 relocation.fmtRelocType(r_type, cpu_arch),700 relocation.fmtRelocType(r_type, cpu_arch),
701 r_offset,701 r_offset,
702 r_sym,702 r_sym,
src/link/MachO/Atom.zig+1-1
...@@ -653,7 +653,7 @@ fn resolveRelocInner(...@@ -653,7 +653,7 @@ fn resolveRelocInner(
653 const divExact = struct {653 const divExact = struct {
654 fn divExact(atom: Atom, r: Relocation, num: u12, den: u12, ctx: *MachO) !u12 {654 fn divExact(atom: Atom, r: Relocation, num: u12, den: u12, ctx: *MachO) !u12 {
655 return math.divExact(u12, num, den) catch {655 return math.divExact(u12, num, den) catch {
656 try ctx.reportParseError2(atom.getFile(ctx).getIndex(), "{s}: unexpected remainder when resolving {s} at offset 0x{x}", .{656 try ctx.reportParseError2(atom.getFile(ctx).getIndex(), "{s}: unexpected remainder when resolving {f} at offset 0x{x}", .{
657 atom.getName(ctx),657 atom.getName(ctx),
658 r.fmtPretty(ctx.getTarget().cpu.arch),658 r.fmtPretty(ctx.getTarget().cpu.arch),
659 r.offset,659 r.offset,
src/link/MachO/dyld_info/bind.zig+2-2
...@@ -205,7 +205,7 @@ pub const Bind = struct {...@@ -205,7 +205,7 @@ pub const Bind = struct {
205 }205 }
206 }206 }
207207
208 log.debug("{x}, {d}, {x}, {?x}, {s}", .{ offset, count, skip, addend, @tagName(state) });208 log.debug("{x}, {d}, {x}, {x}, {s}", .{ offset, count, skip, addend, @tagName(state) });
209 log.debug(" => {x}", .{current.offset});209 log.debug(" => {x}", .{current.offset});
210 switch (state) {210 switch (state) {
211 .start => {211 .start => {
...@@ -447,7 +447,7 @@ pub const WeakBind = struct {...@@ -447,7 +447,7 @@ pub const WeakBind = struct {
447 }447 }
448 }448 }
449449
450 log.debug("{x}, {d}, {x}, {?x}, {s}", .{ offset, count, skip, addend, @tagName(state) });450 log.debug("{x}, {d}, {x}, {x}, {s}", .{ offset, count, skip, addend, @tagName(state) });
451 log.debug(" => {x}", .{current.offset});451 log.debug(" => {x}", .{current.offset});
452 switch (state) {452 switch (state) {
453 .start => {453 .start => {
src/link/Wasm/Flush.zig+1-1
...@@ -534,7 +534,7 @@ pub fn finish(f: *Flush, wasm: *Wasm) !void {...@@ -534,7 +534,7 @@ pub fn finish(f: *Flush, wasm: *Wasm) !void {
534 wasm.memories.limits.max = @intCast(max_memory / page_size);534 wasm.memories.limits.max = @intCast(max_memory / page_size);
535 wasm.memories.limits.flags.has_max = true;535 wasm.memories.limits.flags.has_max = true;
536 if (shared_memory) wasm.memories.limits.flags.is_shared = true;536 if (shared_memory) wasm.memories.limits.flags.is_shared = true;
537 log.debug("maximum memory pages: {?d}", .{wasm.memories.limits.max});537 log.debug("maximum memory pages: {d}", .{wasm.memories.limits.max});
538 }538 }
539 f.memory_layout_finished = true;539 f.memory_layout_finished = true;
540540
src/print_value.zig+19-19
...@@ -73,35 +73,35 @@ pub fn print(...@@ -73,35 +73,35 @@ pub fn print(
73 else => try writer.writeAll(@tagName(simple_value)),73 else => try writer.writeAll(@tagName(simple_value)),
74 },74 },
75 .variable => try writer.writeAll("(variable)"),75 .variable => try writer.writeAll("(variable)"),
76 .@"extern" => |e| try writer.print("(extern '{}')", .{e.name.fmt(ip)}),76 .@"extern" => |e| try writer.print("(extern '{f}')", .{e.name.fmt(ip)}),
77 .func => |func| try writer.print("(function '{}')", .{ip.getNav(func.owner_nav).name.fmt(ip)}),77 .func => |func| try writer.print("(function '{f}')", .{ip.getNav(func.owner_nav).name.fmt(ip)}),
78 .int => |int| switch (int.storage) {78 .int => |int| switch (int.storage) {
79 inline .u64, .i64, .big_int => |x| try writer.print("{}", .{x}),79 inline .u64, .i64, .big_int => |x| try writer.print("{}", .{x}),
80 .lazy_align => |ty| if (opt_sema != null) {80 .lazy_align => |ty| if (opt_sema != null) {
81 const a = try Type.fromInterned(ty).abiAlignmentSema(pt);81 const a = try Type.fromInterned(ty).abiAlignmentSema(pt);
82 try writer.print("{}", .{a.toByteUnits() orelse 0});82 try writer.print("{}", .{a.toByteUnits() orelse 0});
83 } else try writer.print("@alignOf({})", .{Type.fromInterned(ty).fmt(pt)}),83 } else try writer.print("@alignOf({f})", .{Type.fromInterned(ty).fmt(pt)}),
84 .lazy_size => |ty| if (opt_sema != null) {84 .lazy_size => |ty| if (opt_sema != null) {
85 const s = try Type.fromInterned(ty).abiSizeSema(pt);85 const s = try Type.fromInterned(ty).abiSizeSema(pt);
86 try writer.print("{}", .{s});86 try writer.print("{}", .{s});
87 } else try writer.print("@sizeOf({})", .{Type.fromInterned(ty).fmt(pt)}),87 } else try writer.print("@sizeOf({f})", .{Type.fromInterned(ty).fmt(pt)}),
88 },88 },
89 .err => |err| try writer.print("error.{}", .{89 .err => |err| try writer.print("error.{f}", .{
90 err.name.fmt(ip),90 err.name.fmt(ip),
91 }),91 }),
92 .error_union => |error_union| switch (error_union.val) {92 .error_union => |error_union| switch (error_union.val) {
93 .err_name => |err_name| try writer.print("error.{}", .{93 .err_name => |err_name| try writer.print("error.{f}", .{
94 err_name.fmt(ip),94 err_name.fmt(ip),
95 }),95 }),
96 .payload => |payload| try print(Value.fromInterned(payload), writer, level, pt, opt_sema),96 .payload => |payload| try print(Value.fromInterned(payload), writer, level, pt, opt_sema),
97 },97 },
98 .enum_literal => |enum_literal| try writer.print(".{}", .{98 .enum_literal => |enum_literal| try writer.print(".{f}", .{
99 enum_literal.fmt(ip),99 enum_literal.fmt(ip),
100 }),100 }),
101 .enum_tag => |enum_tag| {101 .enum_tag => |enum_tag| {
102 const enum_type = ip.loadEnumType(val.typeOf(zcu).toIntern());102 const enum_type = ip.loadEnumType(val.typeOf(zcu).toIntern());
103 if (enum_type.tagValueIndex(ip, val.toIntern())) |tag_index| {103 if (enum_type.tagValueIndex(ip, val.toIntern())) |tag_index| {
104 return writer.print(".{i}", .{enum_type.names.get(ip)[tag_index].fmt(ip)});104 return writer.print(".{fi}", .{enum_type.names.get(ip)[tag_index].fmt(ip)});
105 }105 }
106 if (level == 0) {106 if (level == 0) {
107 return writer.writeAll("@enumFromInt(...)");107 return writer.writeAll("@enumFromInt(...)");
...@@ -164,7 +164,7 @@ pub fn print(...@@ -164,7 +164,7 @@ pub fn print(
164 }164 }
165 if (un.tag == .none) {165 if (un.tag == .none) {
166 const backing_ty = try val.typeOf(zcu).unionBackingType(pt);166 const backing_ty = try val.typeOf(zcu).unionBackingType(pt);
167 try writer.print("@bitCast(@as({}, ", .{backing_ty.fmt(pt)});167 try writer.print("@bitCast(@as({f}, ", .{backing_ty.fmt(pt)});
168 try print(Value.fromInterned(un.val), writer, level - 1, pt, opt_sema);168 try print(Value.fromInterned(un.val), writer, level - 1, pt, opt_sema);
169 try writer.writeAll("))");169 try writer.writeAll("))");
170 } else {170 } else {
...@@ -206,7 +206,7 @@ fn printAggregate(...@@ -206,7 +206,7 @@ fn printAggregate(
206 for (0..max_len) |i| {206 for (0..max_len) |i| {
207 if (i != 0) try writer.writeAll(", ");207 if (i != 0) try writer.writeAll(", ");
208 const field_name = ty.structFieldName(@intCast(i), zcu).unwrap().?;208 const field_name = ty.structFieldName(@intCast(i), zcu).unwrap().?;
209 try writer.print(".{i} = ", .{field_name.fmt(ip)});209 try writer.print(".{fi} = ", .{field_name.fmt(ip)});
210 try print(try val.fieldValue(pt, i), writer, level - 1, pt, opt_sema);210 try print(try val.fieldValue(pt, i), writer, level - 1, pt, opt_sema);
211 }211 }
212 try writer.writeAll(" }");212 try writer.writeAll(" }");
...@@ -391,14 +391,14 @@ pub fn printPtrDerivation(...@@ -391,14 +391,14 @@ pub fn printPtrDerivation(
391 const agg_ty = (try field.parent.ptrType(pt)).childType(zcu);391 const agg_ty = (try field.parent.ptrType(pt)).childType(zcu);
392 switch (agg_ty.zigTypeTag(zcu)) {392 switch (agg_ty.zigTypeTag(zcu)) {
393 .@"struct" => if (agg_ty.structFieldName(field.field_idx, zcu).unwrap()) |field_name| {393 .@"struct" => if (agg_ty.structFieldName(field.field_idx, zcu).unwrap()) |field_name| {
394 try writer.print(".{i}", .{field_name.fmt(ip)});394 try writer.print(".{fi}", .{field_name.fmt(ip)});
395 } else {395 } else {
396 try writer.print("[{d}]", .{field.field_idx});396 try writer.print("[{d}]", .{field.field_idx});
397 },397 },
398 .@"union" => {398 .@"union" => {
399 const tag_ty = agg_ty.unionTagTypeHypothetical(zcu);399 const tag_ty = agg_ty.unionTagTypeHypothetical(zcu);
400 const field_name = tag_ty.enumFieldName(field.field_idx, zcu);400 const field_name = tag_ty.enumFieldName(field.field_idx, zcu);
401 try writer.print(".{i}", .{field_name.fmt(ip)});401 try writer.print(".{fi}", .{field_name.fmt(ip)});
402 },402 },
403 .pointer => switch (field.field_idx) {403 .pointer => switch (field.field_idx) {
404 Value.slice_ptr_index => try writer.writeAll(".ptr"),404 Value.slice_ptr_index => try writer.writeAll(".ptr"),
...@@ -416,12 +416,12 @@ pub fn printPtrDerivation(...@@ -416,12 +416,12 @@ pub fn printPtrDerivation(
416 },416 },
417417
418 .offset_and_cast => |oac| if (oac.byte_offset == 0) root: {418 .offset_and_cast => |oac| if (oac.byte_offset == 0) root: {
419 try writer.print("@as({}, @ptrCast(", .{oac.new_ptr_ty.fmt(pt)});419 try writer.print("@as({f}, @ptrCast(", .{oac.new_ptr_ty.fmt(pt)});
420 const root = try printPtrDerivation(oac.parent.*, writer, pt, .rvalue, root_strat, ptr_depth - 1);420 const root = try printPtrDerivation(oac.parent.*, writer, pt, .rvalue, root_strat, ptr_depth - 1);
421 try writer.writeAll("))");421 try writer.writeAll("))");
422 break :root root;422 break :root root;
423 } else root: {423 } else root: {
424 try writer.print("@as({}, @ptrFromInt(@intFromPtr(", .{oac.new_ptr_ty.fmt(pt)});424 try writer.print("@as({f}, @ptrFromInt(@intFromPtr(", .{oac.new_ptr_ty.fmt(pt)});
425 const root = try printPtrDerivation(oac.parent.*, writer, pt, .rvalue, root_strat, ptr_depth - 1);425 const root = try printPtrDerivation(oac.parent.*, writer, pt, .rvalue, root_strat, ptr_depth - 1);
426 try writer.print(") + {d}))", .{oac.byte_offset});426 try writer.print(") + {d}))", .{oac.byte_offset});
427 break :root root;427 break :root root;
...@@ -433,22 +433,22 @@ pub fn printPtrDerivation(...@@ -433,22 +433,22 @@ pub fn printPtrDerivation(
433 if (root_or_null == null) switch (root_strat) {433 if (root_or_null == null) switch (root_strat) {
434 .str => |x| try writer.writeAll(x),434 .str => |x| try writer.writeAll(x),
435 .print_val => |x| switch (derivation) {435 .print_val => |x| switch (derivation) {
436 .int => |int| try writer.print("@as({}, @ptrFromInt(0x{x}))", .{ int.ptr_ty.fmt(pt), int.addr }),436 .int => |int| try writer.print("@as({f}, @ptrFromInt(0x{x}))", .{ int.ptr_ty.fmt(pt), int.addr }),
437 .nav_ptr => |nav| try writer.print("{}", .{ip.getNav(nav).fqn.fmt(ip)}),437 .nav_ptr => |nav| try writer.print("{f}", .{ip.getNav(nav).fqn.fmt(ip)}),
438 .uav_ptr => |uav| {438 .uav_ptr => |uav| {
439 const ty = Value.fromInterned(uav.val).typeOf(zcu);439 const ty = Value.fromInterned(uav.val).typeOf(zcu);
440 try writer.print("@as({}, ", .{ty.fmt(pt)});440 try writer.print("@as({f}, ", .{ty.fmt(pt)});
441 try print(Value.fromInterned(uav.val), writer, x.level - 1, pt, x.opt_sema);441 try print(Value.fromInterned(uav.val), writer, x.level - 1, pt, x.opt_sema);
442 try writer.writeByte(')');442 try writer.writeByte(')');
443 },443 },
444 .comptime_alloc_ptr => |info| {444 .comptime_alloc_ptr => |info| {
445 try writer.print("@as({}, ", .{info.val.typeOf(zcu).fmt(pt)});445 try writer.print("@as({f}, ", .{info.val.typeOf(zcu).fmt(pt)});
446 try print(info.val, writer, x.level - 1, pt, x.opt_sema);446 try print(info.val, writer, x.level - 1, pt, x.opt_sema);
447 try writer.writeByte(')');447 try writer.writeByte(')');
448 },448 },
449 .comptime_field_ptr => |val| {449 .comptime_field_ptr => |val| {
450 const ty = val.typeOf(zcu);450 const ty = val.typeOf(zcu);
451 try writer.print("@as({}, ", .{ty.fmt(pt)});451 try writer.print("@as({f}, ", .{ty.fmt(pt)});
452 try print(val, writer, x.level - 1, pt, x.opt_sema);452 try print(val, writer, x.level - 1, pt, x.opt_sema);
453 try writer.writeByte(')');453 try writer.writeByte(')');
454 },454 },