Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
fubark opened this issue Jan 25, 2022 · 4 comments · Fixed by #10950
Closed
Labels
bug Observed behavior contradicts documented or intended behavior contributor friendly This issue is limited in scope and/or knowledge of Zig internals. frontend Tokenization, parsing, AstGen, Sema, and Liveness.
Milestone

Comments

@fubark
Copy link
Sponsor Contributor

fubark commented Jan 25, 2022

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 fubark added the bug Observed behavior contradicts documented or intended behavior label Jan 25, 2022
@fubark
Copy link
Sponsor Contributor Author

fubark commented Jan 30, 2022

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?

@Vexu Vexu added the frontend Tokenization, parsing, AstGen, Sema, and Liveness. label Jan 30, 2022
@Vexu Vexu added this to the 0.10.0 milestone Jan 30, 2022
@Vexu
Copy link
Member

Vexu commented Jan 30, 2022

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.

@andrewrk
Copy link
Member

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

@andrewrk andrewrk reopened this Feb 28, 2022
@andrewrk andrewrk added the contributor friendly This issue is limited in scope and/or knowledge of Zig internals. label Sep 14, 2022
@andrewrk andrewrk modified the milestones: 0.10.0, 0.11.0 Sep 14, 2022
@andrewrk
Copy link
Member

andrewrk commented Feb 18, 2023

Fixed by #11065, landed in 9154a86.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Observed behavior contradicts documented or intended behavior contributor friendly This issue is limited in scope and/or knowledge of Zig internals. frontend Tokenization, parsing, AstGen, Sema, and Liveness.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants