aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJacob Young <jacobly0@users.noreply.github.com>2025-10-09 15:22:14 -0400
committerAndrew Kelley <andrew@ziglang.org>2025-10-10 22:47:36 -0700
commitb2bc6073c8ada065906da9e3b5a4a2e7db04c21d (patch)
treeddaba6a7a70c69ae72bad8c6c5644596e427040c /src
parentc17e18647bf55bae38a1837a6afb19b0f2393892 (diff)
downloadzig-b2bc6073c8ada065906da9e3b5a4a2e7db04c21d.tar.gz
zig-b2bc6073c8ada065906da9e3b5a4a2e7db04c21d.zip
windows: workaround kernel race condition
This was causing flaky CI failures.
Diffstat (limited to 'src')
-rw-r--r--src/link.zig14
1 files changed, 12 insertions, 2 deletions
diff --git a/src/link.zig b/src/link.zig
index 1cf54f531c..9edd58109c 100644
--- a/src/link.zig
+++ b/src/link.zig
@@ -616,9 +616,19 @@ pub const File = struct {
&coff.mf
else
unreachable;
- mf.file = try base.emit.root_dir.handle.openFile(base.emit.sub_path, .{
+ mf.file = for (0..2) |_| break base.emit.root_dir.handle.openFile(base.emit.sub_path, .{
.mode = .read_write,
- });
+ }) catch |err| switch (err) {
+ error.AccessDenied => switch (builtin.os.tag) {
+ .windows => {
+ // give the kernel a chance to finish closing the executable handle
+ std.os.windows.kernel32.Sleep(0);
+ continue;
+ },
+ else => return error.AccessDenied,
+ },
+ else => |e| return e,
+ } else return error.AccessDenied;
base.file = mf.file;
try mf.ensureTotalCapacity(@intCast(mf.nodes.items[0].location().resolve(mf)[1]));
},