zig icon indicating copy to clipboard operation
zig copied to clipboard

zig build returns error.SystemResources on MacOS when build-lib command exceeds ARG_MAX

Open fubark opened this issue 3 years ago • 3 comments

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.

fubark avatar Jan 25 '22 16:01 fubark

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?

fubark avatar Jan 30 '22 09:01 fubark

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.

Vexu avatar Jan 30 '22 10:01 Vexu

Reopened as the improvement introduced a regression and was reverted in 5ab5e2e6731a9f1198df6c53134545ccc6a6bbd3.

andrewrk avatar Feb 28 '22 18:02 andrewrk

Fixed by #11065, landed in 9154a8606996ce34e5f1d805672c83e2b733f5a7.

andrewrk avatar Feb 18 '23 16:02 andrewrk