File 5605-erts-Only-use-THP-options-for-beam-executable.patch of Package erlang

From 5aee2393c1ffe7a67d2e194ee8b733951e1a9573 Mon Sep 17 00:00:00 2001
From: Lukas Larsson <lukas@erlang.org>
Date: Tue, 18 Jun 2024 16:01:12 +0200
Subject: [PATCH 1/2] erts: Only use THP options for beam executable

The erlc, dialyzer and other executables should not have the
common/max page size options as it makes their executables
grow to around 4MB each from just a couple of kbs.

closes #8574
---
 erts/configure.ac         | 6 +++++-
 erts/emulator/Makefile.in | 3 ++-
 2 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/erts/configure.ac b/erts/configure.ac
index 61f9fe48a5..9185e62a17 100644
--- a/erts/configure.ac
+++ b/erts/configure.ac
@@ -3071,6 +3071,7 @@ AS_IF([test "x$erts_cv_linux_thp" = "xyes"],
       ]
     )
     LDFLAGS="$saved_LDFLAGS"
+    EMU_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])
@@ -3079,7 +3080,8 @@ AS_IF([test "x$erts_cv_linux_thp" = "xyes"],
       AC_LINK_IFELSE([AC_LANG_PROGRAM([[]],[[return 0;]])],
          [
            AC_MSG_RESULT([yes])
-           LDFLAGS="$saved_LDFLAGS $flag"
+           EMU_LDFLAGS="$flag"
+           LDFLAGS="$saved_LDFLAGS"
          ],
          [
            AC_MSG_RESULT([no])
@@ -3088,6 +3090,8 @@ AS_IF([test "x$erts_cv_linux_thp" = "xyes"],
     done
   ])
 
+AC_SUBST(EMU_LDFLAGS)
+
 dnl ----------------------------------------------------------------------
 dnl Tests related to configurable options given on command line
 dnl (using the --disable, --enable and --with switches).
diff --git a/erts/emulator/Makefile.in b/erts/emulator/Makefile.in
index e93f052d75..788784d04b 100644
--- a/erts/emulator/Makefile.in
+++ b/erts/emulator/Makefile.in
@@ -95,6 +95,7 @@ M4FLAGS=
 CREATE_DIRS=
 
 LDFLAGS=@LDFLAGS@
+EMU_LDFLAGS=@EMU_LDFLAGS@
 ARFLAGS=rc
 TYPE_LIBS=
 
@@ -1261,7 +1262,7 @@ EMU_LD=$(CC)
 endif
 $(BINDIR)/$(FLAVOR_EXECUTABLE): $(INIT_OBJS) $(OBJS) $(DEPLIBS)
 	$(ld_verbose) $(EMU_LD) -o $@ \
-	$(PROFILE_LDFLAGS) $(LDFLAGS) $(DEXPORT) $(INIT_OBJS) $(OBJS) \
+	$(PROFILE_LDFLAGS) $(LDFLAGS) $(EMU_LDFLAGS) $(DEXPORT) $(INIT_OBJS) $(OBJS) \
 	$(STATIC_NIF_LIBS) $(STATIC_DRIVER_LIBS) $(LIBS)
 
 endif
-- 
2.35.3

openSUSE Build Service is sponsored by