| ... | @@ -536,6 +536,27 @@ pub fn flush(self: *MachO, comp: *Compilation) !void { | ... | @@ -536,6 +536,27 @@ pub fn flush(self: *MachO, comp: *Compilation) !void { |
| 536 | try fs.cwd().copyFile(the_object_path, fs.cwd(), full_out_path, .{}); | 536 | try fs.cwd().copyFile(the_object_path, fs.cwd(), full_out_path, .{}); |
| 537 | } | 537 | } |
| 538 | } else { | 538 | } else { |
| | 539 | if (use_stage1) { |
| | 540 | const sub_path = self.base.options.emit.?.sub_path; |
| | 541 | self.base.file = try directory.handle.createFile(sub_path, .{ |
| | 542 | .truncate = true, |
| | 543 | .read = true, |
| | 544 | .mode = link.determineMode(self.base.options), |
| | 545 | }); |
| | 546 | try self.populateMetadata(); |
| | 547 | |
| | 548 | // TODO mimicking insertion of null symbol from incremental linker. |
| | 549 | // This will need to moved. |
| | 550 | try self.locals.append(self.base.allocator, .{ |
| | 551 | .n_strx = 0, |
| | 552 | .n_type = macho.N_UNDF, |
| | 553 | .n_sect = 0, |
| | 554 | .n_desc = 0, |
| | 555 | .n_value = 0, |
| | 556 | }); |
| | 557 | try self.strtab.append(self.base.allocator, 0); |
| | 558 | } |
| | 559 | |
| 539 | // Positional arguments to the linker such as object files and static archives. | 560 | // Positional arguments to the linker such as object files and static archives. |
| 540 | var positionals = std.ArrayList([]const u8).init(arena); | 561 | var positionals = std.ArrayList([]const u8).init(arena); |
| 541 | | 562 | |
| ... | @@ -673,12 +694,6 @@ pub fn flush(self: *MachO, comp: *Compilation) !void { | ... | @@ -673,12 +694,6 @@ pub fn flush(self: *MachO, comp: *Compilation) !void { |
| 673 | try rpath_table.putNoClobber(rpath, {}); | 694 | try rpath_table.putNoClobber(rpath, {}); |
| 674 | } | 695 | } |
| 675 | | 696 | |
| 676 | var rpaths = std.ArrayList([]const u8).init(arena); | | |
| 677 | try rpaths.ensureCapacity(rpath_table.count()); | | |
| 678 | for (rpath_table.keys()) |*key| { | | |
| 679 | rpaths.appendAssumeCapacity(key.*); | | |
| 680 | } | | |
| 681 | | | |
| 682 | if (self.base.options.verbose_link) { | 697 | if (self.base.options.verbose_link) { |
| 683 | var argv = std.ArrayList([]const u8).init(arena); | 698 | var argv = std.ArrayList([]const u8).init(arena); |
| 684 | | 699 | |
| ... | @@ -704,7 +719,7 @@ pub fn flush(self: *MachO, comp: *Compilation) !void { | ... | @@ -704,7 +719,7 @@ pub fn flush(self: *MachO, comp: *Compilation) !void { |
| 704 | try argv.append(syslibroot); | 719 | try argv.append(syslibroot); |
| 705 | } | 720 | } |
| 706 | | 721 | |
| 707 | for (rpaths.items) |rpath| { | 722 | for (rpath_table.keys()) |rpath| { |
| 708 | try argv.append("-rpath"); | 723 | try argv.append("-rpath"); |
| 709 | try argv.append(rpath); | 724 | try argv.append(rpath); |
| 710 | } | 725 | } |
| ... | @@ -736,27 +751,9 @@ pub fn flush(self: *MachO, comp: *Compilation) !void { | ... | @@ -736,27 +751,9 @@ pub fn flush(self: *MachO, comp: *Compilation) !void { |
| 736 | Compilation.dump_argv(argv.items); | 751 | Compilation.dump_argv(argv.items); |
| 737 | } | 752 | } |
| 738 | | 753 | |
| 739 | if (use_stage1) { | 754 | try self.addRpathLCs(rpath_table.keys()); |
| 740 | const sub_path = self.base.options.emit.?.sub_path; | | |
| 741 | self.base.file = try directory.handle.createFile(sub_path, .{ | | |
| 742 | .truncate = true, | | |
| 743 | .read = true, | | |
| 744 | .mode = link.determineMode(self.base.options), | | |
| 745 | }); | | |
| 746 | | 755 | |
| 747 | // TODO mimicking insertion of null symbol from incremental linker. | 756 | if (use_stage1) { |
| 748 | // This will need to moved. | | |
| 749 | try self.locals.append(self.base.allocator, .{ | | |
| 750 | .n_strx = 0, | | |
| 751 | .n_type = macho.N_UNDF, | | |
| 752 | .n_sect = 0, | | |
| 753 | .n_desc = 0, | | |
| 754 | .n_value = 0, | | |
| 755 | }); | | |
| 756 | try self.strtab.append(self.base.allocator, 0); | | |
| 757 | | | |
| 758 | try self.populateMetadata(); | | |
| 759 | try self.addRpathLCs(rpaths.items); | | |
| 760 | try self.parseInputFiles(positionals.items, self.base.options.sysroot); | 757 | try self.parseInputFiles(positionals.items, self.base.options.sysroot); |
| 761 | try self.parseLibs(libs.items, self.base.options.sysroot); | 758 | try self.parseLibs(libs.items, self.base.options.sysroot); |
| 762 | try self.resolveSymbols(); | 759 | try self.resolveSymbols(); |