aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2024-07-25 18:52:39 -0700
committerGitHub <noreply@github.com>2024-07-25 18:52:39 -0700
commitafddfe25d80ee4db930ba746f25264286af6d325 (patch)
tree13c7fa62cbe65047da0cd109784ef417e92bd6ae /src
parent1c35e73b614398529782f8c027366c6d8d51ac4b (diff)
parent688c2df6464bd10a2dcfdf49e89c313e01da9991 (diff)
downloadzig-afddfe25d80ee4db930ba746f25264286af6d325.tar.gz
zig-afddfe25d80ee4db930ba746f25264286af6d325.zip
Merge pull request #20773 from ziglang/fuzz
integrate fuzz testing into the build system
Diffstat (limited to 'src')
-rw-r--r--src/Compilation.zig4
-rw-r--r--src/codegen/llvm.zig12
-rw-r--r--src/link/Elf.zig2
-rw-r--r--src/main.zig5
4 files changed, 14 insertions, 9 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/codegen/llvm.zig b/src/codegen/llvm.zig
index eec0412492..f83d115b18 100644
--- a/src/codegen/llvm.zig
+++ b/src/codegen/llvm.zig
@@ -1392,16 +1392,12 @@ pub const Object = struct {
}
if (owner_mod.fuzz and !func_analysis.disable_instrumentation) {
try attributes.addFnAttr(.optforfuzzing, &o.builder);
- if (comp.config.any_fuzz) {
- _ = try attributes.removeFnAttr(.skipprofile);
- _ = try attributes.removeFnAttr(.nosanitize_coverage);
- }
+ _ = try attributes.removeFnAttr(.skipprofile);
+ _ = try attributes.removeFnAttr(.nosanitize_coverage);
} else {
_ = try attributes.removeFnAttr(.optforfuzzing);
- if (comp.config.any_fuzz) {
- try attributes.addFnAttr(.skipprofile, &o.builder);
- try attributes.addFnAttr(.nosanitize_coverage, &o.builder);
- }
+ try attributes.addFnAttr(.skipprofile, &o.builder);
+ try attributes.addFnAttr(.nosanitize_coverage, &o.builder);
}
// TODO: disable this if safety is off for the function scope
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);