authorgravatar for kubkon@jakubkonka.comJakub Konka <kubkon@jakubkonka.com> 2024-06-27 06:35:53+02:00
committergravatar for noreply@github.comGitHub <noreply@github.com> 2024-06-27 06:35:53+02:00
log1e3fb482563cc3ce769c01bb608e5a9424ec426f
tree0eee6e45a37c6c45d8a148c0c4bed273824492a6
parenta016ca61706b300534a3a3a3c656b9b0ec24591c
parent766e281a72bb915ebee21cafd862d6b7a2a298ca
signaturebadge-check Signed by PGP key B5690EEEBB952194

Merge pull request #20428 from ziglang/macho-tsan

macho: support TSAN

1 files changed, 10 insertions(+), 1 deletions(-)

src/link/MachO.zig+10-1
......@@ -192,7 +192,7 @@ pub fn createEmpty(
192192 null
193193 else
194194 try std.fmt.allocPrint(arena, "{s}.o", .{emit.sub_path});
195 const allow_shlib_undefined = options.allow_shlib_undefined orelse false;
195 const allow_shlib_undefined = options.allow_shlib_undefined orelse comp.config.any_sanitize_thread;
196196
197197 const self = try arena.create(MachO);
198198 self.* = .{
......@@ -411,6 +411,11 @@ pub fn flushModule(self: *MachO, arena: Allocator, prog_node: std.Progress.Node)
411411
412412 if (module_obj_path) |path| try positionals.append(.{ .path = path });
413413
414 // TSAN
415 if (comp.config.any_sanitize_thread) {
416 try positionals.append(.{ .path = comp.tsan_static_lib.?.full_object_path });
417 }
418
414419 for (positionals.items) |obj| {
415420 self.parsePositional(obj.path, obj.must_link) catch |err| switch (err) {
416421 error.MalformedObject,
......@@ -825,6 +830,10 @@ fn dumpArgv(self: *MachO, comp: *Compilation) !void {
825830 try argv.append(p);
826831 }
827832
833 if (comp.config.any_sanitize_thread) {
834 try argv.append(comp.tsan_static_lib.?.full_object_path);
835 }
836
828837 for (self.lib_dirs) |lib_dir| {
829838 const arg = try std.fmt.allocPrint(arena, "-L{s}", .{lib_dir});
830839 try argv.append(arg);