[HelpWanted][Solved] rustc for x86_64-unknown-linux-musl

TL;DR Here’s my work so far. Help me fix the remaining issues!


Users of musl-based Linux distributions like Alpine can’t use our Linux releases of rustc because those are compiled for x86_64-unknown-linux-gnu and require having glibc installed to work. Having releases of rustc for x86_64-unknown-linux-musl would fix that issue as they can be used on any (x86_64) Linux system regardless of it libc election.

Some time ago I managed to build rustc for x86_64-unknown-linux-musl. But the rustc I built didn’t really work. rustc -V worked fine but trying to compile anything resulted in a segfault. According to the gdb backtrace, the source of the segfault was a strlen call with null pointer argument somewhere inside LLVM.

The solution may require patching LLVM (I’m already using some of Alpine’s patches, maybe we need to apply the other patches?). Unfortunately, I don’t have much time to look into this issue. So I’m sharing my work here with the hope that someone might be able to pick it up and solve the issue. If someone does, let me know! Then we can work together to upstream the necessary changes :smile: .


Update for those watching this thread. (I forget to report this earlier :slight_smile:) I’ve managed to produce a rustc for x86_64-unknown-linux-musl (albeit with some hacks) and verified that it works on Alpine Linux. Also, thanks to this work, someone else packaged rustc for Alpine Linux :tada:.

My patches haven’t been upstreamed yet because I’m waiting for the tooling subteam’s response about how to proceed. Because of that, there is not an official binary release of rustc that works on musl based distros yet but I’m going to go ahead and mark this thread as solved.


Thanks very much for your work on this. I’ve planned to update my Docker image for Rust to use Alpine as soon as it was possible. Hope to see the core team receptive to your patches.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.