File 0794-otp-Ignore-Werror-in-CFLAGS-during-configure.patch of Package erlang

From 7091f816f35f557e77f42942d210b7ee819ee029 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Lukas=20Backstr=C3=B6m?= <lukas@erlang.org>
Date: Mon, 28 Oct 2024 11:01:07 +0100
Subject: [PATCH 04/10] otp: Ignore -Werror in CFLAGS during configure

---
 erts/configure                 | 10 +++++++---
 erts/configure.ac              | 14 ++------------
 lib/common_test/configure      | 16 ++++++++++++++++
 lib/common_test/configure.ac   |  4 ++++
 lib/crypto/configure           | 18 ++++++++++++++++++
 lib/crypto/configure.ac        |  4 ++++
 lib/erl_interface/configure    | 18 +++++++++++++++++-
 lib/erl_interface/configure.ac |  6 +++++-
 lib/megaco/configure           | 16 ++++++++++++++++
 lib/megaco/configure.ac        |  4 ++++
 lib/odbc/configure             | 16 ++++++++++++++++
 lib/odbc/configure.ac          |  4 ++++
 lib/snmp/configure             | 16 ++++++++++++++++
 lib/snmp/configure.ac          |  4 ++++
 lib/wx/configure               | 19 ++++++++++++++++---
 lib/wx/configure.ac            |  7 ++++---
 make/autoconf/otp.m4           | 17 +++++++++++++++++
 make/configure                 | 16 ++++++++++++++++
 make/configure.ac              |  4 ++++
 19 files changed, 190 insertions(+), 23 deletions(-)

diff --git a/erts/configure b/erts/configure
index 0459e638bc..c972cb283d 100755
--- a/erts/configure
+++ b/erts/configure
@@ -702,7 +702,6 @@ PROFILE_COMPILER
 USE_PGO
 XCRUN
 LLVM_PROFDATA
-WERRORFLAGS
 WFLAGS
 DEBUG_FLAGS
 ERTS_CONFIG_H_IDIR
@@ -3663,6 +3662,11 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
 
 
 
+
+
+
+
+
 
 
 
@@ -8302,7 +8306,6 @@ rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
 
 
 
-
 ## Check if we can do profile guided optimization of beam_emu
 
     { printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -fprofile-generate -Werror..." >&5
@@ -26921,8 +26924,9 @@ rm -f core conftest.err conftest.$ac_objext conftest.beam conftest.$ac_ext
 CFLAGS="$saved_CFLAGS"
 
 
+
 if test "x$GCC" = xyes; then
-  CFLAGS="$WERRORFLAGS $CFLAGS"
+    CFLAGS="$WERRORFLAGS $CFLAGS"
 fi
 
 
diff --git a/erts/configure.ac b/erts/configure.ac
index 5bca25bb0b..f546f1a5a5 100644
--- a/erts/configure.ac
+++ b/erts/configure.ac
@@ -29,14 +29,7 @@ m4_include([otp.m4])
 
 LM_PRECIOUS_VARS
 
-dnl We check if -Werror was given on command line and if so
-dnl we disable it for the configure and only use it when
-dnl actually building erts
-no_werror_CFLAGS=$(echo " $CFLAGS " | sed 's/ -Werror / /g')
-if test "X $CFLAGS " != "X$no_werror_CFLAGS"; then
-   CFLAGS="$no_werror_CFLAGS"
-   WERRORFLAGS=-Werror
-fi
+ERL_PUSH_WERROR
 
 dnl How to set srcdir absolute is taken from the GNU Emacs distribution
 #### Make srcdir absolute, if it isn't already.  It's important to
@@ -630,7 +623,6 @@ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]],[[
 dnl DEBUG_FLAGS is obsolete (I hope)
 AC_SUBST(DEBUG_FLAGS)
 AC_SUBST(WFLAGS)
-AC_SUBST(WERRORFLAGS)
 
 ## Check if we can do profile guided optimization of beam_emu
 LM_CHECK_RUN_CFLAG([-fprofile-generate -Werror],[PROFILE_GENERATE])
@@ -3637,9 +3629,7 @@ dnl ----------------------------------------------------------------------
 dnl Enable any -Werror flags
 dnl ----------------------------------------------------------------------
 
-if test "x$GCC" = xyes; then
-  CFLAGS="$WERRORFLAGS $CFLAGS"
-fi
+ERL_POP_WERROR
 
 dnl ----------------------------------------------------------------------
 dnl Enable build determinism flag
diff --git a/lib/common_test/configure b/lib/common_test/configure
index ebe9da56f8..6532c0389f 100755
--- a/lib/common_test/configure
+++ b/lib/common_test/configure
@@ -1917,6 +1917,17 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
 
 
 
+
+
+
+
+
+
+no_werror_CFLAGS=$(echo " $CFLAGS " | sed 's/ -Werror / /g')
+if test "X $CFLAGS " != "X$no_werror_CFLAGS"; then
+   CFLAGS="$no_werror_CFLAGS"
+   WERRORFLAGS=-Werror
+fi
 
 
 
@@ -2124,6 +2135,11 @@ fi
 TARGET=$host
 
 
+
+if test "x$GCC" = xyes; then
+    CFLAGS="$WERRORFLAGS $CFLAGS"
+fi
+
 ac_config_files="$ac_config_files priv/$host/Makefile:priv/Makefile.in"
 
 cat >confcache <<\_ACEOF
diff --git a/lib/common_test/configure.ac b/lib/common_test/configure.ac
index 490a64328d..4f08ae10d3 100644
--- a/lib/common_test/configure.ac
+++ b/lib/common_test/configure.ac
@@ -5,10 +5,14 @@ m4_include([otp.m4])
 
 AC_CONFIG_AUX_DIR([${ERL_TOP}/make/autoconf])
 
+ERL_PUSH_WERROR
+
 ERL_CANONICAL_SYSTEM_TYPE
 
 TARGET=$host
 AC_SUBST(TARGET)
 
+ERL_POP_WERROR
+
 AC_CONFIG_FILES([priv/$host/Makefile:priv/Makefile.in])
 AC_OUTPUT
diff --git a/lib/crypto/configure b/lib/crypto/configure
index 02a0406212..efc69ef0e2 100755
--- a/lib/crypto/configure
+++ b/lib/crypto/configure
@@ -3036,6 +3036,17 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
 
 
 
+
+
+
+
+
+
+no_werror_CFLAGS=$(echo " $CFLAGS " | sed 's/ -Werror / /g')
+if test "X $CFLAGS " != "X$no_werror_CFLAGS"; then
+   CFLAGS="$no_werror_CFLAGS"
+   WERRORFLAGS=-Werror
+fi
 
 
 
@@ -8047,6 +8058,13 @@ LDFLAGS="$saveLDFLAGS"
 LIBS="$saveLIBS"
 
 
+no_werror_CFLAGS=$(echo " $CFLAGS " | sed 's/ -Werror / /g')
+if test "X $CFLAGS " != "X$no_werror_CFLAGS"; then
+   CFLAGS="$no_werror_CFLAGS"
+   WERRORFLAGS=-Werror
+fi
+
+
 
 
 
diff --git a/lib/crypto/configure.ac b/lib/crypto/configure.ac
index b5b5914247..fb31f7d350 100644
--- a/lib/crypto/configure.ac
+++ b/lib/crypto/configure.ac
@@ -30,6 +30,8 @@ m4_include([otp.m4])
 
 AC_CONFIG_AUX_DIR([${ERL_TOP}/make/autoconf])
 
+ERL_PUSH_WERROR
+
 ERL_CANONICAL_SYSTEM_TYPE
 
 AC_LANG(C)
@@ -922,6 +924,8 @@ CFLAGS="$saveCFLAGS"
 LDFLAGS="$saveLDFLAGS"
 LIBS="$saveLIBS"
 
+ERL_PUSH_WERROR
+
 AC_SUBST(SSL_INCLUDE)
 AC_SUBST(SSL_INCDIR)
 AC_SUBST(SSL_LIBDIR)
diff --git a/lib/megaco/configure b/lib/megaco/configure
index 1ee2b0325a..fec557b6b0 100755
--- a/lib/megaco/configure
+++ b/lib/megaco/configure
@@ -2779,6 +2779,10 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
 
 
 
+
+
+
+
 
 
 
@@ -2985,6 +2989,13 @@ fi
 
 
 
+no_werror_CFLAGS=$(echo " $CFLAGS " | sed 's/ -Werror / /g')
+if test "X $CFLAGS " != "X$no_werror_CFLAGS"; then
+   CFLAGS="$no_werror_CFLAGS"
+   WERRORFLAGS=-Werror
+fi
+
+
 
 
 
@@ -5971,6 +5982,11 @@ if test "$PERL" = no_perl; then
   as_fn_error $? "Perl is required to build the flex scanner!" "$LINENO" 5
 fi
 
+
+if test "x$GCC" = xyes; then
+    CFLAGS="$WERRORFLAGS $CFLAGS"
+fi
+
 ac_config_files="$ac_config_files examples/meas/Makefile:examples/meas/Makefile.in"
 
 cat >confcache <<\_ACEOF
diff --git a/lib/megaco/configure.ac b/lib/megaco/configure.ac
index 6f243be8d9..a5c3db9e1a 100644
--- a/lib/megaco/configure.ac
+++ b/lib/megaco/configure.ac
@@ -33,6 +33,8 @@ AC_CONFIG_AUX_DIR([${ERL_TOP}/make/autoconf])
 
 ERL_CANONICAL_SYSTEM_TYPE
 
+ERL_PUSH_WERROR
+
 dnl ----------------------------------------------------------------------
 dnl Checks for programs.
 dnl ----------------------------------------------------------------------
@@ -169,6 +171,8 @@ if test "$PERL" = no_perl; then
   AC_MSG_ERROR([Perl is required to build the flex scanner!])
 fi
 
+ERL_POP_WERROR
+
 AC_CONFIG_FILES([examples/meas/Makefile:examples/meas/Makefile.in])
 AC_OUTPUT
 AC_CONFIG_FILES([src/flex/$host/Makefile:src/flex/Makefile.in])
diff --git a/lib/odbc/configure b/lib/odbc/configure
index 1d27999c11..e43c587ccc 100755
--- a/lib/odbc/configure
+++ b/lib/odbc/configure
@@ -2878,6 +2878,17 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
 
 
 
+
+
+
+
+
+
+no_werror_CFLAGS=$(echo " $CFLAGS " | sed 's/ -Werror / /g')
+if test "X $CFLAGS " != "X$no_werror_CFLAGS"; then
+   CFLAGS="$no_werror_CFLAGS"
+   WERRORFLAGS=-Werror
+fi
 
 
 
@@ -6071,6 +6082,11 @@ fi
 
 fi
 
+
+if test "x$GCC" = xyes; then
+    CFLAGS="$WERRORFLAGS $CFLAGS"
+fi
+
 ac_config_files="$ac_config_files c_src/$host/Makefile:c_src/Makefile.in"
 
 cat >confcache <<\_ACEOF
diff --git a/lib/odbc/configure.ac b/lib/odbc/configure.ac
index febdd044a5..19abc17670 100644
--- a/lib/odbc/configure.ac
+++ b/lib/odbc/configure.ac
@@ -31,6 +31,8 @@ m4_include([otp.m4])
 
 AC_CONFIG_AUX_DIR([${ERL_TOP}/make/autoconf])
 
+ERL_PUSH_WERROR
+
 ERL_CANONICAL_SYSTEM_TYPE
 
 AC_ARG_WITH(odbc,
@@ -256,5 +258,7 @@ AS_IF([test "x$GCC" = xyes],
     LM_TRY_ENABLE_CFLAG([-Werror=return-type], [CFLAGS])
   ])
 
+ERL_POP_WERROR
+
 AC_CONFIG_FILES([c_src/$host/Makefile:c_src/Makefile.in])
 AC_OUTPUT
diff --git a/lib/snmp/configure b/lib/snmp/configure
index 2cc4116fa9..4d91509f63 100755
--- a/lib/snmp/configure
+++ b/lib/snmp/configure
@@ -1912,6 +1912,17 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
 
 
 
+
+
+
+
+
+
+no_werror_CFLAGS=$(echo " $CFLAGS " | sed 's/ -Werror / /g')
+if test "X $CFLAGS " != "X$no_werror_CFLAGS"; then
+   CFLAGS="$no_werror_CFLAGS"
+   WERRORFLAGS=-Werror
+fi
 
 
 
@@ -2191,6 +2202,11 @@ fi
 
 
 
+if test "x$GCC" = xyes; then
+    CFLAGS="$WERRORFLAGS $CFLAGS"
+fi
+
+
 ac_config_files="$ac_config_files mibs/Makefile:mibs/Makefile.in"
 
 ac_config_files="$ac_config_files src/agent/Makefile:src/agent/Makefile.in"
diff --git a/lib/snmp/configure.ac b/lib/snmp/configure.ac
index 8f4c1fd833..4f7954d4fb 100644
--- a/lib/snmp/configure.ac
+++ b/lib/snmp/configure.ac
@@ -31,6 +31,8 @@ m4_include([otp.m4])
 
 AC_CONFIG_AUX_DIRS([${ERL_TOP}/make/autoconf])
 
+ERL_PUSH_WERROR
+
 dnl ----------------------------------------------------------------------
 dnl Checks for programs.
 dnl ----------------------------------------------------------------------
@@ -64,6 +66,8 @@ fi
 
 dnl ----------------------------------------------------------------------
 
+ERL_POP_WERROR
+
 AC_SUBST(SNMP_EMPTY_PDU_SIZE_DEFAULT)
 AC_CONFIG_FILES([mibs/Makefile:mibs/Makefile.in])
 AC_CONFIG_FILES([src/agent/Makefile:src/agent/Makefile.in])
diff --git a/lib/wx/configure b/lib/wx/configure
index 47721faca3..776db74b11 100755
--- a/lib/wx/configure
+++ b/lib/wx/configure
@@ -3093,6 +3093,17 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
 
 
 
+
+
+
+
+
+
+no_werror_CFLAGS=$(echo " $CFLAGS " | sed 's/ -Werror / /g')
+if test "X $CFLAGS " != "X$no_werror_CFLAGS"; then
+   CFLAGS="$no_werror_CFLAGS"
+   WERRORFLAGS=-Werror
+fi
 
 ## Delete previous failed configure results
 if test -f ./CONF_INFO; then
@@ -7332,6 +7343,11 @@ mkdir -p $WXERL_SYS_TYPE
 CONFIG_STATUS=$WXERL_SYS_TYPE/config.status
 
 
+if test "x$GCC" = xyes; then
+    CFLAGS="$WERRORFLAGS $CFLAGS"
+fi
+
+
 ac_config_files="$ac_config_files config.mk c_src/Makefile"
 
 
@@ -8493,6 +8509,3 @@ if test X"$CORES" != X"" ; then
    echo "Configure dumped core files" > ignore_core_files
 fi
 
-
-
-
diff --git a/lib/wx/configure.ac b/lib/wx/configure.ac
index ba34c709fc..3cde261a93 100644
--- a/lib/wx/configure.ac
+++ b/lib/wx/configure.ac
@@ -26,6 +26,8 @@ AC_CONFIG_AUX_DIR([${ERL_TOP}/make/autoconf])
 
 AC_PREREQ([2.71])
 
+ERL_PUSH_WERROR
+
 ## Delete previous failed configure results
 if test -f ./CONF_INFO; then
    rm ./CONF_INFO
@@ -749,6 +751,8 @@ AC_SUBST(WXERL_SYS_TYPE)
 mkdir -p $WXERL_SYS_TYPE
 CONFIG_STATUS=$WXERL_SYS_TYPE/config.status
 
+ERL_POP_WERROR
+
 dnl
 
 AC_CONFIG_FILES([ 
@@ -762,6 +766,3 @@ CORES=`ls core* 2>/dev/null`
 if test X"$CORES" != X"" ; then
    echo "Configure dumped core files" > ignore_core_files
 fi
-
-
-
diff --git a/make/autoconf/otp.m4 b/make/autoconf/otp.m4
index 3d7341b0d4..f0fd384c4b 100644
--- a/make/autoconf/otp.m4
+++ b/make/autoconf/otp.m4
@@ -30,6 +30,23 @@ dnl macros specific dnl to the Erlang system are prefixed ERL_ (this is
 dnl not always consistently made...).
 dnl
 
+dnl We check if -Werror was given on command line and if so
+dnl we disable it for the configure and only use it when
+dnl actually building erts
+AC_DEFUN([ERL_PUSH_WERROR],
+[
+no_werror_CFLAGS=$(echo " $CFLAGS " | sed 's/ -Werror / /g')
+if test "X $CFLAGS " != "X$no_werror_CFLAGS"; then
+   CFLAGS="$no_werror_CFLAGS"
+   WERRORFLAGS=-Werror
+fi])
+
+AC_DEFUN([ERL_POP_WERROR],
+[
+if test "x$GCC" = xyes; then
+    CFLAGS="$WERRORFLAGS $CFLAGS"
+fi])
+
 AC_DEFUN([ERL_CANONICAL_SYSTEM_TYPE],
 [
     AC_CANONICAL_HOST
diff --git a/make/configure b/make/configure
index e0cf279617..b53787e0ba 100755
--- a/make/configure
+++ b/make/configure
@@ -3306,6 +3306,17 @@ ac_compiler_gnu=$ac_cv_c_compiler_gnu
 
 
 
+
+
+
+
+
+
+no_werror_CFLAGS=$(echo " $CFLAGS " | sed 's/ -Werror / /g')
+if test "X $CFLAGS " != "X$no_werror_CFLAGS"; then
+   CFLAGS="$no_werror_CFLAGS"
+   WERRORFLAGS=-Werror
+fi
 
 default_cache_file=./config.cache
 
@@ -7277,6 +7288,11 @@ fi
 
 
 
+
+
+if test "x$GCC" = xyes; then
+    CFLAGS="$WERRORFLAGS $CFLAGS"
+fi
 
 ac_config_files="$ac_config_files ../Makefile output.mk ../make/$host/otp_ded.mk:../make/otp_ded.mk.in"
 
diff --git a/make/configure.ac b/make/configure.ac
index f2f423b09f..3d14c19012 100644
--- a/make/configure.ac
+++ b/make/configure.ac
@@ -26,6 +26,8 @@ m4_include([otp.m4])
 
 LM_PRECIOUS_VARS
 
+ERL_PUSH_WERROR
+
 default_cache_file=./config.cache
 
 if test "x$no_recursion" != "xyes" -a "x$OVERRIDE_CONFIG_CACHE" = "x"; then
@@ -372,6 +374,8 @@ fi
 
 ERL_DED
 
+ERL_POP_WERROR
+
 AC_CONFIG_FILES([../Makefile output.mk ../make/$host/otp_ded.mk:../make/otp_ded.mk.in])
 AC_CONFIG_FILES([emd2exml], [chmod +x emd2exml])
 
-- 
2.43.0

openSUSE Build Service is sponsored by