Strange toolchain UX for musl environments

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.

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.