[libvirt] [PATCH] build: avoid warnings on older gcc

The previous patch pulled in a newer version of stat-time.h from gnulib, which tries to suppress some stupid gcc warnings (see <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54113>) by exploiting a feature of newer gcc. But we still aim to compile on RHEL 6.3, with gcc 4.4.6 (not to mention even older devel platforms like RHEL 5), which fails to build thanks to our development -Werror. It took me a while to figure out how to make our set of warnings smaller on older gcc without losing the benefit of the warnings when using newer gcc (such as the one on Fedora 17), but this should do the trick. * m4/virt-compile-warnings.m4 (LIBVIRT_COMPILE_WARNINGS): Avoid warnings that gnulib can't silence on older gcc. --- If I don't get a review by tomorrow, I will go ahead and push this under the build-breaker rule. m4/virt-compile-warnings.m4 | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/m4/virt-compile-warnings.m4 b/m4/virt-compile-warnings.m4 index 9dee000..702506d 100644 --- a/m4/virt-compile-warnings.m4 +++ b/m4/virt-compile-warnings.m4 @@ -58,6 +58,23 @@ AC_DEFUN([LIBVIRT_COMPILE_WARNINGS],[ # Gnulib's stat-time.h violates this dontwarn="$dontwarn -Waggregate-return" + # Gnulib uses '#pragma GCC diagnostic push' to silence some + # warnings, but older gcc doesn't support this. + AC_CACHE_VAL([lv_cv_gcc_pragma_push_works], [ + save_CFLAGS=$CFLAGS + CFLAGS=-Wunknown-pragmas + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ + #pragma GCC diagnostic push + #pragma GCC diagnostic pop + ]])], + [lv_cv_gcc_pragma_push_works=yes], + [lv_cv_gcc_pragma_push_works=no]) + CFLAGS=$save_CFLAGS]) + if test $lv_cv_gcc_pragma_push_works = no; then + dontwarn="$dontwarn -Wmissing-prototypes" + dontwarn="$dontwarn -Wmissing-declarations" + fi + # We might fundamentally need some of these disabled forever, but # ideally we'd turn many of them on dontwarn="$dontwarn -Wfloat-equal" -- 1.7.11.2

On Tue, Aug 14, 2012 at 04:42:24PM -0600, Eric Blake wrote:
The previous patch pulled in a newer version of stat-time.h from gnulib, which tries to suppress some stupid gcc warnings (see <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54113>) by exploiting a feature of newer gcc. But we still aim to compile on RHEL 6.3, with gcc 4.4.6 (not to mention even older devel platforms like RHEL 5), which fails to build thanks to our development -Werror.
It took me a while to figure out how to make our set of warnings smaller on older gcc without losing the benefit of the warnings when using newer gcc (such as the one on Fedora 17), but this should do the trick.
* m4/virt-compile-warnings.m4 (LIBVIRT_COMPILE_WARNINGS): Avoid warnings that gnulib can't silence on older gcc. ---
If I don't get a review by tomorrow, I will go ahead and push this under the build-breaker rule.
m4/virt-compile-warnings.m4 | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+)
diff --git a/m4/virt-compile-warnings.m4 b/m4/virt-compile-warnings.m4 index 9dee000..702506d 100644 --- a/m4/virt-compile-warnings.m4 +++ b/m4/virt-compile-warnings.m4 @@ -58,6 +58,23 @@ AC_DEFUN([LIBVIRT_COMPILE_WARNINGS],[ # Gnulib's stat-time.h violates this dontwarn="$dontwarn -Waggregate-return"
+ # Gnulib uses '#pragma GCC diagnostic push' to silence some + # warnings, but older gcc doesn't support this. + AC_CACHE_VAL([lv_cv_gcc_pragma_push_works], [ + save_CFLAGS=$CFLAGS + CFLAGS=-Wunknown-pragmas + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ + #pragma GCC diagnostic push + #pragma GCC diagnostic pop + ]])], + [lv_cv_gcc_pragma_push_works=yes], + [lv_cv_gcc_pragma_push_works=no]) + CFLAGS=$save_CFLAGS]) + if test $lv_cv_gcc_pragma_push_works = no; then + dontwarn="$dontwarn -Wmissing-prototypes" + dontwarn="$dontwarn -Wmissing-declarations" + fi + # We might fundamentally need some of these disabled forever, but # ideally we'd turn many of them on dontwarn="$dontwarn -Wfloat-equal"
Looks reasonable, ACK, Daniel -- Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/ daniel@veillard.com | Rpmfind RPM search engine http://rpmfind.net/ http://veillard.com/ | virtualization library http://libvirt.org/

On 08/15/2012 12:42 AM, Eric Blake wrote:
The previous patch pulled in a newer version of stat-time.h from gnulib, which tries to suppress some stupid gcc warnings (see <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54113>) by exploiting a feature of newer gcc. But we still aim to compile on RHEL 6.3, with gcc 4.4.6 (not to mention even older devel platforms like RHEL 5), which fails to build thanks to our development -Werror.
It took me a while to figure out how to make our set of warnings smaller on older gcc without losing the benefit of the warnings when using newer gcc (such as the one on Fedora 17), but this should do the trick.
* m4/virt-compile-warnings.m4 (LIBVIRT_COMPILE_WARNINGS): Avoid warnings that gnulib can't silence on older gcc. ---
If I don't get a review by tomorrow, I will go ahead and push this under the build-breaker rule.
m4/virt-compile-warnings.m4 | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+)
diff --git a/m4/virt-compile-warnings.m4 b/m4/virt-compile-warnings.m4 index 9dee000..702506d 100644 --- a/m4/virt-compile-warnings.m4 +++ b/m4/virt-compile-warnings.m4 @@ -58,6 +58,23 @@ AC_DEFUN([LIBVIRT_COMPILE_WARNINGS],[ # Gnulib's stat-time.h violates this dontwarn="$dontwarn -Waggregate-return"
+ # Gnulib uses '#pragma GCC diagnostic push' to silence some + # warnings, but older gcc doesn't support this. + AC_CACHE_VAL([lv_cv_gcc_pragma_push_works], [ + save_CFLAGS=$CFLAGS + CFLAGS=-Wunknown-pragmas + AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[ + #pragma GCC diagnostic push + #pragma GCC diagnostic pop + ]])], + [lv_cv_gcc_pragma_push_works=yes], + [lv_cv_gcc_pragma_push_works=no]) + CFLAGS=$save_CFLAGS]) + if test $lv_cv_gcc_pragma_push_works = no; then + dontwarn="$dontwarn -Wmissing-prototypes" + dontwarn="$dontwarn -Wmissing-declarations" + fi + # We might fundamentally need some of these disabled forever, but # ideally we'd turn many of them on dontwarn="$dontwarn -Wfloat-equal"
Hi Eric, I assume this was intended to suppress errors like this here: CC libvirt_driver_storage_la-storage_backend.lo cc1: warnings being treated as errors In file included from ../../src/storage/storage_backend.c:59: ../../gnulib/lib/stat-time.h:55: error: no previous prototype for 'get_stat_atime_ns' [-Wmissing-prototypes] ../../gnulib/lib/stat-time.h:68: error: no previous prototype for 'get_stat_ctime_ns' [-Wmissing-prototypes] ../../gnulib/lib/stat-time.h:81: error: no previous prototype for 'get_stat_mtime_ns' [-Wmissing-prototypes] ../../gnulib/lib/stat-time.h:94: error: no previous prototype for 'get_stat_birthtime_ns' [-Wmissing-prototypes] ../../gnulib/lib/stat-time.h:109: error: no previous prototype for 'get_stat_atime' [-Wmissing-prototypes] ../../gnulib/lib/stat-time.h:123: error: no previous prototype for 'get_stat_ctime' [-Wmissing-prototypes] ../../gnulib/lib/stat-time.h:137: error: no previous prototype for 'get_stat_mtime' [-Wmissing-prototypes] ../../gnulib/lib/stat-time.h:152: error: no previous prototype for 'get_stat_birthtime' [-Wmissing-prototypes] unfortunately, even applying the patch above and rerunning bootstrap, configure, make didn't help and I'm still getting the errors ... the interesting thing is that pragma push seems to work... I am compiling on RHEL6.2, gcc 4.4.6 grep pragma_push config.log lv_cv_gcc_pragma_push_works=yes -- Mit freundlichen Grüßen/Kind Regards Viktor Mihajlovski IBM Deutschland Research & Development GmbH Vorsitzender des Aufsichtsrats: Martin Jetter Geschäftsführung: Dirk Wittkopp Sitz der Gesellschaft: Böblingen Registergericht: Amtsgericht Stuttgart, HRB 243294

On 08/15/2012 09:24 AM, Viktor Mihajlovski wrote:
On 08/15/2012 12:42 AM, Eric Blake wrote:
The previous patch pulled in a newer version of stat-time.h from gnulib, which tries to suppress some stupid gcc warnings (see <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54113>) by exploiting a feature of newer gcc. But we still aim to compile on RHEL 6.3, with gcc 4.4.6 (not to mention even older devel platforms like RHEL 5), which fails to build thanks to our development -Werror.
+++ b/m4/virt-compile-warnings.m4 @@ -58,6 +58,23 @@ AC_DEFUN([LIBVIRT_COMPILE_WARNINGS],[ # Gnulib's stat-time.h violates this dontwarn="$dontwarn -Waggregate-return"
+ # Gnulib uses '#pragma GCC diagnostic push' to silence some + # warnings, but older gcc doesn't support this. + AC_CACHE_VAL([lv_cv_gcc_pragma_push_works], [
I want to use AC_CACHE_CHECK instead of AC_CACHE_VAL anyways, so I'll send a v2.
+ save_CFLAGS=$CFLAGS + CFLAGS=-Wunknown-pragmas
If you change this line, does it help? CFLAGS='-Wunknown-pragmas -Werror'
Hi Eric,
I assume this was intended to suppress errors like this here:
CC libvirt_driver_storage_la-storage_backend.lo cc1: warnings being treated as errors In file included from ../../src/storage/storage_backend.c:59: ../../gnulib/lib/stat-time.h:55: error: no previous prototype for 'get_stat_atime_ns' [-Wmissing-prototypes]
Yep. And I need to mention that in my commit message.
unfortunately, even applying the patch above and rerunning bootstrap, configure, make didn't help and I'm still getting the errors ... the interesting thing is that pragma push seems to work... I am compiling on RHEL6.2, gcc 4.4.6
I'm still investigating why it worked for me. I may have had a stale config.cache interfering with what I posted vs. what I tested earlier. Look for a v2 soon. -- Eric Blake eblake@redhat.com +1-919-301-3266 Libvirt virtualization library http://libvirt.org

On 08/15/2012 05:29 PM, Eric Blake wrote:
On 08/15/2012 09:24 AM, Viktor Mihajlovski wrote:
On 08/15/2012 12:42 AM, Eric Blake wrote:
The previous patch pulled in a newer version of stat-time.h from gnulib, which tries to suppress some stupid gcc warnings (see <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54113>) by exploiting a feature of newer gcc. But we still aim to compile on RHEL 6.3, with gcc 4.4.6 (not to mention even older devel platforms like RHEL 5), which fails to build thanks to our development -Werror.
+++ b/m4/virt-compile-warnings.m4 @@ -58,6 +58,23 @@ AC_DEFUN([LIBVIRT_COMPILE_WARNINGS],[ # Gnulib's stat-time.h violates this dontwarn="$dontwarn -Waggregate-return"
+ # Gnulib uses '#pragma GCC diagnostic push' to silence some + # warnings, but older gcc doesn't support this. + AC_CACHE_VAL([lv_cv_gcc_pragma_push_works], [
I want to use AC_CACHE_CHECK instead of AC_CACHE_VAL anyways, so I'll send a v2.
+ save_CFLAGS=$CFLAGS + CFLAGS=-Wunknown-pragmas
If you change this line, does it help?
CFLAGS='-Wunknown-pragmas -Werror'
Hi Eric,
I assume this was intended to suppress errors like this here:
CC libvirt_driver_storage_la-storage_backend.lo cc1: warnings being treated as errors In file included from ../../src/storage/storage_backend.c:59: ../../gnulib/lib/stat-time.h:55: error: no previous prototype for 'get_stat_atime_ns' [-Wmissing-prototypes]
Yep. And I need to mention that in my commit message.
unfortunately, even applying the patch above and rerunning bootstrap, configure, make didn't help and I'm still getting the errors ... the interesting thing is that pragma push seems to work... I am compiling on RHEL6.2, gcc 4.4.6
I'm still investigating why it worked for me. I may have had a stale config.cache interfering with what I posted vs. what I tested earlier. Look for a v2 soon.
I changed to AC_CACHE_CHECK and added -Werror but for some reason the CFLAGS won't get passed to the compilation ... configure:53231: checking lv_cv_gcc_pragma_push_works configure:53250: gcc -std=gnu99 -c -g -O2 conftest.c >&5 conftest.c:460: warning: expected [error|warning|ignored] after '#pragma GCC diagnostic' conftest.c:461: warning: expected [error|warning|ignored] after '#pragma GCC diagnostic' configure:53250: $? = 0 configure:53276: gcc -std=gnu99 -c -g -O2 conftest.c >&5 conftest.c:460: warning: expected [error|warning|ignored] after '#pragma GCC diagnostic' conftest.c:461: warning: expected [error|warning|ignored] after '#pragma GCC diagnostic' -- Mit freundlichen Grüßen/Kind Regards Viktor Mihajlovski IBM Deutschland Research & Development GmbH Vorsitzender des Aufsichtsrats: Martin Jetter Geschäftsführung: Dirk Wittkopp Sitz der Gesellschaft: Böblingen Registergericht: Amtsgericht Stuttgart, HRB 243294

CFLAGS='-Wunknown-pragmas -Werror' worked for me. On 08/15/2012 12:29 PM, Eric Blake wrote:
On 08/15/2012 09:24 AM, Viktor Mihajlovski wrote:
On 08/15/2012 12:42 AM, Eric Blake wrote:
The previous patch pulled in a newer version of stat-time.h from gnulib, which tries to suppress some stupid gcc warnings (see <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54113>) by exploiting a feature of newer gcc. But we still aim to compile on RHEL 6.3, with gcc 4.4.6 (not to mention even older devel platforms like RHEL 5), which fails to build thanks to our development -Werror.
+++ b/m4/virt-compile-warnings.m4 @@ -58,6 +58,23 @@ AC_DEFUN([LIBVIRT_COMPILE_WARNINGS],[ # Gnulib's stat-time.h violates this dontwarn="$dontwarn -Waggregate-return"
+ # Gnulib uses '#pragma GCC diagnostic push' to silence some + # warnings, but older gcc doesn't support this. + AC_CACHE_VAL([lv_cv_gcc_pragma_push_works], [
I want to use AC_CACHE_CHECK instead of AC_CACHE_VAL anyways, so I'll send a v2.
+ save_CFLAGS=$CFLAGS + CFLAGS=-Wunknown-pragmas
If you change this line, does it help?
CFLAGS='-Wunknown-pragmas -Werror'
Hi Eric,
I assume this was intended to suppress errors like this here:
CC libvirt_driver_storage_la-storage_backend.lo cc1: warnings being treated as errors In file included from ../../src/storage/storage_backend.c:59: ../../gnulib/lib/stat-time.h:55: error: no previous prototype for 'get_stat_atime_ns' [-Wmissing-prototypes]
Yep. And I need to mention that in my commit message.
unfortunately, even applying the patch above and rerunning bootstrap, configure, make didn't help and I'm still getting the errors ... the interesting thing is that pragma push seems to work... I am compiling on RHEL6.2, gcc 4.4.6
I'm still investigating why it worked for me. I may have had a stale config.cache interfering with what I posted vs. what I tested earlier. Look for a v2 soon.
-- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list
participants (4)
-
Daniel Veillard
-
Eric Blake
-
Marcelo Cerri
-
Viktor Mihajlovski