authorgravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2022-04-15 21:26:55+02:00
committergravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2022-04-16 12:06:58+02:00
log88d87d65061e7ac171cc23623a25e05b0278a872
tree1a5634cbfd88f74bee18082e36619ed15e004a37
parent4c83b11f71564e0de80f496f471ca6dfb83a95e3

stage2,macho: swap out inodes before checking for intermediary basename

This way we avoid the infamous SIGKILL on arm64 macos.

2 files changed, 7 insertions(+), 9 deletions(-)

src/link.zig+4-7
......@@ -352,11 +352,6 @@ pub const File = struct {
352352 }
353353 switch (base.tag) {
354354 .macho => if (base.file) |f| {
355 if (base.intermediary_basename != null) {
356 // The file we have open is not the final file that we want to
357 // make executable, so we don't have to close it.
358 return;
359 }
360355 if (comptime builtin.target.isDarwin() and builtin.target.cpu.arch == .aarch64) {
361356 if (base.options.target.cpu.arch == .aarch64) {
362357 // XNU starting with Big Sur running on arm64 is caching inodes of running binaries.
......@@ -371,8 +366,10 @@ pub const File = struct {
371366 try emit.directory.handle.copyFile(emit.sub_path, emit.directory.handle, emit.sub_path, .{});
372367 }
373368 }
374 f.close();
375 base.file = null;
369 if (base.intermediary_basename == null) {
370 f.close();
371 base.file = null;
372 }
376373 },
377374 .coff, .elf, .plan9 => if (base.file) |f| {
378375 if (base.intermediary_basename != null) {
src/link/MachO.zig+3-2
......@@ -423,7 +423,7 @@ pub fn flush(self: *MachO, comp: *Compilation) !void {
423423 if (self.base.options.emit == null) {
424424 if (build_options.have_llvm) {
425425 if (self.llvm_object) |llvm_object| {
426 return try llvm_object.flushModule(comp);
426 try llvm_object.flushModule(comp);
427427 }
428428 }
429429 return;
......@@ -1116,7 +1116,8 @@ pub fn flushObject(self: *MachO, comp: *Compilation) !void {
11161116 defer tracy.end();
11171117
11181118 if (build_options.have_llvm)
1119 if (self.llvm_object) |llvm_object| return llvm_object.flushModule(comp);
1119 if (self.llvm_object) |llvm_object|
1120 return llvm_object.flushModule(comp);
11201121
11211122 return error.TODOImplementWritingObjFiles;
11221123}