| ... | ... | @@ -2295,10 +2295,16 @@ pub fn update(comp: *Compilation, main_progress_node: *std.Progress.Node) !void |
| 2295 | 2295 | defer comp.gpa.free(o_sub_path); |
| 2296 | 2296 | |
| 2297 | 2297 | // Work around windows `AccessDenied` if any files within this directory are open |
| 2298 | | // by doing the makeExecutable/makeWritable dance. |
| 2298 | // by closing and reopening the file handles. |
| 2299 | 2299 | const need_writable_dance = builtin.os.tag == .windows and comp.bin_file.file != null; |
| 2300 | 2300 | if (need_writable_dance) { |
| 2301 | | try comp.bin_file.makeExecutable(); |
| 2301 | // We cannot just call `makeExecutable` as it makes a false assumption that we have a |
| 2302 | // file handle open only when linking an executable file. This used to be true when |
| 2303 | // our linkers were incapable of emitting relocatables and static archive. Now that |
| 2304 | // they are capable, we need to unconditionally close the file handle and re-open it |
| 2305 | // in the follow up call to `makeWritable`. |
| 2306 | comp.bin_file.file.?.close(); |
| 2307 | comp.bin_file.file = null; |
| 2302 | 2308 | } |
| 2303 | 2309 | |
| 2304 | 2310 | try comp.bin_file.renameTmpIntoCache(comp.local_cache_directory, tmp_dir_sub_path, o_sub_path); |