[Spice-devel] [vdagent-linux] Add -fno-strict-aliasing to default CFLAGS

Christophe Fergeau cfergeau at redhat.com
Mon Jun 15 07:31:44 PDT 2015


Compilation breaks with older gcc versions (gcc (GCC) 4.4.7 20120313
(Red Hat 4.4.7-11) on RHEL6) with the following error (due to the
additional use of -Werror in the default CFLAGS)
CC     src/src_spice_vdagent-vdagent-x11-randr.o
cc1: warnings being treated as errors
src/vdagent-x11-randr.c: In function ‘vdagent_x11_randr_handle_event’:
src/vdagent-x11-randr.c:499: error: dereferencing pointer ‘sce’ does break strict-aliasing rules
src/vdagent-x11-randr.c:499: error: dereferencing pointer ‘sce’ does break strict-aliasing rules
src/vdagent-x11-randr.c:498: note: initialized from here
make: *** [src/src_spice_vdagent-vdagent-x11-randr.o] Error 1

Strict aliasing is not something we must have for the agent, and the
alternative would most likely involve an anonymous union, or some
casting. Given that this warning only occurs with these older compilers,
better to go with a fix as non-invasive as possible.

Resolves: https://bugs.freedesktop.org/show_bug.cgi?id=90981
---
 configure.ac | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/configure.ac b/configure.ac
index f559c2e..ca9a15b 100644
--- a/configure.ac
+++ b/configure.ac
@@ -130,7 +130,7 @@ fi
 
 # If no CFLAGS are set, set some sane default CFLAGS
 if test "$ac_test_CFLAGS" != set; then
-  DEFAULT_CFLAGS="-Wall -Werror -Wp,-D_FORTIFY_SOURCE=2 -fstack-protector --param=ssp-buffer-size=4"
+  DEFAULT_CFLAGS="-Wall -Werror -Wp,-D_FORTIFY_SOURCE=2 -fno-strict-aliasing -fstack-protector --param=ssp-buffer-size=4"
   for F in $DEFAULT_CFLAGS; do
     AC_MSG_CHECKING([whether $CC supports $F])
     save_CFLAGS="$CFLAGS"
-- 
2.4.3



More information about the Spice-devel mailing list