[commit: ghc] wip/erikd/rts: Set `USE_MMAP` at configure time (5fae81c)

git at git.haskell.org git at git.haskell.org
Mon May 16 00:19:55 UTC 2016


Repository : ssh://git@git.haskell.org/ghc

On branch  : wip/erikd/rts
Link       : http://ghc.haskell.org/trac/ghc/changeset/5fae81ceb24d3e306a127a61bcf5fe6ab8db1f95/ghc

>---------------------------------------------------------------

commit 5fae81ceb24d3e306a127a61bcf5fe6ab8db1f95
Author: Erik de Castro Lopo <erikd at qti.qualcomm.com>
Date:   Sun May 15 21:07:25 2016 +1000

    Set `USE_MMAP` at configure time
    
    The `USE_MMAP` macro is used in the run time linker and was being set with
    some really ugly CPP hackery. Setting it in the configure script is much
    neater.


>---------------------------------------------------------------

5fae81ceb24d3e306a127a61bcf5fe6ab8db1f95
 configure.ac | 22 ++++++++++++++++++++++
 rts/Linker.c | 18 +-----------------
 2 files changed, 23 insertions(+), 17 deletions(-)

diff --git a/configure.ac b/configure.ac
index defc182..e39d77b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1062,6 +1062,28 @@ 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 ${TargetArch}-${TargetOS} in
+    powerpc-darwmin)
+        # Don't use mmap on powerpc/darwin as the mmap there doesn't support
+        # reallocating but we need to allocate jump islands just after each
+        # object images. Otherwise relative branches to jump islands can fail
+        # due to 24-bits displacement overflow.
+         UseMmap=0
+        ;;
+    *-mingw32)
+        # Mmap is not available on Windows.
+        UseMmap=0
+        ;;
+    *)
+        UseMmap=1
+        ;;
+    esac
+
+AC_DEFINE_UNQUOTED([USE_MMAP], [$UseMmap], [Use mmap in the runtime linker])
+
 dnl ** Have libdw?
 dnl --------------------------------------------------------------
 AC_ARG_ENABLE(libdw,
diff --git a/rts/Linker.c b/rts/Linker.c
index 09d4f6a..c4ca32f 100644
--- a/rts/Linker.c
+++ b/rts/Linker.c
@@ -52,19 +52,7 @@
 #include <dlfcn.h>
 #endif
 
-#if (defined(powerpc_HOST_ARCH) && defined(linux_HOST_OS)) \
- || (!defined(powerpc_HOST_ARCH) && \
-    (   defined(linux_HOST_OS)     || defined(freebsd_HOST_OS) || \
-        defined(dragonfly_HOST_OS) || defined(netbsd_HOST_OS ) || \
-        defined(openbsd_HOST_OS  ) || defined(darwin_HOST_OS ) || \
-        defined(kfreebsdgnu_HOST_OS) || defined(gnu_HOST_OS  ) || \
-        defined(solaris2_HOST_OS)))
-/* Don't use mmap on powerpc/darwin as the mmap there doesn't support
- * reallocating but we need to allocate jump islands just after each
- * object images. Otherwise relative branches to jump islands can fail
- * due to 24-bits displacement overflow.
- */
-#define USE_MMAP 1
+#if USE_MMAP
 #include <fcntl.h>
 #include <sys/mman.h>
 
@@ -72,10 +60,6 @@
 #include <unistd.h>
 #endif
 
-#else
-
-#define USE_MMAP 0
-
 #endif
 
 



More information about the ghc-commits mailing list