Commit 873bcb5aa6

Andrew Kelley <andrew@ziglang.org>
2025-10-22 14:01:37
fix some std.Io compilation failures
1 parent 0321524
Changed files (2)
lib
compiler
test
standalone
child_process
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.? }),
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 });