Bug 63633 - httpd 2.4.40 build fails on RHEL5 due to -Wno-error=comment
Summary: httpd 2.4.40 build fails on RHEL5 due to -Wno-error=comment
Status: RESOLVED FIXED
Alias: None
Product: Apache httpd-2
Classification: Unclassified
Component: Build (show other bugs)
Version: 2.4.39
Hardware: PC All
: P2 normal (vote)
Target Milestone: ---
Assignee: Apache HTTPD Bugs Mailing List
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2019-08-05 10:28 UTC by Mike Lothian
Modified: 2019-08-17 19:56 UTC (History)
0 users



Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mike Lothian 2019-08-05 10:28:59 UTC
I think the test to check if the function is available in GCC is wrong - or maybe has the logic backwards

make[3]: Entering directory `/root/build/httpd-2.4.40/modules/filters'
Building shared: mod_buffer.la mod_data.la mod_ratelimit.la mod_reqtimeout.la mod_ext_filter.la mod_request.la mod_include.la mod_filter.la mod_reflector.la mod_substitute.la mod_sed.la mod_charset_lite.la mod_deflate.la mod_xml2enc.la mod_proxy_html.la
make[4]: Entering directory `/root/build/httpd-2.4.40/modules/filters'
/apps/was/apache/build-1/libtool --silent --mode=compile gcc -std=gnu99 -I/usr/include/libxml2 -pthread  -O3 -march=core2 -fPIE -fstack-protector-all -D_FORTIFY_SOURCE=2   -Wno-error=comment -DLINUX -D_REENTRANT -D_GNU_SOURCE     -I. -I/root/build/httpd-2.4.40/os/unix -I/root/build/httpd-2.4.40/include -I/apps/was/apache/include/apr-1 -I/apps/was/apache/include -I/root/build/httpd-2.4.40/modules/aaa -I/root/build/httpd-2.4.40/modules/cache -I/root/build/httpd-2.4.40/modules/core -I/root/build/httpd-2.4.40/modules/database -I/root/build/httpd-2.4.40/modules/filters -I/root/build/httpd-2.4.40/modules/ldap -I/root/build/httpd-2.4.40/server -I/root/build/httpd-2.4.40/modules/loggers -I/root/build/httpd-2.4.40/modules/lua -I/root/build/httpd-2.4.40/modules/proxy -I/root/build/httpd-2.4.40/modules/http2 -I/root/build/httpd-2.4.40/modules/session -I/root/build/httpd-2.4.40/modules/ssl -I/root/build/httpd-2.4.40/modules/test -I/root/build/httpd-2.4.40/server -I/root/build/httpd-2.4.40/modules/md -I/root/build/httpd-2.4.40/modules/arch/unix -I/root/build/httpd-2.4.40/modules/dav/main -I/root/build/httpd-2.4.40/modules/generators -I/root/build/httpd-2.4.40/modules/mappers -prefer-pic -c mod_buffer.c && touch mod_buffer.slo
cc1: error: unrecognized command line option "-Wno-error=comment"

That's built with:

./buildconf --with-apr=${JENKINS_DIR}/apr-${APR_VERSION} --with-apr-util=${JENKINS_DIR}/apr-util-${APR_UTIL_VERSION}

./configure --prefix=${SERVER_ROOT} --with-apr=${SERVER_ROOT} --with-apr-util=${SERVER_ROOT} --with-z=/usr --with-pcre=${SERVER_ROOT} --with-ssl=${SERVER_ROOT} --with-nghttp2=${SERVER_ROOT} --with-port=10880 --with-program-name=httpd --with-mpm=event --disable-suexec --enable-mods-shared=reallyall
Comment 1 Rainer Jung 2019-08-05 10:47:14 UTC
It seems the -Wno-error= switch was added to GCC in 4.2.x. At least in 4.2.4 it is documented, in 4.1.2 ist is not documented. I guess your RHEL 5 GCC is older than 4.2?

r1856931 added its use unconditionally to httpd to silence warnings:

"Make libxml2's inclusion of unicode/*.h files
a non-fatal warning/error under maintainer-mode."

So it seems we need to include the flag conditionally on GCC support or version.
Comment 2 Mike Lothian 2019-08-05 10:54:56 UTC
Reverting https://github.com/apache/httpd/commit/210ef9bca72c0d3a41acdb24fb0c70c267937115 gets things working for me

which is https://svn.apache.org/viewvc?view=revision&revision=1856931 in SVN

And the GCC version is:

gcc (GCC) 4.1.2 20080704 (Red Hat 4.1.2-55)
Copyright (C) 2006 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

I do realise this is ancient and probably unsupported but I'd thought I'd flag it up anyway
Comment 3 Rainer Jung 2019-08-05 11:07:13 UTC
File configure.in uses macro APACHE_ADD_GCC_CFLAG from acinclude.m4 for gcc feature detection. That macro puts the flag into NOTEST_CFLAGS which is then copied elsewhere.

I think in the case here, it would be more appropriate to relax the comment checking using -Wno-error=comment only for compilation of mod_proxy_html.c and mod_xml2enc.c. So probably setting a special LIBXML_CPPFLAGS or such variable and add it to the compilation line for mod_proxy_html.c and mod_xml2enc.c. The macro code could be copied and adjusted from APACHE_ADD_GCC_CFLAG or if we go for something a bit more generic, we could allow that macro to set a variable whose name we inject (haven't tried this) and reuse it for both use cases.

To the OP: as a workaround currently you would need to manually remove -Wno-error=comment from the following file/line after running configure and before running make:

modules/filters/modules.mk:MOD_CPPFLAGS = -Wno-error=comment

As an alternativ, you could undo r1856931 in your 2.4.40 source, run buildconf 8which will regenerate configure without the part that adds the flag) and then proceed building as normal.

Thanks for letting us know about the problem.
Comment 4 Rainer Jung 2019-08-05 12:43:22 UTC
What about the following more fine grained approach: not sure, whether "diagnostic ignored "-Werror=comment"" really reverses the effect of maintainer mode (warnings plus error escalation) or would only reverse an explicitly set "-Werror=comment" which we don't have. But its worth a try:


Index: modules/filters/config.m4
===================================================================
--- modules/filters/config.m4   (revision 1864429)
+++ modules/filters/config.m4   (working copy)
@@ -114,10 +114,6 @@
     if test -n "${xml2_path}" ; then
       ac_cv_libxml2=yes
       XML2_INCLUDES="${xml2_path}"
-      dnl libxml2 includes unicode/*.h files which uses C++ comments
-      if test "$GCC" = "yes"; then
-        APR_ADDTO(MOD_CPPFLAGS, ["-Wno-error=comment"])
-      fi
     else
       ac_cv_libxml2=no
     fi
Index: modules/filters/mod_proxy_html.c
===================================================================
--- modules/filters/mod_proxy_html.c    (revision 1864429)
+++ modules/filters/mod_proxy_html.c    (working copy)
@@ -29,9 +29,28 @@
 #define VERBOSEB(x) if (verbose) {x}
 #endif

+/* libxml2 includes unicode/*.h files which uses C++ comments */
+#if defined(__GNUC__)
+#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)
+#pragma GCC diagnostic push
+#endif
+#pragma GCC diagnostic ignored "-Werror=comment"
+#elif defined(__clang__)
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Werror=comment"
+#endif
+
 /* libxml2 */
 #include <libxml/HTMLparser.h>

+#if defined(__GNUC__)
+#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)
+#pragma GCC diagnostic pop
+#endif
+#elif defined(__clang__)
+#pragma clang diagnostic pop
+#endif
+
 #include "http_protocol.h"
 #include "http_config.h"
 #include "http_log.h"
Index: modules/filters/mod_xml2enc.c
===================================================================
--- modules/filters/mod_xml2enc.c       (revision 1864429)
+++ modules/filters/mod_xml2enc.c       (working copy)
@@ -23,9 +23,30 @@

 #include <ctype.h>

+/* libxml2 includes unicode/*.h files which uses C++ comments */
+#if defined(__GNUC__)
+#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)
+#pragma GCC diagnostic push
+#endif
+#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 2)
+#pragma GCC diagnostic ignored "-Werror=comment"
+#endif
+#elif defined(__clang__)
+#pragma clang diagnostic push
+#pragma clang diagnostic ignored "-Werror=comment"
+#endif
+
 /* libxml2 */
 #include <libxml/encoding.h>

+#if defined(__GNUC__)
+#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6)
+#pragma GCC diagnostic pop
+#endif
+#elif defined(__clang__)
+#pragma clang diagnostic pop
+#endif
+
 #include "http_protocol.h"
 #include "http_config.h"
 #include "http_log.h"
Comment 5 Mike Lothian 2019-08-05 13:13:05 UTC
Hi

I can confirm that works on my RHEL5 build box

Thanks for the quick turnaround on the patch
Comment 6 Rainer Jung 2019-08-05 13:15:36 UTC
Thanks for testing.

Now we need someone doing a maintainer mode build with a more modern GCC, so that we can see, whether the warnings are still enabled but do no longer escalate to errors.
Comment 7 Mike Lothian 2019-08-05 14:17:31 UTC
I've ran the build though RHEL7 with your patch

It does compile but I'm seeing these messages in the logs:

mod_proxy_html.c:37:9: warning: unknown option after '#pragma GCC diagnostic' kind [-Wpragmas]
 #pragma GCC diagnostic ignored "-Werror=comment"
         ^
/apps/was/jenkins/workspace/Compile_HTTPD/apr-1.7.0/libtool --silent --mode=link gcc -std=gnu99 -I/usr/include/libxml2 -pthread  -O3 -march=corei7-avx -fPIE -fstack-protector-all -D_FORTIFY_SOURCE=2     -Wl,-z,now -Wl,-z,relro    -o mod_buffer.la -rpath /apps/was/apache/modules -module -avoid-version  mod_buffer.lo 
mod_xml2enc.c:32:9: warning: unknown option after '#pragma GCC diagnostic' kind [-Wpragmas]
 #pragma GCC diagnostic ignored "-Werror=comment"
         ^


That's with:

gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-36)
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Comment 8 Mike Lothian 2019-08-05 14:18:05 UTC
I probably should have said that didn't happen without the patch
Comment 9 Rainer Jung 2019-08-05 14:30:45 UTC
Thanks for testing and sorry for the trouble. Better with r1864435 applied on top?

What I do expect after the patch is, that the original warnings are shown but do not escalate to errors during maintainer mode compilation.
Comment 10 Rainer Jung 2019-08-05 18:56:07 UTC
My final list of patches that I proposed for 2.4.x is r1864435, r1864438, r1864450 and r1864451.

Without maintainer mode there should be no problems apart from possibly the expected warnings from some library header files we do not control. When using maintainer mode with clang or GCC >= 4.6, the -Werror should get toned down again to a warning (when processig those library headers). Using maintainer mode in combination with old GCC might break, but wasn't actually able to reproduce that breakage in Linux/Solaris. So maybe the unicode header files in question are just broken on MacOS, or it is just clang that complains.
Comment 11 Christophe JAILLET 2019-08-17 19:56:09 UTC
This has been backported in 2.4.x in r1864469.

This is part of 2.4.41.