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

git at git.haskell.org git at git.haskell.org
Mon May 16 02:11:28 UTC 2016


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

On branch  : wip/erikd/rts
Link       : http://ghc.haskell.org/trac/ghc/changeset/431ada2aa2c756316145b290dd2eadfe5978c9e8/ghc

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

commit 431ada2aa2c756316145b290dd2eadfe5978c9e8
Author: Erik de Castro Lopo <erikd at qti.qualcomm.com>
Date:   Mon May 16 09: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 in the configure script is much
    neater.


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

431ada2aa2c756316145b290dd2eadfe5978c9e8
 configure.ac | 30 ++++++++++++++++++++++++++++++
 rts/Linker.c | 18 +-----------------
 2 files changed, 31 insertions(+), 17 deletions(-)

diff --git a/configure.ac b/configure.ac
index defc182..c04e9b0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1062,6 +1062,36 @@ 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|freebsd|dragonfly|netbsd|openbsd|kfreebsdgnu|gnu|solaris2)
+        UseMmap=1
+        ;;
+    darwin)
+        # Don't use mmap on powerpc/darwin as the mmap there doesn't support
+        # reallocating. Reallocating is needed to allocate jump islands just
+        # after each object image. Jumps to these jump islands use relative
+        # branches which are limited to offsets that can be represented in
+        # 24-bits.
+        if test ${TargetArch} != "powerpc" ; then
+            UseMmap=1
+        else
+            UseMmap=0
+        fi
+        ;;
+    mingw32)
+        # Mmap is not available on Windows.
+        UseMmap=0
+        ;;
+    *)
+        UseMmap=0
+        ;;
+    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