zig

fork of https://codeberg.org/ziglang/zig
Log | Files | Refs | README | LICENSE

commit 4a98385b0aa3808ab05a1ebfbc90fd0bcd97c0d9 (tree)
parent e5e6eb983159df0a089e7d1c8efcea9006e253a9
Author: Jakub Konka <kubkon@jakubkonka.com>
Date:   Sat, 20 Aug 2022 17:34:34 +0200

macho: do not leave file descriptors open if unused

This manifested in different `AccessDenied` errors on Windows when
trying to do an atomic file copying in the compiler/linker.

Diffstat:
Msrc/link/MachO.zig | 12++++++------
1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/link/MachO.zig b/src/link/MachO.zig @@ -273,7 +273,7 @@ pub fn openPath(allocator: Allocator, options: link.Options) !*MachO { assert(options.target.ofmt == .macho); const use_stage1 = build_options.have_stage1 and options.use_stage1; - if (use_stage1 or options.emit == null) { + if (use_stage1 or options.emit == null or options.module == null) { return createEmpty(allocator, options); } @@ -293,11 +293,11 @@ pub fn openPath(allocator: Allocator, options: link.Options) !*MachO { }); } - if (options.output_mode == .Lib and - options.link_mode == .Static and self.base.intermediary_basename != null) - { - return self; - } + if (self.base.intermediary_basename != null) switch (options.output_mode) { + .Obj => return self, + .Lib => if (options.link_mode == .Static) return self, + else => {}, + }; const file = try emit.directory.handle.createFile(emit.sub_path, .{ .truncate = false,