authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2025-12-22 22:30:49-08:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2025-12-23 22:15:12-08:00
logc05e2720a1acf0dc86e7f8a2661daae095d4d59b
tree22ccfe2f346839dd867d9cc26a009c4a1617b4ae
parent7a09d579b55f942afe563b2c34b8d96c3e62c8c0

tools: fix compilation errors


8 files changed, 27 insertions(+), 25 deletions(-)

lib/compiler/objcopy.zig+11-11
...@@ -25,11 +25,15 @@ pub fn main() !void {...@@ -25,11 +25,15 @@ pub fn main() !void {
25 var general_purpose_allocator: std.heap.GeneralPurposeAllocator(.{}) = .init;25 var general_purpose_allocator: std.heap.GeneralPurposeAllocator(.{}) = .init;
26 const gpa = general_purpose_allocator.allocator();26 const gpa = general_purpose_allocator.allocator();
2727
28 var threaded: std.Io.Threaded = .init(gpa, .{});
29 defer threaded.deinit();
30 const io = threaded.io();
31
28 const args = try std.process.argsAlloc(arena);32 const args = try std.process.argsAlloc(arena);
29 return cmdObjCopy(gpa, arena, args[1..]);33 return cmdObjCopy(arena, io, args[1..]);
30}34}
3135
32fn cmdObjCopy(gpa: Allocator, arena: Allocator, args: []const []const u8) !void {36fn cmdObjCopy(arena: Allocator, io: Io, args: []const []const u8) !void {
33 var i: usize = 0;37 var i: usize = 0;
34 var opt_out_fmt: ?std.Target.ObjectFormat = null;38 var opt_out_fmt: ?std.Target.ObjectFormat = null;
35 var opt_input: ?[]const u8 = null;39 var opt_input: ?[]const u8 = null;
...@@ -57,7 +61,7 @@ fn cmdObjCopy(gpa: Allocator, arena: Allocator, args: []const []const u8) !void...@@ -57,7 +61,7 @@ fn cmdObjCopy(gpa: Allocator, arena: Allocator, args: []const []const u8) !void
57 fatal("unexpected positional argument: '{s}'", .{arg});61 fatal("unexpected positional argument: '{s}'", .{arg});
58 }62 }
59 } else if (mem.eql(u8, arg, "-h") or mem.eql(u8, arg, "--help")) {63 } else if (mem.eql(u8, arg, "-h") or mem.eql(u8, arg, "--help")) {
60 return Io.File.stdout().writeAll(usage);64 return Io.File.stdout().writeStreamingAll(io, usage);
61 } else if (mem.eql(u8, arg, "-O") or mem.eql(u8, arg, "--output-target")) {65 } else if (mem.eql(u8, arg, "-O") or mem.eql(u8, arg, "--output-target")) {
62 i += 1;66 i += 1;
63 if (i >= args.len) fatal("expected another argument after '{s}'", .{arg});67 if (i >= args.len) fatal("expected another argument after '{s}'", .{arg});
...@@ -148,11 +152,7 @@ fn cmdObjCopy(gpa: Allocator, arena: Allocator, args: []const []const u8) !void...@@ -148,11 +152,7 @@ fn cmdObjCopy(gpa: Allocator, arena: Allocator, args: []const []const u8) !void
148 const input = opt_input orelse fatal("expected input parameter", .{});152 const input = opt_input orelse fatal("expected input parameter", .{});
149 const output = opt_output orelse fatal("expected output parameter", .{});153 const output = opt_output orelse fatal("expected output parameter", .{});
150154
151 var threaded: std.Io.Threaded = .init(gpa, .{});155 const input_file = Io.Dir.cwd().openFile(io, input, .{}) catch |err| fatal("failed to open {s}: {t}", .{ input, err });
152 defer threaded.deinit();
153 const io = threaded.io();
154
155 const input_file = Io.Dir.cwd().openFile(input, .{}) catch |err| fatal("failed to open {s}: {t}", .{ input, err });
156 defer input_file.close(io);156 defer input_file.close(io);
157157
158 const stat = input_file.stat(io) catch |err| fatal("failed to stat {s}: {t}", .{ input, err });158 const stat = input_file.stat(io) catch |err| fatal("failed to stat {s}: {t}", .{ input, err });
...@@ -178,9 +178,9 @@ fn cmdObjCopy(gpa: Allocator, arena: Allocator, args: []const []const u8) !void...@@ -178,9 +178,9 @@ fn cmdObjCopy(gpa: Allocator, arena: Allocator, args: []const []const u8) !void
178 }178 }
179 };179 };
180180
181 const mode = if (out_fmt != .elf or only_keep_debug) Io.File.default_mode else stat.mode;181 const permissions: Io.File.Permissions = if (out_fmt != .elf or only_keep_debug) .default_file else stat.permissions;
182182
183 var output_file = try Io.Dir.cwd().createFile(io, output, .{ .mode = mode });183 var output_file = try Io.Dir.cwd().createFile(io, output, .{ .permissions = permissions });
184 defer output_file.close(io);184 defer output_file.close(io);
185185
186 var out = output_file.writer(io, &output_buffer);186 var out = output_file.writer(io, &output_buffer);
...@@ -223,7 +223,7 @@ fn cmdObjCopy(gpa: Allocator, arena: Allocator, args: []const []const u8) !void...@@ -223,7 +223,7 @@ fn cmdObjCopy(gpa: Allocator, arena: Allocator, args: []const []const u8) !void
223223
224 if (listen) {224 if (listen) {
225 var stdin_reader = Io.File.stdin().reader(io, &stdin_buffer);225 var stdin_reader = Io.File.stdin().reader(io, &stdin_buffer);
226 var stdout_writer = Io.File.stdout().writer(&stdout_buffer);226 var stdout_writer = Io.File.stdout().writer(io, &stdout_buffer);
227 var server = try Server.init(.{227 var server = try Server.init(.{
228 .in = &stdin_reader.interface,228 .in = &stdin_reader.interface,
229 .out = &stdout_writer.interface,229 .out = &stdout_writer.interface,
tools/dump-cov.zig+2-2
...@@ -51,8 +51,8 @@ pub fn main() !void {...@@ -51,8 +51,8 @@ pub fn main() !void {
51 var coverage: std.debug.Coverage = .init;51 var coverage: std.debug.Coverage = .init;
52 defer coverage.deinit(gpa);52 defer coverage.deinit(gpa);
5353
54 var debug_info = std.debug.Info.load(gpa, exe_path, &coverage, target.ofmt, target.cpu.arch) catch |err| {54 var debug_info = std.debug.Info.load(gpa, io, exe_path, &coverage, target.ofmt, target.cpu.arch) catch |err| {
55 fatal("failed to load debug info for {f}: {s}", .{ exe_path, @errorName(err) });55 fatal("failed to load debug info for {f}: {t}", .{ exe_path, err });
56 };56 };
57 defer debug_info.deinit(gpa);57 defer debug_info.deinit(gpa);
5858
tools/gen_spirv_spec.zig+3-2
...@@ -930,8 +930,9 @@ fn parseHexInt(text: []const u8) !u31 {...@@ -930,8 +930,9 @@ fn parseHexInt(text: []const u8) !u31 {
930}930}
931931
932fn usageAndExit(arg0: []const u8, code: u8) noreturn {932fn usageAndExit(arg0: []const u8, code: u8) noreturn {
933 const stderr, _ = std.debug.lockStderrWriter(&.{});933 const stderr = std.debug.lockStderr(&.{});
934 stderr.print(934 const w = &stderr.file_writer.interface;
935 w.print(
935 \\Usage: {s} <SPIRV-Headers repository path> <path/to/zig/src/codegen/spirv/extinst.zig.grammar.json>936 \\Usage: {s} <SPIRV-Headers repository path> <path/to/zig/src/codegen/spirv/extinst.zig.grammar.json>
936 \\937 \\
937 \\Generates Zig bindings for SPIR-V specifications found in the SPIRV-Headers938 \\Generates Zig bindings for SPIR-V specifications found in the SPIRV-Headers
tools/generate_linux_syscalls.zig+2-2
...@@ -181,8 +181,8 @@ pub fn main() !void {...@@ -181,8 +181,8 @@ pub fn main() !void {
181181
182 const args = try std.process.argsAlloc(gpa);182 const args = try std.process.argsAlloc(gpa);
183 if (args.len < 2 or mem.eql(u8, args[1], "--help")) {183 if (args.len < 2 or mem.eql(u8, args[1], "--help")) {
184 const w, _ = std.debug.lockStderrWriter(&.{});184 const stderr = std.debug.lockStderr(&.{});
185 defer std.debug.unlockStderrWriter();185 const w = &stderr.file_writer.interface;
186 usage(w, args[0]) catch std.process.exit(2);186 usage(w, args[0]) catch std.process.exit(2);
187 std.process.exit(1);187 std.process.exit(1);
188 }188 }
tools/update-linux-headers.zig+2-2
...@@ -197,7 +197,7 @@ pub fn main() !void {...@@ -197,7 +197,7 @@ pub fn main() !void {
197 try dir_stack.append(target_include_dir);197 try dir_stack.append(target_include_dir);
198198
199 while (dir_stack.pop()) |full_dir_name| {199 while (dir_stack.pop()) |full_dir_name| {
200 var dir = Dir.cwd().openDir(full_dir_name, .{ .iterate = true }) catch |err| switch (err) {200 var dir = Dir.cwd().openDir(io, full_dir_name, .{ .iterate = true }) catch |err| switch (err) {
201 error.FileNotFound => continue :search,201 error.FileNotFound => continue :search,
202 error.AccessDenied => continue :search,202 error.AccessDenied => continue :search,
203 else => return err,203 else => return err,
...@@ -213,7 +213,7 @@ pub fn main() !void {...@@ -213,7 +213,7 @@ pub fn main() !void {
213 .file => {213 .file => {
214 const rel_path = try Dir.path.relative(arena, target_include_dir, full_path);214 const rel_path = try Dir.path.relative(arena, target_include_dir, full_path);
215 const max_size = 2 * 1024 * 1024 * 1024;215 const max_size = 2 * 1024 * 1024 * 1024;
216 const raw_bytes = try Dir.cwd().readFileAlloc(full_path, arena, .limited(max_size));216 const raw_bytes = try Dir.cwd().readFileAlloc(io, full_path, arena, .limited(max_size));
217 const trimmed = std.mem.trim(u8, raw_bytes, " \r\n\t");217 const trimmed = std.mem.trim(u8, raw_bytes, " \r\n\t");
218 total_bytes += raw_bytes.len;218 total_bytes += raw_bytes.len;
219 const hash = try arena.alloc(u8, 32);219 const hash = try arena.alloc(u8, 32);
tools/update_clang_options.zig+2-2
...@@ -961,8 +961,8 @@ fn objectLessThan(context: void, a: *json.ObjectMap, b: *json.ObjectMap) bool {...@@ -961,8 +961,8 @@ fn objectLessThan(context: void, a: *json.ObjectMap, b: *json.ObjectMap) bool {
961}961}
962962
963fn printUsageAndExit(arg0: []const u8) noreturn {963fn printUsageAndExit(arg0: []const u8) noreturn {
964 const w, _ = std.debug.lockStderrWriter(&.{});964 const stderr = std.debug.lockStderr(&.{});
965 defer std.debug.unlockStderrWriter();965 const w = &stderr.file_writer.interface;
966 printUsage(w, arg0) catch std.process.exit(2);966 printUsage(w, arg0) catch std.process.exit(2);
967 std.process.exit(1);967 std.process.exit(1);
968}968}
tools/update_cpu_features.zig+3-2
...@@ -2426,8 +2426,9 @@ fn processOneTarget(io: Io, job: Job) void {...@@ -2426,8 +2426,9 @@ fn processOneTarget(io: Io, job: Job) void {
2426}2426}
24272427
2428fn usageAndExit(arg0: []const u8, code: u8) noreturn {2428fn usageAndExit(arg0: []const u8, code: u8) noreturn {
2429 const stderr, _ = std.debug.lockStderrWriter(&.{});2429 const stderr = std.debug.lockStderr(&.{});
2430 stderr.print(2430 const w = &stderr.file_writer.interface;
2431 w.print(
2431 \\Usage: {s} /path/to/llvm-tblgen /path/git/llvm-project /path/git/zig [zig_name filter]2432 \\Usage: {s} /path/to/llvm-tblgen /path/git/llvm-project /path/git/zig [zig_name filter]
2432 \\2433 \\
2433 \\Updates lib/std/target/<target>.zig from llvm/lib/Target/<Target>/<Target>.td .2434 \\Updates lib/std/target/<target>.zig from llvm/lib/Target/<Target>/<Target>.td .
tools/update_crc_catalog.zig+2-2
...@@ -195,8 +195,8 @@ pub fn main() anyerror!void {...@@ -195,8 +195,8 @@ pub fn main() anyerror!void {
195}195}
196196
197fn printUsageAndExit(arg0: []const u8) noreturn {197fn printUsageAndExit(arg0: []const u8) noreturn {
198 const w, _ = std.debug.lockStderrWriter(&.{});198 const stderr = std.debug.lockStderr(&.{});
199 defer std.debug.unlockStderrWriter();199 const w = &stderr.file_writer.interface;
200 printUsage(w, arg0) catch std.process.exit(2);200 printUsage(w, arg0) catch std.process.exit(2);
201 std.process.exit(1);201 std.process.exit(1);
202}202}