authorgravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2024-01-15 08:52:05+01:00
committergravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2024-01-24 12:34:40+01:00
log8105390fff82f372645b01dbfe89f7972ba4e49d
tree62d0b70614a167b1d1222f5dc6921506c41ce355
parentb1cf6d310323f2908ed401d1a6926d096ade530d

macho: remove all rpath parsing from the linker


3 files changed, 5 insertions(+), 14 deletions(-)

src/link/MachO.zig+3-12
......@@ -114,8 +114,6 @@ compatibility_version: ?std.SemanticVersion,
114114entry_name: ?[]const u8,
115115platform: Platform,
116116sdk_version: ?std.SemanticVersion,
117/// Rpath table
118rpath_table: std.StringArrayHashMapUnmanaged(void) = .{},
119117/// When set to true, the linker will hoist all dylibs including system dependent dylibs.
120118no_implicit_dylibs: bool = false,
121119
......@@ -210,12 +208,6 @@ pub fn createEmpty(
210208 .mode = link.File.determineMode(false, output_mode, link_mode),
211209 });
212210
213 // Filter rpaths
214 try self.rpath_table.ensureUnusedCapacity(gpa, self.base.rpath_list.len);
215 for (options.rpath_list) |rpath| {
216 _ = self.rpath_table.putAssumeCapacity(rpath, {});
217 }
218
219211 // Append null file
220212 try self.files.append(gpa, .null);
221213 // Atom at index 0 is reserved as null atom
......@@ -333,7 +325,6 @@ pub fn deinit(self: *MachO) void {
333325 }
334326 self.thunks.deinit(gpa);
335327 self.unwind_records.deinit(gpa);
336 self.rpath_table.deinit(gpa);
337328}
338329
339330pub fn flush(self: *MachO, arena: Allocator, prog_node: *std.Progress.Node) link.File.FlushError!void {
......@@ -701,7 +692,7 @@ fn dumpArgv(self: *MachO, comp: *Compilation) !void {
701692 try argv.append(syslibroot);
702693 }
703694
704 for (self.rpath_table.keys()) |rpath| {
695 for (self.base.rpath_list) |rpath| {
705696 try argv.append("-rpath");
706697 try argv.append(rpath);
707698 }
......@@ -2812,8 +2803,8 @@ fn writeLoadCommands(self: *MachO) !struct { usize, usize, usize } {
28122803 ncmds += 1;
28132804 }
28142805
2815 try load_commands.writeRpathLCs(self.rpath_table.keys(), writer);
2816 ncmds += self.rpath_table.keys().len;
2806 try load_commands.writeRpathLCs(self.base.rpath_list, writer);
2807 ncmds += self.base.rpath_list.len;
28172808
28182809 try writer.writeStruct(macho.source_version_command{ .version = 0 });
28192810 ncmds += 1;
src/link/MachO/load_commands.zig+1-1
......@@ -59,7 +59,7 @@ pub fn calcLoadCommandsSize(macho_file: *MachO, assume_max_path_len: bool) u32 {
5959 }
6060 // LC_RPATH
6161 {
62 for (macho_file.rpath_table.keys()) |rpath| {
62 for (macho_file.base.rpath_list) |rpath| {
6363 sizeofcmds += calcInstallNameLen(
6464 @sizeOf(macho.rpath_command),
6565 rpath,
test/link/macho.zig+1-1
......@@ -662,7 +662,7 @@ fn testRelocatableZig(b: *Build, opts: Options) *Step {
662662
663663 const run = addRunArtifact(exe);
664664 run.addCheck(.{ .expect_stderr_match = b.dupe("incrFoo=1") });
665 run.addCheck(.{ .expect_stderr_match = b.dupe("decrFoo=1") });
665 run.addCheck(.{ .expect_stderr_match = b.dupe("decrFoo=0") });
666666 run.addCheck(.{ .expect_stderr_match = b.dupe("panic: Oh no!") });
667667 test_step.dependOn(&run.step);
668668