authorgravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2021-03-18 08:42:07+01:00
committergravatar for jakubkonka@microsoft.comJakub Konka <jakubkonka@microsoft.com> 2021-03-18 11:10:09+01:00
log2cf1c1b96b4869a61d2bfb8d2e9725e2adacde17
tree7cb10a25f6657bab52fce8d55372cae222b52b9f
parent861ea640090f5c4a36889cf65f32c575cbe3b505

macho: honor verbose_link when linking with zld


1 files changed, 26 insertions(+), 2 deletions(-)

src/link/MachO.zig+26-2
......@@ -633,13 +633,15 @@ fn linkWithLLD(self: *MachO, comp: *Compilation) !void {
633633 if (!mem.eql(u8, the_object_path, full_out_path)) {
634634 try fs.cwd().copyFile(the_object_path, fs.cwd(), full_out_path, .{});
635635 }
636 } else {
636 } else outer: {
637637 const use_zld = blk: {
638638 if (self.base.options.is_native_os and self.base.options.system_linker_hack) {
639 // If the user forces the use of ld64, make sure we are running native!
639640 break :blk false;
640641 }
641642
642643 if (self.base.options.target.cpu.arch == .aarch64) {
644 // On aarch64, always use zld.
643645 break :blk true;
644646 }
645647
......@@ -647,6 +649,7 @@ fn linkWithLLD(self: *MachO, comp: *Compilation) !void {
647649 self.base.options.output_mode == .Lib or
648650 self.base.options.linker_script != null)
649651 {
652 // Fallback to LLD in this handful of cases on x86_64 only.
650653 break :blk false;
651654 }
652655
......@@ -674,7 +677,28 @@ fn linkWithLLD(self: *MachO, comp: *Compilation) !void {
674677 try input_files.append(comp.libcxxabi_static_lib.?.full_object_path);
675678 try input_files.append(comp.libcxx_static_lib.?.full_object_path);
676679 }
677 return zld.link(input_files.items, full_out_path);
680
681 if (self.base.options.verbose_link) {
682 var argv = std.ArrayList([]const u8).init(self.base.allocator);
683 defer argv.deinit();
684
685 try argv.append("zig");
686 try argv.append("ld");
687
688 try argv.ensureCapacity(input_files.items.len);
689 for (input_files.items) |f| {
690 argv.appendAssumeCapacity(f);
691 }
692
693 try argv.append("-o");
694 try argv.append(full_out_path);
695
696 Compilation.dump_argv(argv.items);
697 }
698
699 try zld.link(input_files.items, full_out_path);
700
701 break :outer;
678702 }
679703
680704 // Create an LLD command line and invoke it.