From 76c3b6b794ebc9ddb910e369bbf2d121a01e06d8 Mon Sep 17 00:00:00 2001 From: Jakub Konka Date: Thu, 4 Jul 2024 07:26:28 +0200 Subject: [PATCH] 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. --- src/libtsan.zig | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/libtsan.zig b/src/libtsan.zig index 4164200b47..b7d3a9dda2 100644 --- a/src/libtsan.zig +++ b/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,