| author | |
| committer | |
| log | e40557b1f75863d9a66af301e83c8c48f0df81d5 |
| tree | a3b80f2f47add44dec6abbaa22b5083074a341c8 |
| parent | 1a9d75ebe0037bd908ed263bb7f4228f9a8681ef |
The motivation is that libfuzzer is slow in Debug mode and bugs usually
manifest late into fuzzing, which makes testing it in ReleaseSafe
useful.5 files changed, 20 insertions(+), 11 deletions(-)
lib/compiler/build_runner.zig+5-1| ... | ... | @@ -310,7 +310,11 @@ pub fn main(init: process.Init.Minimal) !void { |
| 310 | 310 | } else if (mem.eql(u8, arg, "--debug-pkg-config")) { |
| 311 | 311 | builder.debug_pkg_config = true; |
| 312 | 312 | } else if (mem.eql(u8, arg, "--debug-rt")) { |
| 313 | graph.debug_compiler_runtime_libs = true; | |
| 313 | graph.debug_compiler_runtime_libs = .Debug; | |
| 314 | } else if (mem.cutPrefix(u8, arg, "--debug-rt=")) |rest| { | |
| 315 | graph.debug_compiler_runtime_libs = | |
| 316 | std.meta.stringToEnum(std.builtin.OptimizeMode, rest) orelse | |
| 317 | fatal("unrecognized optimization mode: '{s}'", .{rest}); | |
| 314 | 318 | } else if (mem.eql(u8, arg, "--debug-compile-errors")) { |
| 315 | 319 | builder.debug_compile_errors = true; |
| 316 | 320 | } else if (mem.eql(u8, arg, "--debug-incremental")) { |
lib/std/Build.zig+1-1| ... | ... | @@ -115,7 +115,7 @@ pub const Graph = struct { |
| 115 | 115 | arena: Allocator, |
| 116 | 116 | system_library_options: std.StringArrayHashMapUnmanaged(SystemLibraryMode) = .empty, |
| 117 | 117 | system_package_mode: bool = false, |
| 118 | debug_compiler_runtime_libs: bool = false, | |
| 118 | debug_compiler_runtime_libs: ?std.builtin.OptimizeMode = null, | |
| 119 | 119 | cache: Cache, |
| 120 | 120 | zig_exe: [:0]const u8, |
| 121 | 121 | environ_map: process.Environ.Map, |
lib/std/Build/Step/Compile.zig+2-1| ... | ... | @@ -1462,7 +1462,8 @@ fn getZigArgs(compile: *Compile, fuzz: bool) ![][]const u8 { |
| 1462 | 1462 | try zig_args.append("--global-cache-dir"); |
| 1463 | 1463 | try zig_args.append(b.graph.global_cache_root.path orelse "."); |
| 1464 | 1464 | |
| 1465 | if (b.graph.debug_compiler_runtime_libs) try zig_args.append("--debug-rt"); | |
| 1465 | if (b.graph.debug_compiler_runtime_libs) |mode| | |
| 1466 | try zig_args.append(b.fmt("--debug-rt={t}", .{mode})); | |
| 1466 | 1467 | |
| 1467 | 1468 | try zig_args.append("--name"); |
| 1468 | 1469 | try zig_args.append(compile.name); |
src/Compilation.zig+6-5| ... | ... | @@ -186,7 +186,7 @@ verbose_link: bool, |
| 186 | 186 | link_depfile: ?[]const u8, |
| 187 | 187 | disable_c_depfile: bool, |
| 188 | 188 | stack_report: bool, |
| 189 | debug_compiler_runtime_libs: bool, | |
| 189 | debug_compiler_runtime_libs: ?std.builtin.OptimizeMode, | |
| 190 | 190 | debug_compile_errors: bool, |
| 191 | 191 | /// Do not check this field directly. Instead, use the `debugIncremental` wrapper function. |
| 192 | 192 | debug_incremental: bool, |
| ... | ... | @@ -1749,7 +1749,7 @@ pub const CreateOptions = struct { |
| 1749 | 1749 | link_depfile: ?[]const u8 = null, |
| 1750 | 1750 | verbose_cimport: bool = false, |
| 1751 | 1751 | verbose_llvm_cpu_features: bool = false, |
| 1752 | debug_compiler_runtime_libs: bool = false, | |
| 1752 | debug_compiler_runtime_libs: ?std.builtin.OptimizeMode = null, | |
| 1753 | 1753 | debug_compile_errors: bool = false, |
| 1754 | 1754 | debug_incremental: bool = false, |
| 1755 | 1755 | /// Normally when you create a `Compilation`, Zig will automatically build |
| ... | ... | @@ -2201,7 +2201,8 @@ pub fn create(gpa: Allocator, arena: Allocator, io: Io, diag: *CreateDiagnostic, |
| 2201 | 2201 | cache.hash.addBytes(options.root_name); |
| 2202 | 2202 | cache.hash.add(options.config.wasi_exec_model); |
| 2203 | 2203 | cache.hash.add(options.config.san_cov_trace_pc_guard); |
| 2204 | cache.hash.add(options.debug_compiler_runtime_libs); | |
| 2204 | cache.hash.add(options.debug_compiler_runtime_libs != null); | |
| 2205 | if (options.debug_compiler_runtime_libs) |mode| cache.hash.add(mode); | |
| 2205 | 2206 | // The actual emit paths don't matter. They're only user-specified if we aren't using the |
| 2206 | 2207 | // cache! However, it does matter whether the files are emitted at all. |
| 2207 | 2208 | cache.hash.add(options.emit_bin != .no); |
| ... | ... | @@ -8373,8 +8374,8 @@ pub fn addLinkLib(comp: *Compilation, lib_name: []const u8) !void { |
| 8373 | 8374 | /// This decides the optimization mode for all zig-provided libraries, including |
| 8374 | 8375 | /// compiler-rt, libcxx, libc, libunwind, etc. |
| 8375 | 8376 | pub fn compilerRtOptMode(comp: Compilation) std.builtin.OptimizeMode { |
| 8376 | if (comp.debug_compiler_runtime_libs) { | |
| 8377 | return .Debug; | |
| 8377 | if (comp.debug_compiler_runtime_libs) |mode| { | |
| 8378 | return mode; | |
| 8378 | 8379 | } |
| 8379 | 8380 | const target = &comp.root_mod.resolved_target.result; |
| 8380 | 8381 | switch (comp.root_mod.optimize_mode) { |
src/main.zig+6-3| ... | ... | @@ -708,7 +708,8 @@ const usage_build_generic = |
| 708 | 708 | \\ --debug-log [scope] Enable printing debug/info log messages for scope |
| 709 | 709 | \\ --debug-compile-errors Crash with helpful diagnostics at the first compile error |
| 710 | 710 | \\ --debug-link-snapshot Enable dumping of the linker's state in JSON format |
| 711 | \\ --debug-rt Debug compiler runtime libraries | |
| 711 | \\ --debug-rt[=mode] Build compiler runtime libraries with [mode] optimization | |
| 712 | \\ (Debug if [=mode] is omitted) | |
| 712 | 713 | \\ --debug-incremental Enable incremental compilation debug features |
| 713 | 714 | \\ |
| 714 | 715 | ; |
| ... | ... | @@ -928,7 +929,7 @@ fn buildOutputType( |
| 928 | 929 | var minor_subsystem_version: ?u16 = null; |
| 929 | 930 | var mingw_unicode_entry_point: bool = false; |
| 930 | 931 | var enable_link_snapshots: bool = false; |
| 931 | var debug_compiler_runtime_libs = false; | |
| 932 | var debug_compiler_runtime_libs: ?std.builtin.OptimizeMode = null; | |
| 932 | 933 | var install_name: ?[]const u8 = null; |
| 933 | 934 | var hash_style: link.File.Lld.Elf.HashStyle = .both; |
| 934 | 935 | var entitlements: ?[]const u8 = null; |
| ... | ... | @@ -1382,7 +1383,9 @@ fn buildOutputType( |
| 1382 | 1383 | enable_link_snapshots = true; |
| 1383 | 1384 | } |
| 1384 | 1385 | } else if (mem.eql(u8, arg, "--debug-rt")) { |
| 1385 | debug_compiler_runtime_libs = true; | |
| 1386 | debug_compiler_runtime_libs = .Debug; | |
| 1387 | } else if (mem.cutPrefix(u8, arg, "--debug-rt=")) |rest| { | |
| 1388 | debug_compiler_runtime_libs = parseOptimizeMode(rest); | |
| 1386 | 1389 | } else if (mem.eql(u8, arg, "--debug-incremental")) { |
| 1387 | 1390 | if (build_options.enable_debug_extensions) { |
| 1388 | 1391 | debug_incremental = true; |