From 1a2460a2ff5fc42b0a6295769906cd6ccd890e07 Mon Sep 17 00:00:00 2001
From: Olivier Benz <olivier.benz@b-data.ch>
Date: Fri, 20 Dec 2024 08:42:23 +0100
Subject: [PATCH] Update tweaks to build linux/riscv64 images

---
 VERSION_MATRIX.md       | 3 +++
 latest.Dockerfile       | 5 ++++-
 prior/9.10.1.Dockerfile | 6 +++---
 3 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/VERSION_MATRIX.md b/VERSION_MATRIX.md
index c184acb..4b38702 100644
--- a/VERSION_MATRIX.md
+++ b/VERSION_MATRIX.md
@@ -52,6 +52,9 @@ Topmost entry = Tag `latest`
 
 * Images based on Alpine 3.{17,18}: Package pkgconf downgraded to v1.8.1
   * Due to <https://github.com/haskell/cabal/issues/8923>
+* `linux/riscv64` image for GHC version 9.12.1 built with
+  `--flavour="quick+llvm`
+  * Due to <https://gitlab.haskell.org/ghc/ghc/-/issues/25594>
 
 ## Experimental
 
diff --git a/latest.Dockerfile b/latest.Dockerfile
index 3752670..cf937f0 100644
--- a/latest.Dockerfile
+++ b/latest.Dockerfile
@@ -48,6 +48,9 @@ RUN cd /tmp \
   && tar -xJf "ghc-$GHC_VERSION-src.tar.xz" \
   && cd "ghc-$GHC_VERSION" \
   ## Configure and build
+  && if [ "$(uname -m)" = "riscv64" ]; then \
+    flavour="quick+llvm"; \
+  fi \
   && ./boot.source \
   && ./configure \
     --build=$(uname -m)-alpine-linux \
@@ -64,7 +67,7 @@ RUN cd /tmp \
   && export PATH=/root/.local/bin:$PATH \
   ## 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 \
+    --flavour=${flavour:-perf+llvm+split_sections} \
     --docs=none
 
 FROM bootstrap AS bootstrap-cabal
diff --git a/prior/9.10.1.Dockerfile b/prior/9.10.1.Dockerfile
index 335a887..b2ad443 100644
--- a/prior/9.10.1.Dockerfile
+++ b/prior/9.10.1.Dockerfile
@@ -59,9 +59,9 @@ RUN cd /tmp \
   && mv "/tmp/$GHC_VERSION.patch" . \
   && patch -p0 <"$GHC_VERSION.patch" \
   ## Configure and build
-  && case "$(uname -m)" in \
-    riscv64) numa="no" ;; \
-  esac \
+  && if [ "$(uname -m)" = "riscv64" ]; then \
+    numa="no"; \
+  fi \
   && ./boot.source \
   && ./configure \
     --build=$(uname -m)-alpine-linux \
-- 
GitLab