| ... | ... | @@ -436,7 +436,7 @@ pub fn flush(self: *MachO, comp: *Compilation, prog_node: *std.Progress.Node) !v |
| 436 | 436 | return error.TODOImplementWritingStaticLibFiles; |
| 437 | 437 | } |
| 438 | 438 | } |
| 439 | | try self.flushModule(comp, prog_node); |
| 439 | return self.flushModule(comp, prog_node); |
| 440 | 440 | } |
| 441 | 441 | |
| 442 | 442 | pub fn flushModule(self: *MachO, comp: *Compilation, prog_node: *std.Progress.Node) !void { |
| ... | ... | @@ -444,8 +444,19 @@ pub fn flushModule(self: *MachO, comp: *Compilation, prog_node: *std.Progress.No |
| 444 | 444 | defer tracy.end(); |
| 445 | 445 | |
| 446 | 446 | const use_stage1 = build_options.is_stage1 and self.base.options.use_stage1; |
| 447 | | if (!use_stage1 and self.base.options.output_mode == .Obj) |
| 448 | | return self.flushObject(comp, prog_node); |
| 447 | |
| 448 | if (build_options.have_llvm and !use_stage1) { |
| 449 | if (self.llvm_object) |llvm_object| { |
| 450 | try llvm_object.flushModule(comp, prog_node); |
| 451 | |
| 452 | llvm_object.destroy(self.base.allocator); |
| 453 | self.llvm_object = null; |
| 454 | } |
| 455 | } |
| 456 | |
| 457 | var sub_prog_node = prog_node.start("MachO Flush", 0); |
| 458 | sub_prog_node.activate(); |
| 459 | defer sub_prog_node.end(); |
| 449 | 460 | |
| 450 | 461 | var arena_allocator = std.heap.ArenaAllocator.init(self.base.allocator); |
| 451 | 462 | defer arena_allocator.deinit(); |
| ... | ... | @@ -454,12 +465,6 @@ pub fn flushModule(self: *MachO, comp: *Compilation, prog_node: *std.Progress.No |
| 454 | 465 | const directory = self.base.options.emit.?.directory; // Just an alias to make it shorter to type. |
| 455 | 466 | const full_out_path = try directory.join(arena, &[_][]const u8{self.base.options.emit.?.sub_path}); |
| 456 | 467 | |
| 457 | | if (self.d_sym) |*d_sym| { |
| 458 | | if (self.base.options.module) |module| { |
| 459 | | try d_sym.dwarf.flushModule(&self.base, module); |
| 460 | | } |
| 461 | | } |
| 462 | | |
| 463 | 468 | // If there is no Zig code to compile, then we should skip flushing the output file because it |
| 464 | 469 | // will not be part of the linker line anyway. |
| 465 | 470 | const module_obj_path: ?[]const u8 = if (self.base.options.module) |module| blk: { |
| ... | ... | @@ -482,8 +487,6 @@ pub fn flushModule(self: *MachO, comp: *Compilation, prog_node: *std.Progress.No |
| 482 | 487 | |
| 483 | 488 | const obj_basename = self.base.intermediary_basename orelse break :blk null; |
| 484 | 489 | |
| 485 | | try self.flushObject(comp, prog_node); |
| 486 | | |
| 487 | 490 | if (fs.path.dirname(full_out_path)) |dirname| { |
| 488 | 491 | break :blk try fs.path.join(arena, &.{ dirname, obj_basename }); |
| 489 | 492 | } else { |
| ... | ... | @@ -491,9 +494,11 @@ pub fn flushModule(self: *MachO, comp: *Compilation, prog_node: *std.Progress.No |
| 491 | 494 | } |
| 492 | 495 | } else null; |
| 493 | 496 | |
| 494 | | var sub_prog_node = prog_node.start("MachO Flush", 0); |
| 495 | | sub_prog_node.activate(); |
| 496 | | defer sub_prog_node.end(); |
| 497 | if (self.d_sym) |*d_sym| { |
| 498 | if (self.base.options.module) |module| { |
| 499 | try d_sym.dwarf.flushModule(&self.base, module); |
| 500 | } |
| 501 | } |
| 497 | 502 | |
| 498 | 503 | const is_lib = self.base.options.output_mode == .Lib; |
| 499 | 504 | const is_dyn_lib = self.base.options.link_mode == .Dynamic and is_lib; |
| ... | ... | @@ -1119,17 +1124,6 @@ pub fn flushModule(self: *MachO, comp: *Compilation, prog_node: *std.Progress.No |
| 1119 | 1124 | self.cold_start = false; |
| 1120 | 1125 | } |
| 1121 | 1126 | |
| 1122 | | pub fn flushObject(self: *MachO, comp: *Compilation, prog_node: *std.Progress.Node) !void { |
| 1123 | | const tracy = trace(@src()); |
| 1124 | | defer tracy.end(); |
| 1125 | | |
| 1126 | | if (build_options.have_llvm) |
| 1127 | | if (self.llvm_object) |llvm_object| |
| 1128 | | return llvm_object.flushModule(comp, prog_node); |
| 1129 | | |
| 1130 | | return error.TODOImplementWritingObjFiles; |
| 1131 | | } |
| 1132 | | |
| 1133 | 1127 | fn resolveSearchDir( |
| 1134 | 1128 | arena: Allocator, |
| 1135 | 1129 | dir: []const u8, |