diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2023-12-15 14:31:55 -0700 |
|---|---|---|
| committer | Andrew Kelley <andrew@ziglang.org> | 2024-01-01 17:51:19 -0700 |
| commit | ea0ba4f2b572fad8595ae02ac9c43ab7dd0cc2f2 (patch) | |
| tree | 2b45a88c5f100f11d1011a12d44da4a83a7fda0f /src | |
| parent | a1236b32f9a4114231312b1493dcbac308a2c055 (diff) | |
| download | zig-ea0ba4f2b572fad8595ae02ac9c43ab7dd0cc2f2.tar.gz zig-ea0ba4f2b572fad8595ae02ac9c43ab7dd0cc2f2.zip | |
tsan: update to new Compilation API
Diffstat (limited to 'src')
| -rw-r--r-- | src/libtsan.zig | 74 |
1 files changed, 51 insertions, 23 deletions
diff --git a/src/libtsan.zig b/src/libtsan.zig index d0af65e4c6..745a947153 100644 --- a/src/libtsan.zig +++ b/src/libtsan.zig @@ -4,6 +4,7 @@ const assert = std.debug.assert; const Compilation = @import("Compilation.zig"); const build_options = @import("build_options"); const trace = @import("tracy.zig").trace; +const Module = @import("Package/Module.zig"); pub fn buildTsan(comp: *Compilation, prog_node: *std.Progress.Node) !void { if (!build_options.have_llvm) { @@ -195,44 +196,71 @@ pub fn buildTsan(comp: *Compilation, prog_node: *std.Progress.Node) !void { "-DTSAN_CONTAINS_UBSAN=0", }; + const optimize_mode = comp.compilerRtOptMode(); + const strip = comp.compilerRtStrip(); + + const config = try Compilation.Config.resolve(.{ + .output_mode = output_mode, + .link_mode = link_mode, + .resolved_target = comp.root_mod.resolved_target, + .is_test = false, + .have_zcu = false, + .emit_bin = true, + .root_optimize_mode = optimize_mode, + .root_strip = strip, + .link_libc = true, + }); + + const root_mod = try Module.create(arena, .{ + .global_cache_directory = comp.global_cache_directory, + .paths = .{ + .root = .{ .root_dir = comp.zig_lib_directory }, + .root_src_path = "", + }, + .fully_qualified_name = "root", + .inherited = .{ + .strip = strip, + .stack_check = false, + .stack_protector = 0, + .sanitize_c = false, + .sanitize_thread = false, + .red_zone = comp.root_mod.red_zone, + .omit_frame_pointer = comp.root_mod.omit_frame_pointer, + .valgrind = false, + .optimize_mode = optimize_mode, + .structured_cfg = comp.root_mod.structured_cfg, + .pic = true, + .cc_argv = &common_flags, + }, + .global = config, + .cc_argv = &.{}, + .parent = null, + .builtin_mod = null, + }); + const sub_compilation = try Compilation.create(comp.gpa, .{ .local_cache_directory = comp.global_cache_directory, .global_cache_directory = comp.global_cache_directory, .zig_lib_directory = comp.zig_lib_directory, + .thread_pool = comp.thread_pool, + .self_exe_path = comp.self_exe_path, .cache_mode = .whole, - .target = target, + .config = config, + .root_mod = root_mod, .root_name = root_name, - .main_mod = null, - .output_mode = output_mode, - .thread_pool = comp.thread_pool, - .libc_installation = comp.bin_file.options.libc_installation, + .libc_installation = comp.libc_installation, .emit_bin = emit_bin, - .optimize_mode = comp.compilerRtOptMode(), - .link_mode = link_mode, - .want_sanitize_c = false, - .want_stack_check = false, - .want_stack_protector = 0, - .want_valgrind = false, - .want_tsan = false, - .want_pic = true, - .want_pie = null, .emit_h = null, - .strip = comp.compilerRtStrip(), - .is_native_os = comp.bin_file.options.is_native_os, - .is_native_abi = comp.bin_file.options.is_native_abi, - .self_exe_path = comp.self_exe_path, .c_source_files = c_source_files.items, .verbose_cc = comp.verbose_cc, - .verbose_link = comp.bin_file.options.verbose_link, + .verbose_link = comp.verbose_link, .verbose_air = comp.verbose_air, .verbose_llvm_ir = comp.verbose_llvm_ir, .verbose_llvm_bc = comp.verbose_llvm_bc, .verbose_cimport = comp.verbose_cimport, .verbose_llvm_cpu_features = comp.verbose_llvm_cpu_features, .clang_passthrough_mode = comp.clang_passthrough_mode, - .link_libc = true, .skip_linker_dependencies = true, - .clang_argv = &common_flags, }); defer sub_compilation.destroy(); @@ -240,8 +268,8 @@ pub fn buildTsan(comp: *Compilation, prog_node: *std.Progress.Node) !void { assert(comp.tsan_static_lib == null); comp.tsan_static_lib = Compilation.CRTFile{ - .full_object_path = try sub_compilation.bin_file.options.emit.?.directory.join(comp.gpa, &[_][]const u8{ - sub_compilation.bin_file.options.emit.?.sub_path, + .full_object_path = try sub_compilation.bin_file.?.emit.directory.join(comp.gpa, &[_][]const u8{ + sub_compilation.bin_file.?.emit.sub_path, }), .lock = sub_compilation.bin_file.toOwnedLock(), }; |
