On Mon, Oct 16, 2017 at 3:25 PM, Rainer Jung <rainer.j...@kippdata.de> wrote:
> Am 16.10.2017 um 12:31 schrieb Joe Orton:
>>
>> On Fri, Oct 13, 2017 at 11:51:54AM -0400, Jim Jagielski wrote:
>>>
>>> The long and short is that under maintainer mode, we cannot
>>> expect AC_CHECK_LIB to being correct any longer, because
>>> the combination of -Werror and -Wstrict-prototypes means
>>> that any and all functions looked for/checked for using
>>> AC_CHECK_LIB will NOT be found, due to warnings which are
>>> now fatal errors during configure time, even if those
>>> functions DO exist.
>>
>>
>> IMO the correct fix is to add all -W... flags to NOTEST_CFLAGS not
>> CFLAGS so they don't take effect during the configure run at all.  At
>> least I can't think of a good motivation for having compiler warnings
>> enabled when running autoconf tests in general.
>
>
> Good hint, never used that variable.

+1!

> So what about the following patch
> instead: just tried it on trunk and seemed to work fine there.

Slightly modified (see attached), it works for me too.

I just added a second arg to APACHE_ADD_GCC_CFLAG which allows me to:
+      APACHE_ADD_GCC_CFLAG([-Werror], [-Wno-strict-prototypes])

where $2 is also used for AC_LANG_PROGRAM's CFLAGS (before $1), but
will not be added to NOTEST_CFLAGS.
Without this change, -Werror is still not accepted by AC_LANG_PROGRAM for me...
Index: acinclude.m4
===================================================================
--- acinclude.m4	(revision 1812289)
+++ acinclude.m4	(working copy)
@@ -960,7 +960,7 @@ YES_IS_DEFINED
 dnl
 dnl APACHE_ADD_GCC_CFLAGS
 dnl
-dnl Check if compiler is gcc and supports flag. If yes, add to CFLAGS.
+dnl Check if compiler is gcc and supports flag. If yes, add to NOTEST_CFLAGS.
 dnl
 AC_DEFUN([APACHE_ADD_GCC_CFLAG], [
   define([ap_gcc_ckvar], [ac_cv_gcc_]translit($1, [-:.=], [____]))
@@ -967,13 +967,13 @@ AC_DEFUN([APACHE_ADD_GCC_CFLAG], [
   if test "$GCC" = "yes"; then
     AC_CACHE_CHECK([whether gcc accepts $1], ap_gcc_ckvar, [
       save_CFLAGS="$CFLAGS"
-      CFLAGS="$CFLAGS $1"
+      CFLAGS="$CFLAGS $2 $1"
       AC_COMPILE_IFELSE([AC_LANG_PROGRAM()],
         [ap_gcc_ckvar=yes], [ap_gcc_ckvar=no])
       CFLAGS="$save_CFLAGS"
     ])
     if test "$]ap_gcc_ckvar[" = "yes" ; then
-       APR_ADDTO(CFLAGS,[$1])
+       APR_ADDTO(NOTEST_CFLAGS,[$1])
     fi
   fi
   undefine([ap_gcc_ckvar])
Index: configure.in
===================================================================
--- configure.in	(revision 1812289)
+++ configure.in	(working copy)
@@ -627,21 +627,17 @@ AC_ARG_ENABLE(load-all-modules,APACHE_HELP_STRING(
 AC_ARG_ENABLE(maintainer-mode,APACHE_HELP_STRING(--enable-maintainer-mode,Turn on debugging and compile time warnings and load all compiled modules),
 [
   if test "$enableval" = "yes"; then
-    APR_ADDTO(CPPFLAGS, -DAP_DEBUG)
+    APR_ADDTO(NOTEST_CPPFLAGS, -DAP_DEBUG)
     if test "$GCC" = "yes"; then
-      APR_ADDTO(CFLAGS,[-Wall -Wmissing-prototypes -Wstrict-prototypes -Wmissing-declarations -Wpointer-arith])
-      # Next flag needed, because -Wstrict-prototypes in combination with
-      # -Werror leads to compiler errors during configure checks (autoconf
-      # generates incomplete prototypes).
-      APACHE_ADD_GCC_CFLAG([-Wno-error=strict-prototypes])
+      APR_ADDTO(NOTEST_CFLAGS,[-Wall -Wmissing-prototypes -Wstrict-prototypes -Wmissing-declarations -Wpointer-arith])
       APACHE_ADD_GCC_CFLAG([-std=c89])
-      APACHE_ADD_GCC_CFLAG([-Werror])
+      APACHE_ADD_GCC_CFLAG([-Werror], [-Wno-strict-prototypes])
       APACHE_ADD_GCC_CFLAG([-Wdeclaration-after-statement])
       APACHE_ADD_GCC_CFLAG([-Wformat])
       APACHE_ADD_GCC_CFLAG([-Wformat-security])
       APACHE_ADD_GCC_CFLAG([-Wunused])
     elif test "$AIX_XLC" = "yes"; then
-      APR_ADDTO(CFLAGS,-qfullpath -qinitauto=FE -qcheck=all -qinfo=pro)
+      APR_ADDTO(NOTEST_CFLAGS,-qfullpath -qinitauto=FE -qcheck=all -qinfo=pro)
     fi
     if test "x$enable_load_all_modules" = "x"; then
       LOAD_ALL_MODULES=yes
@@ -657,9 +653,9 @@ AC_ARG_ENABLE(maintainer-mode,APACHE_HELP_STRING(-
 AC_ARG_ENABLE(debugger-mode,APACHE_HELP_STRING(--enable-debugger-mode,Turn on debugging and compile time warnings and turn off optimization),
 [
   if test "$enableval" = "yes"; then
-    APR_ADDTO(CPPFLAGS, -DAP_DEBUG)
+    APR_ADDTO(NOTEST_CPPFLAGS, -DAP_DEBUG)
     if test "$GCC" = "yes"; then
-      APR_ADDTO(CFLAGS,[-Wall -Wmissing-prototypes -Wstrict-prototypes -Wmissing-declarations -Wpointer-arith -O0])
+      APR_ADDTO(NOTEST_CFLAGS,[-Wall -Wmissing-prototypes -Wstrict-prototypes -Wmissing-declarations -Wpointer-arith -O0])
       APACHE_ADD_GCC_CFLAG([-Wdeclaration-after-statement])
       APACHE_ADD_GCC_CFLAG([-Werror=declaration-after-statement])
       APACHE_ADD_GCC_CFLAG([-Wformat])
@@ -666,7 +662,7 @@ AC_ARG_ENABLE(debugger-mode,APACHE_HELP_STRING(--e
       APACHE_ADD_GCC_CFLAG([-Wformat-security])
       APACHE_ADD_GCC_CFLAG([-Werror=format-security])
     elif test "$AIX_XLC" = "yes"; then
-      APR_ADDTO(CFLAGS,-qfullpath -qinitauto=FE -qcheck=all -qinfo=pro)
+      APR_ADDTO(NOTEST_CFLAGS,-qfullpath -qinitauto=FE -qcheck=all -qinfo=pro)
     fi
   fi
 ])dnl

Reply via email to