File 2441-Add-support-for-remapping-the-.text-segment-using-TH.patch of Package erlang

From 07cbdf45322019e4602466df504ceca315ba80fb Mon Sep 17 00:00:00 2001
From: lexprfuncall <5360361+lexprfuncall@users.noreply.github.com>
Date: Wed, 20 Dec 2023 14:34:11 -0800
Subject: [PATCH 1/2] Add support for remapping the .text segment using THP on
 Linux

Linux allows an application to remap its .text segment at runtime
using transparent huge pages.  To do this, an application needs to
determine the start and length of the .text segment and pass this
range as an argument to the madvise(2) system call.  There are many
techniques for doing this, the approach chosen in this change is to
parse the /proc filesystem.  An alternative would be to get this
information from the ELF header.

For this to work reliably, the start address of the text segment
should be aligned to a multiple of the size of a transparent huge
page, and the length text segment should be greater than the size of a
transparent huge page and ideally a multiple of that size.

Finally, page sizes and support for multiple page sizes varies by
architecture.  This change only supports the 64-bit x86 but, in
theory, it can be generalized to other architectures that support THP.
---
 erts/config.h.in                           |   3 +
 erts/configure                             | 127 ++++++++++++++++++++-
 erts/configure.ac                          |  59 ++++++++++
 erts/emulator/beam/erl_alloc_util.c        |  15 +--
 erts/emulator/beam/sys.h                   |   5 +
 erts/emulator/sys/common/erl_mmap.c        |  22 +---
 erts/emulator/sys/common/erl_mseg.c        |  25 +---
 erts/emulator/sys/unix/sys.c               | 103 ++++++++++++++++-
 erts/emulator/sys/win32/sys.c              |  16 ++-
 erts/lib_src/yielding_c_fun/main_target.mk |   4 +-
 lib/wx/configure                           |   8 +-
 make/configure                             |   8 +-
 12 files changed, 330 insertions(+), 65 deletions(-)

diff --git a/erts/config.h.in b/erts/config.h.in
index 61b79a865e..b6f5bbe7f6 100644
--- a/erts/config.h.in
+++ b/erts/config.h.in
@@ -800,6 +800,9 @@
 /* Define if the targeted system supports the `perf` profiler */
 #undef HAVE_LINUX_PERF_SUPPORT
 
+/* Define if the target system is Linux and THP is available */
+#undef HAVE_LINUX_THP
+
 /* Define to 1 if you have the <linux/types.h> header file. */
 #undef HAVE_LINUX_TYPES_H
 
diff --git a/erts/configure b/erts/configure
index 97762ec112..01568bce8d 100755
--- a/erts/configure
+++ b/erts/configure
@@ -6402,11 +6402,11 @@ if test x$ac_prog_cxx_stdcxx = xno
 then :
   { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $CXX option to enable C++11 features" >&5
 printf %s "checking for $CXX option to enable C++11 features... " >&6; }
-if test ${ac_cv_prog_cxx_11+y}
+if test ${ac_cv_prog_cxx_cxx11+y}
 then :
   printf %s "(cached) " >&6
 else $as_nop
-  ac_cv_prog_cxx_11=no
+  ac_cv_prog_cxx_cxx11=no
 ac_save_CXX=$CXX
 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
@@ -6448,11 +6448,11 @@ if test x$ac_prog_cxx_stdcxx = xno
 then :
   { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $CXX option to enable C++98 features" >&5
 printf %s "checking for $CXX option to enable C++98 features... " >&6; }
-if test ${ac_cv_prog_cxx_98+y}
+if test ${ac_cv_prog_cxx_cxx98+y}
 then :
   printf %s "(cached) " >&6
 else $as_nop
-  ac_cv_prog_cxx_98=no
+  ac_cv_prog_cxx_cxx98=no
 ac_save_CXX=$CXX
 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
@@ -24733,7 +24733,126 @@ printf "%s\n" "no" >&6; }
 	;;
 esac
 
+case $OPSYS in #(
+  linux*) :
+
+    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether the Transparent Huge Pages interface is available" >&5
+printf %s "checking whether the Transparent Huge Pages interface is available... " >&6; }
+if test ${erts_cv_linux_thp+y}
+then :
+  printf %s "(cached) " >&6
+else $as_nop
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+
+              #include <sys/mman.h>
+
+int
+main (void)
+{
+
+              madvise((void *)0, 0, MADV_HUGEPAGE);
+
+  ;
+  return 0;
+}
+
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"
+then :
+
+          erts_cv_linux_thp=yes
+
+printf "%s\n" "#define HAVE_LINUX_THP 1" >>confdefs.h
+
+
+else $as_nop
+
+          erts_cv_linux_thp=no
+
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
+fi
+{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $erts_cv_linux_thp" >&5
+printf "%s\n" "$erts_cv_linux_thp" >&6; }
+   ;; #(
+  *) :
+     ;;
+esac
+
+if test "x$erts_cv_linux_thp" = "xyes"
+then :
+
+    saved_LDFLAGS="$LDFLAGS"
+    LDFLAGS="$LDFLAGS -Werror -Wunused-command-line-argument"
+    { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if we can add -Werror -Wunused-command-argument to LDFLAGS" >&5
+printf %s "checking if we can add -Werror -Wunused-command-argument to LDFLAGS... " >&6; }
+    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main (void)
+{
+return 0;
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"
+then :
 
+        { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+printf "%s\n" "yes" >&6; }
+        unused_command_line_argument="-Wunused-command-line-argument"
+
+else $as_nop
+
+        { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
+printf "%s\n" "no" >&6; }
+        unused_command_line_argument=""
+
+
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.beam \
+    conftest$ac_exeext conftest.$ac_ext
+    LDFLAGS=$saved_LDFLAGS
+    for flag in "-Wl,-z,common-page-size=2097152" "-Wl,-z,max-page-size=2097152"
+    do
+      { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking if we can add $flag to LDFLAGS" >&5
+printf %s "checking if we can add $flag to LDFLAGS... " >&6; }
+      saved_LDFLAGS="$LDFLAGS"
+      LDFLAGS="$LDFLAGS $unused_command_line_argument $flag"
+      cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main (void)
+{
+return 0;
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"
+then :
+
+           { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+printf "%s\n" "yes" >&6; }
+           LDFLAGS="$save_LDFLAGS $flag"
+
+else $as_nop
+
+           { printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: no" >&5
+printf "%s\n" "no" >&6; }
+           LDFLAGS="$saved_LDFLAGS"
+
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.beam \
+    conftest$ac_exeext conftest.$ac_ext
+    done
+
+fi
 
 
 JIT_ENABLED=
diff --git a/erts/configure.ac b/erts/configure.ac
index 070880b2f4..8cc0748b95 100644
--- a/erts/configure.ac
+++ b/erts/configure.ac
@@ -3034,7 +3034,66 @@ case $host_os in
 	;;
 esac
 
+dnl Checks for the Transparent Huge pages (THP) availability on Linux
+AS_CASE([$OPSYS],
+  [linux*],
+  [      
+    AC_CACHE_CHECK(
+      [whether the Transparent Huge Pages interface is available],
+      erts_cv_linux_thp,
+      AC_COMPILE_IFELSE(
+        [
+          AC_LANG_PROGRAM(
+            [[
+              #include <sys/mman.h>
+            ]],
+            [[
+              madvise((void *)0, 0, MADV_HUGEPAGE);
+            ]])
+        ],
+        [
+          erts_cv_linux_thp=yes
+  	  AC_DEFINE(HAVE_LINUX_THP,
+            [1],
+            [Define if the target system is Linux and THP is available])
+        ],
+  	[
+          erts_cv_linux_thp=no
+  	]))
+  ])
 
+AS_IF([test "x$erts_cv_linux_thp" = "xyes"],
+  [
+    saved_LDFLAGS="$LDFLAGS"
+    LDFLAGS="$LDFLAGS -Werror -Wunused-command-line-argument"
+    AC_MSG_CHECKING([if we can add -Werror -Wunused-command-argument to LDFLAGS])
+    AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],[[return 0;]])],
+      [
+        AC_MSG_RESULT([yes])
+        unused_command_line_argument="-Wunused-command-line-argument"
+      ],
+      [
+        AC_MSG_RESULT([no])
+        unused_command_line_argument=""
+      ]
+    )
+    LDFLAGS=$saved_LDFLAGS
+    for flag in "-Wl,-z,common-page-size=2097152" "-Wl,-z,max-page-size=2097152"
+    do
+      AC_MSG_CHECKING([if we can add $flag to LDFLAGS])
+      saved_LDFLAGS="$LDFLAGS"
+      LDFLAGS="$LDFLAGS $unused_command_line_argument $flag"
+      AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],[[return 0;]])],
+         [
+           AC_MSG_RESULT([yes])
+           LDFLAGS="$save_LDFLAGS $flag"
+         ],
+         [
+           AC_MSG_RESULT([no])
+           LDFLAGS="$saved_LDFLAGS"
+         ])
+    done
+  ])
 
 dnl ----------------------------------------------------------------------
 dnl Tests related to configurable options given on command line
diff --git a/erts/emulator/beam/erl_alloc_util.c b/erts/emulator/beam/erl_alloc_util.c
index b041b7b8eb..e8b4793abe 100644
--- a/erts/emulator/beam/erl_alloc_util.c
+++ b/erts/emulator/beam/erl_alloc_util.c
@@ -40,6 +40,7 @@
 #  include "config.h"
 #endif
 
+#include "sys.h"
 #include "global.h"
 #include "big.h"
 #include "erl_mmap.h"
@@ -91,8 +92,7 @@ static int initialized = 0;
 #define SYS_ALLOC_CARRIER_FLOOR(X)	((X) & SYS_ALLOC_CARRIER_MASK)
 #define SYS_ALLOC_CARRIER_CEILING(X) \
   SYS_ALLOC_CARRIER_FLOOR((X) + INV_SYS_ALLOC_CARRIER_MASK)
-#define SYS_PAGE_SIZE                   (sys_page_size)
-#define SYS_PAGE_SZ_MASK                ((UWord)(SYS_PAGE_SIZE - 1))
+#define SYS_PAGE_SZ_MASK                ((UWord)(sys_page_size - 1))
 
 #if 0
 /* Can be useful for debugging */
@@ -101,7 +101,6 @@ static int initialized = 0;
 
 /* alloc_util global parameters */
 static Uint sys_alloc_carrier_size;
-static Uint sys_page_size;
 
 #if HAVE_ERTS_MSEG
 static Uint max_mseg_carriers;
@@ -2580,7 +2579,7 @@ mem_discard_coalesce(Allctr_t *allocator, Block_t *neighbor,
     if (region->ptr >= neighbor_start) {
         char *region_start_page;
 
-        region_start_page = region->ptr - SYS_PAGE_SIZE;
+        region_start_page = region->ptr - sys_page_size;
         region_start_page = (char*)((UWord)region_start_page & ~SYS_PAGE_SZ_MASK);
 
         /* Expand if our first page begins within the previous free block's
@@ -2595,7 +2594,7 @@ mem_discard_coalesce(Allctr_t *allocator, Block_t *neighbor,
 
         ASSERT(region->ptr <= neighbor_start);
 
-        region_end_page = region->ptr + region->size + SYS_PAGE_SIZE;
+        region_end_page = region->ptr + region->size + sys_page_size;
         region_end_page = (char*)((UWord)region_end_page & ~SYS_PAGE_SZ_MASK);
 
         neighbor_size = BLK_SZ(neighbor) - FBLK_FTR_SZ;
@@ -2637,11 +2636,11 @@ mem_discard_finish(Allctr_t *allocator, Block_t *block,
     (void)block;
 #endif
 
-    if (region->size > SYS_PAGE_SIZE) {
+    if (region->size > sys_page_size) {
         UWord align_offset, size;
         char *ptr;
 
-        align_offset = SYS_PAGE_SIZE - ((UWord)region->ptr & SYS_PAGE_SZ_MASK);
+        align_offset = sys_page_size - ((UWord)region->ptr & SYS_PAGE_SZ_MASK);
 
         size = (region->size - align_offset) & ~SYS_PAGE_SZ_MASK;
         ptr = region->ptr + align_offset;
@@ -7002,8 +7001,6 @@ erts_alcu_init(AlcUInit_t *init)
 #endif
     allow_sys_alloc_carriers = init->sac;
 
-    sys_page_size = erts_sys_get_page_size();
-
 #ifdef DEBUG
     carrier_alignment = sizeof(Unit_t);
 #endif
diff --git a/erts/emulator/beam/sys.h b/erts/emulator/beam/sys.h
index 8f4bc5e0a1..e484c38d87 100644
--- a/erts/emulator/beam/sys.h
+++ b/erts/emulator/beam/sys.h
@@ -649,6 +649,8 @@ __decl_noreturn void __noreturn erts_exit(int n, const char*, ...);
 
 UWord erts_sys_get_page_size(void);
 
+UWord erts_sys_get_large_page_size(void);
+
 /* Size of misc memory allocated from system dependent code */
 Uint erts_sys_misc_mem_sz(void);
 
@@ -905,6 +907,9 @@ typedef struct {
 
 void sys_alloc_stat(SysAllocStat *);
 
+extern UWord sys_page_size;
+extern UWord sys_large_page_size;
+
 #if defined(DEBUG) || defined(ERTS_ENABLE_LOCK_CHECK)
 #undef ERTS_REFC_DEBUG
 #define ERTS_REFC_DEBUG
diff --git a/erts/emulator/sys/common/erl_mmap.c b/erts/emulator/sys/common/erl_mmap.c
index e3300e3c43..b45146a783 100644
--- a/erts/emulator/sys/common/erl_mmap.c
+++ b/erts/emulator/sys/common/erl_mmap.c
@@ -2155,33 +2155,19 @@ erts_mmap_init(ErtsMemMapper* mm, ErtsMMapInit *init)
 {
     static int is_first_call = 1;
     char *start = NULL, *end = NULL;
-    UWord pagesize;
     int virtual_map = 0;
 
     (void)virtual_map;
 
-#if defined(__WIN32__)
-    {
-        SYSTEM_INFO sysinfo;
-        GetSystemInfo(&sysinfo);
-        pagesize = (UWord) sysinfo.dwPageSize;
-    }
-#elif defined(_SC_PAGESIZE)
-    pagesize = (UWord) sysconf(_SC_PAGESIZE);
-#elif defined(HAVE_GETPAGESIZE)
-    pagesize = (UWord) getpagesize();
-#else
-#  error "Do not know how to get page size"
-#endif
 #if defined(HARD_DEBUG)  || 0
     erts_fprintf(stderr, "erts_mmap: scs = %bpu\n", init->scs);
     erts_fprintf(stderr, "erts_mmap: sco = %i\n", init->sco);
     erts_fprintf(stderr, "erts_mmap: scrfsd = %i\n", init->scrfsd);
 #endif
-    erts_page_inv_mask = pagesize - 1;
-    if (pagesize & erts_page_inv_mask)
-	erts_exit(1, "erts_mmap: Invalid pagesize: %bpu\n",
-		 pagesize);
+    erts_page_inv_mask = sys_page_size - 1;
+    if (sys_page_size & erts_page_inv_mask)
+	erts_exit(1, "erts_mmap: Invalid sys_page_size: %bpu\n",
+		 sys_page_size);
 
     ERTS_MMAP_OP_RINGBUF_INIT();
 
diff --git a/erts/emulator/sys/common/erl_mseg.c b/erts/emulator/sys/common/erl_mseg.c
index 98f45e0f99..44d8cf3627 100644
--- a/erts/emulator/sys/common/erl_mseg.c
+++ b/erts/emulator/sys/common/erl_mseg.c
@@ -44,19 +44,6 @@
 
 #if HAVE_ERTS_MSEG
 
-#ifndef HAVE_GETPAGESIZE
-#define HAVE_GETPAGESIZE 0
-#endif
-
-#ifdef _SC_PAGESIZE
-#  define GET_PAGE_SIZE sysconf(_SC_PAGESIZE)
-#elif HAVE_GETPAGESIZE
-#  define GET_PAGE_SIZE getpagesize()
-#else
-#  error "Page size unknown"
-     /* Implement some other way to get the real page size if needed! */
-#endif
-
 #undef MIN
 #define MIN(X, Y) ((X) < (Y) ? (X) : (Y))
 #undef MAX
@@ -544,8 +531,8 @@ static ERTS_INLINE void *cache_get_segment(ErtsMsegAllctr_t *ma, UWord *size_p,
 	    best->seg  = ((char *)seg) + size;
 	    best->size = csize - size;
 
-	    ASSERT((size % GET_PAGE_SIZE) == 0);
-	    ASSERT((best->size % GET_PAGE_SIZE) == 0);
+	    ASSERT((size % sys_page_size) == 0);
+	    ASSERT((best->size % sys_page_size) == 0);
 
 	    *size_p = size;
 
@@ -1395,11 +1382,11 @@ erts_mseg_init(ErtsMsegInit_t *init)
     erts_mmap_init(&erts_literal_mmapper, &init->literal_mmap);
 #endif
 
-    if (!IS_2POW(GET_PAGE_SIZE))
-	erts_exit(ERTS_ABORT_EXIT, "erts_mseg: Unexpected page_size %beu\n", GET_PAGE_SIZE);
+    if (!IS_2POW(sys_page_size))
+	erts_exit(ERTS_ABORT_EXIT, "erts_mseg: Unexpected sys_page_size %beu\n", sys_page_size);
 
-    ASSERT((MSEG_ALIGNED_SIZE % GET_PAGE_SIZE) == 0
-	   || (GET_PAGE_SIZE % MSEG_ALIGNED_SIZE) == 0);
+    ASSERT((MSEG_ALIGNED_SIZE % sys_page_size) == 0
+	   || (sys_page_size % MSEG_ALIGNED_SIZE) == 0);
 
     for (i = 0; i < no_mseg_allocators; i++) {
 	ErtsMsegAllctr_t *ma = ERTS_MSEG_ALLCTR_IX(i);
diff --git a/erts/emulator/sys/unix/sys.c b/erts/emulator/sys/unix/sys.c
index ada9e974b0..ba5ba255d4 100644
--- a/erts/emulator/sys/unix/sys.c
+++ b/erts/emulator/sys/unix/sys.c
@@ -132,8 +132,11 @@ static int replace_intr = 0;
 /* assume yes initially, ttsl_init will clear it */
 int using_oldshell = 1;
 
-UWord
-erts_sys_get_page_size(void)
+UWord sys_page_size;
+UWord sys_large_page_size;
+
+static UWord
+get_page_size(void)
 {
 #if defined(_SC_PAGESIZE)
     return (UWord) sysconf(_SC_PAGESIZE);
@@ -144,6 +147,25 @@ erts_sys_get_page_size(void)
 #endif
 }
 
+static UWord
+get_large_page_size(void)
+{
+#ifdef HAVE_LINUX_THP
+    FILE *fp;
+    UWord result;
+    int matched;
+
+    fp = fopen("/sys/kernel/mm/transparent_hugepage/hpage_pmd_size", "r");
+    if (fp == NULL)
+        return 0;
+    matched = fscanf(fp, "%lu", &result);
+    fclose(fp);
+    return matched == 1 ? result : 0;
+#else
+    return 0;
+#endif
+}
+
 Uint
 erts_sys_misc_mem_sz(void)
 {
@@ -230,6 +252,74 @@ thr_create_cleanup(void *vtcdp)
     erts_free(ERTS_ALC_T_TMP, tcdp);
 }
 
+#ifdef HAVE_LINUX_THP
+static int
+is_linux_thp_enabled(void)
+{
+    FILE *fp;
+    char always[9], madvise[10], never[8];
+    int matched;
+
+    fp = fopen("/sys/kernel/mm/transparent_hugepage/enabled", "r");
+    if (fp == NULL)
+        return 0;
+    matched = fscanf(fp, "%8s %9s %7s", always, madvise, never);
+    fclose(fp);
+    if (matched != 3 || strcmp("[never]", never) == 0)
+        return 0;
+    return strcmp("[always]", always) != 0 || strcmp("[madvise]", madvise) != 0;
+}
+
+#define ALIGN_DOWN(x, a) ((void*)(((UWord)(x)) & ~((a) - 1)))
+
+static void
+enable_linux_thp_for_text(void)
+{
+    FILE *fp;
+    char *from, *to;
+    extern char etext;  /* see end(3) for details */
+
+    /*
+     * If sysfs(5) is not accessible we will not be able to determine the THP
+     * page size.  While we could madvise(2) the whole .text segment and just
+     * hope for the best, other things will likely go wrong so we simply fail
+     * fast instead.
+     */
+    if (sys_large_page_size == 0)
+        return;
+
+    /*
+     * Our use of madvise(... MADV_HUGEPAGE) only makes sense when the THP
+     * behavior is set to the default of [madvise].  Check that we are in this
+     * mode and exit if we are not.
+     */
+    if (is_linux_thp_enabled() == 0)
+        return;
+
+    fp = fopen("/proc/self/maps", "r");
+    if (fp == NULL)
+        return;
+
+    /*
+     * Iterate through the current process mappings to find the text segment.
+     * When they are found, madvise their memory region to use huge pages.
+     */
+    while (fscanf(fp, "%p-%p %*[^\n]\n", &from, &to) == 2) {
+        if (to < &etext)
+            continue;
+        if (from > &etext)
+            break;
+        if ((UWord)from % sys_large_page_size != 0)
+            break;
+        to = ALIGN_DOWN(to, sys_large_page_size);
+        if (to - from < sys_large_page_size)
+            break;
+        madvise(from, to - from, MADV_HUGEPAGE);
+    }
+    fclose(fp);
+}
+#endif
+
 static void
 thr_create_prepare_child(void *vtcdp)
 {
@@ -254,7 +344,14 @@ erts_sys_pre_init(void)
     /* Before creation in parent */
     eid.thread_create_prepare_func = thr_create_prepare;
     /* After creation in parent */
-    eid.thread_create_parent_func = thr_create_cleanup,
+    eid.thread_create_parent_func = thr_create_cleanup;
+
+    sys_page_size = get_page_size();
+    sys_large_page_size = get_large_page_size();
+
+#ifdef HAVE_LINUX_THP
+    enable_linux_thp_for_text();
+#endif
 
 #ifdef ERTS_ENABLE_LOCK_COUNT
     erts_lcnt_pre_thr_init();
diff --git a/erts/emulator/sys/win32/sys.c b/erts/emulator/sys/win32/sys.c
index c701db1b7b..0a046a5f23 100644
--- a/erts/emulator/sys/win32/sys.c
+++ b/erts/emulator/sys/win32/sys.c
@@ -45,6 +45,9 @@ void erl_start(int, char**);
 void erts_exit(int n, const char*, ...);
 void erl_error(const char*, va_list);
 
+UWord sys_page_size;
+UWord sys_large_page_size;
+
 /*
  * Microsoft-specific function to map a WIN32 error code to a Posix errno.
  */
@@ -189,14 +192,20 @@ void sys_primitive_init(HMODULE beam)
     beam_module = (HMODULE) beam;
 }
 
-UWord
-erts_sys_get_page_size(void)
+static UWord
+get_page_size(void)
 {
     SYSTEM_INFO info;
     GetSystemInfo(&info);
     return (UWord)info.dwPageSize;
 }
 
+static UWord
+get_large_page_size(void)
+{
+    return 0;
+}
+
 Uint
 erts_sys_misc_mem_sz(void)
 {
@@ -3256,6 +3265,9 @@ erts_sys_pre_init(void)
     /* After creation in parent */
     eid.thread_create_parent_func = thr_create_cleanup;
 
+    sys_page_size = get_page_size();
+    sys_large_page_size = get_large_page_size();
+
 #ifdef ERTS_ENABLE_LOCK_COUNT
     erts_lcnt_pre_thr_init();
 #endif
diff --git a/erts/lib_src/yielding_c_fun/main_target.mk b/erts/lib_src/yielding_c_fun/main_target.mk
index b7410e6075..e7a43bb7d1 100644
--- a/erts/lib_src/yielding_c_fun/main_target.mk
+++ b/erts/lib_src/yielding_c_fun/main_target.mk
@@ -32,7 +32,7 @@ $(YCF_EXECUTABLE): $(YCF_OBJECTS)
 	$(V_LD) $(YCF_CFLAGS) $(YCF_LDFLAGS) $(YCF_OBJECTS) -o $@
 
 $(YCF_OBJ_DIR)/%.o: $(YCF_SOURCE_DIR)/lib/simple_c_gc/%.c $(YCF_HEADERS)
-	$(V_CC) $(YCF_CFLAGS) $(YCF_LDFLAGS) $(YCF_INCLUDE_DIRS) -c $< -o $@
+	$(V_CC) $(YCF_CFLAGS) $(YCF_INCLUDE_DIRS) -c $< -o $@
 
 $(YCF_OBJ_DIR)/%.o: $(YCF_SOURCE_DIR)/%.c $(YCF_HEADERS)
-	$(V_CC) $(YCF_CFLAGS) $(YCF_LDFLAGS) $(YCF_INCLUDE_DIRS) -c $< -o $@
+	$(V_CC) $(YCF_CFLAGS) $(YCF_INCLUDE_DIRS) -c $< -o $@
diff --git a/lib/wx/configure b/lib/wx/configure
index 9c0df916d4..d44a8515fc 100755
--- a/lib/wx/configure
+++ b/lib/wx/configure
@@ -4554,11 +4554,11 @@ if test x$ac_prog_cxx_stdcxx = xno
 then :
   { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $CXX option to enable C++11 features" >&5
 printf %s "checking for $CXX option to enable C++11 features... " >&6; }
-if test ${ac_cv_prog_cxx_11+y}
+if test ${ac_cv_prog_cxx_cxx11+y}
 then :
   printf %s "(cached) " >&6
 else $as_nop
-  ac_cv_prog_cxx_11=no
+  ac_cv_prog_cxx_cxx11=no
 ac_save_CXX=$CXX
 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
@@ -4600,11 +4600,11 @@ if test x$ac_prog_cxx_stdcxx = xno
 then :
   { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $CXX option to enable C++98 features" >&5
 printf %s "checking for $CXX option to enable C++98 features... " >&6; }
-if test ${ac_cv_prog_cxx_98+y}
+if test ${ac_cv_prog_cxx_cxx98+y}
 then :
   printf %s "(cached) " >&6
 else $as_nop
-  ac_cv_prog_cxx_98=no
+  ac_cv_prog_cxx_cxx98=no
 ac_save_CXX=$CXX
 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
diff --git a/make/configure b/make/configure
index 875958e72e..3dd553d78a 100755
--- a/make/configure
+++ b/make/configure
@@ -4815,11 +4815,11 @@ if test x$ac_prog_cxx_stdcxx = xno
 then :
   { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $CXX option to enable C++11 features" >&5
 printf %s "checking for $CXX option to enable C++11 features... " >&6; }
-if test ${ac_cv_prog_cxx_11+y}
+if test ${ac_cv_prog_cxx_cxx11+y}
 then :
   printf %s "(cached) " >&6
 else $as_nop
-  ac_cv_prog_cxx_11=no
+  ac_cv_prog_cxx_cxx11=no
 ac_save_CXX=$CXX
 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
@@ -4861,11 +4861,11 @@ if test x$ac_prog_cxx_stdcxx = xno
 then :
   { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking for $CXX option to enable C++98 features" >&5
 printf %s "checking for $CXX option to enable C++98 features... " >&6; }
-if test ${ac_cv_prog_cxx_98+y}
+if test ${ac_cv_prog_cxx_cxx98+y}
 then :
   printf %s "(cached) " >&6
 else $as_nop
-  ac_cv_prog_cxx_98=no
+  ac_cv_prog_cxx_cxx98=no
 ac_save_CXX=$CXX
 cat confdefs.h - <<_ACEOF >conftest.$ac_ext
 /* end confdefs.h.  */
-- 
2.35.3

openSUSE Build Service is sponsored by