Skip to content

fix: detect cross-arch build by comparing target platform to host - #242

Merged
carrodher merged 1 commit into
masterfrom
fix/cross-arch-build-host-mismatch
Sep 3, 2026
Merged

carrodher merged 1 commit into
masterfrom
fix/cross-arch-build-host-mismatch

Conversation

@carrodher

@carrodher carrodher commented Sep 3, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • use_qemu_static in mkimage, and the equivalent QEMU-install/setup checks in test and .github/actions/build/action.yml, only ever enabled cross-arch handling for the amd64-host → arm64-target direction (hardcoded PLATFORM == "arm64").
  • Building amd64 on an arm64 host (e.g. running the build manually from an Apple Silicon machine) silently skipped debootstrap --arch amd64 and produced a native arm64 rootfs that got tagged/pushed as amd64, causing exec format error on real amd64 hosts.
  • The images currently published as latest, latest-amd64, bullseye-amd64, bookworm-amd64 and trixie-amd64 have already been rebuilt from an arm64 host with this fix and re-pushed to Docker Hub, verified to contain genuine amd64 binaries.

Fix

Compare the requested $PLATFORM against dpkg --print-architecture (the actual host arch) instead of hardcoding arm64, so the check is symmetric regardless of which direction the cross-build goes.

…t hardcoding arm64

use_qemu_static (mkimage) and the equivalent QEMU-install/setup checks in
`test` and .github/actions/build/action.yml only ever triggered QEMU when
building arm64 on a non-arm64 host. Building amd64 on an arm64 host (e.g.
the manual-push workaround run from an Apple Silicon machine) silently
skipped `debootstrap --arch amd64` and produced a native arm64 rootfs
mislabeled and pushed as amd64, causing "exec format error" on real amd64
hosts (#240, #241).

Comparing the requested platform against `dpkg --print-architecture`
makes the check symmetric for either cross-build direction.

ai-assisted=no
@carrodher
carrodher merged commit 6ea9e48 into master Sep 3, 2026
17 checks passed
@carrodher
carrodher deleted the fix/cross-arch-build-host-mismatch branch September 3, 2026 12:19
@github-actions github-actions Bot added the solved label Sep 3, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bitnami/minideb amd64 images contain ARM64 rootfs and fail with "exec format error" Wrong image built for latest amd64

3 participants