From 639237c7b4655d7d4c38c24d9b36a145bbfb1e1c Mon Sep 17 00:00:00 2001 From: Jakub Konka Date: Wed, 7 Sep 2022 16:10:19 +0200 Subject: [PATCH] macho: set file instance in linkOneShot only if not already set --- src/link/MachO.zig | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/link/MachO.zig b/src/link/MachO.zig index bceaa55d8a..e1392d8903 100644 --- a/src/link/MachO.zig +++ b/src/link/MachO.zig @@ -793,11 +793,13 @@ fn linkOneShot(self: *MachO, comp: *Compilation, prog_node: *std.Progress.Node) } } else { const sub_path = self.base.options.emit.?.sub_path; - self.base.file = try directory.handle.createFile(sub_path, .{ - .truncate = true, - .read = true, - .mode = link.determineMode(self.base.options), - }); + if (self.base.file == null) { + self.base.file = try directory.handle.createFile(sub_path, .{ + .truncate = true, + .read = true, + .mode = link.determineMode(self.base.options), + }); + } // Index 0 is always a null symbol. try self.locals.append(gpa, .{ .n_strx = 0,