From 18de37e45decdb1672c411c0f9976ddfa9b3b83c Mon Sep 17 00:00:00 2001
From: John Ericson <John.Ericson@Obsidian.Systems>
Date: Fri, 22 Sep 2023 15:22:54 -0400
Subject: [PATCH] Move mmap in the runtime linker check to the RTS configure

`AC_DEFINE` should go there instead.
---
 configure.ac     | 20 --------------------
 rts/configure.ac | 19 +++++++++++++++++++
 2 files changed, 19 insertions(+), 20 deletions(-)

diff --git a/configure.ac b/configure.ac
index 75601ed5430e..31c7f2fc4456 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1097,26 +1097,6 @@ if test "$use_large_address_space" = "yes" ; then
    AC_DEFINE([USE_LARGE_ADDRESS_SPACE], [1], [Enable single heap address space support])
 fi
 
-dnl ** Use MMAP in the runtime linker?
-dnl --------------------------------------------------------------
-
-case ${TargetOS} in
-    linux|linux-android|freebsd|dragonfly|netbsd|openbsd|kfreebsdgnu|gnu|solaris2)
-        RtsLinkerUseMmap=1
-        ;;
-    darwin|ios|watchos|tvos)
-        RtsLinkerUseMmap=1
-        ;;
-    *)
-        # Windows (which doesn't have mmap) and everything else.
-        RtsLinkerUseMmap=0
-        ;;
-    esac
-
-AC_DEFINE_UNQUOTED([RTS_LINKER_USE_MMAP], [$RtsLinkerUseMmap],
-                   [Use mmap in the runtime linker])
-
-
 GHC_ADJUSTORS_METHOD([Target])
 AC_SUBST([UseLibffiForAdjustors])
 
diff --git a/rts/configure.ac b/rts/configure.ac
index ade26210c77e..5ccf7c6df05f 100644
--- a/rts/configure.ac
+++ b/rts/configure.ac
@@ -33,6 +33,25 @@ GHC_CONVERT_PLATFORM_PARTS([host], [Host])
 FPTOOLS_SET_PLATFORM_VARS([host], [Host])
 FPTOOLS_SET_HASKELL_PLATFORM_VARS([Host])
 
+dnl ** Use MMAP in the runtime linker?
+dnl --------------------------------------------------------------
+
+case ${HostOS} in
+    linux|linux-android|freebsd|dragonfly|netbsd|openbsd|kfreebsdgnu|gnu|solaris2)
+        RtsLinkerUseMmap=1
+        ;;
+    darwin|ios|watchos|tvos)
+        RtsLinkerUseMmap=1
+        ;;
+    *)
+        # Windows (which doesn't have mmap) and everything else.
+        RtsLinkerUseMmap=0
+        ;;
+    esac
+
+AC_DEFINE_UNQUOTED([RTS_LINKER_USE_MMAP], [$RtsLinkerUseMmap],
+                   [Use mmap in the runtime linker])
+
 dnl ** ARM outline atomics
 dnl --------------------------------------------------------------
 FP_ARM_OUTLINE_ATOMICS
-- 
GitLab