aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2024-02-26 23:48:56 -0700
committerAndrew Kelley <andrew@ziglang.org>2024-02-26 23:48:56 -0700
commit97f2a8b5cb4c882e05add16a69c7a55f7fe46794 (patch)
tree1e43782596289add5da2d11e68b907d03b071739
parent1a01151a4e1e83826d6911c929210aabcaed36e9 (diff)
downloadzig-97f2a8b5cb4c882e05add16a69c7a55f7fe46794.tar.gz
zig-97f2a8b5cb4c882e05add16a69c7a55f7fe46794.zip
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.
-rw-r--r--src/introspect.zig1
-rw-r--r--src/main.zig8
2 files changed, 7 insertions, 2 deletions
diff --git a/src/introspect.zig b/src/introspect.zig
index 765e9409ed..36821592df 100644
--- 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
index 65632cd16a..24ca355238 100644
--- 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,