Hey, On Mon, Jun 04, 2012 at 12:08:20PM -0600, Eric Blake wrote: > glibc 2.15 (on Fedora 17) coupled with explicit disabling of > optimization during development dies a painful death: > > In file included from /usr/include/limits.h:27:0, > from > /usr/lib/gcc/x86_64-redhat-linux/4.7.0/include/limits.h:169, > from > /usr/lib/gcc/x86_64-redhat-linux/4.7.0/include/syslimits.h:7, > from > /usr/lib/gcc/x86_64-redhat-linux/4.7.0/include/limits.h:34, > from util/bitmap.c:26: > /usr/include/features.h:314:4: error: #warning _FORTIFY_SOURCE requires > compiling with optimization (-O) [-Werror=cpp] > cc1: all warnings being treated as errors > > Work around this by only conditionally defining _FORTIFY_SOURCE, > in the case where glibc can actually use it. The trick is using > AH_VERBATIM instead of AC_DEFINE. > > * m4/virt-compile-warnings.m4 (LIBVIRT_COMPILE_WARNINGS): Squelch > _FORTIFY_SOURCE when needed to avoid glibc #warnings. > --- > > Pushing under the build-breaker rule. > > m4/virt-compile-warnings.m4 | 8 ++++++-- > 1 file changed, 6 insertions(+), 2 deletions(-) > > diff --git a/m4/virt-compile-warnings.m4 b/m4/virt-compile-warnings.m4 > index 5527bff..a91d69f 100644 > --- a/m4/virt-compile-warnings.m4 > +++ b/m4/virt-compile-warnings.m4 > @@ -102,8 +102,12 @@ AC_DEFUN([LIBVIRT_COMPILE_WARNINGS],[ > # Silence certain warnings in gnulib, and use improved glibc headers > AC_DEFINE([lint], [1], > [Define to 1 if the compiler is checking for lint.]) > - AC_DEFINE([_FORTIFY_SOURCE], [2], > - [enable compile-time and run-time bounds-checking, and some warnings]) > + AH_VERBATIM([FORTIFY_SOURCE], > + [/* Enable compile-time and run-time bounds-checking, and some warnings. > */ > + #if __OPTIMIZE__ > + # define _FORTIFY_SOURCE 2 > + #endif > + ])
This is not causing an actual issue while compiling libvirt, but
__OPTIMIZE__ is not defined when using -O0, which causes a warning
with -Wundef
I've tested this with
$ gcc --version
gcc (GCC) 4.7.0 20120507 (Red Hat 4.7.0-5)
$ gcc -c -Wundef -O0 test.c
#if __OPTIMIZE__
#warning if __OPTIMIZE__
#endif
#ifdef __OPTIMIZE__
#warning ifdef __OPTIMIZE
#endif
Using a #ifdef would be more correct:
diff --git a/m4/virt-compile-warnings.m4 b/m4/virt-compile-warnings.m4
index a91d69f..0ea7276 100644
--- a/m4/virt-compile-warnings.m4
+++ b/m4/virt-compile-warnings.m4
@@ -104,7 +104,7 @@ AC_DEFUN([LIBVIRT_COMPILE_WARNINGS],[
[Define to 1 if the compiler is checking for lint.])
AH_VERBATIM([FORTIFY_SOURCE],
[/* Enable compile-time and run-time bounds-checking, and some
warnings. */
- #if __OPTIMIZE__
+ #ifdef __OPTIMIZE__
# define _FORTIFY_SOURCE 2
#endif
])
[
(or doing #ifdef __OPTIMIZE__ #if __OPTIMIZE .... if __OPTIMIZE__ was set
to 0 with -O0 with some gcc/libc versions)
Christophe
pgpyQdrb3dHpu.pgp
Description: PGP signature
-- libvir-list mailing list [email protected] https://www.redhat.com/mailman/listinfo/libvir-list
