diff --git a/src/main.zig b/src/main.zig index 817e8d29dc..95ee9a82f1 100644 --- a/src/main.zig +++ b/src/main.zig @@ -977,6 +977,11 @@ fn buildOutputType( var cc_argv: std.ArrayList([]const u8) = .empty; var deps: std.ArrayList(CliModule.Dep) = .empty; + // We need to raise the FD limit *before* CLI parsing, because we open link inputs during CLI + // parsing (in `createModule`), so a large number of link inputs could push us past the limit on + // targets with a low soft limit (e.g. macOS has a default limit of 256). + process.raiseFileDescriptorLimit(); + // Contains every module specified via -M. The dependencies are added // after argument parsing is completed. We use a StringArrayHashMap to make // error output consistent. "root" is special. @@ -3534,8 +3539,6 @@ fn buildOutputType( break :b .whole; }; - process.raiseFileDescriptorLimit(); - var file_system_inputs: std.ArrayList(u8) = .empty; defer file_system_inputs.deinit(gpa);