From 28feeaf77818c801bac4f7959ace39af5bdc40a5 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Mon, 14 Sep 2026 18:48:12 -0700 Subject: [PATCH] link: pass request_handle=true to addInputPath when passing already open handle, this is now required when the caller wants the cache system to keep the file handle open. --- lib/std/Build/Cache.zig | 2 ++ src/link.zig | 13 ++++++++----- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/lib/std/Build/Cache.zig b/lib/std/Build/Cache.zig index 9bb44df1a6aa0560e39382642f136de519f6e751..88fb82d74456fd011581463557d4eb66f5a03c66 100644 --- a/lib/std/Build/Cache.zig +++ b/lib/std/Build/Cache.zig @@ -650,8 +650,10 @@ pub const Manifest = struct { }; pub const AddInputPathOptions = struct { + /// If provided, will be closed when `check` is called, unless `request_handle` is also set. handle: PathHandle = .{ .file = null }, stat: ?Stat = null, + /// If set, file handle will remain open after `check` is called. request_handle: bool = false, /// Can request file or directory contents depending on `handle`. request_contents: bool = false, diff --git a/src/link.zig b/src/link.zig index df68e0216d3f20ab09837c55f849461c30fbd5a4..c97c752517928551c1753933a9c512417cb9e434 100644 --- a/src/link.zig +++ b/src/link.zig @@ -1500,11 +1500,11 @@ pub fn doPrelinkTask(comp: *Compilation, task: PrelinkTask) void { base.loadInput(input) catch |err| switch (err) { error.AlreadyReported => return, // error reported via diags else => |e| switch (input) { - .dso => |dso| diags.addParseError(dso.path, "failed to parse shared library: {s}", .{@errorName(e)}), - .object => |obj| diags.addParseError(obj.path, "failed to parse object: {s}", .{@errorName(e)}), - .archive => |obj| diags.addParseError(obj.path, "failed to parse archive: {s}", .{@errorName(e)}), - .res => |res| diags.addParseError(res.path, "failed to parse Windows resource: {s}", .{@errorName(e)}), - .dso_exact => diags.addError("failed to handle dso_exact: {s}", .{@errorName(e)}), + .dso => |dso| diags.addParseError(dso.path, "failed to parse shared library: {t}", .{e}), + .object => |obj| diags.addParseError(obj.path, "failed to parse object: {t}", .{e}), + .archive => |obj| diags.addParseError(obj.path, "failed to parse archive: {t}", .{e}), + .res => |res| diags.addParseError(res.path, "failed to parse Windows resource: {t}", .{e}), + .dso_exact => diags.addError("failed to handle dso_exact: {t}", .{e}), }, }; prog_node.completeOne(); @@ -1927,6 +1927,7 @@ pub fn hashInputs(man: *Cache.Manifest, link_inputs: []const Input) !void { .object, .archive => |obj| { _ = try man.addInputPath(obj.path, .{ .handle = .{ .file = obj.file }, + .request_handle = true, }); man.hash.add(obj.must_link); man.hash.add(obj.hidden); @@ -1934,11 +1935,13 @@ pub fn hashInputs(man: *Cache.Manifest, link_inputs: []const Input) !void { .res => |res| { _ = try man.addInputPath(res.path, .{ .handle = .{ .file = res.file }, + .request_handle = true, }); }, .dso => |dso| { _ = try man.addInputPath(dso.path, .{ .handle = .{ .file = dso.file }, + .request_handle = true, }); man.hash.add(dso.needed); man.hash.add(dso.weak); -- 2.54.0