[Git][ghc/ghc][wip/rts-configure-1] 14 commits: RTS configure: Move over mem management checks

John Ericson (@Ericson2314) gitlab at gitlab.haskell.org
Tue Sep 26 14:37:17 UTC 2023



John Ericson pushed to branch wip/rts-configure-1 at Glasgow Haskell Compiler / GHC


Commits:
8376424c by John Ericson at 2023-09-26T10:20:49-04:00
RTS configure: Move over mem management checks

These are for heap allocation, a strictly RTS concern.

All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it
belongs in the RTS configure and should be safe to move without
modification.

The RTS configure one has a new
```
AC_CHECK_SIZEOF([void *])
```
that the top-level configure version didn't have, so that
`ac_cv_sizeof_void_p` is defined. Once more code is moved over in latter
commits, that can go away.

Progress towards #17191

- - - - -
da2aef77 by John Ericson at 2023-09-26T10:21:05-04:00
RTS configure: Move over `__thread` check

This used by (@bgamari thinks) the `GCThread` abstraction in the RTS.

All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it
belongs in the RTS configure and should be safe to move without
modification.

Progress towards #17191

- - - - -
7cb2985c by John Ericson at 2023-09-26T10:21:41-04:00
RTS configure: Move over misc function checks

These are for general use in the RTS.

All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it
belongs in the RTS configure and should be safe to move without
modification.

Progress towards #17191

- - - - -
d07c237b by John Ericson at 2023-09-26T10:21:55-04:00
RTS configure: Move over `eventfd` check

This check is for the RTS part of the event manager and has a
corresponding part in `base`.

All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it
belongs in the RTS configure and should be safe to move without
modification.

Progress towards #17191

- - - - -
268250a1 by John Ericson at 2023-09-26T10:30:11-04:00
Split `FP_CHECK_PTHREADS` and move part to RTS configure

`NEED_PTHREAD_LIB` is unused since
3609340743c1b25fdfd0e18b1670dac54c8d8623 (part of the make build
system), and so is no longer defined.

Progress towards #17191

- - - - -
87e6bdc2 by John Ericson at 2023-09-26T10:30:21-04:00
Move apple compat check to RTS configure

- - - - -
3850d3be by John Ericson at 2023-09-26T10:32:06-04:00
Move clock/timer fun checks to RTS configure

Actual library check (which will set the Cabal flag) is left in the
top-level configure for now.

Progress towards #17191

- - - - -
d5016e2d by John Ericson at 2023-09-26T10:32:53-04:00
Move visibility and "musttail" annotation checks to the RTS configure

All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it
belongs in the RTS configure and should be safe to move without
modification.

Progress towards #17191

- - - - -
25c14435 by John Ericson at 2023-09-26T10:33:33-04:00
Move leading underscore checks to RTS configure

`CabalLeadingUnderscore` is done via Hadrian already, so we can stop
`AC_SUBST`ing it completely.

- - - - -
20f20114 by John Ericson at 2023-09-26T10:33:33-04:00
Move alloca, fork, const, and big endian checks to RTS configure

All of this should boil down to `AC_DEFINE` not `AC_SUBST`, so it
belongs in the RTS configure and should be safe to move without
modification.

- - - - -
1c3054a5 by John Ericson at 2023-09-26T10:33:33-04:00
Move libdl check to RTS configure

- - - - -
61ffadea by John Ericson at 2023-09-26T10:34:27-04:00
Adjust `FP_FIND_LIBFFI`

Just set vars, and `AC_SUBST` in top-level configure.

Don't define `HAVE_SYSTEM_LIBFFI` because nothing is using it. It hasn't
be in used since 3609340743c1b25fdfd0e18b1670dac54c8d8623 (part of the
make build system).

- - - - -
d3fe76fc by John Ericson at 2023-09-26T10:35:07-04:00
Split BFD support to RTS configure

The flag is still in the top-level configure, but the other checks
(which define various macros --- important) are in the RTS configure.

- - - - -
df1c1921 by John Ericson at 2023-09-26T10:35:07-04:00
Split libm check between top level and RTS

- - - - -


5 changed files:

- configure.ac
- m4/fp_bfd_support.m4
- m4/fp_check_pthreads.m4
- m4/fp_find_libffi.m4
- rts/configure.ac


Changes:

=====================================
configure.ac
=====================================
@@ -937,18 +937,13 @@ dnl    Keep that check as early as possible.
 dnl    as we need to know whether we need libm
 dnl    for math functions or not
 dnl    (see https://gitlab.haskell.org/ghc/ghc/issues/3730)
-AC_CHECK_LIB(m, atan, HaveLibM=YES, HaveLibM=NO)
-if test $HaveLibM = YES
-then
-  AC_DEFINE([HAVE_LIBM], [1], [Define to 1 if you need to link with libm])
-  AC_SUBST([UseLibm],[YES])
-else
-  AC_SUBST([UseLibm],[NO])
-fi
-TargetHasLibm=$HaveLibM
+AC_CHECK_LIB(m, atan, UseLibm=YES, UseLibm=NO)
+AC_SUBST([UseLibm])
+TargetHasLibm=$UseLibm
 AC_SUBST(TargetHasLibm)
 
-FP_BFD_SUPPORT
+FP_BFD_FLAG
+AC_SUBST([UseLibbfd])
 
 dnl ################################################################
 dnl Check for libraries
@@ -956,146 +951,23 @@ dnl ################################################################
 
 FP_FIND_LIBFFI
 AC_SUBST(UseSystemLibFFI)
+AC_SUBST(FFILibDir)
+AC_SUBST(FFIIncludeDir)
 
 dnl ** check whether we need -ldl to get dlopen()
-AC_CHECK_LIB([dl], [dlopen])
-AC_CHECK_LIB([dl], [dlopen], HaveLibdl=YES, HaveLibdl=NO)
-AC_SUBST([UseLibdl],[$HaveLibdl])
-dnl ** check whether we have dlinfo
-AC_CHECK_FUNCS([dlinfo])
-
-dnl --------------------------------------------------
-dnl * Miscellaneous feature tests
-dnl --------------------------------------------------
-
-dnl ** can we get alloca?
-AC_FUNC_ALLOCA
-
-dnl ** working vfork?
-AC_FUNC_FORK
-
-dnl ** determine whether or not const works
-AC_C_CONST
-
-dnl ** are we big endian?
-AC_C_BIGENDIAN
-FPTOOLS_FLOAT_WORD_ORDER_BIGENDIAN
+AC_CHECK_LIB([dl], [dlopen], UseLibdl=YES, UseLibdl=NO)
+AC_SUBST([UseLibdl])
 
 dnl ** check for leading underscores in symbol names
 FP_LEADING_UNDERSCORE
 AC_SUBST([LeadingUnderscore], [`echo $fptools_cv_leading_underscore | sed 'y/yesno/YESNO/'`])
-if test x"$fptools_cv_leading_underscore" = xyes; then
-   AC_SUBST([CabalLeadingUnderscore],[True])
-   AC_DEFINE([LEADING_UNDERSCORE], [1], [Define to 1 if C symbols have a leading underscore added by the compiler.])
-else
-   AC_SUBST([CabalLeadingUnderscore],[False])
-fi
-
-FP_VISIBILITY_HIDDEN
-
-FP_MUSTTAIL
 
 dnl ** check for librt
-AC_CHECK_LIB([rt], [clock_gettime])
-AC_CHECK_LIB([rt], [clock_gettime], HaveLibrt=YES, HaveLibrt=NO)
-if test $HaveLibrt = YES
-then
-  AC_SUBST([UseLibrt],[YES])
-else
-  AC_SUBST([UseLibrt],[NO])
-fi
-AC_CHECK_FUNCS(clock_gettime timer_settime)
-FP_CHECK_TIMER_CREATE
-
-dnl ** check for Apple's "interesting" long double compatibility scheme
-AC_MSG_CHECKING(for printf\$LDBLStub)
-AC_LINK_IFELSE([AC_LANG_CALL([], [printf\$LDBLStub])],
-    [
-        AC_MSG_RESULT(yes)
-        AC_DEFINE([HAVE_PRINTF_LDBLSTUB],[1],
-            [Define to 1 if we have printf$LDBLStub (Apple Mac OS >= 10.4, PPC).])
-    ],
-    [
-        AC_MSG_RESULT(no)
-        AC_DEFINE([HAVE_PRINTF_LDBLSTUB],[0],
-            [Define to 1 if we have printf$LDBLStub (Apple Mac OS >= 10.4, PPC).])
-    ])
-
-FP_CHECK_PTHREADS
-
-dnl ** check for eventfd which is needed by the I/O manager
-AC_CHECK_HEADERS([sys/eventfd.h])
-AC_CHECK_FUNCS([eventfd])
-
-AC_CHECK_FUNCS([getpid getuid raise])
-
-dnl ** Check for __thread support in the compiler
-AC_MSG_CHECKING(for __thread support)
-AC_COMPILE_IFELSE(
-  [ AC_LANG_SOURCE([[__thread int tester = 0;]]) ],
-  [
-   AC_MSG_RESULT(yes)
-   AC_DEFINE([CC_SUPPORTS_TLS],[1],[Define to 1 if __thread is supported])
-  ],
-  [
-   AC_MSG_RESULT(no)
-   AC_DEFINE([CC_SUPPORTS_TLS],[0],[Define to 1 if __thread is supported])
-  ])
-
-dnl large address space support (see rts/include/rts/storage/MBlock.h)
-dnl
-dnl Darwin has vm_allocate/vm_protect
-dnl Linux has mmap(MAP_NORESERVE)/madv(MADV_DONTNEED)
-dnl FreeBSD, Solaris and maybe other have MAP_NORESERVE/MADV_FREE
-dnl (They also have MADV_DONTNEED, but it means something else!)
-dnl
-dnl Windows has VirtualAlloc MEM_RESERVE/MEM_COMMIT, however
-dnl it counts page-table space as committed memory, and so quickly
-dnl runs out of paging file when we have multiple processes reserving
-dnl 1TB of address space, we get the following error:
-dnl    VirtualAlloc MEM_RESERVE 1099512676352 bytes failed: The paging file is too small for this operation to complete.
-dnl
+AC_CHECK_LIB([rt], [clock_gettime], UseLibrt=YES, UseLibrt=NO)
+AC_SUBST([UseLibrt])
 
-AC_ARG_ENABLE(large-address-space,
-    [AS_HELP_STRING([--enable-large-address-space],
-        [Use a single large address space on 64 bit systems (enabled by default on 64 bit platforms)])],
-    EnableLargeAddressSpace=$enableval,
-    EnableLargeAddressSpace=yes
-)
-
-use_large_address_space=no
-if test "$ac_cv_sizeof_void_p" -eq 8 ; then
-    if test "x$EnableLargeAddressSpace" = "xyes" ; then
-        if test "$ghc_host_os" = "darwin" ; then
-            use_large_address_space=yes
-        elif test "$ghc_host_os" = "openbsd" ; then
-            # as of OpenBSD 5.8 (2015), OpenBSD does not support mmap with MAP_NORESERVE.
-            # The flag MAP_NORESERVE is supported for source compatibility reasons,
-            # but is completely ignored by OS mmap
-                  use_large_address_space=no
-        elif test "$ghc_host_os" = "mingw32" ; then
-            # as of Windows 8.1/Server 2012 windows does no longer allocate the page
-            # tabe for reserved memory eagerly. So we are now free to use LAS there too.
-                  use_large_address_space=yes
-        else
-            AC_CHECK_DECLS([MAP_NORESERVE, MADV_FREE, MADV_DONTNEED],[],[],
-                [
-                #include <unistd.h>
-                #include <sys/types.h>
-                #include <sys/mman.h>
-                #include <fcntl.h>
-            ])
-            if test "$ac_cv_have_decl_MAP_NORESERVE" = "yes" &&
-                test "$ac_cv_have_decl_MADV_FREE" = "yes" ||
-                test "$ac_cv_have_decl_MADV_DONTNEED" = "yes" ; then
-                    use_large_address_space=yes
-            fi
-        fi
-    fi
-fi
-if test "$use_large_address_space" = "yes" ; then
-   AC_DEFINE([USE_LARGE_ADDRESS_SPACE], [1], [Enable single heap address space support])
-fi
+FP_CHECK_PTHREAD_LIB
+AC_SUBST([UseLibpthread])
 
 GHC_ADJUSTORS_METHOD([Target])
 AC_SUBST([UseLibffiForAdjustors])


=====================================
m4/fp_bfd_support.m4
=====================================
@@ -1,49 +1,59 @@
 # FP_BFD_SUPPORT()
 # ----------------------
-# whether to use libbfd for debugging RTS
-AC_DEFUN([FP_BFD_SUPPORT], [
-    HaveLibbfd=NO
-    AC_ARG_ENABLE(bfd-debug,
-        [AS_HELP_STRING([--enable-bfd-debug],
-              [Enable symbol resolution for -debug rts ('+RTS -Di') via binutils' libbfd [default=no]])],
-        [
-            # don't pollute general LIBS environment
-            save_LIBS="$LIBS"
-            AC_CHECK_HEADERS([bfd.h])
-            dnl ** check whether this machine has BFD and libiberty installed (used for debugging)
-            dnl    the order of these tests matters: bfd needs libiberty
-            AC_CHECK_LIB(iberty, xmalloc)
-            dnl 'bfd_init' is a rare non-macro in libbfd
-            AC_CHECK_LIB(bfd,    bfd_init)
+# Whether to use libbfd for debugging RTS
+#
+# Sets:
+#   UseLibbfd: [YES|NO]
+AC_DEFUN([FP_BFD_FLAG], [
+  UseLibbfd=NO
+  AC_ARG_ENABLE(bfd-debug,
+    [AS_HELP_STRING([--enable-bfd-debug],
+          [Enable symbol resolution for -debug rts ('+RTS -Di') via binutils' libbfd [default=no]])],
+    [UseLibbfd=YES],
+    [UseLibbfd=NO])
+])
+
+# FP_WHEN_ENABLED_BFD
+# ----------------------
+# Checks for libraries in the default way, which will define various
+# `HAVE_*` macros.
+AC_DEFUN([FP_WHEN_ENABLED_BFD], [
+  # don't pollute general LIBS environment
+  save_LIBS="$LIBS"
+  AC_CHECK_HEADERS([bfd.h])
+  dnl ** check whether this machine has BFD and libiberty installed (used for debugging)
+  dnl    the order of these tests matters: bfd needs libiberty
+  AC_CHECK_LIB(iberty, xmalloc)
+  dnl 'bfd_init' is a rare non-macro in libbfd
+  AC_CHECK_LIB(bfd,    bfd_init)
 
-            AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <bfd.h>]],
-                        [[
-                                /* mimic our rts/Printer.c */
-                                bfd* abfd;
-                                const char * name;
-                                char **matching;
+  AC_LINK_IFELSE(
+    [AC_LANG_PROGRAM(
+      [[#include <bfd.h>]],
+      [[
+        /* mimic our rts/Printer.c */
+        bfd* abfd;
+        const char * name;
+        char **matching;
 
-                                name = "some.executable";
-                                bfd_init();
-                                abfd = bfd_openr(name, "default");
-                                bfd_check_format_matches (abfd, bfd_object, &matching);
-                                {
-                                    long storage_needed;
-                                    storage_needed = bfd_get_symtab_upper_bound (abfd);
-                                }
-                                {
-                                    asymbol **symbol_table;
-                                    long number_of_symbols;
-                                    symbol_info info;
+        name = "some.executable";
+        bfd_init();
+        abfd = bfd_openr(name, "default");
+        bfd_check_format_matches (abfd, bfd_object, &matching);
+        {
+            long storage_needed;
+            storage_needed = bfd_get_symtab_upper_bound (abfd);
+        }
+        {
+            asymbol **symbol_table;
+            long number_of_symbols;
+            symbol_info info;
 
-                                    number_of_symbols = bfd_canonicalize_symtab (abfd, symbol_table);
-                                    bfd_get_symbol_info(abfd,symbol_table[0],&info);
-                                }
-                        ]])],
-                        HaveLibbfd=YES,dnl bfd seems to work
-                        [AC_MSG_ERROR([can't use 'bfd' library])])
-            LIBS="$save_LIBS"
-        ]
-    )
-    AC_SUBST([UseLibbfd],[$HaveLibbfd])
+            number_of_symbols = bfd_canonicalize_symtab (abfd, symbol_table);
+            bfd_get_symbol_info(abfd,symbol_table[0],&info);
+        }
+      ]])],
+    [], dnl bfd seems to work
+    [AC_MSG_ERROR([can't use 'bfd' library])])
+  LIBS="$save_LIBS"
 ])


=====================================
m4/fp_check_pthreads.m4
=====================================
@@ -1,7 +1,10 @@
-dnl FP_CHECK_PTHREADS
-dnl ----------------------------------
-dnl Check various aspects of the platform's pthreads support
-AC_DEFUN([FP_CHECK_PTHREADS],
+# FP_CHECK_PTHREAD_LIB
+# ----------------------------------
+# Check whether -lpthread is needed for pthread.
+#
+# Sets variables:
+#   - UseLibpthread: [YES|NO]
+AC_DEFUN([FP_CHECK_PTHREAD_LIB],
 [
   dnl Some platforms (e.g. Android's Bionic) have pthreads support available
   dnl without linking against libpthread. Check whether -lpthread is necessary
@@ -12,25 +15,28 @@ AC_DEFUN([FP_CHECK_PTHREADS],
   AC_CHECK_FUNC(pthread_create,
       [
           AC_MSG_RESULT(no)
-          AC_SUBST([UseLibpthread],[NO])
-          need_lpthread=0
+          UseLibpthread=NO
       ],
       [
           AC_CHECK_LIB(pthread, pthread_create,
               [
                   AC_MSG_RESULT(yes)
-                  AC_SUBST([UseLibpthread],[YES])
-                  need_lpthread=1
+                  UseLibpthread=YES
               ],
               [
-                  AC_SUBST([UseLibpthread],[NO])
                   AC_MSG_RESULT([no pthreads support found.])
-                  need_lpthread=0
+                  UseLibpthread=NO
               ])
       ])
-  AC_DEFINE_UNQUOTED([NEED_PTHREAD_LIB], [$need_lpthread],
-      [Define 1 if we need to link code using pthreads with -lpthread])
+])
 
+# FP_CHECK_PTHREAD_FUNCS
+# ----------------------------------
+# Check various aspects of the platform's pthreads support
+#
+# `AC_DEFINE`s various C `HAVE_*` macros.
+AC_DEFUN([FP_CHECK_PTHREAD_FUNCS],
+[
   dnl Setting thread names
   dnl ~~~~~~~~~~~~~~~~~~~~
   dnl The portability situation here is complicated:


=====================================
m4/fp_find_libffi.m4
=====================================
@@ -1,6 +1,11 @@
-dnl ** Have libffi?
-dnl --------------------------------------------------------------
-dnl Sets UseSystemLibFFI.
+# FP_FIND_LIBFFI
+# --------------------------------------------------------------
+# Should we used libffi? (yes or no)
+#
+# Sets variables:
+#   - UseSystemLibFFI: [YES|NO]
+#   - FFILibDir: optional path
+#   - FFIIncludeDir: optional path
 AC_DEFUN([FP_FIND_LIBFFI],
 [
   # system libffi
@@ -28,8 +33,6 @@ AC_DEFUN([FP_FIND_LIBFFI],
    fi
   ])
 
-  AC_SUBST(FFIIncludeDir)
-
   AC_ARG_WITH([ffi-libraries],
   [AS_HELP_STRING([--with-ffi-libraries=ARG],
     [Find libffi in ARG [default=system default]])
@@ -42,8 +45,6 @@ AC_DEFUN([FP_FIND_LIBFFI],
    fi
   ])
 
-  AC_SUBST(FFILibDir)
-
   AS_IF([test "$UseSystemLibFFI" = "YES"], [
    CFLAGS2="$CFLAGS"
    CFLAGS="$LIBFFI_CFLAGS $CFLAGS"
@@ -63,7 +64,7 @@ AC_DEFUN([FP_FIND_LIBFFI],
    AC_CHECK_LIB(ffi, ffi_call,
     [AC_CHECK_HEADERS(
       [ffi.h],
-      [AC_DEFINE([HAVE_SYSTEM_LIBFFI], [1], [Define to 1 if you have libffi.])],
+      [],
       [AC_MSG_ERROR([Cannot find ffi.h for system libffi])]
      )],
     [AC_MSG_ERROR([Cannot find system libffi])]


=====================================
rts/configure.ac
=====================================
@@ -33,6 +33,147 @@ GHC_CONVERT_PLATFORM_PARTS([host], [Host])
 FPTOOLS_SET_PLATFORM_VARS([host], [Host])
 FPTOOLS_SET_HASKELL_PLATFORM_VARS([Host])
 
+dnl ** check for math library
+dnl    Keep that check as early as possible.
+dnl    as we need to know whether we need libm
+dnl    for math functions or not
+dnl    (see https://gitlab.haskell.org/ghc/ghc/issues/3730)
+AS_IF(
+  [test "$CABAL_FLAG_libm" = 1],
+  [AC_DEFINE([HAVE_LIBM], [1], [Define to 1 if you need to link with libm])])
+
+AS_IF([test "$CABAL_FLAG_libbfd" = 1], [FP_WHEN_ENABLED_BFD])
+
+dnl ################################################################
+dnl Check for libraries
+dnl ################################################################
+
+dnl ** check whether we need -ldl to get dlopen()
+AC_CHECK_LIB([dl], [dlopen])
+dnl ** check whether we have dlinfo
+AC_CHECK_FUNCS([dlinfo])
+
+dnl --------------------------------------------------
+dnl * Miscellaneous feature tests
+dnl --------------------------------------------------
+
+dnl ** can we get alloca?
+AC_FUNC_ALLOCA
+
+dnl ** working vfork?
+AC_FUNC_FORK
+
+dnl ** determine whether or not const works
+AC_C_CONST
+
+dnl ** are we big endian?
+AC_C_BIGENDIAN
+FPTOOLS_FLOAT_WORD_ORDER_BIGENDIAN
+
+dnl ** check for leading underscores in symbol names
+if test "$CABAL_FLAG_leading_underscore" = 1; then
+   AC_DEFINE([LEADING_UNDERSCORE], [1], [Define to 1 if C symbols have a leading underscore added by the compiler.])
+fi
+
+FP_VISIBILITY_HIDDEN
+
+FP_MUSTTAIL
+
+dnl ** check for librt
+AC_CHECK_FUNCS(clock_gettime timer_settime)
+FP_CHECK_TIMER_CREATE
+
+dnl ** check for Apple's "interesting" long double compatibility scheme
+AC_MSG_CHECKING(for printf\$LDBLStub)
+AC_LINK_IFELSE([AC_LANG_CALL([], [printf\$LDBLStub])],
+    [
+        AC_MSG_RESULT(yes)
+        AC_DEFINE([HAVE_PRINTF_LDBLSTUB],[1],
+            [Define to 1 if we have printf$LDBLStub (Apple Mac OS >= 10.4, PPC).])
+    ],
+    [
+        AC_MSG_RESULT(no)
+        AC_DEFINE([HAVE_PRINTF_LDBLSTUB],[0],
+            [Define to 1 if we have printf$LDBLStub (Apple Mac OS >= 10.4, PPC).])
+    ])
+
+FP_CHECK_PTHREAD_FUNCS
+
+dnl ** check for eventfd which is needed by the I/O manager
+AC_CHECK_HEADERS([sys/eventfd.h])
+AC_CHECK_FUNCS([eventfd])
+
+AC_CHECK_FUNCS([getpid getuid raise])
+
+dnl ** Check for __thread support in the compiler
+AC_MSG_CHECKING(for __thread support)
+AC_COMPILE_IFELSE(
+  [ AC_LANG_SOURCE([[__thread int tester = 0;]]) ],
+  [
+   AC_MSG_RESULT(yes)
+   AC_DEFINE([CC_SUPPORTS_TLS],[1],[Define to 1 if __thread is supported])
+  ],
+  [
+   AC_MSG_RESULT(no)
+   AC_DEFINE([CC_SUPPORTS_TLS],[0],[Define to 1 if __thread is supported])
+  ])
+
+dnl large address space support (see rts/include/rts/storage/MBlock.h)
+dnl
+dnl Darwin has vm_allocate/vm_protect
+dnl Linux has mmap(MAP_NORESERVE)/madv(MADV_DONTNEED)
+dnl FreeBSD, Solaris and maybe other have MAP_NORESERVE/MADV_FREE
+dnl (They also have MADV_DONTNEED, but it means something else!)
+dnl
+dnl Windows has VirtualAlloc MEM_RESERVE/MEM_COMMIT, however
+dnl it counts page-table space as committed memory, and so quickly
+dnl runs out of paging file when we have multiple processes reserving
+dnl 1TB of address space, we get the following error:
+dnl    VirtualAlloc MEM_RESERVE 1099512676352 bytes failed: The paging file is too small for this operation to complete.
+dnl
+
+AC_ARG_ENABLE(large-address-space,
+    [AS_HELP_STRING([--enable-large-address-space],
+        [Use a single large address space on 64 bit systems (enabled by default on 64 bit platforms)])],
+    EnableLargeAddressSpace=$enableval,
+    EnableLargeAddressSpace=yes
+)
+
+use_large_address_space=no
+AC_CHECK_SIZEOF([void *])
+if test "$ac_cv_sizeof_void_p" -eq 8 ; then
+    if test "x$EnableLargeAddressSpace" = "xyes" ; then
+        if test "$ghc_host_os" = "darwin" ; then
+            use_large_address_space=yes
+        elif test "$ghc_host_os" = "openbsd" ; then
+            # as of OpenBSD 5.8 (2015), OpenBSD does not support mmap with MAP_NORESERVE.
+            # The flag MAP_NORESERVE is supported for source compatibility reasons,
+            # but is completely ignored by OS mmap
+                  use_large_address_space=no
+        elif test "$ghc_host_os" = "mingw32" ; then
+            # as of Windows 8.1/Server 2012 windows does no longer allocate the page
+            # tabe for reserved memory eagerly. So we are now free to use LAS there too.
+                  use_large_address_space=yes
+        else
+            AC_CHECK_DECLS([MAP_NORESERVE, MADV_FREE, MADV_DONTNEED],[],[],
+                [
+                #include <unistd.h>
+                #include <sys/types.h>
+                #include <sys/mman.h>
+                #include <fcntl.h>
+            ])
+            if test "$ac_cv_have_decl_MAP_NORESERVE" = "yes" &&
+                test "$ac_cv_have_decl_MADV_FREE" = "yes" ||
+                test "$ac_cv_have_decl_MADV_DONTNEED" = "yes" ; then
+                    use_large_address_space=yes
+            fi
+        fi
+    fi
+fi
+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 --------------------------------------------------------------
 



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/4a201e20d691aa52773998c5c48a85178e3b403f...df1c19214fb7fd6e451353029b649b42d12de001

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/4a201e20d691aa52773998c5c48a85178e3b403f...df1c19214fb7fd6e451353029b649b42d12de001
You're receiving this email because of your account on gitlab.haskell.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20230926/35e1287f/attachment-0001.html>


More information about the ghc-commits mailing list