Disable strict aliasing with gcc where vtree.h is used

Please replace this commit with a better solution, if you have one.

e1ac5933 brought us the VRBT node
color encoded in the lower two bits of pointers.

gcc strict aliasing rules (as enabled with -O2 and higher) forbid
aliased lvalue access as in the following macro expanded code:

(*(uintptr_t *)&(parent)->entry.rbe_parent) &= ~((uintptr_t)3);

Until we have a better solution, disable strict aliasing with gcc
for targets with any source file using vtree.h.

Note that we would want to limit -fno-strict-aliasing to individual
compliation units, but automake does not offer a simple and clean way
to achieve this:

https://www.gnu.org/software/automake/manual/html_node/Per_002dObject-Flags.html
parent 8a913e2b
......@@ -159,6 +159,7 @@ nobase_pkginclude_HEADERS = \
vcldir=$(datarootdir)/$(PACKAGE)/vcl
varnishd_CFLAGS = \
@vtree_extra_cflags@ \
@PCRE_CFLAGS@ \
@SAN_CFLAGS@ \
-DNOT_IN_A_VMOD \
......
......@@ -13,6 +13,7 @@ varnishtop_SOURCES = \
varnishtop_CFLAGS = \
@vtree_extra_cflags@ \
@SAN_CFLAGS@
varnishtop_LDADD = \
......
......@@ -291,6 +291,8 @@ CFLAGS="${save_CFLAGS}"
if test "x$GCC" = "xyes"; then
libvgz_extra_cflags="${libvgz_extra_cflags} -Wno-unknown-warning-option -Wno-implicit-fallthrough"
AC_SUBST(libvgz_extra_cflags)
vtree_extra_cflags="-fno-strict-aliasing"
AC_SUBST(vtree_extra_cflags)
fi
SAN_CFLAGS=
......
......@@ -37,6 +37,7 @@ endif
libvarnishapi_la_CFLAGS = \
-DVARNISH_STATE_DIR='"${VARNISH_STATE_DIR}"' \
@vtree_extra_cflags@ \
@SAN_CFLAGS@
libvarnishapi_la_LIBADD = \
......
......@@ -9,6 +9,7 @@ AM_CPPFLAGS = \
noinst_LIBRARIES = libvcc.a
libvcc_a_CFLAGS = \
@vtree_extra_cflags@ \
@SAN_CFLAGS@
libvcc_a_SOURCES = \
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment