authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2026-09-14 18:48:12-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2026-09-16 13:12:47-07:00
log28feeaf77818c801bac4f7959ace39af5bdc40a5
tree051fdda941e95d2a0a5478412a0cf7f222716fff
parent7911f377441a1717ac1ab82933af826926b29ff7

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.

2 files changed, 10 insertions(+), 5 deletions(-)

lib/std/Build/Cache.zig+2
......@@ -650,8 +650,10 @@ pub const Manifest = struct {
650650 };
651651
652652 pub const AddInputPathOptions = struct {
653 /// If provided, will be closed when `check` is called, unless `request_handle` is also set.
653654 handle: PathHandle = .{ .file = null },
654655 stat: ?Stat = null,
656 /// If set, file handle will remain open after `check` is called.
655657 request_handle: bool = false,
656658 /// Can request file or directory contents depending on `handle`.
657659 request_contents: bool = false,
src/link.zig+8-5
......@@ -1500,11 +1500,11 @@ pub fn doPrelinkTask(comp: *Compilation, task: PrelinkTask) void {
15001500 base.loadInput(input) catch |err| switch (err) {
15011501 error.AlreadyReported => return, // error reported via diags
15021502 else => |e| switch (input) {
1503 .dso => |dso| diags.addParseError(dso.path, "failed to parse shared library: {s}", .{@errorName(e)}),
1504 .object => |obj| diags.addParseError(obj.path, "failed to parse object: {s}", .{@errorName(e)}),
1505 .archive => |obj| diags.addParseError(obj.path, "failed to parse archive: {s}", .{@errorName(e)}),
1506 .res => |res| diags.addParseError(res.path, "failed to parse Windows resource: {s}", .{@errorName(e)}),
1507 .dso_exact => diags.addError("failed to handle dso_exact: {s}", .{@errorName(e)}),
1503 .dso => |dso| diags.addParseError(dso.path, "failed to parse shared library: {t}", .{e}),
1504 .object => |obj| diags.addParseError(obj.path, "failed to parse object: {t}", .{e}),
1505 .archive => |obj| diags.addParseError(obj.path, "failed to parse archive: {t}", .{e}),
1506 .res => |res| diags.addParseError(res.path, "failed to parse Windows resource: {t}", .{e}),
1507 .dso_exact => diags.addError("failed to handle dso_exact: {t}", .{e}),
15081508 },
15091509 };
15101510 prog_node.completeOne();
......@@ -1927,6 +1927,7 @@ pub fn hashInputs(man: *Cache.Manifest, link_inputs: []const Input) !void {
19271927 .object, .archive => |obj| {
19281928 _ = try man.addInputPath(obj.path, .{
19291929 .handle = .{ .file = obj.file },
1930 .request_handle = true,
19301931 });
19311932 man.hash.add(obj.must_link);
19321933 man.hash.add(obj.hidden);
......@@ -1934,11 +1935,13 @@ pub fn hashInputs(man: *Cache.Manifest, link_inputs: []const Input) !void {
19341935 .res => |res| {
19351936 _ = try man.addInputPath(res.path, .{
19361937 .handle = .{ .file = res.file },
1938 .request_handle = true,
19371939 });
19381940 },
19391941 .dso => |dso| {
19401942 _ = try man.addInputPath(dso.path, .{
19411943 .handle = .{ .file = dso.file },
1944 .request_handle = true,
19421945 });
19431946 man.hash.add(dso.needed);
19441947 man.hash.add(dso.weak);