Skip to content

Commit 73da508

Browse files
committed
ci: musl cross-compile gate matching the release matrix
Rework build.yml's cross-compile job into a 22-arch cross-tools/musl-cross matrix (per-arch cached, parallel), identical in coverage to release.yml — so every shipped arch, including loongarch64, is compile-gated on push/PR with the same musl toolchains we release. Drops the apt-GNU install. Makefile: make CROSS_TARGETS musl-only (drop the GNU triples that only existed for the old apt-based CI) and make `make cross` a real gate — skip absent toolchains, but fail if any present target fails to build (was `|| true`, which always passed). `make cross` is now the local musl mirror of the CI matrices.
1 parent 1eafb05 commit 73da508

3 files changed

Lines changed: 91 additions & 42 deletions

File tree

.github/workflows/build.yml

Lines changed: 64 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -34,30 +34,73 @@ jobs:
3434
- name: End-to-end replay (x86, native)
3535
run: KASLD_NATIVE=1 tests/replay tests/fixtures/x86_64/* tests/fixtures/x86_32/*
3636

37+
# Compile-gate every arch we release, on push/PR. Same musl toolchains
38+
# release.yml ships (musl.cc blocks GitHub Actions), minus packaging — so a
39+
# per-arch toolchain or arch-gated-code break is caught here, not at release.
3740
cross-compile:
3841
runs-on: ubuntu-latest
42+
# Pinned for deterministic PR builds + a stable per-arch toolchain cache;
43+
# bump periodically. release.yml tracks the latest cross-tools release.
44+
env:
45+
MUSL_CROSS_VERSION: '20260515'
46+
strategy:
47+
fail-fast: false
48+
matrix:
49+
# KEEP IN SYNC with release.yml's build-release matrix. armeb (big-endian
50+
# ARM) is omitted in both — cross-tools/musl-cross ships no armeb
51+
# toolchain. (The float/baseline variants compile identically to their
52+
# base arch, but are built here too so every shipped toolchain is gated.)
53+
include:
54+
- { arch: x86_64, musl_triple: x86_64-unknown-linux-musl }
55+
- { arch: i686, musl_triple: i686-unknown-linux-musl }
56+
- { arch: i586, musl_triple: i586-unknown-linux-musl }
57+
- { arch: aarch64, musl_triple: aarch64-unknown-linux-musl }
58+
- { arch: arm, musl_triple: arm-unknown-linux-musleabi }
59+
- { arch: armhf, musl_triple: arm-unknown-linux-musleabihf }
60+
- { arch: armv7, musl_triple: armv7-unknown-linux-musleabi }
61+
- { arch: armv7l, musl_triple: armv7-unknown-linux-musleabihf }
62+
- { arch: mips, musl_triple: mips-unknown-linux-musl }
63+
- { arch: mipssf, musl_triple: mips-unknown-linux-muslsf }
64+
- { arch: mipsel, musl_triple: mipsel-unknown-linux-musl }
65+
- { arch: mipselsf, musl_triple: mipsel-unknown-linux-muslsf }
66+
- { arch: mips64, musl_triple: mips64-unknown-linux-musl }
67+
- { arch: mips64el, musl_triple: mips64el-unknown-linux-musl }
68+
- { arch: powerpc, musl_triple: powerpc-unknown-linux-musl }
69+
- { arch: powerpcle, musl_triple: powerpcle-unknown-linux-musl }
70+
- { arch: powerpc64, musl_triple: powerpc64-unknown-linux-musl }
71+
- { arch: powerpc64le, musl_triple: powerpc64le-unknown-linux-musl }
72+
- { arch: riscv32, musl_triple: riscv32-unknown-linux-musl }
73+
- { arch: riscv64, musl_triple: riscv64-unknown-linux-musl }
74+
- { arch: s390x, musl_triple: s390x-ibm-linux-musl }
75+
- { arch: loongarch64, musl_triple: loongarch64-unknown-linux-musl }
3976
steps:
4077
- uses: actions/checkout@v6
4178

42-
- name: Install cross-compilers
79+
- name: Cache toolchain
80+
uses: actions/cache@v4
81+
with:
82+
path: ~/musl-cross/${{ matrix.musl_triple }}
83+
key: musl-${{ matrix.musl_triple }}-${{ env.MUSL_CROSS_VERSION }}
84+
85+
- name: Fetch toolchain + add to PATH
86+
run: |
87+
set -euo pipefail
88+
t="${{ matrix.musl_triple }}"
89+
root="$HOME/musl-cross"; mkdir -p "$root"
90+
if [ ! -d "$root/$t" ]; then
91+
base="https://github.com/cross-tools/musl-cross/releases/download/${MUSL_CROSS_VERSION}"
92+
dl() { curl -fsSL --retry 5 --retry-delay 5 --retry-all-errors "$1" -o "$2"; }
93+
dl "${base}/${t}.tar.xz" "/tmp/${t}.tar.xz"
94+
dl "${base}/${t}.tar.xz.sha256" "/tmp/${t}.sha256"
95+
echo "$(cut -d' ' -f1 "/tmp/${t}.sha256") /tmp/${t}.tar.xz" | sha256sum -c -
96+
tar -xJf "/tmp/${t}.tar.xz" -C "$root"
97+
fi
98+
echo "$root/$t/bin" >> "$GITHUB_PATH"
99+
100+
- name: Compile
101+
run: make build CC=${{ matrix.musl_triple }}-gcc
102+
103+
- name: Verify static linkage
43104
run: |
44-
sudo apt-get update
45-
sudo apt-get install -y \
46-
gcc-aarch64-linux-gnu \
47-
gcc-arm-linux-gnueabi \
48-
gcc-arm-linux-gnueabihf \
49-
gcc-i686-linux-gnu \
50-
gcc-mips-linux-gnu \
51-
gcc-mipsel-linux-gnu \
52-
gcc-mips64-linux-gnuabi64 \
53-
gcc-mips64el-linux-gnuabi64 \
54-
gcc-powerpc-linux-gnu \
55-
gcc-powerpc64-linux-gnu \
56-
gcc-powerpc64le-linux-gnu \
57-
gcc-riscv64-linux-gnu \
58-
gcc-s390x-linux-gnu
59-
# TODO: loongarch64 — no gcc-loongarch64-linux-gnu package in Ubuntu.
60-
# TODO: armeb — no big-endian ARM package in Ubuntu.
61-
62-
- name: Cross-compile all targets
63-
run: make cross
105+
d="build/$(${{ matrix.musl_triple }}-gcc -dumpmachine)"
106+
file "$d/kasld" | grep -q "statically linked"

.github/workflows/release.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ jobs:
5353
# arch: friendly name, used only in the artifact / tarball name.
5454
# musl_triple: cross-tools/musl-cross triple — the tar.xz stem, the
5555
# extracted directory name, and the <triple>-gcc prefix.
56+
# KEEP IN SYNC with build.yml's cross-compile matrix (which gates the
57+
# same arches on every push/PR). armeb has no cross-tools toolchain.
5658
include:
5759
# --- x86 ---
5860
- { arch: x86_64, musl_triple: x86_64-unknown-linux-musl, native_test: true }

Makefile

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -397,41 +397,45 @@ uninstall :
397397
rm -rf "$(DESTDIR)$(PREFIX)/libexec/kasld"
398398

399399

400-
# Cross-compile for all supported architectures.
401-
# Expects <triple>-gcc to be in PATH for each target.
400+
# Cross-compile all supported architectures with `make cross` — a local,
401+
# musl-only mirror of the CI / release matrices. Expects <triple>-gcc on PATH;
402+
# absent toolchains are skipped. Both the cross-tools/musl-cross triple names and
403+
# the short musl-cross-make names are listed so either musl toolchain set works.
404+
# GNU is intentionally absent (releases are built with musl). armeb is
405+
# musl-cross-make-only — cross-tools/musl-cross provides no armeb toolchain.
402406

403407
CROSS_TARGETS := \
404-
aarch64-linux-musl \
405-
arm-unknown-linux-musleabi armeb-linux-musleabi \
406-
armv7-unknown-linux-musleabi \
407-
arm-linux-gnueabihf \
408+
x86_64-unknown-linux-musl x86_64-linux-musl \
408409
i686-unknown-linux-musl \
409-
mips-linux-gnu mipsel-linux-gnu \
410+
aarch64-unknown-linux-musl aarch64-linux-musl \
411+
arm-unknown-linux-musleabi armv7-unknown-linux-musleabi \
412+
armeb-linux-musleabi \
410413
mips-unknown-linux-musl mipsel-unknown-linux-musl \
411-
mips64-linux-gnuabi64 mips64el-linux-gnuabi64 \
412414
mips64-unknown-linux-musl mips64el-unknown-linux-musl \
413-
loongarch64-unknown-linux-musl \
414-
powerpc-linux-gnu powerpc64le-linux-gnu \
415-
powerpc-linux-musl \
416-
powerpc64-unknown-linux-musl powerpc64le-unknown-linux-musl \
415+
powerpc-unknown-linux-musl powerpc-linux-musl \
417416
powerpcle-unknown-linux-musl \
418-
riscv32-linux-musl riscv64-linux-musl \
419-
riscv64-linux-gnu \
420-
s390x-linux-gnu s390x-ibm-linux-musl \
421-
x86_64-linux-musl \
422-
aarch64-linux-gnu
423-
417+
powerpc64-unknown-linux-musl powerpc64le-unknown-linux-musl \
418+
riscv32-unknown-linux-musl riscv32-linux-musl \
419+
riscv64-unknown-linux-musl riscv64-linux-musl \
420+
s390x-ibm-linux-musl \
421+
loongarch64-unknown-linux-musl
422+
423+
# Skip targets whose toolchain is absent, but FAIL if any present target fails
424+
# to build (so CI is a real gate). All present targets are attempted first, so
425+
# a single run surfaces every breakage rather than stopping at the first.
424426
.PHONY: cross
425427
cross :
426-
@for triple in $(CROSS_TARGETS); do \
428+
@rc=0; for triple in $(CROSS_TARGETS); do \
427429
if command -v $${triple}-gcc >/dev/null 2>&1; then \
428430
echo "=== Building for $$triple ==="; \
429-
$(MAKE) build CC=$${triple}-gcc || true; \
431+
$(MAKE) build CC=$${triple}-gcc || { rc=1; echo "!!! FAILED: $$triple"; }; \
430432
echo; \
431433
else \
432434
echo "=== Skipping $$triple (toolchain not found) ==="; \
433435
fi; \
434-
done
436+
done; \
437+
[ $$rc -eq 0 ] || echo "cross: one or more present targets FAILED"; \
438+
exit $$rc
435439

436440

437441
.PHONY: help

0 commit comments

Comments
 (0)