aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2024-07-24 17:41:44 -0700
committerAndrew Kelley <andrew@ziglang.org>2024-07-25 18:52:21 -0700
commita3c74aca99c7eaf719c745ec6e9ee7366cad1910 (patch)
treeb0396505cb9623d1a906501ed97905f7cc8bb6c6 /src
parent90dfd86ebee1639e5455ace4e34157ff9b68ac0f (diff)
downloadzig-a3c74aca99c7eaf719c745ec6e9ee7366cad1910.tar.gz
zig-a3c74aca99c7eaf719c745ec6e9ee7366cad1910.zip
add --debug-rt CLI arg to the compiler + bonus edits
The flag makes compiler_rt and libfuzzer be in debug mode. Also: * fuzzer: override debug logs and disable debug logs for frequently called functions * std.Build.Fuzz: fix bug of rerunning the old unit test binary * report errors from rebuilding the unit tests better * link.Elf: additionally add tsan lib and fuzzer lib to the hash
Diffstat (limited to 'src')
-rw-r--r--src/Compilation.zig4
-rw-r--r--src/link/Elf.zig2
-rw-r--r--src/main.zig5
3 files changed, 10 insertions, 1 deletions
diff --git a/src/Compilation.zig b/src/Compilation.zig
index bc5a2bb456..8808e72e04 100644
--- a/src/Compilation.zig
+++ b/src/Compilation.zig
@@ -2180,7 +2180,9 @@ pub fn update(comp: *Compilation, main_progress_node: std.Progress.Node) !void {
comp.bin_file = try link.File.createEmpty(arena, comp, emit, whole.lf_open_opts);
}
},
- .incremental => {},
+ .incremental => {
+ log.debug("Compilation.update for {s}, CacheMode.incremental", .{comp.root_name});
+ },
}
// From this point we add a preliminary set of file system inputs that
diff --git a/src/link/Elf.zig b/src/link/Elf.zig
index ecb38974ca..7c1d695bd9 100644
--- a/src/link/Elf.zig
+++ b/src/link/Elf.zig
@@ -2286,6 +2286,8 @@ fn linkWithLLD(self: *Elf, arena: Allocator, tid: Zcu.PerThread.Id, prog_node: s
}
try man.addOptionalFile(module_obj_path);
try man.addOptionalFile(compiler_rt_path);
+ try man.addOptionalFile(if (comp.tsan_lib) |l| l.full_object_path else null);
+ try man.addOptionalFile(if (comp.fuzzer_lib) |l| l.full_object_path else null);
// We can skip hashing libc and libc++ components that we are in charge of building from Zig
// installation sources because they are always a product of the compiler version + target information.
diff --git a/src/main.zig b/src/main.zig
index 9940312bcd..ddd2e79f44 100644
--- a/src/main.zig
+++ b/src/main.zig
@@ -655,6 +655,7 @@ const usage_build_generic =
\\ --debug-log [scope] Enable printing debug/info log messages for scope
\\ --debug-compile-errors Crash with helpful diagnostics at the first compile error
\\ --debug-link-snapshot Enable dumping of the linker's state in JSON format
+ \\ --debug-rt Debug compiler runtime libraries
\\
;
@@ -912,6 +913,7 @@ fn buildOutputType(
var minor_subsystem_version: ?u16 = null;
var mingw_unicode_entry_point: bool = false;
var enable_link_snapshots: bool = false;
+ var debug_compiler_runtime_libs = false;
var opt_incremental: ?bool = null;
var install_name: ?[]const u8 = null;
var hash_style: link.File.Elf.HashStyle = .both;
@@ -1367,6 +1369,8 @@ fn buildOutputType(
} else {
enable_link_snapshots = true;
}
+ } else if (mem.eql(u8, arg, "--debug-rt")) {
+ debug_compiler_runtime_libs = true;
} else if (mem.eql(u8, arg, "-fincremental")) {
dev.check(.incremental);
opt_incremental = true;
@@ -3408,6 +3412,7 @@ fn buildOutputType(
// noise when --search-prefix and --mod are combined.
.global_cc_argv = try cc_argv.toOwnedSlice(arena),
.file_system_inputs = &file_system_inputs,
+ .debug_compiler_runtime_libs = debug_compiler_runtime_libs,
}) catch |err| switch (err) {
error.LibCUnavailable => {
const triple_name = try target.zigTriple(arena);