Skip to content

Fix/musl static linking#370

Merged
DorianZheng merged 2 commits intomainfrom
fix/musl-static-linking
Mar 12, 2026
Merged

Fix/musl static linking#370
DorianZheng merged 2 commits intomainfrom
fix/musl-static-linking

Conversation

@DorianZheng
Copy link
Copy Markdown
Member

No description provided.

The go.dev install puts Go in /usr/local/go/bin, but the PATH export
only lasted for the setup script session. Subsequent shells still found
the old distro Go. Now appends PATH to ~/.profile and ~/.bashrc.
The musl-gcc wrapper on Linux (musl-tools) uses musl headers/libraries
but doesn't enforce static linking by default. Rust's +crt-static only
controls library selection (libc.a vs libc.so) via #[link] attributes —
it does NOT pass -static to the linker. Without -static, the binary
still gets an ELF INTERP header (/lib/ld-musl-x86_64.so.1), making it
"dynamically linked" even though code is from .a files.

The guest binary runs inside a minimal VM where the musl dynamic linker
doesn't exist, so it needs a truly static binary (no INTERP header).

- Add -C link-arg=-static to musl target rustflags in both
  .cargo/config.toml files
- Re-enable check_prerequisites in build-guest.sh for fail-fast
  on missing musl toolchain
@DorianZheng DorianZheng merged commit d5a63e7 into main Mar 12, 2026
8 checks passed
@DorianZheng DorianZheng deleted the fix/musl-static-linking branch March 12, 2026 07:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant