-
Notifications
You must be signed in to change notification settings - Fork 5
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
Rust can be compiled against musl libc without cross-compilation from glibc #7
Comments
Did you find a way to do so? My compilation always fails with
I used the following Dockerfile for reference:
|
Nope, I haven't had time yet to try. May be you ask this question in that issue discussion? |
Sure, I was just curious. It seems like it's still necessary to cross compile using a glibc. |
With some hacks to the Dockerfile, I got a tiny bit further: in the end I ran into rust-lang/rust#28667. The configure parameters FROM alpine:3.3
RUN apk add --no-cache 'curl'
# TODO: Verify download.
RUN curl -LOsS 'https://static.rust-lang.org/dist/rustc-1.8.0-src.tar.gz' \
&& tar -xzvf 'rustc-1.8.0-src.tar.gz' \
&& cd 'rustc-1.8.0/' \
&& apk add --no-cache --virtual '.build-deps' \
'tree' \
'python' \
'file' \
'make' \
'g++' \
'llvm-dev' \
'musl-dev' \
&& apk add 'libunwind-dev' --no-cache --repository 'http://nl.alpinelinux.org/alpine/edge/testing/'
RUN ln -vsf '/bin/true' '/usr/bin/FileCheck' \
&& chmod a+x '/usr/bin/FileCheck'
RUN cd 'rustc-1.8.0/' \
&& ./configure \
--enable-dist-host-only \
--enable-llvm-static-stdcpp \
--target='x86_64-unknown-linux-musl' \
--musl-root='/usr' \
--prefix='/usr'
&& make install
|
@sanmai-NL Hmm. Have you read the threads and the follow-up fixes? rust-lang/rust#28667 was fixed by introduction of Could you try to pass |
That |
Yeap, that is exactly what I have just discovered. The fix went to the
P.S. I have tried to combine all configure options from the two provided Dockerfiles and the result is always the same: the mysterious |
@frol can you share your build script? |
Not sure how you're getting your
then you get past that and get a different error:
This is because the stage 0 compiler is linked against libc:
|
I got rustc building in alpine with some serious hacks: Hoping to use this rustc in place of the bootstrapped stage0. |
Okay, I have a branch that properly builds I'm going to keep investigating this and see how much more I can get done :-) Another thing I want to try, instead of using Arch Linux's glibc, is this project. Ideally, we'll have the following:
It would also be nice to have a statically-linked version of rustc itself... |
Related issue: rust-lang/rust#31322. |
I have just noticed that @jirutka has managed to prepare an Alpine Linux package for Rust: https://github.com/alpinelinux/aports/tree/master/testing/rust
At the moment, I have only one issue with it, it cannot build completely static binaries because of the package patch explicitly disabling static linkage:
|
FYI, we have updated our rust package with proper support for both dynamic and static linking. rustc on Alpine produces dynamically linked binary by default, but you can use option |
@jirutka It seems that
Any ideas? P.S.
|
Alpine 3.6 has been released, and it features Rust package in the main repo which can produce static binaries with |
According to this resolved issue: rust-lang/rust#28667, Rust should be able to be compiled against musl libc on a musl libc-based OS. It seems it is time to build an Alpine package: https://bugs.alpinelinux.org/issues/3949
The text was updated successfully, but these errors were encountered: