| ... | ... | @@ -93,11 +93,12 @@ pub fn buildTsan(comp: *Compilation, prog_node: std.Progress.Node) BuildError!vo |
| 93 | 93 | .sanitize_c = false, |
| 94 | 94 | .sanitize_thread = false, |
| 95 | 95 | .red_zone = comp.root_mod.red_zone, |
| 96 | | .omit_frame_pointer = comp.root_mod.omit_frame_pointer, |
| 96 | .omit_frame_pointer = optimize_mode != .Debug and !target.os.tag.isDarwin(), |
| 97 | 97 | .valgrind = false, |
| 98 | 98 | .optimize_mode = optimize_mode, |
| 99 | 99 | .structured_cfg = comp.root_mod.structured_cfg, |
| 100 | 100 | .pic = true, |
| 101 | .no_builtin = true, |
| 101 | 102 | }, |
| 102 | 103 | .global = config, |
| 103 | 104 | .cc_argv = &common_flags, |
| ... | ... | @@ -123,10 +124,7 @@ pub fn buildTsan(comp: *Compilation, prog_node: std.Progress.Node) BuildError!vo |
| 123 | 124 | try cflags.append("-I"); |
| 124 | 125 | try cflags.append(tsan_include_path); |
| 125 | 126 | |
| 126 | | try cflags.append("-nostdinc++"); |
| 127 | | try cflags.append("-fvisibility-inlines-hidden"); |
| 128 | | try cflags.append("-std=c++17"); |
| 129 | | try cflags.append("-fno-rtti"); |
| 127 | try addCcArgs(target, &cflags); |
| 130 | 128 | |
| 131 | 129 | c_source_files.appendAssumeCapacity(.{ |
| 132 | 130 | .src_path = try comp.zig_lib_directory.join(arena, &.{ "tsan", tsan_src }), |
| ... | ... | @@ -147,10 +145,7 @@ pub fn buildTsan(comp: *Compilation, prog_node: std.Progress.Node) BuildError!vo |
| 147 | 145 | try cflags.append("-I"); |
| 148 | 146 | try cflags.append(tsan_include_path); |
| 149 | 147 | |
| 150 | | try cflags.append("-nostdinc++"); |
| 151 | | try cflags.append("-fvisibility-inlines-hidden"); |
| 152 | | try cflags.append("-std=c++17"); |
| 153 | | try cflags.append("-fno-rtti"); |
| 148 | try addCcArgs(target, &cflags); |
| 154 | 149 | |
| 155 | 150 | c_source_files.appendAssumeCapacity(.{ |
| 156 | 151 | .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{ "tsan", tsan_src }), |
| ... | ... | @@ -195,10 +190,7 @@ pub fn buildTsan(comp: *Compilation, prog_node: std.Progress.Node) BuildError!vo |
| 195 | 190 | try cflags.append("-I"); |
| 196 | 191 | try cflags.append(tsan_include_path); |
| 197 | 192 | |
| 198 | | try cflags.append("-nostdinc++"); |
| 199 | | try cflags.append("-fvisibility-inlines-hidden"); |
| 200 | | try cflags.append("-std=c++17"); |
| 201 | | try cflags.append("-fno-rtti"); |
| 193 | try addCcArgs(target, &cflags); |
| 202 | 194 | |
| 203 | 195 | c_source_files.appendAssumeCapacity(.{ |
| 204 | 196 | .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{ |
| ... | ... | @@ -222,10 +214,7 @@ pub fn buildTsan(comp: *Compilation, prog_node: std.Progress.Node) BuildError!vo |
| 222 | 214 | try cflags.append("-I"); |
| 223 | 215 | try cflags.append(tsan_include_path); |
| 224 | 216 | |
| 225 | | try cflags.append("-nostdinc++"); |
| 226 | | try cflags.append("-fvisibility-inlines-hidden"); |
| 227 | | try cflags.append("-std=c++17"); |
| 228 | | try cflags.append("-fno-rtti"); |
| 217 | try addCcArgs(target, &cflags); |
| 229 | 218 | |
| 230 | 219 | c_source_files.appendAssumeCapacity(.{ |
| 231 | 220 | .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{ |
| ... | ... | @@ -243,10 +232,7 @@ pub fn buildTsan(comp: *Compilation, prog_node: std.Progress.Node) BuildError!vo |
| 243 | 232 | try cflags.append("-I"); |
| 244 | 233 | try cflags.append(tsan_include_path); |
| 245 | 234 | |
| 246 | | try cflags.append("-nostdinc++"); |
| 247 | | try cflags.append("-fvisibility-inlines-hidden"); |
| 248 | | try cflags.append("-std=c++17"); |
| 249 | | try cflags.append("-fno-rtti"); |
| 235 | try addCcArgs(target, &cflags); |
| 250 | 236 | |
| 251 | 237 | c_source_files.appendAssumeCapacity(.{ |
| 252 | 238 | .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{ |
| ... | ... | @@ -272,10 +258,7 @@ pub fn buildTsan(comp: *Compilation, prog_node: std.Progress.Node) BuildError!vo |
| 272 | 258 | try cflags.append("-I"); |
| 273 | 259 | try cflags.append(tsan_include_path); |
| 274 | 260 | |
| 275 | | try cflags.append("-nostdinc++"); |
| 276 | | try cflags.append("-fvisibility-inlines-hidden"); |
| 277 | | try cflags.append("-std=c++17"); |
| 278 | | try cflags.append("-fno-rtti"); |
| 261 | try addCcArgs(target, &cflags); |
| 279 | 262 | |
| 280 | 263 | c_source_files.appendAssumeCapacity(.{ |
| 281 | 264 | .src_path = try comp.zig_lib_directory.join(arena, &[_][]const u8{ |
| ... | ... | @@ -348,6 +331,25 @@ pub fn buildTsan(comp: *Compilation, prog_node: std.Progress.Node) BuildError!vo |
| 348 | 331 | comp.tsan_lib = crt_file; |
| 349 | 332 | } |
| 350 | 333 | |
| 334 | fn addCcArgs(target: std.Target, args: *std.ArrayList([]const u8)) error{OutOfMemory}!void { |
| 335 | try args.appendSlice(&[_][]const u8{ |
| 336 | "-nostdinc++", |
| 337 | "-fvisibility=hidden", |
| 338 | "-fvisibility-inlines-hidden", |
| 339 | "-std=c++17", |
| 340 | "-fno-rtti", |
| 341 | "-fno-exceptions", |
| 342 | }); |
| 343 | |
| 344 | if (target.abi.isAndroid() and target.os.version_range.linux.android >= 29) { |
| 345 | try args.append("-fno-emulated-tls"); |
| 346 | } |
| 347 | |
| 348 | if (target.isMinGW()) { |
| 349 | try args.append("-fms-extensions"); |
| 350 | } |
| 351 | } |
| 352 | |
| 351 | 353 | const tsan_sources = [_][]const u8{ |
| 352 | 354 | "tsan_debugging.cpp", |
| 353 | 355 | "tsan_external.cpp", |