Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No init build against musl libc #354

Closed
sagebind opened this issue Apr 22, 2016 · 16 comments
Closed

No init build against musl libc #354

sagebind opened this issue Apr 22, 2016 · 16 comments

Comments

@sagebind
Copy link

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.

@japaric
Copy link
Member

japaric commented Apr 25, 2016

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
Copy link
Author

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

Thanks anyway!

@palfrey
Copy link

palfrey commented Dec 29, 2016

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
Copy link

@palfrey, @japaric: Also wondering ...

@japaric
Copy link
Member

japaric commented Apr 2, 2017

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
Copy link

jirutka commented Apr 6, 2017

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
Copy link

mcandre commented Apr 11, 2017

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
Copy link

jirutka commented Apr 12, 2017

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
Copy link

corbinu commented Aug 27, 2017

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

@fzgregor
Copy link

@japaric WDYT?

@japaric
Copy link
Member

japaric commented Feb 24, 2018

@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
Copy link

corbinu commented Feb 24, 2018

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

@jirutka
Copy link

jirutka commented Feb 25, 2018

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
Copy link
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
Copy link

corbinu commented Nov 2, 2018

@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
Copy link

corbinu commented Nov 2, 2018

@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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants