build-sys: Use -fno-strict-aliasing by default
authorColin Walters <walters@verbum.org>
Fri, 15 Dec 2017 14:20:58 +0000 (09:20 -0500)
committerAtomic Bot <atomic-devel@projectatomic.io>
Fri, 15 Dec 2017 14:52:38 +0000 (14:52 +0000)
See discussion in https://bugzilla.gnome.org/show_bug.cgi?id=791622

This is what e.g. systemd, the Linux kernel, and lots of other projects do. It's
astonishingly hard to reliably get right; the optimization IMO only really
matters for truly high performance inner loops, but if you're doing
that kind of stuff today you're probably doing it on a GPU anyways.

Closes: #1384
Approved by: pwithnall

Makefile.am
configure.ac

index 6043b2aa2d6fc673f02364e9122751b1f3fc6802..ea1863d3dece2ce09db8b4371bd7df17cf7abd98 100644 (file)
@@ -31,7 +31,8 @@ AM_CPPFLAGS += -DDATADIR='"$(datadir)"' -DLIBEXECDIR='"$(libexecdir)"' \
   -DOSTREE_GITREV='"$(OSTREE_GITREV)"' \
        -DGLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_40 '-DGLIB_VERSION_MAX_ALLOWED=G_ENCODE_VERSION(2,50)' \
        -DSOUP_VERSION_MIN_REQUIRED=SOUP_VERSION_2_40 '-DSOUP_VERSION_MAX_ALLOWED=G_ENCODE_VERSION(2,48)'
-AM_CFLAGS += -std=gnu99 $(WARN_CFLAGS)
+# For strict aliasing, see https://bugzilla.gnome.org/show_bug.cgi?id=791622
+AM_CFLAGS += -std=gnu99 -fno-strict-aliasing $(WARN_CFLAGS)
 AM_DISTCHECK_CONFIGURE_FLAGS += \
        --enable-gtk-doc \
        --enable-man \
index e2c27822fcb697c89fe5e59fa85d02a729405ce9..36071c937e1f242a2ef2b2b7491ac266958d45f7 100644 (file)
@@ -48,6 +48,7 @@ CC_CHECK_FLAGS_APPEND([WARN_CFLAGS], [CFLAGS], [\
   -Werror=incompatible-pointer-types \
   -Werror=misleading-indentation \
   -Werror=missing-include-dirs -Werror=aggregate-return \
+  -Wstrict-aliasing=2 \
   -Werror=unused-result \
 ])])
 AC_SUBST(WARN_CFLAGS)