authorgravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2022-08-20 17:34:34+02:00
committergravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2022-08-20 19:41:23+02:00
log4a98385b0aa3808ab05a1ebfbc90fd0bcd97c0d9
treeb56c8c5ade284425e275733a963dc636ece63a55
parente5e6eb983159df0a089e7d1c8efcea9006e253a9

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.

1 files changed, 6 insertions(+), 6 deletions(-)

src/link/MachO.zig+6-6
......@@ -273,7 +273,7 @@ pub fn openPath(allocator: Allocator, options: link.Options) !*MachO {
273273 assert(options.target.ofmt == .macho);
274274
275275 const use_stage1 = build_options.have_stage1 and options.use_stage1;
276 if (use_stage1 or options.emit == null) {
276 if (use_stage1 or options.emit == null or options.module == null) {
277277 return createEmpty(allocator, options);
278278 }
279279
......@@ -293,11 +293,11 @@ pub fn openPath(allocator: Allocator, options: link.Options) !*MachO {
293293 });
294294 }
295295
296 if (options.output_mode == .Lib and
297 options.link_mode == .Static and self.base.intermediary_basename != null)
298 {
299 return self;
300 }
296 if (self.base.intermediary_basename != null) switch (options.output_mode) {
297 .Obj => return self,
298 .Lib => if (options.link_mode == .Static) return self,
299 else => {},
300 };
301301
302302 const file = try emit.directory.handle.createFile(emit.sub_path, .{
303303 .truncate = false,