diff options
| author | Andrew Kelley <andrew@ziglang.org> | 2024-07-23 11:39:19 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-07-23 11:39:19 -0700 |
| commit | 6f3e9939d0389539570d4a7cad95b1e96bc8f0d4 (patch) | |
| tree | abf951c8dc19393655df93f23a6911ce6fad660d /src/codegen/llvm.zig | |
| parent | 255547d7a6a1acee9c9b65d251ec4935433b6878 (diff) | |
| parent | 61ad1be6bd7d27f79773e7da891898449a45a80e (diff) | |
| download | zig-6f3e9939d0389539570d4a7cad95b1e96bc8f0d4.tar.gz zig-6f3e9939d0389539570d4a7cad95b1e96bc8f0d4.zip | |
Merge pull request #20725 from ziglang/fuzz
initial support for integrated fuzzing
Diffstat (limited to 'src/codegen/llvm.zig')
| -rw-r--r-- | src/codegen/llvm.zig | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/src/codegen/llvm.zig b/src/codegen/llvm.zig index 58e71c7eda..e5f8250064 100644 --- a/src/codegen/llvm.zig +++ b/src/codegen/llvm.zig @@ -1101,6 +1101,7 @@ pub const Object = struct { is_small: bool, time_report: bool, sanitize_thread: bool, + fuzz: bool, lto: bool, }; @@ -1287,6 +1288,7 @@ pub const Object = struct { options.is_small, options.time_report, options.sanitize_thread, + options.fuzz, options.lto, null, emit_bin_path, @@ -1311,6 +1313,7 @@ pub const Object = struct { options.is_small, options.time_report, options.sanitize_thread, + options.fuzz, options.lto, options.asm_path, emit_bin_path, @@ -1380,6 +1383,25 @@ pub const Object = struct { _ = try attributes.removeFnAttr(.cold); } + if (owner_mod.sanitize_thread and !func_analysis.disable_instrumentation) { + try attributes.addFnAttr(.sanitize_thread, &o.builder); + } else { + _ = try attributes.removeFnAttr(.sanitize_thread); + } + 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); + } + } else { + _ = try attributes.removeFnAttr(.optforfuzzing); + if (comp.config.any_fuzz) { + try attributes.addFnAttr(.skipprofile, &o.builder); + try attributes.addFnAttr(.nosanitize_coverage, &o.builder); + } + } + // TODO: disable this if safety is off for the function scope const ssp_buf_size = owner_mod.stack_protector; if (ssp_buf_size != 0) { @@ -2979,9 +3001,6 @@ pub const Object = struct { try attributes.addFnAttr(.minsize, &o.builder); try attributes.addFnAttr(.optsize, &o.builder); } - if (owner_mod.sanitize_thread) { - try attributes.addFnAttr(.sanitize_thread, &o.builder); - } const target = owner_mod.resolved_target.result; if (target.cpu.model.llvm_name) |s| { try attributes.addFnAttr(.{ .string = .{ |
