From 74b018ceb3822e0810ddfe434605bee69aba8b73 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Thu, 19 Feb 2026 15:04:01 -0800 Subject: [PATCH] zig build: make --error-limit globally configurable still overridable by individual Compile steps --- lib/compiler/Maker.zig | 5 +++++ lib/compiler/Maker/Graph.zig | 1 + lib/compiler/Maker/Step/Compile.zig | 2 +- lib/std/Build/Step/Compile.zig | 4 ++-- 4 files changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/compiler/Maker.zig b/lib/compiler/Maker.zig index 48da409813..278cb5340e 100644 --- a/lib/compiler/Maker.zig +++ b/lib/compiler/Maker.zig @@ -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 diff --git a/lib/compiler/Maker/Graph.zig b/lib/compiler/Maker/Graph.zig index c62e49a9a5..e1b9ef5875 100644 --- a/lib/compiler/Maker/Graph.zig +++ b/lib/compiler/Maker/Graph.zig @@ -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, diff --git a/lib/compiler/Maker/Step/Compile.zig b/lib/compiler/Maker/Step/Compile.zig index 1deb6d1289..28638565fa 100644 --- a/lib/compiler/Maker/Step/Compile.zig +++ b/lib/compiler/Maker/Step/Compile.zig @@ -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}), }); diff --git a/lib/std/Build/Step/Compile.zig b/lib/std/Build/Step/Compile.zig index ee4068e991..40d2a4a38a 100644 --- a/lib/std/Build/Step/Compile.zig +++ b/lib/std/Build/Step/Compile.zig @@ -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().