mirror of
https://codeberg.org/ziglang/zig.git
synced 2026-10-28 10:45:48 +08:00
main: reimplement compiler debug flags
* Add `.llvmbc`/`.llvmir` to `ObjectFormat` for emitting unoptimized IR * Replace `--verbose-air`, `--verbose-intern-pool`, `--verbose-generic-instances`, `--verbose-llvm-ir`, and `--verbose-llvm-bc` with various `--debug-log` scopes * `--debug-log illegal-air`: pre-legalized Air * `--debug-log legal-air`: post-legalized Air * `--debug-log air`: final Air with liveness * `--debug-log ip-stats`: InternPool statistics * `--debug-log ip-values`: InternPool values * `--debug-log ip-generic-instances`: InternPool generic instances * `--debug-log llvm-ir`: pre-optimized LLVM IR * `--debug-log opt-llvm-ir`: post-optimized LLVM IR * Delete `--verbose-cimport` which does nothing * Delete `--verbose-llvm-cpu-features` which is equivalent to looking at the outputs of `--show-builtin` and `--debug-log llvm-ir`
This commit is contained in:
1 parent
77576c9603
commit
f08a8f0fc2
48 files changed
+349
-421
No files matched your search
@@ -25,6 +25,10 @@ pub fn build(b: *std.Build) !void {
|
||||
},
|
||||
});
|
||||
const optimize = b.standardOptimizeOption(.{});
|
||||
const is_debug = switch (optimize) {
|
||||
.debug => true,
|
||||
.safe, .fast, .small => false,
|
||||
};
|
||||
|
||||
const flat = b.option(bool, "flat", "Put files into the installation prefix in a manner suited for upstream distribution rather than a posix file system hierarchy standard") orelse false;
|
||||
const single_threaded = b.option(bool, "single-threaded", "Build artifacts that run in single threaded mode");
|
||||
@@ -205,9 +209,9 @@ pub fn build(b: *std.Build) !void {
|
||||
const value_tracing = b.option(bool, "value-tracing", "Enable extra state tracking to help troubleshoot bugs in the compiler (using the std.debug.Trace API)") orelse false;
|
||||
|
||||
const mem_leak_frames: u32 = b.option(u32, "mem-leak-frames", "How many stack frames to print when a memory leak occurs. Tests get 2x this amount.") orelse blk: {
|
||||
if (strip == true) break :blk @as(u32, 0);
|
||||
if (optimize != .debug) break :blk 0;
|
||||
break :blk 4;
|
||||
if (strip == true) break :blk 0;
|
||||
if (is_debug) break :blk 4;
|
||||
break :blk 0;
|
||||
};
|
||||
|
||||
const exe = addCompilerStep(b, .{
|
||||
@@ -255,9 +259,15 @@ pub fn build(b: *std.Build) !void {
|
||||
exe.root_module.link_libc = true;
|
||||
}
|
||||
|
||||
const is_debug = optimize == .debug;
|
||||
const enable_debug_extensions = b.option(bool, "debug-extensions", "Enable commands and options useful for debugging the compiler") orelse is_debug;
|
||||
const enable_logging = b.option(bool, "log", "Enable debug logging with --debug-log") orelse is_debug;
|
||||
const log_level: std.log.Level = b.option(std.log.Level, "log", "Enable logs of the given or higher severity. Passing 'debug' still requires passing '--debug-log' to actually see any debug logs.") orelse switch (enable_debug_extensions) {
|
||||
true => .debug,
|
||||
false => switch (optimize) {
|
||||
.debug => .debug,
|
||||
.safe, .fast => .info,
|
||||
.small => .err,
|
||||
},
|
||||
};
|
||||
|
||||
const opt_version_string = b.option([]const u8, "version-string", "Override Zig version string. Default is to find out with git.");
|
||||
const version_slice = if (opt_version_string) |version| version else v: {
|
||||
@@ -398,7 +408,7 @@ pub fn build(b: *std.Build) !void {
|
||||
exe_options.addOption(std.SemanticVersion, "semver", semver);
|
||||
|
||||
exe_options.addOption(bool, "enable_debug_extensions", enable_debug_extensions);
|
||||
exe_options.addOption(bool, "enable_logging", enable_logging);
|
||||
exe_options.addOption(std.log.Level, "log_level", log_level);
|
||||
exe_options.addOption(bool, "enable_tracy", tracy != null);
|
||||
exe_options.addOption(bool, "enable_tracy_callstack", tracy_callstack);
|
||||
exe_options.addOption(bool, "enable_tracy_allocation", tracy_allocation);
|
||||
@@ -837,7 +847,7 @@ fn addWasiUpdateStep(b: *std.Build, version: [:0]const u8) !void {
|
||||
exe_options.addOption([:0]const u8, "version", version);
|
||||
exe_options.addOption(std.SemanticVersion, "semver", semver);
|
||||
exe_options.addOption(bool, "enable_debug_extensions", false);
|
||||
exe_options.addOption(bool, "enable_logging", false);
|
||||
exe_options.addOption(std.log.Level, "log_level", .err);
|
||||
exe_options.addOption(bool, "enable_tracy", false);
|
||||
exe_options.addOption(bool, "enable_tracy_callstack", false);
|
||||
exe_options.addOption(bool, "enable_tracy_allocation", false);
|
||||
|
||||
Reference in new issue
Block a user