From 4ccc6f2b5777afd06f0fddbea4e0e0d0c92b007d Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Thu, 3 Jul 2025 19:50:33 -0700 Subject: [PATCH] compiler: fix remaining build failures --- lib/std/fs/File.zig | 10 +++++----- src/libs/freebsd.zig | 4 ++-- src/libs/glibc.zig | 4 ++-- src/libs/netbsd.zig | 4 ++-- src/link/Lld.zig | 2 +- src/translate_c.zig | 6 +++--- 6 files changed, 15 insertions(+), 15 deletions(-) diff --git a/lib/std/fs/File.zig b/lib/std/fs/File.zig index ed691b8e19..33e33c609f 100644 --- a/lib/std/fs/File.zig +++ b/lib/std/fs/File.zig @@ -1802,10 +1802,10 @@ pub const Writer = struct { } const copy_file_range = switch (native_os) { .freebsd => std.os.freebsd.copy_file_range, - .linux => if (std.c.versionCheck(.{ .major = 2, .minor = 27, .patch = 0 })) std.os.linux.wrapped.copy_file_range else void, - else => void, + .linux => if (std.c.versionCheck(.{ .major = 2, .minor = 27, .patch = 0 })) std.os.linux.wrapped.copy_file_range else {}, + else => {}, }; - if (copy_file_range != void) cfr: { + if (@TypeOf(copy_file_range) != void) cfr: { if (w.copy_file_range_err != null) break :cfr; const buffered = limit.slice(file_reader.interface.buffer); if (io_w.end != 0 or buffered.len != 0) return drain(io_w, &.{buffered}, 1); @@ -1814,7 +1814,7 @@ pub const Writer = struct { const off_in_ptr: ?*i64 = switch (file_reader.mode) { .positional_reading, .streaming_reading => return error.Unimplemented, .positional => p: { - off_in = file_reader.pos; + off_in = @intCast(file_reader.pos); break :p &off_in; }, .streaming => null, @@ -1823,7 +1823,7 @@ pub const Writer = struct { const off_out_ptr: ?*i64 = switch (w.mode) { .positional_reading, .streaming_reading => return error.Unimplemented, .positional => p: { - off_out = w.pos; + off_out = @intCast(w.pos); break :p &off_out; }, .streaming => null, diff --git a/src/libs/freebsd.zig b/src/libs/freebsd.zig index 55d097b71b..6baa899087 100644 --- a/src/libs/freebsd.zig +++ b/src/libs/freebsd.zig @@ -497,13 +497,13 @@ pub fn buildSharedObjects(comp: *Compilation, prog_node: std.Progress.Node) anye .lt => continue, .gt => { // TODO Expose via compile error mechanism instead of log. - log.warn("invalid target FreeBSD libc version: {}", .{target_version}); + log.warn("invalid target FreeBSD libc version: {f}", .{target_version}); return error.InvalidTargetLibCVersion; }, } } else blk: { const latest_index = metadata.all_versions.len - 1; - log.warn("zig cannot build new FreeBSD libc version {}; providing instead {}", .{ + log.warn("zig cannot build new FreeBSD libc version {f}; providing instead {f}", .{ target_version, metadata.all_versions[latest_index], }); break :blk latest_index; diff --git a/src/libs/glibc.zig b/src/libs/glibc.zig index da6ee74962..43baaf38d4 100644 --- a/src/libs/glibc.zig +++ b/src/libs/glibc.zig @@ -736,13 +736,13 @@ pub fn buildSharedObjects(comp: *Compilation, prog_node: std.Progress.Node) anye .lt => continue, .gt => { // TODO Expose via compile error mechanism instead of log. - log.warn("invalid target glibc version: {}", .{target_version}); + log.warn("invalid target glibc version: {f}", .{target_version}); return error.InvalidTargetGLibCVersion; }, } } else blk: { const latest_index = metadata.all_versions.len - 1; - log.warn("zig cannot build new glibc version {}; providing instead {}", .{ + log.warn("zig cannot build new glibc version {f}; providing instead {f}", .{ target_version, metadata.all_versions[latest_index], }); break :blk latest_index; diff --git a/src/libs/netbsd.zig b/src/libs/netbsd.zig index 38570c43a6..094165b9c5 100644 --- a/src/libs/netbsd.zig +++ b/src/libs/netbsd.zig @@ -442,13 +442,13 @@ pub fn buildSharedObjects(comp: *Compilation, prog_node: std.Progress.Node) anye .lt => continue, .gt => { // TODO Expose via compile error mechanism instead of log. - log.warn("invalid target NetBSD libc version: {}", .{target_version}); + log.warn("invalid target NetBSD libc version: {f}", .{target_version}); return error.InvalidTargetLibCVersion; }, } } else blk: { const latest_index = metadata.all_versions.len - 1; - log.warn("zig cannot build new NetBSD libc version {}; providing instead {}", .{ + log.warn("zig cannot build new NetBSD libc version {f}; providing instead {f}", .{ target_version, metadata.all_versions[latest_index], }); break :blk latest_index; diff --git a/src/link/Lld.zig b/src/link/Lld.zig index aa3d057ce6..1aeeb5d214 100644 --- a/src/link/Lld.zig +++ b/src/link/Lld.zig @@ -294,7 +294,7 @@ fn linkAsArchive(lld: *Lld, arena: Allocator) !void { break :p try comp.resolveEmitPathFlush(arena, .temp, base.zcu_object_basename.?); } else null; - log.debug("zcu_obj_path={?}", .{zcu_obj_path}); + log.debug("zcu_obj_path={?f}", .{zcu_obj_path}); const compiler_rt_path: ?Cache.Path = if (comp.compiler_rt_strat == .obj) comp.compiler_rt_obj.?.full_object_path diff --git a/src/translate_c.zig b/src/translate_c.zig index 3e6e161393..301e0a219d 100644 --- a/src/translate_c.zig +++ b/src/translate_c.zig @@ -3327,7 +3327,7 @@ fn transConstantExpr(c: *Context, scope: *Scope, expr: *const clang.Expr, used: return maybeSuppressResult(c, used, as_node); }, else => |kind| { - return fail(c, error.UnsupportedTranslation, expr.getBeginLoc(), "unsupported constant expression kind '{f}'", .{kind}); + return fail(c, error.UnsupportedTranslation, expr.getBeginLoc(), "unsupported constant expression kind '{}'", .{kind}); }, } } @@ -5884,9 +5884,9 @@ fn escapeUnprintables(ctx: *Context, m: *MacroCtx) ![]const u8 { if (std.unicode.utf8ValidateSlice(zigified)) return zigified; const formatter = std.ascii.hexEscape(zigified, .lower); - const encoded_size = @as(usize, @intCast(std.fmt.count("{fs}", .{formatter}))); + const encoded_size: usize = @intCast(std.fmt.count("{f}", .{formatter})); const output = try ctx.arena.alloc(u8, encoded_size); - return std.fmt.bufPrint(output, "{fs}", .{formatter}) catch |err| switch (err) { + return std.fmt.bufPrint(output, "{f}", .{formatter}) catch |err| switch (err) { error.NoSpaceLeft => unreachable, else => |e| return e, };