Skip to content

Commit 1aa03ee

Browse files
philzexedev-shelley
andcommitted
exe-scroll: per-target zig cache dir for reproducible cross builds
Prompt: is the zig build for exe-scroll reproducible? / Can we make it so that we use a different cache directory Zig's local .zig-cache isn't fully partitioned by -Dtarget, so building both arches back-to-back through one checkout produced a non-reproducible second binary (its .text differed ~48 bytes from a clean build). Point 'zig build' at a per-target cache dir (.zig-cache/<triple>, still gitignored, overridable via CACHE_DIR). Each arch now builds byte-identical to its clean build regardless of order. Verified amd64->arm64 and arm64->amd64 both reproduce the clean-build hashes. Co-authored-by: Shelley <shelley@exe.dev>
1 parent 76866bb commit 1aa03ee

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

exe-scroll/build-static.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,10 +77,19 @@ ln -sfn "$GHOSTTY_SRC" "$SRC_DIR/ghostty-src"
7777
# rovol bin tree; defaults to the usual zig-out. -Dstrip strips at link time so
7878
# cross-arch builds don't depend on a matching host `strip`.
7979
OUT_DIR="${OUT_DIR:-$SRC_DIR/zig-out}"
80+
81+
# Key the local build cache by target triple. Zig's local `.zig-cache` isn't
82+
# fully partitioned by `-Dtarget`, so building both arches through one cache
83+
# yields a non-reproducible second binary (its .text differs from a clean
84+
# build). A per-target cache dir keeps each arch's build deterministic even
85+
# when both run back-to-back in the same checkout. Defaults under .zig-cache
86+
# (gitignored); override with CACHE_DIR.
87+
CACHE_DIR="${CACHE_DIR:-$SRC_DIR/.zig-cache/$ZIG_TARGET}"
8088
(
8189
cd "$SRC_DIR"
8290
mise exec -- zig build \
8391
-Dtarget="$ZIG_TARGET" -Doptimize=ReleaseFast -Dstrip=true \
92+
--cache-dir "$CACHE_DIR" \
8493
-p "$OUT_DIR"
8594
)
8695

0 commit comments

Comments
 (0)