Skip to content

fix(build): enable musl target compatibility for boxlite-shim#317

Merged
DorianZheng merged 1 commit intomainfrom
fix/musl-build-compat
Mar 1, 2026
Merged

fix(build): enable musl target compatibility for boxlite-shim#317
DorianZheng merged 1 commit intomainfrom
fix/musl-build-compat

Conversation

@DorianZheng
Copy link
Copy Markdown
Member

Summary

  • Fix make shim build failures on Linux musl (x86_64-unknown-linux-musl) by addressing four compatibility issues:
    • libc::statx — update libc at build time and set RUST_LIBC_UNSTABLE_MUSL_V1_2_3=1 to enable musl statx support
    • libc::__rlimit_resource_t — use c_int for musl (glibc-specific type)
    • Go CGO — set CC to musl-gcc to avoid glibc-specific __fprintf_chk references
    • rust_eh_personality duplicate — add --allow-multiple-definition linker flag for all Linux targets (libkrun.a staticlib bundles its own std)

Test plan

  • make shim succeeds on Linux musl (tested on boxlite-dev GCE instance)
  • Binary verified: static-pie ELF x86-64, 24MB
  • CI passes on glibc targets

Four issues prevented `make shim` from building on Linux musl
(x86_64-unknown-linux-musl):

1. libc::statx missing on musl — the libc crate gates statx behind a
   musl_v1_2_3 cfg flag. Update libc at build time and set
   RUST_LIBC_UNSTABLE_MUSL_V1_2_3=1 to enable it.

2. libc::__rlimit_resource_t is glibc-specific — use c_int for musl
   (same as macOS).

3. Go CGO compiled with glibc gcc — set CC to musl-gcc when building
   libgvproxy for musl targets to avoid __fprintf_chk references.

4. Duplicate rust_eh_personality from libkrun.a staticlib — add
   --allow-multiple-definition to musl linker flags in .cargo/config.toml.
@DorianZheng DorianZheng merged commit 3b61662 into main Mar 1, 2026
18 checks passed
@DorianZheng DorianZheng deleted the fix/musl-build-compat branch March 1, 2026 05:04
DorianZheng added a commit that referenced this pull request Mar 1, 2026
Go c-archive (libgvproxy) is fundamentally incompatible with musl TLS,
causing SIGSEGV at runtime. Replace musl target with gnu + crt-static
for a fully static binary using glibc's static libraries.

Key changes:
- Revert musl compat commits (#317, #318) that are no longer needed
- Use x86_64-unknown-linux-gnu with +crt-static and relocation-model=static
- Add link-krun feature to gate libkrun.a linking (shim-only)
- Feature-gate krun VMM module so boxlite-cli doesn't link libkrun.a
- Remove shim pre-build from CI (builds natively in manylinux container)
- Remove configure_library_env dependency on krun_create_ctx symbol

--target is required on Linux so RUSTFLAGS don't affect proc-macro
compilation. relocation-model=static avoids static-pie which crashes
with Go c-archive relocations.
DorianZheng added a commit that referenced this pull request Mar 1, 2026
Go c-archive (libgvproxy) is fundamentally incompatible with musl TLS,
causing SIGSEGV at runtime. Replace musl target with gnu + crt-static
for a fully static binary using glibc's static libraries.

Key changes:
- Revert musl compat commits (#317, #318) that are no longer needed
- Use x86_64-unknown-linux-gnu with +crt-static and relocation-model=static
- Add link-krun feature to gate libkrun.a linking (shim-only)
- Feature-gate krun VMM module so boxlite-cli doesn't link libkrun.a
- Remove shim pre-build from CI (builds natively in manylinux container)
- Remove configure_library_env dependency on krun_create_ctx symbol

--target is required on Linux so RUSTFLAGS don't affect proc-macro
compilation. relocation-model=static avoids static-pie which crashes
with Go c-archive relocations.
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