Commit 1df2434
committed
feat(native-armhf-on-arm64): opt-in extension + host_binfmt_ready core hook
Opt-in extension that disables qemu-arm in binfmt_misc for the duration
of an armhf build on an aarch64 host. The kernel's binfmt_elf path then
runs 32-bit ARM ELF binaries natively via CONFIG_COMPAT, removing the
~10× qemu-user-static overhead from mmdebstrap, chroot apt-get, dpkg
--configure, and customize_image stages.
Activate with ENABLE_EXTENSIONS=native-armhf-on-arm64.
Core change (lib/functions/host/prepare-host.sh):
Add a new extension hook `host_binfmt_ready`, fired from
`prepare_host_noninteractive` immediately after
`prepare_host_binfmt_qemu`. At this point the binfmt_misc registrations
for the target architecture are in place, which is the right window
for any extension that wants to mutate them. Five lines, no behavioral
change for builds that don't use the hook.
Extension (extensions/native-armhf-on-arm64.sh):
- Gate: ARCH=armhf and host arch aarch64 — silent no-op otherwise.
- Verify qemu-arm is registered and enabled (it always is after
prepare_host_binfmt_qemu — otherwise abort with a clear message).
- Disable qemu-arm via /proc/sys/fs/binfmt_misc/qemu-arm.
- Probe-with-rollback: exec /usr/arm-linux-gnueabihf/lib/ld-linux-armhf.so.3
--help to verify the kernel can still run armhf natively via
CONFIG_COMPAT. If it can't (no COMPAT), re-enable qemu-arm and
abort with a clear message. We use a direct ld-linux exec rather
than `arch-test armhf` because the latter is unreliable on some
aarch64 hosts (e.g. Hetzner Ampere CAX, Ubuntu Noble 6.8) — it
returns failure even when CONFIG_COMPAT is fully functional.
- add_cleanup_handler on success: re-enable qemu-arm on build exit
(best-effort; if the build is SIGKILL'd, qemu-arm stays disabled;
documented manual restore in the header).
Restrictions (header):
- NO CONCURRENT ARMBIAN BUILDS on the same host while this extension
is active. The disable mutates global kernel state. The operator
owns the host while this extension runs — no flock dance, no
concurrency claims. Matches the safety level of baseline armbian
(which also doesn't synchronize binfmt_misc mutations across
concurrent builds).
- The in-core flock-based variant at PR armbian#9769 covers concurrent-safe
use; this extension is the opt-in lightweight alternative.
Validated on Hetzner CAX21 (Ampere Altra, Ubuntu Noble 6.8.0-90,
CONFIG_COMPAT=y, no COMPAT_VDSO): ld-linux-armhf exec succeeds with
qemu-arm disabled.
Assisted-by: Claude:claude-opus-4.71 parent 761d04e commit 1df2434
2 files changed
Lines changed: 116 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
97 | 97 | | |
98 | 98 | | |
99 | 99 | | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
100 | 108 | | |
101 | 109 | | |
102 | 110 | | |
| |||
0 commit comments