diff --git a/VERSION_MATRIX.md b/VERSION_MATRIX.md
index c184acb2b713cdbdfec8803dc8056890f79365ca..4b387028d87a84bc893f1b98d0f6fd7232e6596d 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 3752670153882218ec3daf1c297204eb4ef13a41..cf937f0b08608f4b512603fca2ee6ea03b5d47a0 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 335a887b4c5b94074ef37b79d468faf09e84d918..b2ad4438ac828d686b92a6ec62982f6ff49aebfd 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 \