diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2022-10-17 16:54:52 -0700 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2022-10-18 16:52:43 -0700 |
| commit | cb635e084b0c36e3c7a6bf63f49f7e7e9918532d (patch) | |
| tree | 92d53f835566b630fd39f44a5e8c8ef9b3339add /src/link.zig | |
| parent | 9ee4530b9b38805f88a1e3df4b4b74db240f05df (diff) | |
| download | zig-cb635e084b0c36e3c7a6bf63f49f7e7e9918532d.tar.gz zig-cb635e084b0c36e3c7a6bf63f49f7e7e9918532d.zip | |
stage2: better handling of CacheMode.whole on Windows
Windows gives AccessDenied if you delete a directory which contains open
file handles. This could be triggered when using CacheMode.whole when
cross compiling macho test binaries.
Diffstat (limited to 'src/link.zig')
| -rw-r--r-- | src/link.zig | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/src/link.zig b/src/link.zig index 0b6ffa8bf4..1b5ce2246b 100644 --- a/src/link.zig +++ b/src/link.zig @@ -403,10 +403,8 @@ pub const File = struct { try emit.directory.handle.copyFile(emit.sub_path, emit.directory.handle, emit.sub_path, .{}); } } - if (base.intermediary_basename == null) { - f.close(); - base.file = null; - } + f.close(); + base.file = null; }, .coff, .elf, .plan9, .wasm => if (base.file) |f| { if (base.intermediary_basename != null) { @@ -777,7 +775,7 @@ pub const File = struct { _ = base; while (true) { if (builtin.os.tag == .windows) { - // workaround windows `renameW` can't fail with `PathAlreadyExists` + // Work around windows `renameW` can't fail with `PathAlreadyExists` // See https://github.com/ziglang/zig/issues/8362 if (cache_directory.handle.access(o_sub_path, .{})) |_| { try cache_directory.handle.deleteTree(o_sub_path); @@ -791,9 +789,9 @@ pub const File = struct { tmp_dir_sub_path, cache_directory.handle, o_sub_path, - ) catch |err| switch (err) { - error.AccessDenied => unreachable, // We are most likely trying to move a dir with open handles to its resources - else => |e| return e, + ) catch |err| { + log.err("unable to rename cache dir {s} to {s}: {s}", .{ tmp_dir_sub_path, o_sub_path, @errorName(err) }); + return err; }; break; } else { |
