| ... | ... | @@ -150,7 +150,6 @@ no_implicit_dylibs: bool = false, |
| 150 | 150 | /// Whether the linker should parse and always force load objects containing ObjC in archives. |
| 151 | 151 | // TODO: in Zig we currently take -ObjC as always on |
| 152 | 152 | force_load_objc: bool = true, |
| 153 | | rpaths: std.ArrayListUnmanaged([]const u8) = .{}, |
| 154 | 153 | |
| 155 | 154 | /// Hot-code swapping state. |
| 156 | 155 | hot_state: if (is_hot_update_compatible) HotUpdateState else struct {} = .{}, |
| ... | ... | @@ -359,8 +358,6 @@ pub fn deinit(self: *MachO) void { |
| 359 | 358 | } |
| 360 | 359 | self.thunks.deinit(gpa); |
| 361 | 360 | self.unwind_records.deinit(gpa); |
| 362 | | |
| 363 | | self.rpaths.deinit(gpa); |
| 364 | 361 | } |
| 365 | 362 | |
| 366 | 363 | pub fn flush(self: *MachO, arena: Allocator, prog_node: std.Progress.Node) link.File.FlushError!void { |
| ... | ... | @@ -398,9 +395,6 @@ pub fn flushModule(self: *MachO, arena: Allocator, prog_node: std.Progress.Node) |
| 398 | 395 | if (self.base.isStaticLib()) return relocatable.flushStaticLib(self, comp, module_obj_path); |
| 399 | 396 | if (self.base.isObject()) return relocatable.flushObject(self, comp, module_obj_path); |
| 400 | 397 | |
| 401 | | try self.rpaths.ensureUnusedCapacity(gpa, self.base.rpath_list.len); |
| 402 | | self.rpaths.appendSliceAssumeCapacity(self.base.rpath_list); |
| 403 | | |
| 404 | 398 | var positionals = std.ArrayList(Compilation.LinkObject).init(gpa); |
| 405 | 399 | defer positionals.deinit(); |
| 406 | 400 | |
| ... | ... | @@ -419,10 +413,7 @@ pub fn flushModule(self: *MachO, arena: Allocator, prog_node: std.Progress.Node) |
| 419 | 413 | |
| 420 | 414 | // TSAN |
| 421 | 415 | if (comp.config.any_sanitize_thread) { |
| 422 | | const path = comp.tsan_dynamic_lib.?.full_object_path; |
| 423 | | try positionals.append(.{ .path = path }); |
| 424 | | const basename = std.fs.path.dirname(path) orelse "."; |
| 425 | | try self.rpaths.append(gpa, basename); |
| 416 | try positionals.append(.{ .path = comp.tsan_dynamic_lib.?.full_object_path }); |
| 426 | 417 | } |
| 427 | 418 | |
| 428 | 419 | for (positionals.items) |obj| { |
| ... | ... | @@ -780,7 +771,7 @@ fn dumpArgv(self: *MachO, comp: *Compilation) !void { |
| 780 | 771 | try argv.append(syslibroot); |
| 781 | 772 | } |
| 782 | 773 | |
| 783 | | for (self.rpaths.items) |rpath| { |
| 774 | for (self.base.rpath_list) |rpath| { |
| 784 | 775 | try argv.append("-rpath"); |
| 785 | 776 | try argv.append(rpath); |
| 786 | 777 | } |
| ... | ... | @@ -840,7 +831,9 @@ fn dumpArgv(self: *MachO, comp: *Compilation) !void { |
| 840 | 831 | } |
| 841 | 832 | |
| 842 | 833 | if (comp.config.any_sanitize_thread) { |
| 843 | | try argv.append(comp.tsan_dynamic_lib.?.full_object_path); |
| 834 | const path = comp.tsan_dynamic_lib.?.full_object_path; |
| 835 | try argv.append(path); |
| 836 | try argv.appendSlice(&.{ "-rpath", std.fs.path.dirname(path) orelse "." }); |
| 844 | 837 | } |
| 845 | 838 | |
| 846 | 839 | for (self.lib_dirs) |lib_dir| { |
| ... | ... | @@ -2968,7 +2961,8 @@ pub fn writeStrtab(self: *MachO, off: u32) !u32 { |
| 2968 | 2961 | } |
| 2969 | 2962 | |
| 2970 | 2963 | fn writeLoadCommands(self: *MachO) !struct { usize, usize, u64 } { |
| 2971 | | const gpa = self.base.comp.gpa; |
| 2964 | const comp = self.base.comp; |
| 2965 | const gpa = comp.gpa; |
| 2972 | 2966 | const needed_size = try load_commands.calcLoadCommandsSize(self, false); |
| 2973 | 2967 | const buffer = try gpa.alloc(u8, needed_size); |
| 2974 | 2968 | defer gpa.free(buffer); |
| ... | ... | @@ -3024,8 +3018,16 @@ fn writeLoadCommands(self: *MachO) !struct { usize, usize, u64 } { |
| 3024 | 3018 | ncmds += 1; |
| 3025 | 3019 | } |
| 3026 | 3020 | |
| 3027 | | try load_commands.writeRpathLCs(self.rpaths.items, writer); |
| 3028 | | ncmds += self.rpaths.items.len; |
| 3021 | for (self.base.rpath_list) |rpath| { |
| 3022 | try load_commands.writeRpathLC(rpath, writer); |
| 3023 | ncmds += 1; |
| 3024 | } |
| 3025 | if (comp.config.any_sanitize_thread) { |
| 3026 | const path = comp.tsan_dynamic_lib.?.full_object_path; |
| 3027 | const rpath = std.fs.path.dirname(path) orelse "."; |
| 3028 | try load_commands.writeRpathLC(rpath, writer); |
| 3029 | ncmds += 1; |
| 3030 | } |
| 3029 | 3031 | |
| 3030 | 3032 | try writer.writeStruct(macho.source_version_command{ .version = 0 }); |
| 3031 | 3033 | ncmds += 1; |