Skip to content

Instantly share code, notes, and snippets.

@chrisdone
Created November 6, 2018 16:25
Show Gist options
  • Select an option

  • Save chrisdone/0a7af6776a1f31ccb5af9bc219b04a00 to your computer and use it in GitHub Desktop.

Select an option

Save chrisdone/0a7af6776a1f31ccb5af9bc219b04a00 to your computer and use it in GitHub Desktop.
Dockerfile: Build ghc-prim, integer-gmp and base alone
FROM debian:stretch-slim
MAINTAINER Chris Done
################################################################################
# OS deps
RUN apt-get update && apt-get install -y \
gnupg \
gpgv && \
apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys BA3CBA3FFE22B574 \
&& echo 'deb http://downloads.haskell.org/debian stretch main' >> /etc/apt/sources.list.d/haskell.list && \
apt-get update && apt-get install -y \
libtinfo5 \
autoconf automake libtool make libgmp-dev ncurses-dev g++ python bzip2 ca-certificates \
xz-utils \
ghc-8.2.2 \
alex \
cabal-install-2.2 \
happy \
sudo xutils-dev \
&& apt-get install git -y \
&& apt-get clean
ENV LANG C.UTF-8
ENV LC_ALL C.UTF-8
ENV LANGUAGE C.UTF-8
################################################################################
# Getting the GHC sources and GHC as a bootstrap compiler
RUN cd; \
mkdir ghc_build; \
cd ghc_build; \
git clone -b ghc-8.0 --recursive git://git.haskell.org/ghc.git ghc-8.0; \
cd ghc-8.0; \
git checkout ghc-8.0; \
git submodule update --init
RUN apt-get install ghc -y
################################################################################
# Building GHC
RUN cd; \
cd ghc_build/ghc-8.0; \
cd mk; \
sed -e 's/^#BuildFlavour = quickest$/BuildFlavour = quickest/' \
build.mk.sample > build.mk; \
cd ..; \
./boot
RUN cd; cd ghc_build/ghc-8.0 && ./configure
RUN cd; cd ghc_build/ghc-8.0 && make -j5
################################################################################
# Setup an empty package database for prana
ENV PREFIX /root/prana
RUN mkdir -p $PREFIX/package.conf.d && \
ghc-pkg --package-db $PREFIX/package.conf.d recache && \
ghc-pkg --package-db $PREFIX/package.conf.d list
################################################################################
# Building ghc-prim
WORKDIR /root/ghc_build/ghc-8.0/utils/genprimopcode
RUN echo 'import Distribution.Simple; main = defaultMain' > Setup.hs && \
runhaskell Setup.hs configure && \
runhaskell Setup.hs build
RUN cp dist/build/genprimopcode/genprimopcode .
WORKDIR /root/ghc_build/ghc-8.0/libraries/ghc-prim
RUN cp /root/ghc_build/ghc-8.0/compiler/stage2/build/primops.txt ../../compiler/prelude/primops.txt && \
ghc Setup.hs && \
./Setup configure --package-db $PREFIX/package.conf.d --prefix $PREFIX && \
./Setup build && \
./Setup install && \
sed -i -e 's,^exposed-modules:,exposed-modules: GHC.Prim,' $PREFIX/package.conf.d/ghc-prim-*.conf && \
ghc-pkg --package-db $PREFIX/package.conf.d recache
################################################################################
# Building integer-gmp
WORKDIR /root/ghc_build/ghc-8.0/libraries/integer-gmp
RUN ghc Setup.hs
RUN ./Setup configure --package-db $PREFIX/package.conf.d --prefix $PREFIX && \
./Setup build && \
./Setup install
################################################################################
# Building base
WORKDIR /root/ghc_build/ghc-8.0/libraries/base/
RUN echo 'import Distribution.Simple; main = defaultMainWithHooks autoconfUserHooks' > Setup.hs
RUN ghc -hide-all-packages -package Cabal Setup.hs -XNoImplicitPrelude
RUN ./Setup configure -finteger-gmp --package-db $PREFIX/package.conf.d --prefix $PREFIX && \
./Setup build && \
./Setup install
RUN ghc-pkg --package-db $PREFIX/package.conf.d list
# =>
#/root/prana/package.conf.d
# base-4.9.1.0
# ghc-prim-0.5.0.0
# integer-gmp-1.0.0.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment