diff --git a/src/link/MachO.zig b/src/link/MachO.zig index 9cec01c437..dd185fcaec 100644 --- a/src/link/MachO.zig +++ b/src/link/MachO.zig @@ -192,7 +192,7 @@ pub fn createEmpty( null else try std.fmt.allocPrint(arena, "{s}.o", .{emit.sub_path}); - const allow_shlib_undefined = options.allow_shlib_undefined orelse false; + const allow_shlib_undefined = options.allow_shlib_undefined orelse comp.config.any_sanitize_thread; const self = try arena.create(MachO); self.* = .{ @@ -411,6 +411,11 @@ pub fn flushModule(self: *MachO, arena: Allocator, prog_node: std.Progress.Node) if (module_obj_path) |path| try positionals.append(.{ .path = path }); + // TSAN + if (comp.config.any_sanitize_thread) { + try positionals.append(.{ .path = comp.tsan_static_lib.?.full_object_path }); + } + for (positionals.items) |obj| { self.parsePositional(obj.path, obj.must_link) catch |err| switch (err) { error.MalformedObject, @@ -825,6 +830,10 @@ fn dumpArgv(self: *MachO, comp: *Compilation) !void { try argv.append(p); } + if (comp.config.any_sanitize_thread) { + try argv.append(comp.tsan_static_lib.?.full_object_path); + } + for (self.lib_dirs) |lib_dir| { const arg = try std.fmt.allocPrint(arena, "-L{s}", .{lib_dir}); try argv.append(arg);