Skip to content

No init build against musl libc #354

Closed
@sagebind

Description

@sagebind

There's no build of rustup-init against musl libc, which means that rustup cannot be installed on Alpine Linux, for example, without building rustup yourself.

Activity

japaric

japaric commented on Apr 25, 2016

@japaric
Member

Building rustup-init for x86_64-unknown-linux-musl is not going to be enough because there is no rustc component for that triple. I'm not aware of anyone that has built a working rustc for that triple. I have tried and managed to built a rustc but it always crashed in the LLVM phase when I tried to compile anything. Probably, LLVM needed more patching (I applied some of Alpine Linux patches) to work correctly with musl but I didn't investigate further.

sagebind

sagebind commented on Apr 25, 2016

@sagebind
Author

Alright then, my bad. This issue isn't really relevant to rustup then, so I'll close it.

Thanks anyway!

palfrey

palfrey commented on Dec 29, 2016

@palfrey

Using https://github.com/emk/rust-musl-builder I've just built what appears to be a perfectly good x86_64-unknown-linux-musl rustup-init (nothing fancy, just a cargo build --release). Is this problem now solvable or am I missing some other missing detail?

sanmai-NL

sanmai-NL commented on Mar 31, 2017

@sanmai-NL

@palfrey, @japaric: Also wondering ...

japaric

japaric commented on Apr 2, 2017

@japaric
Member

It's still not possible to build a rustc that works on musl distros like Alpine. PR rust-lang/rust#40113 is one of the requirements to build such rustc.

jirutka

jirutka commented on Apr 6, 2017

@jirutka

It's still not possible to build a rustc that works on musl distros like Alpine.

That’s not entirely correct. It is possible (see APKBUILD), I did it in August 2016 (with your help), but it requires cross-compiling rustc against musl on GNU-based system and applying some hacks.

It’d like to also note that there’s no problem with musl itself, just in Rust build system. 😿

mcandre

mcandre commented on Apr 11, 2017

@mcandre

Oy, the cargo package on alpine:edge fails to access the cargo index, due to linking against a broken libgit2... Could someone fix the Alpine rust & cargo packages plz

jirutka

jirutka commented on Apr 12, 2017

@jirutka

Rust and Cargo in Alpine testing are currently broken. We’ve updated Rust to the latest version, with better patches that allow both dynamic and static linking on Alpine. Initially it seemed that everything is okay, but then we found many breakages. Still hard working on it, fixing Rust build system…

corbinu

corbinu commented on Aug 27, 2017

@corbinu

Now that rust-lang/rust#40113 has closed can't this be reopened?

fzgregor

fzgregor commented on Feb 14, 2018

@fzgregor

@japaric WDYT?

japaric

japaric commented on Feb 24, 2018

@japaric
Member

@fzgregor

@japaric WDYT?

The same thing as almost two years ago:

Building rustup-init for x86_64-unknown-linux-musl is not going to be enough because there is no rustc component for that triple.

Is rust-lang/rust producing rustc binaries for x86_64-unknown-linux-musl? I'm no longer involved with infrastructure stuff so I don't know. Producing rustc binaries is a rust-lang/rust issue that the infra team is in charge of so you should ask them.

P.S. Also, I'm not a rustup developer so I can't reopen issues in this repo.

corbinu

corbinu commented on Feb 24, 2018

@corbinu

Thanks I will ping them then. This is super important for things like building rocket services into a docker container

jirutka

jirutka commented on Feb 25, 2018

@jirutka

Is rust-lang/rust producing rustc binaries for x86_64-unknown-linux-musl?

No, they still do not. 😞 However, it is possible to build rustc on and for x86_64-unknown-linux-musl system with fully working both static and dynamic compilation, but it still requires some patches (see here). We in Alpine Linux do it since rust 1.17.0 (package rust). About half of the patches has been already upstreamed, somewhere between 1.19.0 and 1.21.0.

raphaelcohn

raphaelcohn commented on Nov 2, 2018

@raphaelcohn
Contributor

@corbinu @japaric Not sure if this is helpful, but it is possible to run rustup-init on Alpine Linux if one builds (or installs) glibc first and then uses patchelf to adjust the rpath of the rust binaries. See this docket file for an example script https://github.com/libertine-linux/libertine/blob/master/dockers/libertine-build-environment/Dockerfile.

I've got my fingers crossed that mrustc gets mature enough that I can bootstrap new Linux distros without this horrible chicken-and-egginess.

corbinu

corbinu commented on Nov 2, 2018

@corbinu

@raphaelcohn Your amazing! After only a little playing it looks like you don't even need the patches

FROM frolvlad/alpine-glibc

RUN apk add --no-cache curl bash

RUN curl https://sh.rustup.rs -o rustup-init
RUN chmod +x rustup-init
RUN ./rustup-init --verbose -y --no-modify-path --default-toolchain nightly --default-host x86_64-unknown-linux-gnu
RUN rm rustup-init

ENV PATH=/root/.cargo/bin:"$PATH"
RUN rustup target add x86_64-unknown-linux-musl
RUN rustup update
RUN rustc -Vv

ENTRYPOINT ["rustc"]

However it does appear that if I try to compile anything with a C/C++ dep then it implodes on jemalloc. I will have to look into other solutions there.

corbinu

corbinu commented on Nov 2, 2018

@corbinu

@raphaelcohn actually it looks like this may finally be coming anyway! rust-lang/rust#55163

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @mcandre@palfrey@corbinu@jirutka@fzgregor

        Issue actions

          No init build against musl libc · Issue #354 · rust-lang/rustup