mirror of
https://github.com/ziglang/zig.git
synced 2026-02-14 05:20:34 +00:00
tsan: Synchronize CFLAGS with upstream.
In particular: * -fms-extensions for MinGW * -fno-builtin * -fno-emulated-tls for Android 29+ * -fno-exceptions * -fomit-frame-pointer * -fvisibility=hidden
This commit is contained in:
parent
bdca2d0f48
commit
0563525b21
@ -93,11 +93,12 @@ pub fn buildTsan(comp: *Compilation, prog_node: std.Progress.Node) BuildError!vo
|
||||
.sanitize_c = false,
|
||||
.sanitize_thread = false,
|
||||
.red_zone = comp.root_mod.red_zone,
|
||||
.omit_frame_pointer = comp.root_mod.omit_frame_pointer,
|
||||
.omit_frame_pointer = optimize_mode != .Debug and !target.os.tag.isDarwin(),
|
||||
.valgrind = false,
|
||||
.optimize_mode = optimize_mode,
|
||||
.structured_cfg = comp.root_mod.structured_cfg,
|
||||
.pic = true,
|
||||
.no_builtin = true,
|
||||
},
|
||||
.global = config,
|
||||
.cc_argv = &common_flags,
|
||||
@ -123,10 +124,7 @@ pub fn buildTsan(comp: *Compilation, prog_node: std.Progress.Node) BuildError!vo
|
||||
try cflags.append("-I");
|
||||
try cflags.append(tsan_include_path);
|
||||
|
||||
try cflags.append("-nostdinc++");
|
||||
try cflags.append("-fvisibility-inlines-hidden");
|
||||
try cflags.append("-std=c++17");
|
||||
try cflags.append("-fno-rtti");
|
||||
try addCcArgs(target, &cflags);
|
||||
|
||||
c_source_files.appendAssumeCapacity(.{
|
||||
.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
|
||||
try cflags.append("-I");
|
||||
try cflags.append(tsan_include_path);
|
||||
|
||||
try cflags.append("-nostdinc++");
|
||||
try cflags.append("-fvisibility-inlines-hidden");
|
||||
try cflags.append("-std=c++17");
|
||||
try cflags.append("-fno-rtti");
|
||||
try addCcArgs(target, &cflags);
|
||||
|
||||
c_source_files.appendAssumeCapacity(.{
|
||||
.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
|
||||
try cflags.append("-I");
|
||||
try cflags.append(tsan_include_path);
|
||||
|
||||
try cflags.append("-nostdinc++");
|
||||
try cflags.append("-fvisibility-inlines-hidden");
|
||||
try cflags.append("-std=c++17");
|
||||
try cflags.append("-fno-rtti");
|
||||
try addCcArgs(target, &cflags);
|
||||
|
||||
c_source_files.appendAssumeCapacity(.{
|
||||
.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
|
||||
try cflags.append("-I");
|
||||
try cflags.append(tsan_include_path);
|
||||
|
||||
try cflags.append("-nostdinc++");
|
||||
try cflags.append("-fvisibility-inlines-hidden");
|
||||
try cflags.append("-std=c++17");
|
||||
try cflags.append("-fno-rtti");
|
||||
try addCcArgs(target, &cflags);
|
||||
|
||||
c_source_files.appendAssumeCapacity(.{
|
||||
.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
|
||||
try cflags.append("-I");
|
||||
try cflags.append(tsan_include_path);
|
||||
|
||||
try cflags.append("-nostdinc++");
|
||||
try cflags.append("-fvisibility-inlines-hidden");
|
||||
try cflags.append("-std=c++17");
|
||||
try cflags.append("-fno-rtti");
|
||||
try addCcArgs(target, &cflags);
|
||||
|
||||
c_source_files.appendAssumeCapacity(.{
|
||||
.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
|
||||
try cflags.append("-I");
|
||||
try cflags.append(tsan_include_path);
|
||||
|
||||
try cflags.append("-nostdinc++");
|
||||
try cflags.append("-fvisibility-inlines-hidden");
|
||||
try cflags.append("-std=c++17");
|
||||
try cflags.append("-fno-rtti");
|
||||
try addCcArgs(target, &cflags);
|
||||
|
||||
c_source_files.appendAssumeCapacity(.{
|
||||
.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
|
||||
comp.tsan_lib = crt_file;
|
||||
}
|
||||
|
||||
fn addCcArgs(target: std.Target, args: *std.ArrayList([]const u8)) error{OutOfMemory}!void {
|
||||
try args.appendSlice(&[_][]const u8{
|
||||
"-nostdinc++",
|
||||
"-fvisibility=hidden",
|
||||
"-fvisibility-inlines-hidden",
|
||||
"-std=c++17",
|
||||
"-fno-rtti",
|
||||
"-fno-exceptions",
|
||||
});
|
||||
|
||||
if (target.abi.isAndroid() and target.os.version_range.linux.android >= 29) {
|
||||
try args.append("-fno-emulated-tls");
|
||||
}
|
||||
|
||||
if (target.isMinGW()) {
|
||||
try args.append("-fms-extensions");
|
||||
}
|
||||
}
|
||||
|
||||
const tsan_sources = [_][]const u8{
|
||||
"tsan_debugging.cpp",
|
||||
"tsan_external.cpp",
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user