Strange toolchain UX for musl environments

⚓ Rust    📅 2026-03-08    👤 surdeus    👁️ 2      

surdeus

rustup target list on a fresh library/alpine:3.23 Docker container claims that the default toolchain is stable-<arch>-unknown-linux-musl.

However, cargo build --release continues to build glibc binaries by default.

If building fully static with RUSTFLAGS="-C target-feature=+crt-static", then proc macros trigger compilation errors without an explicit --target "$(uname -m)-unknown-linux-musl". Because rustup targets glibc by default.

And cargo build always aborts when libgcc is not installed. Even though musl-dev(el) is installed.

As a workaround, I have to install gcc or clang21. Then insert an additional subdirectory path *.../-unknown-linux-musl/...when copying binaries between Docker stages.

Unknown behavior on Void Linux musl.

On musl environments, I think it is perfectly reasonable for rustup to target musl by default.

Regardless, rustup should provide provide more accurate data when querying its own live target configuration.

1 post - 1 participant

Read full topic

🏷️ Rust_feed