Use LLVM + split-sections
This commit is contained in:
parent
a68e3aeb26
commit
a5a7b332f1
48
Dockerfile
48
Dockerfile
|
@ -1,22 +1,56 @@
|
|||
# Build-only image
|
||||
FROM ubuntu:17.10 AS build
|
||||
FROM ubuntu:18.04 AS build
|
||||
USER root
|
||||
WORKDIR /opt/shellCheck
|
||||
|
||||
# Install OS deps
|
||||
RUN apt-get update && apt-get install -y ghc cabal-install
|
||||
# Install OS deps, including GHC from HVR-PPA
|
||||
# https://launchpad.net/~hvr/+archive/ubuntu/ghc
|
||||
RUN apt-get -yq update \
|
||||
&& apt-get -yq install software-properties-common \
|
||||
&& apt-add-repository -y "ppa:hvr/ghc" \
|
||||
&& apt-get -yq update \
|
||||
&& apt-get -yq install cabal-install-2.4 ghc-8.4.3 llvm-5.0 pandoc \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
ENV PATH="/opt/ghc/bin:/usr/lib/llvm-5.0/bin:${PATH}"
|
||||
|
||||
# Use gold linker and check tools versions
|
||||
RUN ln -s $(which ld.gold) /usr/local/bin/ld && \
|
||||
cabal --version \
|
||||
&& ghc --version \
|
||||
&& ld --version
|
||||
|
||||
# Install Haskell deps
|
||||
# (This is a separate copy/run so that source changes don't require rebuilding)
|
||||
#
|
||||
# We also patch regex-tdfa and aeson removing hard-coded -O2 flag.
|
||||
# This makes compilation faster and binary smaller.
|
||||
# Performance loss is unnoticeable for ShellCheck
|
||||
#
|
||||
# Remember to update versions, once in a while.
|
||||
COPY ShellCheck.cabal ./
|
||||
RUN cabal update && cabal install --dependencies-only --ghc-options="-optlo-Os -split-sections"
|
||||
RUN cabal update && \
|
||||
cabal get regex-tdfa-1.2.3.1 && sed -i 's/-O2//' regex-tdfa-1.2.3.1/regex-tdfa.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' && \
|
||||
cabal new-build --dependencies-only \
|
||||
--ghc-options='-fllvm -optlo-Os' \
|
||||
--disable-executable-dynamic --enable-split-sections --disable-tests
|
||||
|
||||
# Copy source and build it
|
||||
COPY LICENSE Setup.hs shellcheck.hs ./
|
||||
COPY LICENSE Setup.hs shellcheck.hs shellcheck.1.md ./
|
||||
COPY src src
|
||||
RUN cabal build Paths_ShellCheck && \
|
||||
ghc -optl-static -optl-pthread -isrc -idist/build/autogen --make shellcheck -split-sections -optc-Wl,--gc-sections -optlo-Os && \
|
||||
COPY test test
|
||||
# This SED is the only "nastyness" we have to do
|
||||
# Hopefully soon we could add per-component ld-options to cabal.project
|
||||
RUN sed -i 's/-- STATIC/ld-options: -static -pthread -Wl,--gc-sections/' ShellCheck.cabal && \
|
||||
cat ShellCheck.cabal && \
|
||||
cabal new-build \
|
||||
--ghc-options='-fllvm -optlo-Os' \
|
||||
--disable-executable-dynamic --enable-split-sections --disable-tests && \
|
||||
cp $(find dist-newstyle -type f -name shellcheck) . && \
|
||||
strip --strip-all shellcheck && \
|
||||
file shellcheck && \
|
||||
ls -l shellcheck
|
||||
|
||||
RUN mkdir -p /out/bin && \
|
||||
|
|
|
@ -28,15 +28,13 @@ Extra-Source-Files:
|
|||
shellcheck.1.md
|
||||
-- built with a cabal sdist hook
|
||||
shellcheck.1
|
||||
-- tests
|
||||
test/shellcheck.hs
|
||||
|
||||
custom-setup
|
||||
setup-depends:
|
||||
base >= 4 && <5,
|
||||
process >= 1.0 && <1.7,
|
||||
base >= 4 && <5,
|
||||
process >= 1.0 && <1.7,
|
||||
cabal-doctest >= 1.0.6 && <1.1,
|
||||
Cabal >= 1.10 && <2.5
|
||||
Cabal >= 1.10 && <2.5
|
||||
|
||||
source-repository head
|
||||
type: git
|
||||
|
@ -94,10 +92,12 @@ executable shellcheck
|
|||
directory,
|
||||
mtl >= 2.2.1,
|
||||
parsec >= 3.0,
|
||||
QuickCheck >= 2.7.4,
|
||||
regex-tdfa
|
||||
main-is: shellcheck.hs
|
||||
|
||||
-- Marker to add flags for static linking
|
||||
-- STATIC
|
||||
|
||||
test-suite doctests
|
||||
type: exitcode-stdio-1.0
|
||||
main-is: doctests.hs
|
||||
|
|
Loading…
Reference in New Issue