[master] 599b183d3 Silence gcc strict aliasing warnings where vtree.h is used

Nils Goroll nils.goroll at uplex.de
Sat Mar 27 18:14:04 UTC 2021


commit 599b183d3f34d5280bddb2abf755ca8b4cfe768b
Author: Nils Goroll <nils.goroll at uplex.de>
Date:   Sat Mar 27 19:00:40 2021 +0100

    Silence gcc strict aliasing warnings where vtree.h is used
    
    Please relace the vtree.h #pragma change of this commit with a better
    solution once you have one.
    
    777e03ba9774bf635a972fa0561b50ff071908a9 had the disadvantage that it
    requires all vmods to adjust their build, besides affecting more code
    than necessary.
    
    Under the assumption that the issue with VRBT is not acutally a
    violation of strict aliasing, but rather only a violation of gcc's
    pedantic "compatible lvalue rule", we silence gcc warnings rather than
    turning off strict aliasing.
    
    Note that this is more convenient, but also more dangerous, because we
    fail to catch any actual strict aliasing errors where vtree.h is used.
    
    This reverts commit 777e03ba9774bf635a972fa0561b50ff071908a9.

diff --git a/bin/varnishd/Makefile.am b/bin/varnishd/Makefile.am
index 76a47ad2c..ce7145efd 100644
--- a/bin/varnishd/Makefile.am
+++ b/bin/varnishd/Makefile.am
@@ -159,7 +159,6 @@ nobase_pkginclude_HEADERS = \
 vcldir=$(datarootdir)/$(PACKAGE)/vcl
 
 varnishd_CFLAGS = \
-	@vtree_extra_cflags@ \
 	@PCRE_CFLAGS@ \
 	@SAN_CFLAGS@ \
 	-DNOT_IN_A_VMOD \
diff --git a/bin/varnishtop/Makefile.am b/bin/varnishtop/Makefile.am
index 0427e1140..cdb63b5f8 100644
--- a/bin/varnishtop/Makefile.am
+++ b/bin/varnishtop/Makefile.am
@@ -13,7 +13,6 @@ varnishtop_SOURCES = \
 
 
 varnishtop_CFLAGS = \
-	@vtree_extra_cflags@ \
 	@SAN_CFLAGS@
 
 varnishtop_LDADD = \
diff --git a/configure.ac b/configure.ac
index 9fcfb5693..59aa57b9e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -291,8 +291,6 @@ 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=
diff --git a/include/vtree.h b/include/vtree.h
index c652c48d8..6fb2fdaae 100644
--- a/include/vtree.h
+++ b/include/vtree.h
@@ -32,6 +32,10 @@
 #ifndef	_VTREE_H_
 #define	_VTREE_H_
 
+/* XXX
+ * Enable -Wall with gcc -O2
+ */
+#pragma GCC diagnostic ignored "-Wstrict-aliasing"
 
 /*
  * This file defines data structures for different types of trees:
@@ -832,5 +836,4 @@ name##_VRBT_REINSERT(struct name *head, struct type *elm)			\
 	for ((x) = VRBT_MAX(name, head);					\
 	    ((x) != NULL) && ((y) = name##_VRBT_PREV(x), (x) != NULL);	\
 	     (x) = (y))
-
 #endif	/* _VTREE_H_ */
diff --git a/lib/libvarnishapi/Makefile.am b/lib/libvarnishapi/Makefile.am
index a2a314581..0cbff3c4d 100644
--- a/lib/libvarnishapi/Makefile.am
+++ b/lib/libvarnishapi/Makefile.am
@@ -37,7 +37,6 @@ endif
 
 libvarnishapi_la_CFLAGS = \
 	-DVARNISH_STATE_DIR='"${VARNISH_STATE_DIR}"' \
-	@vtree_extra_cflags@ \
 	@SAN_CFLAGS@
 
 libvarnishapi_la_LIBADD = \
diff --git a/lib/libvcc/Makefile.am b/lib/libvcc/Makefile.am
index 965e0b3f4..1e3d6f2d0 100644
--- a/lib/libvcc/Makefile.am
+++ b/lib/libvcc/Makefile.am
@@ -9,7 +9,6 @@ AM_CPPFLAGS = \
 noinst_LIBRARIES = libvcc.a
 
 libvcc_a_CFLAGS = \
-	@vtree_extra_cflags@ \
 	@SAN_CFLAGS@
 
 libvcc_a_SOURCES = \


More information about the varnish-commit mailing list