From 0ed277acb8418b337a55cc753031eecd875f58df Mon Sep 17 00:00:00 2001
From: Olivier Benz <olivier.benz@b-data.ch>
Date: Tue, 17 Dec 2024 13:18:49 +0100
Subject: [PATCH] Update GHC to v9.12.1

- LLVM: Remove patch to force v18 backend
- cabal-install: Allow newer when building with GHC v9.12.1
- Dev Container: Add 'GHC 9.12 (latest)'
---
 .devcontainer/VERSION_MATRIX.md          | 11 ++--
 .devcontainer/ghc-9.10/devcontainer.json |  2 +-
 .devcontainer/ghc-9.12/devcontainer.json | 73 ++++++++++++++++++++++++
 .gitlab-ci.yml                           |  6 +-
 README.md                                |  4 +-
 VERSION_MATRIX.md                        |  1 +
 latest.Dockerfile                        | 28 ++-------
 7 files changed, 91 insertions(+), 34 deletions(-)
 create mode 100644 .devcontainer/ghc-9.12/devcontainer.json

diff --git a/.devcontainer/VERSION_MATRIX.md b/.devcontainer/VERSION_MATRIX.md
index 2052fa4..98701cb 100644
--- a/.devcontainer/VERSION_MATRIX.md
+++ b/.devcontainer/VERSION_MATRIX.md
@@ -2,11 +2,12 @@
 
 ## Current
 
-| GHC                           | Cabal[^1] | Stack[^1] | HLS                                                 |
-|:------------------------------|:----------|:----------|:--------------------------------------------------- |
-| latest<br>9.10.1<br>9.10<br>9 | 3.12.1.0  | ≥ 2.13.1  | latest<br>2.10.0.0<br>2.9.0.1<br>2.9.0.0            |
-| 9.8.4<br>9.8                  | 3.10.3.0  | ≥ 2.13.1  | 2.10.0.0                                            |
-| 9.6.6<br>9.6                  | 3.10.3.0  | ≥ 2.13.1  | 2.10.0.0<br>2.9.0.1                                 |
+| GHC                           | Cabal[^1] | Stack[^1] | HLS                            |
+|:------------------------------|:----------|:----------|:------------------------------ |
+| latest<br>9.12.1<br>9.12<br>9 | 3.14.1.0  | ≥ 2.13.1  | n/a                            |
+| 9.10.1<br>9.10                | 3.12.1.0  | ≥ 2.13.1  | 2.10.0.0<br>2.9.0.1<br>2.9.0.0 |
+| 9.8.4<br>9.8                  | 3.10.3.0  | ≥ 2.13.1  | 2.10.0.0                       |
+| 9.6.6<br>9.6                  | 3.10.3.0  | ≥ 2.13.1  | 2.10.0.0<br>2.9.0.1            |
 
 [^1]: built-in version; see [GHC musl > Version Matrix](../VERSION_MATRIX.md)
 
diff --git a/.devcontainer/ghc-9.10/devcontainer.json b/.devcontainer/ghc-9.10/devcontainer.json
index 3b304ca..6b41be7 100644
--- a/.devcontainer/ghc-9.10/devcontainer.json
+++ b/.devcontainer/ghc-9.10/devcontainer.json
@@ -1,5 +1,5 @@
 {
-  "name": "GHC 9.10 (latest)",
+  "name": "GHC 9.10",
   "build": {
     "dockerfile": "../GHC.Dockerfile",
     "context": "..",
diff --git a/.devcontainer/ghc-9.12/devcontainer.json b/.devcontainer/ghc-9.12/devcontainer.json
new file mode 100644
index 0000000..da8d08b
--- /dev/null
+++ b/.devcontainer/ghc-9.12/devcontainer.json
@@ -0,0 +1,73 @@
+{
+  "name": "GHC 9.12 (latest)",
+  "build": {
+    "dockerfile": "../GHC.Dockerfile",
+    "context": "..",
+    "args": {
+      "GHC_VERSION": "9.12",
+      "USE_ZSH_FOR_ROOT": "unset-to-use-ash",
+      "SET_LANG": "C.UTF-8",
+      "SET_TZ": ""
+    }
+  },
+
+  "onCreateCommand": "onCreateCommand.sh",
+  "postCreateCommand": "cabal update",
+  "postAttachCommand": "${HOME}/.local/bin/checkForUpdates.sh",
+
+  "features": {
+    "ghcr.io/devcontainers/features/common-utils:2": {
+      "configureZshAsDefaultShell": true,
+      "upgradePackages": false,
+      "username": "vscode",
+      "userUid": "automatic",
+      "userGid": "automatic"
+    }
+  },
+
+  "customizations": {
+    "vscode": {
+      "extensions": [
+        "alefragnani.project-manager",
+        "christian-kohler.path-intellisense",
+        "DavidAnson.vscode-markdownlint",
+        "eamodio.gitlens@11.7.0",
+        "editorconfig.editorconfig",
+        "exiasr.hadolint",
+        "GitHub.vscode-pull-request-github",
+        "GitLab.gitlab-workflow",
+        "haskell.haskell",
+        "mhutchie.git-graph",
+        "mutantdino.resourcemonitor",
+        "piotrpalarz.vscode-gitignore-generator",
+        "redhat.vscode-yaml",
+        "timonwong.shellcheck"
+      ],
+      "settings": {
+        "gitlab.aiAssistedCodeSuggestions.enabled": false,
+        "gitlab.duoChat.enabled": false,
+        "gitlens.showWelcomeOnInstall": false,
+        "gitlens.showWhatsNewAfterUpgrades": false,
+        "haskell.manageHLS": "PATH",
+        "resmon.show.battery": false,
+        "resmon.show.cpufreq": false
+      }
+    }
+  },
+
+  // Set 'remoteUser' to 'root' to connect as root instead.
+  "remoteUser": "vscode",
+  "workspaceMount": "source=ghc-musl-ghc-9.12-home-vscode,target=/home/vscode,type=volume",
+  // "workspaceMount": "source=${localWorkspaceFolder}/.devcontainer/bind-mounts/ghc-musl-ghc-9.12-home-vscode,target=/home/vscode,type=bind",
+  "workspaceFolder": "/home/vscode",
+
+  // "remoteUser": "root",
+  // "workspaceMount": "source=ghc-musl-ghc-9.12-root,target=/root,type=volume",
+  // // "workspaceMount": "source=${localWorkspaceFolder}/.devcontainer/bind-mounts/ghc-musl-ghc-9.12-root,target=/root,type=bind",
+  // "workspaceFolder": "/root",
+
+  "remoteEnv": {
+    // Pip: Install packages to the user site
+    "PIP_USER": "1"
+  }
+}
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 70ed22e..c604f9c 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -1,12 +1,12 @@
 .env:
   variables:
-    GHC_VERSION: "9.10.1"
-    CABAL_VERSION: "3.12.1.0"
+    GHC_VERSION: "9.12.1"
+    CABAL_VERSION: "3.14.1.0"
     STACK_VERSION: "3.1.1"
     HLS_VERSION: "2.10.0.0"
     BUILD_GHC: "true"
     BUILD_HLS: "false"
-    TAG_VERSION_MAJ_MIN: "true"
+    TAG_VERSION_MAJ_MIN: "false"
     TAG_VERSION_MAJ: "false"
     TAG_HLS_LATEST: "true"
 
diff --git a/README.md b/README.md
index 78aecc5..38cf312 100644
--- a/README.md
+++ b/README.md
@@ -61,8 +61,8 @@ To install docker, follow the instructions for your platform:
 
 ```bash
 docker build \
-  --build-arg GHC_VERSION=9.10.1 \
-  --build-arg CABAL_VERSION=3.12.1.0 \
+  --build-arg GHC_VERSION=9.12.1 \
+  --build-arg CABAL_VERSION=3.14.1.0 \
   --build-arg STACK_VERSION=3.1.1 \
   -t ghc-musl \
   -f latest.Dockerfile .
diff --git a/VERSION_MATRIX.md b/VERSION_MATRIX.md
index d423073..c184acb 100644
--- a/VERSION_MATRIX.md
+++ b/VERSION_MATRIX.md
@@ -4,6 +4,7 @@ Topmost entry = Tag `latest`
 
 | GHC        | Cabal    | Stack      | LLVM | Linux distro |
 |:-----------|:---------|:-----------|:---- |:-------------|
+| 9.12.1     | 3.14.1.0 | 3.1.1      | 18   | Alpine 3.21  |
 | 9.10.1     | 3.12.1.0 | 3.1.1      | 18   | Alpine 3.21  |
 | 9.8.4      | 3.10.3.0 | 3.1.1      | 16   | Alpine 3.21  |
 | 9.8.3      | 3.10.3.0 | 3.1.1      | 16   | Alpine 3.20  |
diff --git a/latest.Dockerfile b/latest.Dockerfile
index d79973b..3752670 100644
--- a/latest.Dockerfile
+++ b/latest.Dockerfile
@@ -5,12 +5,7 @@ ARG STACK_VERSION
 ARG GHC_VERSION_BUILD=${GHC_VERSION}
 ARG CABAL_VERSION_BUILD=${CABAL_VERSION}
 
-FROM glcr.b-data.ch/ghc/ghc-musl:9.8.2-linux-amd64 AS bootstrap-amd64
-FROM glcr.b-data.ch/ghc/ghc-musl:9.8.2-linux-arm64v8 AS bootstrap-arm64
-FROM glcr.b-data.ch/ghc/ghc-musl:9.8.2-linux-riscv64 AS bootstrap-riscv64
-## linux/riscv64 bootstrap image: binutils-gold n/a; numactl-dev pre-installed
-
-FROM bootstrap-${TARGETARCH}${TARGETVARIANT} AS bootstrap
+FROM glcr.b-data.ch/ghc/ghc-musl:9.10.1 AS bootstrap
 
 RUN case "$(uname -m)" in \
     x86_64) linker="gold" ;; \
@@ -42,32 +37,22 @@ ARG GHC_VERSION_BUILD
 
 ENV GHC_VERSION=${GHC_VERSION_BUILD}
 
-COPY patches/${GHC_VERSION}.patch /tmp/
-
 RUN cd /tmp \
   && curl -sSLO https://downloads.haskell.org/~ghc/"$GHC_VERSION"/ghc-"$GHC_VERSION"-src.tar.xz \
   && curl -sSLO https://downloads.haskell.org/~ghc/"$GHC_VERSION"/ghc-"$GHC_VERSION"-src.tar.xz.sig \
   && gpg --keyserver hkps://keyserver.ubuntu.com:443 \
-    --receive-keys FFEB7CE81E16A36B3E2DED6F2DE04D4E97DB64AD || \
+    --receive-keys 88B57FCF7DB53B4DB3BFA4B1588764FBE22D19C4 || \
     gpg --keyserver hkp://keyserver.ubuntu.com:80 \
-    --receive-keys FFEB7CE81E16A36B3E2DED6F2DE04D4E97DB64AD \
+    --receive-keys 88B57FCF7DB53B4DB3BFA4B1588764FBE22D19C4 \
   && gpg --verify "ghc-$GHC_VERSION-src.tar.xz.sig" "ghc-$GHC_VERSION-src.tar.xz" \
   && tar -xJf "ghc-$GHC_VERSION-src.tar.xz" \
   && cd "ghc-$GHC_VERSION" \
-  ## Apply patch: Bump max LLVM version to 19 (not inclusive)
-  ## https://gitlab.haskell.org/ghc/ghc/-/merge_requests/12726
-  && mv "/tmp/$GHC_VERSION.patch" . \
-  && patch -p0 <"$GHC_VERSION.patch" \
   ## Configure and build
-  && case "$(uname -m)" in \
-    riscv64) numa="no" ;; \
-  esac \
   && ./boot.source \
   && ./configure \
     --build=$(uname -m)-alpine-linux \
     --host=$(uname -m)-alpine-linux \
     --target=$(uname -m)-alpine-linux \
-    --enable-numa=${numa:-auto} \
   ## Use the LLVM backend
   ## Switch llvm-targets from unknown-linux-gnueabihf->alpine-linux
   ## so we can match the llvm vendor string alpine uses
@@ -179,11 +164,8 @@ FROM ghc-stage1 AS ghc-stage2
 COPY --from=bootstrap-cabal /root/.local/bin/cabal /usr/local/bin/cabal
 
 ## Rebuild Cabal (the tool) with the GHC target version
-RUN if [ "$(uname -m)" = "riscv64" ]; then \
-    apk add --no-cache numactl-dev; \
-  fi \
-  && cabal update \
-  && cabal install "cabal-install-$CABAL_VERSION"
+RUN cabal update \
+  && cabal install --allow-newer "cabal-install-$CABAL_VERSION"
 
 FROM ghc-stage1 AS test
 
-- 
GitLab