Commit 76c3b6b794

Jakub Konka <kubkon@jakubkonka.com>
2024-07-04 07:26:28
tsan: add workaround for TSAN Apple bug
Addresses TSAN bug on Apple platforms by always setting the headerpad size to a non-zero value when building the TSAN dylib.
1 parent c9d19eb
Changed files (1)
src/libtsan.zig
@@ -290,6 +290,8 @@ pub fn buildTsan(comp: *Compilation, prog_node: std.Progress.Node) BuildError!vo
         try std.fmt.allocPrintZ(arena, "@rpath/{s}", .{basename})
     else
         null;
+    // This is temp conditional on resolving https://github.com/llvm/llvm-project/issues/97627 upstream.
+    const headerpad_size: ?u32 = if (target.isDarwin()) 32 else null;
     const sub_compilation = Compilation.create(comp.gpa, arena, .{
         .local_cache_directory = comp.global_cache_directory,
         .global_cache_directory = comp.global_cache_directory,
@@ -315,6 +317,7 @@ pub fn buildTsan(comp: *Compilation, prog_node: std.Progress.Node) BuildError!vo
         .skip_linker_dependencies = skip_linker_dependencies,
         .linker_allow_shlib_undefined = linker_allow_shlib_undefined,
         .install_name = install_name,
+        .headerpad_size = headerpad_size,
     }) catch |err| {
         comp.setMiscFailure(
             .libtsan,