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 {...@@ -390,6 +390,10 @@ pub fn main(init: process.Init.Minimal) !void {
390 fatal("unable to parse reference_trace count {q}: {t}", .{ num, err });390 fatal("unable to parse reference_trace count {q}: {t}", .{ num, err });
391 } else if (mem.eql(u8, arg, "-fno-reference-trace")) {391 } else if (mem.eql(u8, arg, "-fno-reference-trace")) {
392 graph.reference_trace = null;392 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 });
393 } else if (mem.cutPrefix(u8, arg, "-j")) |text| {397 } else if (mem.cutPrefix(u8, arg, "-j")) |text| {
394 const n = std.fmt.parseUnsigned(u32, text, 10) catch |err|398 const n = std.fmt.parseUnsigned(u32, text, 10) catch |err|
395 fatal("unable to parse jobs count {q}: {t}", .{ text, err });399 fatal("unable to parse jobs count {q}: {t}", .{ text, err });
...@@ -1838,6 +1842,7 @@ const ScannedConfig = struct {...@@ -1838,6 +1842,7 @@ const ScannedConfig = struct {
1838 \\ -fno-reference-trace Disable reference trace1842 \\ -fno-reference-trace Disable reference trace
1839 \\ -fallow-so-scripts Allows .so files to be GNU ld scripts1843 \\ -fallow-so-scripts Allows .so files to be GNU ld scripts
1840 \\ -fno-allow-so-scripts (default) .so files must be ELF files1844 \\ -fno-allow-so-scripts (default) .so files must be ELF files
1845 \\ --error-limit [num] Set the maximum amount of distinct error values
1841 \\ --build-file [file] Override path to build.zig1846 \\ --build-file [file] Override path to build.zig
1842 \\ --cache-dir [path] Override path to local Zig cache directory1847 \\ --cache-dir [path] Override path to local Zig cache directory
1843 \\ --global-cache-dir [path] Override path to global Zig cache directory1848 \\ --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,...@@ -43,3 +43,4 @@ libc_file: ?[]const u8 = null,
43sysroot: ?[]const u8 = null,43sysroot: ?[]const u8 = null,
44search_prefixes: std.ArrayList([]const u8) = .empty,44search_prefixes: std.ArrayList([]const u8) = .empty,
45build_id: ?std.zig.BuildId = null,45build_id: ?std.zig.BuildId = null,
46error_limit: ?u32 = null,
lib/compiler/Maker/Step/Compile.zig+1-1
...@@ -759,7 +759,7 @@ fn lowerZigArgs(...@@ -759,7 +759,7 @@ fn lowerZigArgs(
759 try zig_args.append(gpa, "-municode");759 try zig_args.append(gpa, "-municode");
760 }760 }
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, &.{
763 "--error-limit", try allocPrint(arena, "{d}", .{err_limit}),763 "--error-limit", try allocPrint(arena, "{d}", .{err_limit}),
764 });764 });
765765
lib/std/Build/Step/Compile.zig+2-2
...@@ -224,8 +224,8 @@ generated_llvm_bc: ?*GeneratedFile,...@@ -224,8 +224,8 @@ generated_llvm_bc: ?*GeneratedFile,
224generated_llvm_ir: ?*GeneratedFile,224generated_llvm_ir: ?*GeneratedFile,
225generated_h: ?*GeneratedFile,225generated_h: ?*GeneratedFile,
226226
227/// The maximum number of distinct errors within a compilation step227/// The maximum number of distinct errors within a compilation step Defaults to
228/// Defaults to `std.math.maxInt(u16)`228/// `std.math.maxInt(u16)`. Overrides the argument passed to `zig build`.
229error_limit: ?u32 = null,229error_limit: ?u32 = null,
230230
231/// Computed during make().231/// Computed during make().