authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2026-02-19 15:04:01-08:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2026-05-25 18:54:34-07:00
log74b018ceb3822e0810ddfe434605bee69aba8b73
treebfd7767a5ec8ced32f9b870724832f9298a7f599
parent174532c78e254449c61d1729f8761b30b6f05eff

zig build: make --error-limit globally configurable

still overridable by individual Compile steps

4 files changed, 9 insertions(+), 3 deletions(-)

lib/compiler/Maker.zig+5
......@@ -390,6 +390,10 @@ pub fn main(init: process.Init.Minimal) !void {
390390 fatal("unable to parse reference_trace count {q}: {t}", .{ num, err });
391391 } else if (mem.eql(u8, arg, "-fno-reference-trace")) {
392392 graph.reference_trace = null;
393 } else if (mem.eql(u8, arg, "--error-limit")) {
394 const next_arg = nextArgOrFatal(args, &arg_idx);
395 graph.error_limit = std.fmt.parseUnsigned(u32, next_arg, 0) catch |err|
396 fatal("unable to parse error limit {q}: {t}", .{ next_arg, err });
393397 } else if (mem.cutPrefix(u8, arg, "-j")) |text| {
394398 const n = std.fmt.parseUnsigned(u32, text, 10) catch |err|
395399 fatal("unable to parse jobs count {q}: {t}", .{ text, err });
......@@ -1838,6 +1842,7 @@ const ScannedConfig = struct {
18381842 \\ -fno-reference-trace Disable reference trace
18391843 \\ -fallow-so-scripts Allows .so files to be GNU ld scripts
18401844 \\ -fno-allow-so-scripts (default) .so files must be ELF files
1845 \\ --error-limit [num] Set the maximum amount of distinct error values
18411846 \\ --build-file [file] Override path to build.zig
18421847 \\ --cache-dir [path] Override path to local Zig cache directory
18431848 \\ --global-cache-dir [path] Override path to global Zig cache directory
lib/compiler/Maker/Graph.zig+1
......@@ -43,3 +43,4 @@ libc_file: ?[]const u8 = null,
4343sysroot: ?[]const u8 = null,
4444search_prefixes: std.ArrayList([]const u8) = .empty,
4545build_id: ?std.zig.BuildId = null,
46error_limit: ?u32 = null,
lib/compiler/Maker/Step/Compile.zig+1-1
......@@ -759,7 +759,7 @@ fn lowerZigArgs(
759759 try zig_args.append(gpa, "-municode");
760760 }
761761
762 if (compile.error_limit) |err_limit| try zig_args.appendSlice(gpa, &.{
762 if (compile.error_limit orelse graph.error_limit) |err_limit| try zig_args.appendSlice(gpa, &.{
763763 "--error-limit", try allocPrint(arena, "{d}", .{err_limit}),
764764 });
765765
lib/std/Build/Step/Compile.zig+2-2
......@@ -224,8 +224,8 @@ generated_llvm_bc: ?*GeneratedFile,
224224generated_llvm_ir: ?*GeneratedFile,
225225generated_h: ?*GeneratedFile,
226226
227/// The maximum number of distinct errors within a compilation step
228/// Defaults to `std.math.maxInt(u16)`
227/// The maximum number of distinct errors within a compilation step Defaults to
228/// `std.math.maxInt(u16)`. Overrides the argument passed to `zig build`.
229229error_limit: ?u32 = null,
230230
231231/// Computed during make().