Merge pull request #20428 from ziglang/macho-tsan

macho: support TSAN
This commit is contained in:
Jakub Konka 2024-06-27 06:35:53 +02:00 committed by GitHub
commit 1e3fb48256
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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);