Use native codegen in docker build, results in smaller binary

This commit is contained in:
Oleg Grenrus 2018-09-10 19:00:05 +03:00
parent a5a7b332f1
commit 9e7539c10b
1 changed files with 2 additions and 4 deletions

View File

@ -9,10 +9,10 @@ RUN apt-get -yq update \
&& apt-get -yq install software-properties-common \ && apt-get -yq install software-properties-common \
&& apt-add-repository -y "ppa:hvr/ghc" \ && apt-add-repository -y "ppa:hvr/ghc" \
&& apt-get -yq update \ && apt-get -yq update \
&& apt-get -yq install cabal-install-2.4 ghc-8.4.3 llvm-5.0 pandoc \ && apt-get -yq install cabal-install-2.4 ghc-8.4.3 pandoc \
&& rm -rf /var/lib/apt/lists/* && rm -rf /var/lib/apt/lists/*
ENV PATH="/opt/ghc/bin:/usr/lib/llvm-5.0/bin:${PATH}" ENV PATH="/opt/ghc/bin:${PATH}"
# Use gold linker and check tools versions # Use gold linker and check tools versions
RUN ln -s $(which ld.gold) /usr/local/bin/ld && \ RUN ln -s $(which ld.gold) /usr/local/bin/ld && \
@ -34,7 +34,6 @@ RUN cabal update && \
cabal get aeson-1.4.0.0 && sed -i 's/-O2//' aeson-1.4.0.0/aeson.cabal && \ cabal get aeson-1.4.0.0 && sed -i 's/-O2//' aeson-1.4.0.0/aeson.cabal && \
echo 'packages: . regex-tdfa-1.2.3.1 aeson-1.4.0.0 > cabal.project' && \ echo 'packages: . regex-tdfa-1.2.3.1 aeson-1.4.0.0 > cabal.project' && \
cabal new-build --dependencies-only \ cabal new-build --dependencies-only \
--ghc-options='-fllvm -optlo-Os' \
--disable-executable-dynamic --enable-split-sections --disable-tests --disable-executable-dynamic --enable-split-sections --disable-tests
# Copy source and build it # Copy source and build it
@ -46,7 +45,6 @@ COPY test test
RUN sed -i 's/-- STATIC/ld-options: -static -pthread -Wl,--gc-sections/' ShellCheck.cabal && \ RUN sed -i 's/-- STATIC/ld-options: -static -pthread -Wl,--gc-sections/' ShellCheck.cabal && \
cat ShellCheck.cabal && \ cat ShellCheck.cabal && \
cabal new-build \ cabal new-build \
--ghc-options='-fllvm -optlo-Os' \
--disable-executable-dynamic --enable-split-sections --disable-tests && \ --disable-executable-dynamic --enable-split-sections --disable-tests && \
cp $(find dist-newstyle -type f -name shellcheck) . && \ cp $(find dist-newstyle -type f -name shellcheck) . && \
strip --strip-all shellcheck && \ strip --strip-all shellcheck && \