1
Fork 0
Commit Graph

38 Commits

Author SHA1 Message Date
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
Motiejus Jakštys 8bc78753e2 ci/test: quote {}
This is recommended in the man page
2022-12-11 07:20:14 +02:00
Motiejus Jakštys bf88ddb2d5 ci/test: fail on error 2022-11-29 14:23:45 +02:00
Motiejus Jakštys 557b726d62 shellcheck 2022-10-13 12:48:43 +03:00
Motiejus Jakštys 7383c4984e ci/test: add tests for exact expected artifacts.
Cache reuse in zig is currently quite fragile (we are using a forked
version with github.com/ziglang/zig/issues/13051), so ensure that it
does not regress when zig SDK upgrades.
2022-10-13 12:41:07 +03:00
Motiejus Jakštys ae57dac00d ci/lint: make it fail in CI
It would "fix" the files on CI and not fail. ci/lint should verify they
are OK first, and give guidance to fix them.

also, `shellcheck -x` is no longer necessary; we can use the plain one
now.
2022-09-29 12:11:34 +03:00
Motiejus Jakštys 79674a1d96 replace /usr/bin/env sh with /bin/sh
/bin/sh exists in NixOS and in fact is the only file in `/bin`:

    $ docker run -ti --rm nixos/nix ls /bin /usr/bin
    /bin:
    sh

    /usr/bin:
    env

More context in
https://lists.sr.ht/~motiejus/bazel-zig-cc/%3CCAFVMu-pvNx%2BpeQYdge_fvmSGrHDmn78VmoYwTxkDgMjbzfVAwQ%40mail.gmail.com%3E
2022-08-30 09:21:27 +03:00
Motiejus Jakštys 4629534c19 [ci] add colors to test output 2022-08-12 05:54:33 +03:00
Motiejus Jakštys 5240246cab ci/test: simplify the script even more 2022-07-28 14:13:53 -07:00
Motiejus Jakštys 09ebb03d47 ci/lint: more verbose output 2022-07-28 14:10:11 -07:00
Luis Holanda 8b5c41e409 misc: use /usr/bin/env in scripts
This patch continues the work to support NixOS and others non-FHS
distributions by replacing instances of `/bin/bash` with
`/usr/bin/env bash`, which works correctly in more systems than the
former.

Signed-off-by: Luis Holanda <luiscmholanda@gmail.com>
2022-07-28 12:44:57 -07:00
Motiejus Jakštys db2f187aa9 ci/test: switch to proper fastbuild
turns out this was overwritten in .bazelrc from a long time ago.
2022-06-28 13:34:02 +03:00
Motiejus Jakštys fe1949388f [ci/test] set -c fastbuild
Seems like it's not the default, unlike the docs say. Will investigate
on why is that later.
2022-06-28 12:48:31 +03:00
Motiejus Jakštys 3ac217e2cc windows tests: move tests, get rid of wine-binfmt
This removes all other Bazel test commands, so all tests can be again
tested with `bazel test ...`.

Also, fixes linux-arm64 glibc tests. Until now they've worked only in
CI. Now they work everywhere I tried.
2022-06-06 10:33:46 +03:00
Fabian Hahn 6f2ae838cd added Windows target testing 2022-06-02 05:27:22 +03:00
Motiejus Jakštys d4f40a19fb fix ci/release
by adding a stub commit there
2022-04-20 14:45:48 +03:00
Motiejus Jakštys c2c6edd11c Merge branch 'laurynasl_libc' 2022-04-20 12:24:05 +03:00
Motiejus Jakštys d2af022174 shellcheck 2022-04-18 12:55:53 +03:00
Motiejus Jakštys 486a26a196 [release] add to CI 2022-04-18 12:37:12 +03:00
Motiejus Jakštys a53170cf82 ci/list* and ci/test: simple style improvements 2022-04-18 11:58:43 +03:00
laurynasl 4d65b80903 Add libc constraint and libc aware toolchains
- Also get rid of @bazel_skylib dependency
2022-04-14 14:29:06 +00:00
laurynasl 7a81e2a129 Restructure tests to all run in bazel
- add rules to run tests for a specific platform
- use downloaded buildifier
- move lint to a script
- rename ci tasks
- stop running under qemu-aarch64-static as it doesn't do anything
2022-04-14 10:47:02 +00:00
laurynasl 723e6f051d Move toolchainss under @zig_sdk//platform: 2022-04-07 12:43:34 +03:00
laurynasl dd76e0b76f move platforms under @zig_cc//platform: 2022-04-07 12:43:34 +03:00
Motiejus Jakštys 3d166c5671 use .bazelrc for qemu configuration 2022-02-08 14:22:21 +02:00
Motiejus Jakštys acb4fd475a restructure tests for merging 2022-02-05 06:12:41 +02:00
Motiejus Jakštys 7c8682b865 run tests with qemu-aarch64 2022-02-05 05:35:39 +02:00
Motiejus Jakštys 5871171549 run bazel test
This simplifies the tests somewhat.
2022-02-04 10:07:34 +02:00
Motiejus Jakštys 78a77ebbe5 preparing for aarch64 tests 2022-02-03 18:01:32 +02:00
Motiejus Jakštys ebbf499208 move golang tests to its own directory
this prepares for more test binaries.
2022-02-03 15:24:26 +02:00
Motiejus Jakštys 5631c7e2b6 build everything under //test/... and remove duplicate test binaries 2022-02-03 14:58:42 +02:00
Motiejus Jakštys bcd9731f92 add @zig_sdk//:<os>_<arch>_platform values 2022-02-03 14:24:26 +02:00
Motiejus Jakštys 871fd63e6e disable darwin/arm64 test 2021-12-13 03:33:24 +02:00
Motiejus Jakštys 47d91cbbed [shellcheck] ci/test 2021-10-21 11:39:46 +03:00
Motiejus Jakštys 5090715b97 [ci/test] simplify _build_and_file 2021-10-21 11:38:24 +03:00
Motiejus Jakštys f6016ab830 upgrade zig to 0.9.0-dev.1414+cde3dd365 2021-10-20 07:54:01 +03:00
Motiejus Jakštys d9dbca2c63 shellcheck 2021-10-18 15:15:02 +03:00
Motiejus Jakštys 4bbae178ca add release and build scripts 2021-10-18 15:12:31 +03:00