From 873bcb5aa66fd4fdd747b90ba0ed529117478368 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Wed, 22 Oct 2025 05:01:37 -0700 Subject: [PATCH] fix some std.Io compilation failures --- lib/compiler/objcopy.zig | 7 +++++-- test/standalone/child_process/main.zig | 6 +++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/lib/compiler/objcopy.zig b/lib/compiler/objcopy.zig index 5908f8b73d..3e8c4a508a 100644 --- a/lib/compiler/objcopy.zig +++ b/lib/compiler/objcopy.zig @@ -29,7 +29,6 @@ pub fn main() !void { } fn cmdObjCopy(gpa: Allocator, arena: Allocator, args: []const []const u8) !void { - _ = gpa; var i: usize = 0; var opt_out_fmt: ?std.Target.ObjectFormat = null; var opt_input: ?[]const u8 = null; @@ -148,12 +147,16 @@ fn cmdObjCopy(gpa: Allocator, arena: Allocator, args: []const []const u8) !void const input = opt_input orelse fatal("expected input parameter", .{}); const output = opt_output orelse fatal("expected output parameter", .{}); + var threaded: std.Io.Threaded = .init(gpa); + defer threaded.deinit(); + const io = threaded.io(); + const input_file = fs.cwd().openFile(input, .{}) catch |err| fatal("failed to open {s}: {t}", .{ input, err }); defer input_file.close(); const stat = input_file.stat() catch |err| fatal("failed to stat {s}: {t}", .{ input, err }); - var in: File.Reader = .initSize(input_file, &input_buffer, stat.size); + var in: File.Reader = .initSize(input_file, io, &input_buffer, stat.size); const elf_hdr = std.elf.Header.read(&in.interface) catch |err| switch (err) { error.ReadFailed => fatal("unable to read {s}: {t}", .{ input, in.err.? }), diff --git a/test/standalone/child_process/main.zig b/test/standalone/child_process/main.zig index 4be5e1fec3..5970cdd952 100644 --- a/test/standalone/child_process/main.zig +++ b/test/standalone/child_process/main.zig @@ -20,6 +20,10 @@ pub fn main() !void { }; defer if (needs_free) gpa.free(child_path); + var threaded: std.Io.Threaded = .init(gpa); + defer threaded.deinit(); + const io = threaded.io(); + var child = std.process.Child.init(&.{ child_path, "hello arg" }, gpa); child.stdin_behavior = .Pipe; child.stdout_behavior = .Pipe; @@ -32,7 +36,7 @@ pub fn main() !void { const hello_stdout = "hello from stdout"; var buf: [hello_stdout.len]u8 = undefined; - var stdout_reader = child.stdout.?.readerStreaming(&.{}); + var stdout_reader = child.stdout.?.readerStreaming(io, &.{}); const n = try stdout_reader.interface.readSliceShort(&buf); if (!std.mem.eql(u8, buf[0..n], hello_stdout)) { testError("child stdout: '{s}'; want '{s}'", .{ buf[0..n], hello_stdout });