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 {...@@ -650,8 +650,10 @@ pub const Manifest = struct {
650 };650 };
651651
652 pub const AddInputPathOptions = struct {652 pub const AddInputPathOptions = struct {
653 /// If provided, will be closed when `check` is called, unless `request_handle` is also set.
653 handle: PathHandle = .{ .file = null },654 handle: PathHandle = .{ .file = null },
654 stat: ?Stat = null,655 stat: ?Stat = null,
656 /// If set, file handle will remain open after `check` is called.
655 request_handle: bool = false,657 request_handle: bool = false,
656 /// Can request file or directory contents depending on `handle`.658 /// Can request file or directory contents depending on `handle`.
657 request_contents: bool = false,659 request_contents: bool = false,
src/link.zig+8-5
...@@ -1500,11 +1500,11 @@ pub fn doPrelinkTask(comp: *Compilation, task: PrelinkTask) void {...@@ -1500,11 +1500,11 @@ pub fn doPrelinkTask(comp: *Compilation, task: PrelinkTask) void {
1500 base.loadInput(input) catch |err| switch (err) {1500 base.loadInput(input) catch |err| switch (err) {
1501 error.AlreadyReported => return, // error reported via diags1501 error.AlreadyReported => return, // error reported via diags
1502 else => |e| switch (input) {1502 else => |e| switch (input) {
1503 .dso => |dso| diags.addParseError(dso.path, "failed to parse shared library: {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: {s}", .{@errorName(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: {s}", .{@errorName(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: {s}", .{@errorName(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: {s}", .{@errorName(e)}),1507 .dso_exact => diags.addError("failed to handle dso_exact: {t}", .{e}),
1508 },1508 },
1509 };1509 };
1510 prog_node.completeOne();1510 prog_node.completeOne();
...@@ -1927,6 +1927,7 @@ pub fn hashInputs(man: *Cache.Manifest, link_inputs: []const Input) !void {...@@ -1927,6 +1927,7 @@ pub fn hashInputs(man: *Cache.Manifest, link_inputs: []const Input) !void {
1927 .object, .archive => |obj| {1927 .object, .archive => |obj| {
1928 _ = try man.addInputPath(obj.path, .{1928 _ = try man.addInputPath(obj.path, .{
1929 .handle = .{ .file = obj.file },1929 .handle = .{ .file = obj.file },
1930 .request_handle = true,
1930 });1931 });
1931 man.hash.add(obj.must_link);1932 man.hash.add(obj.must_link);
1932 man.hash.add(obj.hidden);1933 man.hash.add(obj.hidden);
...@@ -1934,11 +1935,13 @@ pub fn hashInputs(man: *Cache.Manifest, link_inputs: []const Input) !void {...@@ -1934,11 +1935,13 @@ pub fn hashInputs(man: *Cache.Manifest, link_inputs: []const Input) !void {
1934 .res => |res| {1935 .res => |res| {
1935 _ = try man.addInputPath(res.path, .{1936 _ = try man.addInputPath(res.path, .{
1936 .handle = .{ .file = res.file },1937 .handle = .{ .file = res.file },
1938 .request_handle = true,
1937 });1939 });
1938 },1940 },
1939 .dso => |dso| {1941 .dso => |dso| {
1940 _ = try man.addInputPath(dso.path, .{1942 _ = try man.addInputPath(dso.path, .{
1941 .handle = .{ .file = dso.file },1943 .handle = .{ .file = dso.file },
1944 .request_handle = true,
1942 });1945 });
1943 man.hash.add(dso.needed);1946 man.hash.add(dso.needed);
1944 man.hash.add(dso.weak);1947 man.hash.add(dso.weak);