zig build: make --error-limit globally configurable

still overridable by individual Compile steps
This commit is contained in:
Andrew Kelley
2026-02-19 15:04:01 -08:00
parent 174532c78e
commit 74b018ceb3
4 changed files with 9 additions and 3 deletions
+5
View File
@@ -390,6 +390,10 @@ pub fn main(init: process.Init.Minimal) !void {
fatal("unable to parse reference_trace count {q}: {t}", .{ num, err });
} else if (mem.eql(u8, arg, "-fno-reference-trace")) {
graph.reference_trace = null;
} else if (mem.eql(u8, arg, "--error-limit")) {
const next_arg = nextArgOrFatal(args, &arg_idx);
graph.error_limit = std.fmt.parseUnsigned(u32, next_arg, 0) catch |err|
fatal("unable to parse error limit {q}: {t}", .{ next_arg, err });
} else if (mem.cutPrefix(u8, arg, "-j")) |text| {
const n = std.fmt.parseUnsigned(u32, text, 10) catch |err|
fatal("unable to parse jobs count {q}: {t}", .{ text, err });
@@ -1838,6 +1842,7 @@ const ScannedConfig = struct {
\\ -fno-reference-trace Disable reference trace
\\ -fallow-so-scripts Allows .so files to be GNU ld scripts
\\ -fno-allow-so-scripts (default) .so files must be ELF files
\\ --error-limit [num] Set the maximum amount of distinct error values
\\ --build-file [file] Override path to build.zig
\\ --cache-dir [path] Override path to local Zig cache directory
\\ --global-cache-dir [path] Override path to global Zig cache directory
+1
View File
@@ -43,3 +43,4 @@ libc_file: ?[]const u8 = null,
sysroot: ?[]const u8 = null,
search_prefixes: std.ArrayList([]const u8) = .empty,
build_id: ?std.zig.BuildId = null,
error_limit: ?u32 = null,
+1 -1
View File
@@ -759,7 +759,7 @@ fn lowerZigArgs(
try zig_args.append(gpa, "-municode");
}
if (compile.error_limit) |err_limit| try zig_args.appendSlice(gpa, &.{
if (compile.error_limit orelse graph.error_limit) |err_limit| try zig_args.appendSlice(gpa, &.{
"--error-limit", try allocPrint(arena, "{d}", .{err_limit}),
});
+2 -2
View File
@@ -224,8 +224,8 @@ generated_llvm_bc: ?*GeneratedFile,
generated_llvm_ir: ?*GeneratedFile,
generated_h: ?*GeneratedFile,
/// The maximum number of distinct errors within a compilation step
/// Defaults to `std.math.maxInt(u16)`
/// The maximum number of distinct errors within a compilation step Defaults to
/// `std.math.maxInt(u16)`. Overrides the argument passed to `zig build`.
error_limit: ?u32 = null,
/// Computed during make().