From a6e166625d7421ae1d0b9f48c54de9d9b69e8d9f Mon Sep 17 00:00:00 2001 From: Jianjun Chen Date: Mon, 13 Jul 2026 19:44:50 +0800 Subject: [PATCH] fix(ci): use ZIG_LOCAL_CACHE_DIR and pre-warm zig cc for cross-compile MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ZIG_GLOBAL_CACHE_DIR does not control where zig cc caches compiled objects (.o files) — that is ZIG_LOCAL_CACHE_DIR. The arm64 build was silently using the default ~/.cache/zig, causing tree-sitter-java's build script to hit a corrupted cache entry (parser.o FileNotFound) when parallel C compilations raced on the first aarch64 libc setup. - Replace ZIG_GLOBAL_CACHE_DIR with ZIG_LOCAL_CACHE_DIR in all build steps - Add a pre-warm step that compiles a trivial C file before the parallel cargo build, serializing zig's bundled libc compilation Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent) Co-authored-by: Sisyphus --- .github/workflows/release.yml | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 067da99..a0bc826 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -34,15 +34,21 @@ jobs: with: version: "0.14.0" # fixes zig cc cache race in 0.13.0 - run: cargo install cargo-zigbuild --version 0.19.2 + - name: Pre-warm zig cc cache + env: + ZIG_LOCAL_CACHE_DIR: ${{ runner.temp }}/zig-cache + run: | + echo 'int main(void) { return 0; }' > /tmp/zigwarm.c + zig cc --target=x86_64-unknown-linux-gnu -c /tmp/zigwarm.c -o /tmp/zigwarm.o - name: Build embedded astgrep (target) env: - ZIG_GLOBAL_CACHE_DIR: ${{ runner.temp }}/zig-cache + ZIG_LOCAL_CACHE_DIR: ${{ runner.temp }}/zig-cache run: cargo zigbuild --manifest-path lib/astgrep/Cargo.toml --release --target x86_64-unknown-linux-gnu.2.17 - name: Build coderc (embed-astgrep) env: ASTGREP_RELEASE_BIN: ${{ github.workspace }}/lib/astgrep/target/x86_64-unknown-linux-gnu/release/astgrep CARGO_BUILD_EMBED_REQUIRED: "1" - ZIG_GLOBAL_CACHE_DIR: ${{ runner.temp }}/zig-cache + ZIG_LOCAL_CACHE_DIR: ${{ runner.temp }}/zig-cache run: cargo zigbuild -p cr-cli --release --target x86_64-unknown-linux-gnu.2.17 --features cr-audit-static/embed-astgrep - run: strip target/x86_64-unknown-linux-gnu/release/${{ env.BINARY_NAME }} - run: | @@ -72,15 +78,21 @@ jobs: with: version: "0.14.0" # fixes zig cc cache race in 0.13.0 - run: cargo install cargo-zigbuild --version 0.19.2 + - name: Pre-warm zig cc cache + env: + ZIG_LOCAL_CACHE_DIR: ${{ runner.temp }}/zig-cache + run: | + echo 'int main(void) { return 0; }' > /tmp/zigwarm.c + zig cc --target=aarch64-unknown-linux-gnu -c /tmp/zigwarm.c -o /tmp/zigwarm.o - name: Build embedded astgrep (target) env: - ZIG_GLOBAL_CACHE_DIR: ${{ runner.temp }}/zig-cache + ZIG_LOCAL_CACHE_DIR: ${{ runner.temp }}/zig-cache run: cargo zigbuild --manifest-path lib/astgrep/Cargo.toml --release --target aarch64-unknown-linux-gnu - name: Build coderc (embed-astgrep) env: ASTGREP_RELEASE_BIN: ${{ github.workspace }}/lib/astgrep/target/aarch64-unknown-linux-gnu/release/astgrep CARGO_BUILD_EMBED_REQUIRED: "1" - ZIG_GLOBAL_CACHE_DIR: ${{ runner.temp }}/zig-cache + ZIG_LOCAL_CACHE_DIR: ${{ runner.temp }}/zig-cache run: cargo zigbuild -p cr-cli --release --target aarch64-unknown-linux-gnu --features cr-audit-static/embed-astgrep - run: | sudo apt-get install -y binutils-aarch64-linux-gnu