authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2023-12-15 14:31:55-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2024-01-01 17:51:19-07:00
logea0ba4f2b572fad8595ae02ac9c43ab7dd0cc2f2
tree2b45a88c5f100f11d1011a12d44da4a83a7fda0f
parenta1236b32f9a4114231312b1493dcbac308a2c055

tsan: update to new Compilation API


1 files changed, 51 insertions(+), 23 deletions(-)

src/libtsan.zig+51-23
......@@ -4,6 +4,7 @@ const assert = std.debug.assert;
44const Compilation = @import("Compilation.zig");
55const build_options = @import("build_options");
66const trace = @import("tracy.zig").trace;
7const Module = @import("Package/Module.zig");
78
89pub fn buildTsan(comp: *Compilation, prog_node: *std.Progress.Node) !void {
910 if (!build_options.have_llvm) {
......@@ -195,44 +196,71 @@ pub fn buildTsan(comp: *Compilation, prog_node: *std.Progress.Node) !void {
195196 "-DTSAN_CONTAINS_UBSAN=0",
196197 };
197198
199 const optimize_mode = comp.compilerRtOptMode();
200 const strip = comp.compilerRtStrip();
201
202 const config = try Compilation.Config.resolve(.{
203 .output_mode = output_mode,
204 .link_mode = link_mode,
205 .resolved_target = comp.root_mod.resolved_target,
206 .is_test = false,
207 .have_zcu = false,
208 .emit_bin = true,
209 .root_optimize_mode = optimize_mode,
210 .root_strip = strip,
211 .link_libc = true,
212 });
213
214 const root_mod = try Module.create(arena, .{
215 .global_cache_directory = comp.global_cache_directory,
216 .paths = .{
217 .root = .{ .root_dir = comp.zig_lib_directory },
218 .root_src_path = "",
219 },
220 .fully_qualified_name = "root",
221 .inherited = .{
222 .strip = strip,
223 .stack_check = false,
224 .stack_protector = 0,
225 .sanitize_c = false,
226 .sanitize_thread = false,
227 .red_zone = comp.root_mod.red_zone,
228 .omit_frame_pointer = comp.root_mod.omit_frame_pointer,
229 .valgrind = false,
230 .optimize_mode = optimize_mode,
231 .structured_cfg = comp.root_mod.structured_cfg,
232 .pic = true,
233 .cc_argv = &common_flags,
234 },
235 .global = config,
236 .cc_argv = &.{},
237 .parent = null,
238 .builtin_mod = null,
239 });
240
198241 const sub_compilation = try Compilation.create(comp.gpa, .{
199242 .local_cache_directory = comp.global_cache_directory,
200243 .global_cache_directory = comp.global_cache_directory,
201244 .zig_lib_directory = comp.zig_lib_directory,
245 .thread_pool = comp.thread_pool,
246 .self_exe_path = comp.self_exe_path,
202247 .cache_mode = .whole,
203 .target = target,
248 .config = config,
249 .root_mod = root_mod,
204250 .root_name = root_name,
205 .main_mod = null,
206 .output_mode = output_mode,
207 .thread_pool = comp.thread_pool,
208 .libc_installation = comp.bin_file.options.libc_installation,
251 .libc_installation = comp.libc_installation,
209252 .emit_bin = emit_bin,
210 .optimize_mode = comp.compilerRtOptMode(),
211 .link_mode = link_mode,
212 .want_sanitize_c = false,
213 .want_stack_check = false,
214 .want_stack_protector = 0,
215 .want_valgrind = false,
216 .want_tsan = false,
217 .want_pic = true,
218 .want_pie = null,
219253 .emit_h = null,
220 .strip = comp.compilerRtStrip(),
221 .is_native_os = comp.bin_file.options.is_native_os,
222 .is_native_abi = comp.bin_file.options.is_native_abi,
223 .self_exe_path = comp.self_exe_path,
224254 .c_source_files = c_source_files.items,
225255 .verbose_cc = comp.verbose_cc,
226 .verbose_link = comp.bin_file.options.verbose_link,
256 .verbose_link = comp.verbose_link,
227257 .verbose_air = comp.verbose_air,
228258 .verbose_llvm_ir = comp.verbose_llvm_ir,
229259 .verbose_llvm_bc = comp.verbose_llvm_bc,
230260 .verbose_cimport = comp.verbose_cimport,
231261 .verbose_llvm_cpu_features = comp.verbose_llvm_cpu_features,
232262 .clang_passthrough_mode = comp.clang_passthrough_mode,
233 .link_libc = true,
234263 .skip_linker_dependencies = true,
235 .clang_argv = &common_flags,
236264 });
237265 defer sub_compilation.destroy();
238266
......@@ -240,8 +268,8 @@ pub fn buildTsan(comp: *Compilation, prog_node: *std.Progress.Node) !void {
240268
241269 assert(comp.tsan_static_lib == null);
242270 comp.tsan_static_lib = Compilation.CRTFile{
243 .full_object_path = try sub_compilation.bin_file.options.emit.?.directory.join(comp.gpa, &[_][]const u8{
244 sub_compilation.bin_file.options.emit.?.sub_path,
271 .full_object_path = try sub_compilation.bin_file.?.emit.directory.join(comp.gpa, &[_][]const u8{
272 sub_compilation.bin_file.?.emit.sub_path,
245273 }),
246274 .lock = sub_compilation.bin_file.toOwnedLock(),
247275 };