zig build returns error.SystemResources on MacOS when build-lib command exceeds ARG_MAX
Zig Version
0.9.0
Steps to Reproduce
Create build.zig with a static lib step that adds many c source files with lib.addCSourceFile (and many c flags). run: zig build
Expected Behavior
zig build should work and not have this limit or at the very least return a more useful error.
Actual Behavior
Prints error.SystemResources and quits.
Since zig build creates a build-lib command the args list can dramatically go up with many c source files/flags. On linux: getconf ARG_MAX returns 2097152 so I did not run into this issue before but on MacOS this number is much lower: 262144.
This is even worse on Windows where CreateProcessW has a max char limit of 32,766.
The error returned was useful though: error.Unexpected: GetLastError(206): The filename or extension is too long.
Maybe zig build-lib should also be able to read input from a generated file instead of relying on args?
We're getting response file support directly in Zig soon #9654, so we could also use it for build-lib, build-obj, build-exe and run.
Reopened as the improvement introduced a regression and was reverted in 5ab5e2e6731a9f1198df6c53134545ccc6a6bbd3.
Fixed by #11065, landed in 9154a8606996ce34e5f1d805672c83e2b733f5a7.