Skip to content

Commit 1e3fb48

Browse files
authored
Merge pull request #20428 from ziglang/macho-tsan
macho: support TSAN
2 parents a016ca6 + 766e281 commit 1e3fb48

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

src/link/MachO.zig

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -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);

0 commit comments

Comments
 (0)