Last active
July 6, 2016 13:12
-
-
Save thumphries/b08f8b9ba42385afc8a4f2ceb097e2ab to your computer and use it in GitHub Desktop.
ghc-musl bootstrapping
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
V = 0 | |
DYNAMIC_GHC_PROGRAMS = NO | |
GhcLibWays = v | |
SRC_HC_OPTS = -O -H64m -optl--no-pie | |
GhcStage1HcOpts = -O -fasm | |
GhcStage2HcOpts = -O2 -fasm | |
GhcHcOpts = -Rghc-timing | |
GhcLibHcOpts = -O2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM alpine:latest | |
COPY build.mk /tmp/ | |
RUN apk add --update curl xz alpine-sdk perl gmp-dev file gmp openssh openssl zlib-dev strace vim less jq ncurses-dev bash autoconf | |
RUN cd /tmp && \ | |
wget http://ghc-musl-dist-apse2.s3-website-ap-southeast-2.amazonaws.com/ghc-7.8.4/ghc-7.8.4-x86_64-unknown-linux.tar.bz2 && \ | |
tar xvf ghc*.tar.bz2 && \ | |
cd ghc-7.8.4 && \ | |
./configure && \ | |
: musl ld requires --no-pie to work for some reason with ghc && \ | |
sed -i '/C\ compiler\ link/{ s/""/"--no-pie"/ }' settings && \ | |
make install | |
RUN cd /tmp && \ | |
wget https://www.haskell.org/ghc/dist/7.10.3/ghc-7.10.3-src.tar.bz2 && \ | |
tar xvfj ghc-7.10.3-src.tar.bz2 && \ | |
cd /tmp/ghc-7.10.3 && \ | |
cp -v /tmp/build.mk mk/build.mk && \ | |
./configure && \ | |
# : "libffi has a bug, which we patch here" && \ | |
# sed -i 's,chmod,sed -i s/__gnu_linux__/1/ libffi/build/src/closures.c \&\& chmod,' libffi/ghc.mk && \ | |
make -j16 && \ | |
make binary-dist | |
CMD /bin/sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM debian:8.0 | |
# https://github.com/nilcons/ghc-musl | |
RUN apt-get update | |
RUN apt-get install -y musl-tools build-essential wget curl ghc libncurses-dev less vim-tiny autoconf | |
# file | |
WORKDIR /tmp | |
RUN wget https://www.haskell.org/ghc/dist/7.8.4/ghc-7.8.4-src.tar.bz2 | |
RUN tar xvfj ghc-7.8.4-src.tar.bz2 | |
WORKDIR /tmp/ghc-7.8.4 | |
COPY build.mk /tmp/ghc-7.8.4/mk/build.mk | |
RUN ./configure --target=x86_64-pc-linux-musl --with-gcc=musl-gcc --with-ld=ld --with-nm=nm --with-ar=ar --with-ranlib=ranlib --prefix=/opt/ghc-cross | |
# stole this from https://github.com/redneb/ghc-alt-libc, thanks! | |
COPY fix-execvpe-signature-ghc-7.8.4.patch /tmp/fix-execvpe.patch | |
RUN patch -p1 </tmp/fix-execvpe.patch | |
# compile without ncurses or terminfo | |
RUN sed -i s/terminfo// ghc.mk | |
RUN sed -i s/terminfo// utils/ghc-pkg/ghc-pkg.cabal | |
RUN sed -i s/unix,/unix/ utils/ghc-pkg/ghc-pkg.cabal | |
RUN sed -i '1{p; s/.*/#define BOOTSTRAPPING/}' utils/ghc-pkg/Main.hs | |
# update config.sub in libffi, so it supports x86_64-pc-linux | |
RUN sed -i 's,chmod,cp /usr/share/misc/config.sub libffi/build/config.sub \&\& chmod,' libffi/ghc.mk | |
# then just build it! | |
RUN make -j8 | |
RUN make install | |
WORKDIR /opt/ghc-cross | |
# linked with glibc, not musl, build system bug, but we don't need it | |
RUN rm bin/x86_64-pc-linux-musl-hp2ps | |
# linked with glibc, not musl, build system bug, let's build an alternative one | |
RUN rm lib/x86_64-pc-linux-musl-ghc-7.8.4/unlit | |
RUN ( cd /tmp/ghc-7.8.4/utils/unlit ; musl-gcc unlit.c ) ; cp /tmp/ghc-7.8.4/utils/unlit/a.out lib/x86_64-pc-linux-musl-ghc-7.8.4/unlit | |
# we want to use normal gcc, not musl-gcc once we move this ghc-cross into a musl based distro | |
RUN sed -i 's/musl-gcc/gcc/' lib/x86_64-pc-linux-musl-ghc-7.8.4/settings | |
# musl ld requires --no-pie to work for some reason with ghc | |
RUN sed -i '/C\ compiler\ link/{ s/""/"--no-pie"/ }' lib/x86_64-pc-linux-musl-ghc-7.8.4/settings | |
# Remove the cross compiler prefix from binaries | |
RUN (cd bin ; for i in x86_64-pc-linux-musl-* ; do ln -s $i ${i#x86_64-pc-linux-musl-} ; done ) | |
WORKDIR / | |
RUN tar cvfJ ghc-7.8.4-x86_64-unknown-linux-musl.tar.xz /opt/ghc-cross |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM alpine:latest | |
COPY build.mk /tmp/ | |
RUN apk add --update curl xz alpine-sdk perl gmp-dev file gmp openssh openssl zlib-dev strace vim less jq ncurses-dev bash autoconf | |
RUN cd /tmp && \ | |
wget http://ghc-musl-dist-apse2.s3-website-ap-southeast-2.amazonaws.com/ghc-7.8.4/ghc-7.8.4-x86_64-unknown-linux.tar.bz2 && \ | |
tar xvf ghc*.tar.bz2 && \ | |
cd ghc-7.8.4 && \ | |
./configure && \ | |
: musl ld requires --no-pie to work for some reason with ghc && \ | |
sed -i '/C\ compiler\ link/{ s/""/"--no-pie"/ }' settings && \ | |
make install | |
RUN cd /tmp && \ | |
wget https://www.haskell.org/ghc/dist/8.0.1/ghc-8.0.1-src.tar.xz && \ | |
tar xvf ghc-8.0.1-src.tar.xz && \ | |
cd /tmp/ghc-8.0.1 && \ | |
cp -v /tmp/build.mk mk/build.mk && \ | |
./configure && \ | |
make -j16 && \ | |
make binary-dist | |
CMD /bin/sh |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
still dynamically linking musl and possibly gmp
will retry with
-optl-static -optl-pthread
in the GHC stage1 and stage2 build.mk flagshttps://ro-che.info/articles/2015-10-26-static-linking-ghc