mirror of
https://codeberg.org/ziglang/zig.git
synced 2025-12-06 13:54:21 +00:00
allow specifying mode in --debug-rt
The motivation is that libfuzzer is slow in Debug mode and bugs usually manifest late into fuzzing, which makes testing it in ReleaseSafe useful.
This commit is contained in:
parent
0dbbb93dbe
commit
bb88f7bc4e
5 changed files with 20 additions and 11 deletions
|
|
@ -304,7 +304,11 @@ pub fn main() !void {
|
||||||
} else if (mem.eql(u8, arg, "--debug-pkg-config")) {
|
} else if (mem.eql(u8, arg, "--debug-pkg-config")) {
|
||||||
builder.debug_pkg_config = true;
|
builder.debug_pkg_config = true;
|
||||||
} else if (mem.eql(u8, arg, "--debug-rt")) {
|
} else if (mem.eql(u8, arg, "--debug-rt")) {
|
||||||
graph.debug_compiler_runtime_libs = true;
|
graph.debug_compiler_runtime_libs = .Debug;
|
||||||
|
} else if (mem.cutPrefix(u8, arg, "--debug-rt=")) |rest| {
|
||||||
|
graph.debug_compiler_runtime_libs =
|
||||||
|
std.meta.stringToEnum(std.builtin.OptimizeMode, rest) orelse
|
||||||
|
fatal("unrecognized optimization mode: '{s}'", .{rest});
|
||||||
} else if (mem.eql(u8, arg, "--debug-compile-errors")) {
|
} else if (mem.eql(u8, arg, "--debug-compile-errors")) {
|
||||||
builder.debug_compile_errors = true;
|
builder.debug_compile_errors = true;
|
||||||
} else if (mem.eql(u8, arg, "--debug-incremental")) {
|
} else if (mem.eql(u8, arg, "--debug-incremental")) {
|
||||||
|
|
|
||||||
|
|
@ -116,7 +116,7 @@ pub const Graph = struct {
|
||||||
arena: Allocator,
|
arena: Allocator,
|
||||||
system_library_options: std.StringArrayHashMapUnmanaged(SystemLibraryMode) = .empty,
|
system_library_options: std.StringArrayHashMapUnmanaged(SystemLibraryMode) = .empty,
|
||||||
system_package_mode: bool = false,
|
system_package_mode: bool = false,
|
||||||
debug_compiler_runtime_libs: bool = false,
|
debug_compiler_runtime_libs: ?std.builtin.OptimizeMode = null,
|
||||||
cache: Cache,
|
cache: Cache,
|
||||||
zig_exe: [:0]const u8,
|
zig_exe: [:0]const u8,
|
||||||
env_map: EnvMap,
|
env_map: EnvMap,
|
||||||
|
|
|
||||||
|
|
@ -1572,7 +1572,8 @@ fn getZigArgs(compile: *Compile, fuzz: bool) ![][]const u8 {
|
||||||
try zig_args.append("--global-cache-dir");
|
try zig_args.append("--global-cache-dir");
|
||||||
try zig_args.append(b.graph.global_cache_root.path orelse ".");
|
try zig_args.append(b.graph.global_cache_root.path orelse ".");
|
||||||
|
|
||||||
if (b.graph.debug_compiler_runtime_libs) try zig_args.append("--debug-rt");
|
if (b.graph.debug_compiler_runtime_libs) |mode|
|
||||||
|
try zig_args.append(b.fmt("--debug-rt={t}", .{mode}));
|
||||||
|
|
||||||
try zig_args.append("--name");
|
try zig_args.append("--name");
|
||||||
try zig_args.append(compile.name);
|
try zig_args.append(compile.name);
|
||||||
|
|
|
||||||
|
|
@ -175,7 +175,7 @@ verbose_llvm_cpu_features: bool,
|
||||||
verbose_link: bool,
|
verbose_link: bool,
|
||||||
disable_c_depfile: bool,
|
disable_c_depfile: bool,
|
||||||
stack_report: bool,
|
stack_report: bool,
|
||||||
debug_compiler_runtime_libs: bool,
|
debug_compiler_runtime_libs: ?std.builtin.OptimizeMode,
|
||||||
debug_compile_errors: bool,
|
debug_compile_errors: bool,
|
||||||
/// Do not check this field directly. Instead, use the `debugIncremental` wrapper function.
|
/// Do not check this field directly. Instead, use the `debugIncremental` wrapper function.
|
||||||
debug_incremental: bool,
|
debug_incremental: bool,
|
||||||
|
|
@ -1734,7 +1734,7 @@ pub const CreateOptions = struct {
|
||||||
verbose_llvm_bc: ?[]const u8 = null,
|
verbose_llvm_bc: ?[]const u8 = null,
|
||||||
verbose_cimport: bool = false,
|
verbose_cimport: bool = false,
|
||||||
verbose_llvm_cpu_features: bool = false,
|
verbose_llvm_cpu_features: bool = false,
|
||||||
debug_compiler_runtime_libs: bool = false,
|
debug_compiler_runtime_libs: ?std.builtin.OptimizeMode = null,
|
||||||
debug_compile_errors: bool = false,
|
debug_compile_errors: bool = false,
|
||||||
debug_incremental: bool = false,
|
debug_incremental: bool = false,
|
||||||
/// Normally when you create a `Compilation`, Zig will automatically build
|
/// Normally when you create a `Compilation`, Zig will automatically build
|
||||||
|
|
@ -2134,7 +2134,8 @@ pub fn create(gpa: Allocator, arena: Allocator, io: Io, diag: *CreateDiagnostic,
|
||||||
cache.hash.addBytes(options.root_name);
|
cache.hash.addBytes(options.root_name);
|
||||||
cache.hash.add(options.config.wasi_exec_model);
|
cache.hash.add(options.config.wasi_exec_model);
|
||||||
cache.hash.add(options.config.san_cov_trace_pc_guard);
|
cache.hash.add(options.config.san_cov_trace_pc_guard);
|
||||||
cache.hash.add(options.debug_compiler_runtime_libs);
|
cache.hash.add(options.debug_compiler_runtime_libs != null);
|
||||||
|
if (options.debug_compiler_runtime_libs) |mode| cache.hash.add(mode);
|
||||||
// The actual emit paths don't matter. They're only user-specified if we aren't using the
|
// The actual emit paths don't matter. They're only user-specified if we aren't using the
|
||||||
// cache! However, it does matter whether the files are emitted at all.
|
// cache! However, it does matter whether the files are emitted at all.
|
||||||
cache.hash.add(options.emit_bin != .no);
|
cache.hash.add(options.emit_bin != .no);
|
||||||
|
|
@ -8152,8 +8153,8 @@ pub fn addLinkLib(comp: *Compilation, lib_name: []const u8) !void {
|
||||||
/// This decides the optimization mode for all zig-provided libraries, including
|
/// This decides the optimization mode for all zig-provided libraries, including
|
||||||
/// compiler-rt, libcxx, libc, libunwind, etc.
|
/// compiler-rt, libcxx, libc, libunwind, etc.
|
||||||
pub fn compilerRtOptMode(comp: Compilation) std.builtin.OptimizeMode {
|
pub fn compilerRtOptMode(comp: Compilation) std.builtin.OptimizeMode {
|
||||||
if (comp.debug_compiler_runtime_libs) {
|
if (comp.debug_compiler_runtime_libs) |mode| {
|
||||||
return .Debug;
|
return mode;
|
||||||
}
|
}
|
||||||
const target = &comp.root_mod.resolved_target.result;
|
const target = &comp.root_mod.resolved_target.result;
|
||||||
switch (comp.root_mod.optimize_mode) {
|
switch (comp.root_mod.optimize_mode) {
|
||||||
|
|
|
||||||
|
|
@ -678,7 +678,8 @@ const usage_build_generic =
|
||||||
\\ --debug-log [scope] Enable printing debug/info log messages for scope
|
\\ --debug-log [scope] Enable printing debug/info log messages for scope
|
||||||
\\ --debug-compile-errors Crash with helpful diagnostics at the first compile error
|
\\ --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-link-snapshot Enable dumping of the linker's state in JSON format
|
||||||
\\ --debug-rt Debug compiler runtime libraries
|
\\ --debug-rt[=mode] Build compiler runtime libraries with [mode] optimization
|
||||||
|
\\ (Debug if [=mode] is omitted)
|
||||||
\\ --debug-incremental Enable incremental compilation debug features
|
\\ --debug-incremental Enable incremental compilation debug features
|
||||||
\\
|
\\
|
||||||
;
|
;
|
||||||
|
|
@ -895,7 +896,7 @@ fn buildOutputType(
|
||||||
var minor_subsystem_version: ?u16 = null;
|
var minor_subsystem_version: ?u16 = null;
|
||||||
var mingw_unicode_entry_point: bool = false;
|
var mingw_unicode_entry_point: bool = false;
|
||||||
var enable_link_snapshots: bool = false;
|
var enable_link_snapshots: bool = false;
|
||||||
var debug_compiler_runtime_libs = false;
|
var debug_compiler_runtime_libs: ?std.builtin.OptimizeMode = null;
|
||||||
var install_name: ?[]const u8 = null;
|
var install_name: ?[]const u8 = null;
|
||||||
var hash_style: link.File.Lld.Elf.HashStyle = .both;
|
var hash_style: link.File.Lld.Elf.HashStyle = .both;
|
||||||
var entitlements: ?[]const u8 = null;
|
var entitlements: ?[]const u8 = null;
|
||||||
|
|
@ -1350,7 +1351,9 @@ fn buildOutputType(
|
||||||
enable_link_snapshots = true;
|
enable_link_snapshots = true;
|
||||||
}
|
}
|
||||||
} else if (mem.eql(u8, arg, "--debug-rt")) {
|
} else if (mem.eql(u8, arg, "--debug-rt")) {
|
||||||
debug_compiler_runtime_libs = true;
|
debug_compiler_runtime_libs = .Debug;
|
||||||
|
} else if (mem.cutPrefix(u8, arg, "--debug-rt=")) |rest| {
|
||||||
|
debug_compiler_runtime_libs = parseOptimizeMode(rest);
|
||||||
} else if (mem.eql(u8, arg, "--debug-incremental")) {
|
} else if (mem.eql(u8, arg, "--debug-incremental")) {
|
||||||
if (build_options.enable_debug_extensions) {
|
if (build_options.enable_debug_extensions) {
|
||||||
debug_incremental = true;
|
debug_incremental = true;
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue