nightly: fix arm64 cross-link (musl cross toolchain) - #23
Closed
thepagent wants to merge 1 commit into
Closed
Conversation
The first multi-arch nightly run (33774193328) failed the arm64 legs at
link time: `musl-tools` only ships the build host's musl-gcc
(x86_64-linux-musl-gcc), so cross-linking the static aarch64-musl binary
died at crt1.o. cargo-zigbuild is not a drop-in either — it rejects
rustc's `--fix-cortex-a53-843419` linker arg (tested zig 0.13/0.14).
Install the official musl.cc cross toolchain for the target arch and point
the Rust target's linker/CC at its `<triple>-gcc`; strip with the
toolchain's `<triple>-strip` since host binutils strip cannot read a
foreign-arch ELF ("Unable to recognise the format").
The amd64 leg was unaffected and this keeps it identical in shape (its own
musl cross toolchain instead of musl-tools), so both arches build the same
way.
Verified on an M4 by building the whole image for linux/amd64,linux/arm64
from an amd64 builder context (the real CI cross-compile path, not the
native build the earlier check used): manifest list with both platforms,
amd64 leg ELF e_machine 0x3E and arm64 leg 0xB7 for both openab-pty and
kiro-cli, uname reports x86_64 / aarch64 respectively.
Follow-up to #21 / #22.
Contributor
Author
|
Superseding this with native arm64 runners. GitHub provides free |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Follow-up to #21 / #22.
Problem
The first real multi-arch nightly run (33774193328) failed the arm64 legs at link time (grok, the amd64-only variant, passed — which localized it to the arm64 cross-compile):
Root cause:
musl-toolsonly provides the build host's musl-gcc (x86_64-linux-musl-gcc). Cross-linking a staticaarch64-unknown-linux-muslbinary needs an aarch64 musl linker, which it does not ship — so the link dies atcrt1.o.My earlier verification for #22 had a blind spot: I built the arm64 image natively on an M4, which is not a cross-compile, so it never exercised the cross-linker path CI uses.
Why not cargo-zigbuild
Tried it (zig 0.13 + zigbuild 0.19.8, and zig 0.14 + zigbuild 0.20.1). Both reject rustc's aarch64 linker arg:
Fix
Install the official musl.cc cross toolchain for the target arch and point the Rust target's linker/CC at its
<triple>-gcc. Strip with the toolchain's<triple>-strip(host binutilsstripcannot read a foreign-arch ELF — "Unable to recognise the format"). The amd64 leg is kept identical in shape (its own musl cross toolchain instead ofmusl-tools), so both arches build the same way.Verification
Built the whole image for
linux/amd64,linux/arm64from an amd64 builder context on an M4 (the real CI cross-compile path this time, not a native build):Both legs compile, cross-link, strip, install the correct-arch kiro CLI, and produce a valid two-platform manifest.
Note
Depends on musl.cc being reachable at build time (retried 5x). If that host's flakiness becomes a problem, a follow-up can vendor the toolchains or switch to a mirror.