Skip to content

fix(docker): revert builder base from rust:alpine to rust:latest - #13

Merged
vishwateja-angirekula merged 1 commit into
mainfrom
fix/revert-alpine-builder-to-glibc
Jul 9, 2026
Merged

fix(docker): revert builder base from rust:alpine to rust:latest#13
vishwateja-angirekula merged 1 commit into
mainfrom
fix/revert-alpine-builder-to-glibc

Conversation

@muralidhar-challa

Copy link
Copy Markdown
Collaborator

Summary

Every build failure since the Alpine builder switch (2h QEMU hang → stale cache ABI mismatch → host/target CC mixup → UBSan symbol relocation) traces back to one root cause, confirmed via web research: rust-lang/cargo#7563. *-unknown-linux-musl targets default to +crt-static, which is fundamentally incompatible with proc-macro crates (dylib-style loading) on a musl host. sqlx-macros must run natively during compilation regardless of the cross --target requested for the final binary, and that host-native build is broken by this cargo/rustc limitation on Alpine — no amount of CC/linker wrapper configuration fixes it, since the problem is the host toolchain itself.

On a glibc host (rust:latest), the host triple (x86_64-unknown-linux-gnu) never touches musl or the zig wrapper at all — proc-macros build natively against glibc, and only the actual --target musl artifacts (compiled via zig) end up statically linked. This is exactly what the Dockerfile did for weeks (PRs #1-8) before the Alpine switch.

Important: this does not affect the shipped artifact. The builder's own base image is a throwaway compile-time container; the final uc-server binary is still cross-compiled via --target x86_64/aarch64-unknown-linux-musl and the final stage is still FROM scratch. Verified locally: file on the built binary confirms statically linked, stripped — still a fully static musl binary, still runs on Alpine or anywhere else with no libc present.

Test plan

  • Local cold-cache build for amd64 completes cleanly (previously failed consistently on Alpine with an UBSan symbol relocation error)
  • file on the resulting binary confirms it's statically linked (no glibc/dynamic dependency leaked into the shipped artifact)
  • CI run on this PR (fmt/clippy/test) passes
  • Once merged, push-to-main build actually completes for both amd64 and arm64

Every build failure since switching the builder to rust:alpine (in an
earlier "lighter/faster pull" change) traces back to one root cause,
confirmed via web research: rust-lang/cargo#7563. *-unknown-linux-musl
targets default to +crt-static, which is fundamentally incompatible
with proc-macro crates (dylib-style loading) on a musl HOST. sqlx-macros
needs to run natively during compilation regardless of the cross
--target requested for the final binary, and on an Alpine/musl builder
that host-native build is broken by this cargo/rustc limitation --
no combination of CC/linker wrapper juggling fixes it, since the
problem is the host toolchain itself, not our zig configuration.

On a glibc host (rust:latest), the host triple (x86_64-unknown-linux-gnu)
never touches musl or our zig wrapper at all -- proc-macros just build
natively against glibc, and only the actual --target musl artifacts
(compiled via the zig wrapper) end up statically linked. This is what
the Dockerfile did for weeks (PRs #1-8) before the alpine switch.

Verified locally: full cold-cache build for amd64 completes cleanly
(previously failed consistently on alpine), and `file` on the resulting
binary confirms "statically linked" -- the shipped artifact is still a
fully static musl binary either way, since the builder's own base image
has no bearing on the --target-compiled output. Only the throwaway
build-time toolchain container changes; nothing about the shipped image
does.
@vishwateja-angirekula
vishwateja-angirekula merged commit 12b2fe3 into main Jul 9, 2026
5 checks passed
@muralidhar-challa
muralidhar-challa deleted the fix/revert-alpine-builder-to-glibc branch July 9, 2026 10:58
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.

2 participants