At the moment, it is impossible to build rust for musl because the only bootstrap tarballs available are dynamically linked for glibc. Upstream Bug: https://github.com/rust-lang/rust/issues/31322 New Development: https://github.com/rust-lang/rust/pull/37545
Aric, how can a gentoo developer help here? As far I could see this option is not yet in the upstream tar ball, right?
I managed to get most of musl support upstream for the 1.21 release currently in beta (the PR is at https://github.com/rust-lang/rust/pull/40113). Backports of the PR and a few additional patches needed for bootstrapping are in my copy of the rust repository at https://github.com/smaeul/rust. stage0 tarballs for all architectures supported by rust+musl (armv6 and older) are at https://portage.smaeul.xyz/distfiles/. These have statically-linked LLVM and libstdc++ (the only dependency for rustc is libc.so), so they should be usable directly by Gentoo. The cargo in the tarballs does depend on a few shared libraries. It can be linked fully statically (so it would work on both glibc and musl regardless of installed libraries), but only if is built separately from rustc. I have done this for x86_64; that's the cargo at the URL above without a file extension. ebuilds for cargo and rust that work for amd64 and *should* work for other architectures (maybe minor adjustments to CTARGET needed) are in the overlay at https://github.com/smaeul/portage-overlay. The ebuilds should also work for glibc.