From 0a06ccafa1f972b449fadd8be4dba2bd3859b2b4 Mon Sep 17 00:00:00 2001 From: casjay Date: Sun, 21 Jun 2026 18:17:10 -0400 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Replace=20musl-cross=20with=20zi?= =?UTF-8?q?g=20cc=20wrappers=20for=20arm64=20cross-compile=20=F0=9F=90=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit musl-cross does not exist in any Alpine package repo (main, community, or edge) — both attempts to install it failed at build time. Zig ships with Alpine (`apk add zig`) and bundles its own musl headers and stdlib for every target triple, making it a drop-in replacement for a musl cross-toolchain with zero external dependencies. Three wrapper scripts are created at install time: /usr/local/bin/aarch64-linux-musl-gcc → zig cc -target aarch64-linux-musl /usr/local/bin/aarch64-linux-musl-g++ → zig c++ -target aarch64-linux-musl /usr/local/bin/aarch64-linux-musl-ar → zig ar The CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_LINKER and CC_*/CXX_*/AR_* env vars are unchanged — they still point to aarch64-linux-musl-gcc, which now resolves to the zig wrapper. - Dockerfile: replace musl-cross apk install with zig + wrapper scripts Dockerfile --- Dockerfile | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index bfc982b..38d189b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -40,10 +40,20 @@ FROM tianon/gosu:latest AS gosu FROM --platform=$BUILDPLATFORM rust:alpine AS rust-tools ARG TARGETARCH -# musl-cross provides aarch64-linux-musl-gcc for arm64 cross-compilation; -# it lives in the Alpine community repo which rust:alpine does not enable by default -RUN apk add --no-cache curl jq \ - && apk add --no-cache --repository https://dl-cdn.alpinelinux.org/alpine/edge/community musl-cross +# zig acts as a universal C/C++ cross-compiler — ships with bundled musl headers +# and stdlib for all targets, so no separate musl-cross toolchain is needed. +# Wrapper scripts named aarch64-linux-musl-{gcc,g++,ar} let the CARGO_TARGET_* +# env vars below work without any changes. +RUN apk add --no-cache curl jq zig \ + && printf '#!/bin/sh\nexec zig cc -target aarch64-linux-musl "$@"\n' \ + > /usr/local/bin/aarch64-linux-musl-gcc \ + && printf '#!/bin/sh\nexec zig c++ -target aarch64-linux-musl "$@"\n' \ + > /usr/local/bin/aarch64-linux-musl-g++ \ + && printf '#!/bin/sh\nexec zig ar "$@"\n' \ + > /usr/local/bin/aarch64-linux-musl-ar \ + && chmod +x /usr/local/bin/aarch64-linux-musl-gcc \ + /usr/local/bin/aarch64-linux-musl-g++ \ + /usr/local/bin/aarch64-linux-musl-ar # Resolve Docker TARGETARCH → Rust target triple RUN case "${TARGETARCH}" in \