File 6841-autoconf-Refactor-ERL_DED-to-export-ERL_DED_FLAGS.patch of Package erlang

From cb94f984cd764aa827fb1f4bc2169ce3d2d137d3 Mon Sep 17 00:00:00 2001
From: Lukas Larsson <lukas@erlang.org>
Date: Mon, 29 Nov 2021 17:42:53 +0100
Subject: [PATCH 1/2] autoconf: Refactor ERL_DED to export ERL_DED_FLAGS

We can use ERL_DED_FLAGS when we want to configure for dynamic
libaries, but do not want the thread initialization to run.
This is for usage with erl_interface when --disable-threads is
passed.
---
 erts/aclocal.m4      | 29 ++++++++++++++++++-----------
 erts/configure       |  2 +-
 lib/crypto/configure | 26 +++++++++++++++-----------
 lib/megaco/configure | 26 +++++++++++++++-----------
 make/configure       | 28 ++++++++++++++++------------
 5 files changed, 65 insertions(+), 46 deletions(-)

diff --git a/erts/aclocal.m4 b/erts/aclocal.m4
index 4227cc6a66..4720a422c8 100644
--- a/erts/aclocal.m4
+++ b/erts/aclocal.m4
@@ -42,7 +42,7 @@ AC_ARG_VAR(CPPFLAGS, [C/C++ preprocessor flags])
 AC_ARG_VAR(CXX, [C++ compiler])
 AC_ARG_VAR(CXXFLAGS, [C++ compiler flags])
 AC_ARG_VAR(LD, [linker (is often overridden by configure)])
-AC_ARG_VAR(LDFLAGS, [linker flags (can be risky to set since LD may be overriden by configure)])
+AC_ARG_VAR(LDFLAGS, [linker flags (can be risky to set since LD may be overridden by configure)])
 AC_ARG_VAR(LIBS, [libraries])
 AC_ARG_VAR(DED_LD, [linker for Dynamic Erlang Drivers (set all DED_LD* variables or none)])
 AC_ARG_VAR(DED_LDFLAGS, [linker flags for Dynamic Erlang Drivers (set all DED_LD* variables or none)])
@@ -2957,11 +2957,26 @@ dnl
 AC_DEFUN(ERL_DED,
 	[
 
+LM_CHECK_THR_LIB
+
+if test "$THR_DEFS" = ""; then
+    DED_THR_DEFS="-D_THREAD_SAFE -D_REENTRANT"
+else
+    DED_THR_DEFS="$THR_DEFS"
+fi
+
+AC_SUBST(DED_THR_DEFS)
+
+ERL_DED_FLAGS
+
+])
+
+AC_DEFUN(ERL_DED_FLAGS,
+         [
+
 USER_LD=$LD
 USER_LDFLAGS="$LDFLAGS"
 
-LM_CHECK_THR_LIB
-
 DED_CC=$CC
 DED_GCC=$GCC
 
@@ -2977,7 +2992,6 @@ case $host_os in
         ;;
 esac
 
-
 DED_WARN_FLAGS="-Wall -Wstrict-prototypes"
 case "$host_cpu" in
   tile*)
@@ -2997,12 +3011,6 @@ LM_TRY_ENABLE_CFLAG([-Werror=undef], [DED_WERRORFLAGS])
 DED_SYS_INCLUDE="-I${ERL_TOP}/erts/emulator/beam -I${ERL_TOP}/erts/include -I${ERL_TOP}/erts/include/$host -I${ERL_TOP}/erts/include/internal -I${ERL_TOP}/erts/include/internal/$host -I${ERL_TOP}/erts/emulator/sys/$DED_OSTYPE -I${ERL_TOP}/erts/emulator/sys/common"
 DED_INCLUDE=$DED_SYS_INCLUDE
 
-if test "$THR_DEFS" = ""; then
-    DED_THR_DEFS="-D_THREAD_SAFE -D_REENTRANT"
-else
-    DED_THR_DEFS="$THR_DEFS"
-fi
-# DED_EMU_THR_DEFS=$EMU_THR_DEFS
 DED_CFLAGS="$CFLAGS $CPPFLAGS $DED_CFLAGS"
 if test "x$GCC" = xyes; then
     # Use -fno-common for gcc, that is link error if multiple definitions of
@@ -3187,7 +3195,6 @@ AC_SUBST(DED_LD)
 AC_SUBST(DED_LDFLAGS)
 AC_SUBST(DED_LD_FLAG_RUNTIME_LIBRARY_PATH)
 AC_SUBST(DED_LIBS)
-AC_SUBST(DED_THR_DEFS)
 AC_SUBST(DED_OSTYPE)
 
 ])
diff --git a/erts/configure b/erts/configure
index a264407cd2..3a6023ad7d 100755
--- a/erts/configure
+++ b/erts/configure
@@ -1652,7 +1652,7 @@ Some influential environment variables:
   CXX         C++ compiler
   CXXFLAGS    C++ compiler flags
   LD          linker (is often overridden by configure)
-  LDFLAGS     linker flags (can be risky to set since LD may be overriden by
+  LDFLAGS     linker flags (can be risky to set since LD may be overridden by
               configure)
   LIBS        libraries
   DED_LD      linker for Dynamic Erlang Drivers (set all DED_LD* variables or
diff --git a/lib/crypto/configure b/lib/crypto/configure
index 6b7bb6327e..39766e0f0b 100755
--- a/lib/crypto/configure
+++ b/lib/crypto/configure
@@ -633,7 +633,6 @@ SSL_LIBDIR
 SSL_INCLUDE
 REGTOOL
 DED_OSTYPE
-DED_THR_DEFS
 DED_LIBS
 DED_WERRORFLAGS
 DED_WARN_FLAGS
@@ -645,6 +644,7 @@ DED_SYS_INCLUDE
 DED_EXT
 DED_GCC
 DED_CC
+DED_THR_DEFS
 EGREP
 GREP
 MIXED_MINGW
@@ -3974,9 +3974,6 @@ done
 
 
 
-USER_LD=$LD
-USER_LDFLAGS="$LDFLAGS"
-
 
 
 NEED_NPTL_PTHREAD_H=no
@@ -4427,6 +4424,19 @@ fi
 
 
 
+if test "$THR_DEFS" = ""; then
+    DED_THR_DEFS="-D_THREAD_SAFE -D_REENTRANT"
+else
+    DED_THR_DEFS="$THR_DEFS"
+fi
+
+
+
+
+
+USER_LD=$LD
+USER_LDFLAGS="$LDFLAGS"
+
 DED_CC=$CC
 DED_GCC=$GCC
 
@@ -4442,7 +4452,6 @@ case $host_os in
         ;;
 esac
 
-
 DED_WARN_FLAGS="-Wall -Wstrict-prototypes"
 case "$host_cpu" in
   tile*)
@@ -4586,12 +4595,6 @@ $as_echo "no" >&6; }
 DED_SYS_INCLUDE="-I${ERL_TOP}/erts/emulator/beam -I${ERL_TOP}/erts/include -I${ERL_TOP}/erts/include/$host -I${ERL_TOP}/erts/include/internal -I${ERL_TOP}/erts/include/internal/$host -I${ERL_TOP}/erts/emulator/sys/$DED_OSTYPE -I${ERL_TOP}/erts/emulator/sys/common"
 DED_INCLUDE=$DED_SYS_INCLUDE
 
-if test "$THR_DEFS" = ""; then
-    DED_THR_DEFS="-D_THREAD_SAFE -D_REENTRANT"
-else
-    DED_THR_DEFS="$THR_DEFS"
-fi
-# DED_EMU_THR_DEFS=$EMU_THR_DEFS
 DED_CFLAGS="$CFLAGS $CPPFLAGS $DED_CFLAGS"
 if test "x$GCC" = xyes; then
     # Use -fno-common for gcc, that is link error if multiple definitions of
diff --git a/lib/megaco/configure b/lib/megaco/configure
index 6471979298..13ed7b96a6 100755
--- a/lib/megaco/configure
+++ b/lib/megaco/configure
@@ -623,7 +623,6 @@ ac_subst_vars='LTLIBOBJS
 LIBOBJS
 PERL
 DED_OSTYPE
-DED_THR_DEFS
 DED_LIBS
 DED_LD_FLAG_RUNTIME_LIBRARY_PATH
 DED_LDFLAGS
@@ -638,6 +637,7 @@ DED_EXT
 DED_GCC
 DED_CC
 DED_LD
+DED_THR_DEFS
 EGREP
 GREP
 CPP
@@ -4061,9 +4061,6 @@ done
 
 
 
-USER_LD=$LD
-USER_LDFLAGS="$LDFLAGS"
-
 
 
 NEED_NPTL_PTHREAD_H=no
@@ -4514,6 +4511,19 @@ fi
 
 
 
+if test "$THR_DEFS" = ""; then
+    DED_THR_DEFS="-D_THREAD_SAFE -D_REENTRANT"
+else
+    DED_THR_DEFS="$THR_DEFS"
+fi
+
+
+
+
+
+USER_LD=$LD
+USER_LDFLAGS="$LDFLAGS"
+
 DED_CC=$CC
 DED_GCC=$GCC
 
@@ -4529,7 +4539,6 @@ case $host_os in
         ;;
 esac
 
-
 DED_WARN_FLAGS="-Wall -Wstrict-prototypes"
 case "$host_cpu" in
   tile*)
@@ -4673,12 +4682,6 @@ $as_echo "no" >&6; }
 DED_SYS_INCLUDE="-I${ERL_TOP}/erts/emulator/beam -I${ERL_TOP}/erts/include -I${ERL_TOP}/erts/include/$host -I${ERL_TOP}/erts/include/internal -I${ERL_TOP}/erts/include/internal/$host -I${ERL_TOP}/erts/emulator/sys/$DED_OSTYPE -I${ERL_TOP}/erts/emulator/sys/common"
 DED_INCLUDE=$DED_SYS_INCLUDE
 
-if test "$THR_DEFS" = ""; then
-    DED_THR_DEFS="-D_THREAD_SAFE -D_REENTRANT"
-else
-    DED_THR_DEFS="$THR_DEFS"
-fi
-# DED_EMU_THR_DEFS=$EMU_THR_DEFS
 DED_CFLAGS="$CFLAGS $CPPFLAGS $DED_CFLAGS"
 if test "x$GCC" = xyes; then
     # Use -fno-common for gcc, that is link error if multiple definitions of
@@ -5034,6 +5037,7 @@ fi
 
 
 
+
 
 # Extract the first word of "perl", so it can be a program name with args.
 set dummy perl; ac_word=$2
diff --git a/make/configure b/make/configure
index 02204f72d0..698d94db9c 100755
--- a/make/configure
+++ b/make/configure
@@ -621,7 +621,6 @@ ac_includes_default="\
 ac_subst_vars='LTLIBOBJS
 LIBOBJS
 DED_OSTYPE
-DED_THR_DEFS
 DED_LIBS
 DED_WERRORFLAGS
 DED_WARN_FLAGS
@@ -633,6 +632,7 @@ DED_SYS_INCLUDE
 DED_EXT
 DED_GCC
 DED_CC
+DED_THR_DEFS
 EGREP
 GREP
 NATIVE_LIBS_ENABLED
@@ -5082,9 +5082,6 @@ done
 
 
 
-USER_LD=$LD
-USER_LDFLAGS="$LDFLAGS"
-
 
 
 NEED_NPTL_PTHREAD_H=no
@@ -5535,6 +5532,19 @@ fi
 
 
 
+if test "$THR_DEFS" = ""; then
+    DED_THR_DEFS="-D_THREAD_SAFE -D_REENTRANT"
+else
+    DED_THR_DEFS="$THR_DEFS"
+fi
+
+
+
+
+
+USER_LD=$LD
+USER_LDFLAGS="$LDFLAGS"
+
 DED_CC=$CC
 DED_GCC=$GCC
 
@@ -5550,7 +5560,6 @@ case $host_os in
         ;;
 esac
 
-
 DED_WARN_FLAGS="-Wall -Wstrict-prototypes"
 case "$host_cpu" in
   tile*)
@@ -5694,12 +5703,6 @@ $as_echo "no" >&6; }
 DED_SYS_INCLUDE="-I${ERL_TOP}/erts/emulator/beam -I${ERL_TOP}/erts/include -I${ERL_TOP}/erts/include/$host -I${ERL_TOP}/erts/include/internal -I${ERL_TOP}/erts/include/internal/$host -I${ERL_TOP}/erts/emulator/sys/$DED_OSTYPE -I${ERL_TOP}/erts/emulator/sys/common"
 DED_INCLUDE=$DED_SYS_INCLUDE
 
-if test "$THR_DEFS" = ""; then
-    DED_THR_DEFS="-D_THREAD_SAFE -D_REENTRANT"
-else
-    DED_THR_DEFS="$THR_DEFS"
-fi
-# DED_EMU_THR_DEFS=$EMU_THR_DEFS
 DED_CFLAGS="$CFLAGS $CPPFLAGS $DED_CFLAGS"
 if test "x$GCC" = xyes; then
     # Use -fno-common for gcc, that is link error if multiple definitions of
@@ -6055,6 +6058,7 @@ fi
 
 
 
+
 
 ac_config_files="$ac_config_files ../Makefile output.mk ../make/$host/otp_ded.mk:../make/otp_ded.mk.in"
 
-- 
2.31.1

openSUSE Build Service is sponsored by