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

Do not fail to build if 'zig build-lib' etc. arguments exceed OS limits #10950

Merged
merged 8 commits into from
Feb 23, 2022
Merged

Do not fail to build if 'zig build-lib' etc. arguments exceed OS limits #10950

merged 8 commits into from
Feb 23, 2022

Commits on Feb 20, 2022

  1. use process.argsWithAllocator iterator for command line handling

    This change refactors the `zig` argument handling (for `build-lib`, etc.
    commands) to use a `process.argsWithAllocator` iterator instead of
    directly accessing arguments via array indices. This supports the next
    commit which will enable us to use a response file argument iterator
    here seamlessly.
    
    Helps #10693
    
    Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
    slimsag committed Feb 20, 2022
    Configuration menu
    Copy the full SHA
    0778f64 View commit details
    Browse the repository at this point in the history
  2. enable passing build-[lib|exe|obj] params via @args.rsp file

    This change enables `zig build-lib` and friends to take a response file
    of command line arguments, for example:
    
    ```sh
    zig build-lib @args.rsp
    ```
    
    Which effectively does the same thing as this in Bash:
    
    ```sh
    zig build-lib $(cat args.rsp)
    ```
    
    Being able to use a file for arguments is important as one can quickly
    exceed the 32 KiB limit that Windows imposes on arguments to a process.
    
    Helps #10693
    
    Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
    slimsag committed Feb 20, 2022
    Configuration menu
    Copy the full SHA
    e41d4df View commit details
    Browse the repository at this point in the history
  3. std: have Builder use response files if zig build args exceed OS limits

    In Mach engine we're seeing command line arguments to `zig build-lib`
    exceed the 32 KiB limit that Windows imposes, due to the number of
    sources and compiler flags we must pass in order to build gpu-dawn.
    
    This change fixes the issue by having `Builder` check if the arguments
    to a `zig build-*` command are >30 KiB and, if so, writes the arguments
    to a file `zig-cache/args/<SHA2 of args>`. Then the command invocation
    merely becomes `zig build-lib @<that file>`.
    
    Fixes #10693
    
    Fixes hexops/mach#167
    
    Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
    slimsag committed Feb 20, 2022
    Configuration menu
    Copy the full SHA
    2bd10f4 View commit details
    Browse the repository at this point in the history

Commits on Feb 21, 2022

  1. zig build: use orelse to fetch next argument

    Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
    slimsag committed Feb 21, 2022
    Configuration menu
    Copy the full SHA
    fb61db1 View commit details
    Browse the repository at this point in the history
  2. std: Builder: account for null term considering response files

    Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
    slimsag committed Feb 21, 2022
    Configuration menu
    Copy the full SHA
    9c1c474 View commit details
    Browse the repository at this point in the history
  3. std: Builder: use response files for zig test invocations too

    Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
    slimsag committed Feb 21, 2022
    Configuration menu
    Copy the full SHA
    efd473b View commit details
    Browse the repository at this point in the history
  4. zig build: use a custom iterator for merging args and response file

    Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
    slimsag committed Feb 21, 2022
    Configuration menu
    Copy the full SHA
    b341967 View commit details
    Browse the repository at this point in the history

Commits on Feb 22, 2022

  1. zig build: style: remove unnecessary constant bindings

    Signed-off-by: Stephen Gutekanst <stephen@hexops.com>
    slimsag committed Feb 22, 2022
    Configuration menu
    Copy the full SHA
    c577926 View commit details
    Browse the repository at this point in the history