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,...@@ -114,8 +114,6 @@ compatibility_version: ?std.SemanticVersion,
114entry_name: ?[]const u8,114entry_name: ?[]const u8,
115platform: Platform,115platform: Platform,
116sdk_version: ?std.SemanticVersion,116sdk_version: ?std.SemanticVersion,
117/// Rpath table
118rpath_table: std.StringArrayHashMapUnmanaged(void) = .{},
119/// When set to true, the linker will hoist all dylibs including system dependent dylibs.117/// When set to true, the linker will hoist all dylibs including system dependent dylibs.
120no_implicit_dylibs: bool = false,118no_implicit_dylibs: bool = false,
121119
...@@ -210,12 +208,6 @@ pub fn createEmpty(...@@ -210,12 +208,6 @@ pub fn createEmpty(
210 .mode = link.File.determineMode(false, output_mode, link_mode),208 .mode = link.File.determineMode(false, output_mode, link_mode),
211 });209 });
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
219 // Append null file211 // Append null file
220 try self.files.append(gpa, .null);212 try self.files.append(gpa, .null);
221 // Atom at index 0 is reserved as null atom213 // Atom at index 0 is reserved as null atom
...@@ -333,7 +325,6 @@ pub fn deinit(self: *MachO) void {...@@ -333,7 +325,6 @@ pub fn deinit(self: *MachO) void {
333 }325 }
334 self.thunks.deinit(gpa);326 self.thunks.deinit(gpa);
335 self.unwind_records.deinit(gpa);327 self.unwind_records.deinit(gpa);
336 self.rpath_table.deinit(gpa);
337}328}
338329
339pub fn flush(self: *MachO, arena: Allocator, prog_node: *std.Progress.Node) link.File.FlushError!void {330pub 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 {...@@ -701,7 +692,7 @@ fn dumpArgv(self: *MachO, comp: *Compilation) !void {
701 try argv.append(syslibroot);692 try argv.append(syslibroot);
702 }693 }
703694
704 for (self.rpath_table.keys()) |rpath| {695 for (self.base.rpath_list) |rpath| {
705 try argv.append("-rpath");696 try argv.append("-rpath");
706 try argv.append(rpath);697 try argv.append(rpath);
707 }698 }
...@@ -2812,8 +2803,8 @@ fn writeLoadCommands(self: *MachO) !struct { usize, usize, usize } {...@@ -2812,8 +2803,8 @@ fn writeLoadCommands(self: *MachO) !struct { usize, usize, usize } {
2812 ncmds += 1;2803 ncmds += 1;
2813 }2804 }
28142805
2815 try load_commands.writeRpathLCs(self.rpath_table.keys(), writer);2806 try load_commands.writeRpathLCs(self.base.rpath_list, writer);
2816 ncmds += self.rpath_table.keys().len;2807 ncmds += self.base.rpath_list.len;
28172808
2818 try writer.writeStruct(macho.source_version_command{ .version = 0 });2809 try writer.writeStruct(macho.source_version_command{ .version = 0 });
2819 ncmds += 1;2810 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 {...@@ -59,7 +59,7 @@ pub fn calcLoadCommandsSize(macho_file: *MachO, assume_max_path_len: bool) u32 {
59 }59 }
60 // LC_RPATH60 // LC_RPATH
61 {61 {
62 for (macho_file.rpath_table.keys()) |rpath| {62 for (macho_file.base.rpath_list) |rpath| {
63 sizeofcmds += calcInstallNameLen(63 sizeofcmds += calcInstallNameLen(
64 @sizeOf(macho.rpath_command),64 @sizeOf(macho.rpath_command),
65 rpath,65 rpath,
test/link/macho.zig+1-1
...@@ -662,7 +662,7 @@ fn testRelocatableZig(b: *Build, opts: Options) *Step {...@@ -662,7 +662,7 @@ fn testRelocatableZig(b: *Build, opts: Options) *Step {
662662
663 const run = addRunArtifact(exe);663 const run = addRunArtifact(exe);
664 run.addCheck(.{ .expect_stderr_match = b.dupe("incrFoo=1") });664 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") });
666 run.addCheck(.{ .expect_stderr_match = b.dupe("panic: Oh no!") });666 run.addCheck(.{ .expect_stderr_match = b.dupe("panic: Oh no!") });
667 test_step.dependOn(&run.step);667 test_step.dependOn(&run.step);
668668