1
Fork 0
hermetic_cc_toolchain/toolchain
Motiejus Jakštys eced0109ca zig launcher: replace shell wrappers with a binary
Until now we needed to maintain two versions of the zig launcher: one
for Windows and one for everything else. This was problematic for two
reasons:
1. I do not know powershell and thus keep breaking the Windows wrapper
   all the time (see git history of Fabian fixing stuff that I broke).
2. This makes bazel-zig-cc dependent on the system shell, making it not
   really hermetic. So the recently added
   `--experimental_use_hermetic_linux_sandbox` does not work with
   bazel-zig-cc, unless we bind-mount a bunch of stuff: `/usr`, `/bin`,
   `/lib`, `/usr/lib:/lib`, `/usr/lib64:/lib64` and `/proc`.

Switching to a Zig-based wrapper solves both issues, and we can do this:

    bazel build "$@" \
        --experimental_use_hermetic_linux_sandbox \
        --sandbox_add_mount_pair=/proc \
        <...>

Zig itself still depends on `/proc` for `/proc/self/exe`, so we need to
keep that. I will look into reducing even that dependency separately.

Not all is nice and shiny though: this commit replaces ~80 LOC worth of
shell scripts wrappers with a singe ~300 LOC zig program, which is
arguably harder to understand. However, it is easier to change, at least
for me, because it's a single file with unit tests! Most importantly,
the gnarly code (which resolves paths and sets environment variables) is
cross-platform.

Thanks to Fabian Hahn for testing this on Windows and pointing out
errors.
2023-01-03 11:46:58 +02:00
..
libc Add libc constraint and libc aware toolchains 2022-04-14 14:29:06 +00:00
libc_aware Add libc constraint and libc aware toolchains 2022-04-14 14:29:06 +00:00
platform added support for Windows targets 2022-06-02 05:27:22 +03:00
private zig launcher: replace shell wrappers with a binary 2023-01-03 11:46:58 +02:00
toolchain WIP: use relative paths for tools 2022-09-27 10:14:59 +03:00
BUILD add .build.yml 2021-06-08 06:28:15 +03:00
BUILD.sdk.bazel remove zig_include_root 2022-12-07 12:17:44 +02:00
defs.bzl zig launcher: replace shell wrappers with a binary 2023-01-03 11:46:58 +02:00
launcher.zig zig launcher: replace shell wrappers with a binary 2023-01-03 11:46:58 +02:00
zig_toolchain.bzl Use artifact_name_pattern to specify proper macos and windows artifact names. 2022-12-18 05:29:04 +02:00