commit 97f2a8b5cb4c882e05add16a69c7a55f7fe46794 (tree)
parent 1a01151a4e1e83826d6911c929210aabcaed36e9
Author: Andrew Kelley <andrew@ziglang.org>
Date: Mon, 26 Feb 2024 23:48:56 -0700
introduce ZIG_DEBUG_CMD to choose debug mode
for lazily built commands such as `zig fmt` and `zig reduce`. Useful if
you want to test a patch to them.
Diffstat:
2 files changed, 7 insertions(+), 2 deletions(-)
diff --git a/src/introspect.zig b/src/introspect.zig
@@ -153,6 +153,7 @@ pub const EnvVar = enum {
ZIG_VERBOSE_LINK,
ZIG_VERBOSE_CC,
ZIG_BTRFS_WORKAROUND,
+ ZIG_DEBUG_CMD,
CC,
NO_COLOR,
XDG_CACHE_HOME,
diff --git a/src/main.zig b/src/main.zig
@@ -5735,6 +5735,10 @@ fn jitCmd(
fatal("unable to find self exe path: {s}", .{@errorName(err)});
};
+ const optimize_mode: std.builtin.OptimizeMode = if (EnvVar.ZIG_DEBUG_CMD.isSet())
+ .Debug
+ else
+ .ReleaseFast;
const override_lib_dir: ?[]const u8 = try EnvVar.ZIG_LIB_DIR.get(arena);
const override_global_cache_dir: ?[]const u8 = try EnvVar.ZIG_GLOBAL_CACHE_DIR.get(arena);
@@ -5777,7 +5781,7 @@ fn jitCmd(
const config = try Compilation.Config.resolve(.{
.output_mode = .Exe,
- .root_optimize_mode = .ReleaseFast,
+ .root_optimize_mode = optimize_mode,
.resolved_target = resolved_target,
.have_zcu = true,
.emit_bin = true,
@@ -5791,7 +5795,7 @@ fn jitCmd(
.cc_argv = &.{},
.inherited = .{
.resolved_target = resolved_target,
- .optimize_mode = .ReleaseFast,
+ .optimize_mode = optimize_mode,
},
.global = config,
.parent = null,