Skip to content
Snippets Groups Projects
Verified Commit 9ca36d18 authored by Olivier Benz's avatar Olivier Benz
Browse files

Rebuild Cabal (the tool) with the GHC target version

parent b4a42a1d
No related branches found
No related tags found
No related merge requests found
Pipeline #24563 passed
......@@ -69,7 +69,7 @@ build:latest-linux-amd64:
--build-arg GHC_VERSION
--build-arg CABAL_VERSION
--build-arg STACK_VERSION
--target tester
--target test
-t $CI_APP_REPO:$CI_APP_TAG-linux-amd64
-t $CI_APP_REPO:$VERSION_MAJ_MIN_PAT-linux-amd64
-f latest.Dockerfile .
......@@ -101,7 +101,7 @@ build:latest-linux-arm64v8:
--build-arg GHC_VERSION
--build-arg CABAL_VERSION
--build-arg STACK_VERSION
--target tester
--target test
-t $CI_APP_REPO:$CI_APP_TAG-linux-arm64v8
-t $CI_APP_REPO:$VERSION_MAJ_MIN_PAT-linux-arm64v8
-f latest.Dockerfile .
......@@ -130,7 +130,7 @@ build:version-linux-amd64:
script:
- >
docker build
--target tester
--target test
-t $CI_APP_REPO:$CI_APP_TAG-linux-amd64
-f prior/$GHC_VERSION.Dockerfile .
- >
......@@ -152,7 +152,7 @@ build:version-linux-arm64v8:
script:
- >
docker build
--target tester
--target test
-t $CI_APP_REPO:$CI_APP_TAG-linux-arm64v8
-f prior/$GHC_VERSION.Dockerfile .
- >
......
......@@ -44,21 +44,26 @@ RUN cd /tmp \
&& cd "ghc-$GHC_VERSION" \
&& ./boot.source \
&& ./configure --disable-ld-override LD=ld.gold \
# Use the LLVM backend
# Switch llvm-targets from unknown-linux-gnueabihf->alpine-linux
# so we can match the llvm vendor string alpine uses
## Use the LLVM backend
## Switch llvm-targets from unknown-linux-gnueabihf->alpine-linux
## so we can match the llvm vendor string alpine uses
&& sed -i -e 's/unknown-linux-gnueabihf/alpine-linux/g' llvm-targets \
&& sed -i -e 's/unknown-linux-gnueabi/alpine-linux/g' llvm-targets \
&& sed -i -e 's/unknown-linux-gnu/alpine-linux/g' llvm-targets \
&& cabal update \
# See https://unix.stackexchange.com/questions/519092/what-is-the-logic-of-using-nproc-1-in-make-command
## See https://unix.stackexchange.com/questions/519092/what-is-the-logic-of-using-nproc-1-in-make-command
&& hadrian/build binary-dist -j"$(($(nproc)+1))" \
--flavour=perf+llvm+split_sections \
--docs=none \
# See https://gitlab.haskell.org/ghc/ghc/-/wikis/commentary/libraries/version-history
--docs=none
FROM bootstrap as bootstrap-cabal
## Build Cabal (the tool) with the GHC bootstrap version
RUN cabal update \
## See https://gitlab.haskell.org/ghc/ghc/-/wikis/commentary/libraries/version-history
&& cabal install --allow-newer --constraint 'Cabal-syntax<3.11' "cabal-install-$CABAL_VERSION"
FROM alpine:3.18 as builder
FROM alpine:3.18 as ghc-stage1
LABEL org.opencontainers.image.licenses="MIT" \
org.opencontainers.image.source="https://gitlab.b-data.ch/ghc/ghc-musl" \
......@@ -110,10 +115,10 @@ RUN apk add --no-cache \
COPY --from=bootstrap /tmp/ghc-"$GHC_VERSION"/_build/bindist/ghc-"$GHC_VERSION"-*-alpine-linux.tar.xz /tmp/
RUN cd /tmp \
# Fix https://github.com/haskell/cabal/issues/8923
## Fix https://github.com/haskell/cabal/issues/8923
&& PKG_CONFIG_VERSION="$(pkg-config --version)" \
&& if [ "${PKG_CONFIG_VERSION%.*}" = "1.9" ]; then \
# Downgrade pkgconf from 1.9.x to 1.8.1
## Downgrade pkgconf from 1.9.x to 1.8.1
curl -sSLO http://dl-cdn.alpinelinux.org/alpine/v3.16/main/"$(uname -m)"/pkgconf-1.8.1-r0.apk; \
apk add --no-cache pkgconf-1.8.1-r0.apk; \
fi \
......@@ -132,25 +137,37 @@ RUN cd /tmp \
## Clean up
&& rm -rf /tmp/*
## Install Cabal
COPY --from=bootstrap /root/.local/bin/cabal /usr/local/bin/cabal
FROM ghc-stage1 as ghc-stage2
FROM builder as tester
## Install Cabal (the tool) built with the GHC bootstrap version
COPY --from=bootstrap-cabal /root/.local/bin/cabal /usr/local/bin/cabal
## Rebuild Cabal (the tool) with the GHC target version
RUN cabal update \
&& cabal install --allow-newer --constraint 'Cabal-syntax<3.11' "cabal-install-$CABAL_VERSION"
FROM ghc-stage1 as test
WORKDIR /usr/local/src
## Install Cabal (the tool) built with the GHC target version
COPY --from=ghc-stage2 /root/.local/bin/cabal /usr/local/bin/cabal
COPY Main.hs Main.hs
RUN ghc -static -optl-pthread -optl-static Main.hs \
&& file Main \
&& ./Main \
# Test cabal workflow
## Test cabal workflow
&& mkdir cabal-test \
&& cd cabal-test \
&& cabal update \
&& cabal init -n --is-executable -p tester -l MIT \
&& cabal run
FROM builder as final
FROM ghc-stage1
## Install Cabal (the tool) built with the GHC target version
COPY --from=ghc-stage2 /root/.local/bin/cabal /usr/local/bin/cabal
CMD ["ghci"]
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment