diff options
| author | Jakub Konka <kubkon@jakubkonka.com> | 2023-11-07 03:22:14 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-11-07 03:22:14 +0100 |
| commit | bf0387b6bb9c65c30f14e699a2f2cfbfea27184e (patch) | |
| tree | c0d68c1f225ed91cc900475958d1c125ae3239fb /src/Compilation.zig | |
| parent | 234693bcbba6f55ff6e975ddbedf0fad4dfaa8f1 (diff) | |
| parent | 261db02018c71e8977d2bf2a78d495cc31abd1bc (diff) | |
| download | zig-bf0387b6bb9c65c30f14e699a2f2cfbfea27184e.tar.gz zig-bf0387b6bb9c65c30f14e699a2f2cfbfea27184e.zip | |
Merge pull request #17873 from ziglang/elf-archive
elf: implement archiving input object files
Diffstat (limited to 'src/Compilation.zig')
| -rw-r--r-- | src/Compilation.zig | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/src/Compilation.zig b/src/Compilation.zig index c2a48f57ff..c8618154d9 100644 --- a/src/Compilation.zig +++ b/src/Compilation.zig @@ -2304,10 +2304,16 @@ pub fn update(comp: *Compilation, main_progress_node: *std.Progress.Node) !void defer comp.gpa.free(o_sub_path); // Work around windows `AccessDenied` if any files within this directory are open - // by doing the makeExecutable/makeWritable dance. + // by closing and reopening the file handles. const need_writable_dance = builtin.os.tag == .windows and comp.bin_file.file != null; if (need_writable_dance) { - try comp.bin_file.makeExecutable(); + // We cannot just call `makeExecutable` as it makes a false assumption that we have a + // file handle open only when linking an executable file. This used to be true when + // our linkers were incapable of emitting relocatables and static archive. Now that + // they are capable, we need to unconditionally close the file handle and re-open it + // in the follow up call to `makeWritable`. + comp.bin_file.file.?.close(); + comp.bin_file.file = null; } try comp.bin_file.renameTmpIntoCache(comp.local_cache_directory, tmp_dir_sub_path, o_sub_path); |
