]> git.ipfire.org Git - thirdparty/haproxy.git/commitdiff
[BUILD] add -fno-strict-aliasing to fix warnings with gcc >= 4.4
authorWilly Tarreau <w@1wt.eu>
Sun, 28 Nov 2010 07:28:15 +0000 (08:28 +0100)
committerWilly Tarreau <w@1wt.eu>
Sun, 28 Nov 2010 07:57:53 +0000 (08:57 +0100)
Gcc 4.4 enables strict aliasing by default, resuling in complaints
when casting struct sockaddr_storage to sockaddr_in. Not only doing
this does not provide any noticeable performance improvement, it also
presents a risk of strange bugs even when the compiler does not emit
a warning, so let's disable this optimization !

Makefile
Makefile.bsd
Makefile.osx

index fc7d85f112db382ec80879f0a648bc3e75f66316..6d3f15651623890bf26637c8559775a4a47b86dc 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -97,6 +97,11 @@ LD = $(CC)
 # Those flags only feed CFLAGS so it is not mandatory to use this form.
 DEBUG_CFLAGS = -g
 
+#### Compiler-specific flags that may be used to disable some negative over-
+# optimization or to silence some warnings. -fno-strict-aliasing is needed with
+# gcc >= 4.4.
+SPEC_CFLAGS = -fno-strict-aliasing
+
 #### Memory usage tuning
 # If small memory footprint is required, you can reduce the buffer size. There
 # are 2 buffers per concurrent session, so 16 kB buffers will eat 32 MB memory
@@ -154,7 +159,7 @@ ARCH_FLAGS        = $(ARCH_FLAGS.$(ARCH))
 # These CFLAGS contain general optimization options, CPU-specific optimizations
 # and debug flags. They may be overridden by some distributions which prefer to
 # set all of them at once instead of playing with the CPU and DEBUG variables.
-CFLAGS = $(ARCH_FLAGS) $(CPU_CFLAGS) $(DEBUG_CFLAGS)
+CFLAGS = $(ARCH_FLAGS) $(CPU_CFLAGS) $(DEBUG_CFLAGS) $(SPEC_CFLAGS)
 
 #### Common LDFLAGS
 # These LDFLAGS are used as the first "ld" options, regardless of any library
index 5027830431a233463341202c4739a0fa672c321a..1ce871b72420a43b80b50f17b7f3bc767b745c6b 100644 (file)
@@ -86,6 +86,7 @@ DLMALLOC_THRES=4096
 TARGET_OPTS=$(COPTS.$(TARGET))
 REGEX_OPTS=$(COPTS.$(REGEX))
 CPU_OPTS=$(COPTS.$(CPU))
+SPEC_OPTS=-fno-strict-aliasing
 
 VERSION != cat VERSION 2>/dev/null || touch VERSION
 SUBVERS != cat SUBVERS 2>/dev/null || touch SUBVERS
@@ -98,7 +99,7 @@ VER_OPTS := -DCONFIG_HAPROXY_VERSION=\"$(VERSION)$(SUBVERS)\" \
 EBTREE_DIR := ebtree
 
 COPTS   = -Iinclude -I$(EBTREE_DIR) $(ADDINC) $(CPU_OPTS) $(TARGET_OPTS) \
-          $(REGEX_OPTS) $(SMALL_OPTS) $(VER_OPTS) $(DEFINE)
+          $(SPEC_OPTS) $(REGEX_OPTS) $(SMALL_OPTS) $(VER_OPTS) $(DEFINE)
 LIBS    = $(LIBS.$(TARGET)) $(LIBS.$(REGEX)) $(ADDLIB)
 CFLAGS  = -Wall $(COPTS) $(DEBUG)
 LDFLAGS = -g
index ab15e10764e125d9bf6d6da710594b79949a7f1c..f60508e99a9fa8becc79046b7f25f62edbc372f5 100644 (file)
@@ -86,6 +86,7 @@ DLMALLOC_THRES=4096
 TARGET_OPTS=$(COPTS.$(TARGET))
 REGEX_OPTS=$(COPTS.$(REGEX))
 CPU_OPTS=$(COPTS.$(CPU))
+SPEC_OPTS=-fno-strict-aliasing
 
 VERSION != cat VERSION 2>/dev/null || touch VERSION
 SUBVERS != cat SUBVERS 2>/dev/null || touch SUBVERS
@@ -95,7 +96,7 @@ VER_OPTS := -DCONFIG_HAPROXY_VERSION=\"$(VERSION)$(SUBVERS)\" \
             -DCONFIG_HAPROXY_DATE=\"$(VERDATE)\"
 
 COPTS   = -Iinclude -I$(EBTREE_DIR) $(ADDINC) $(CPU_OPTS) $(TARGET_OPTS) \
-          $(REGEX_OPTS) $(SMALL_OPTS) $(VER_OPTS) $(DEFINE)
+          $(SPEC_OPTS) $(REGEX_OPTS) $(SMALL_OPTS) $(VER_OPTS) $(DEFINE)
 LIBS    = $(LIBS.$(TARGET)) $(LIBS.$(REGEX)) $(ADDLIB)
 CFLAGS  = -Wall $(COPTS) $(DEBUG) -isysroot /Developer/SDKs/MacOSX10.4u.sdk -arch ppc -arch i386 -mmacosx-version-min=10.4
 LDFLAGS = -g -isysroot /Developer/SDKs/MacOSX10.4u.sdk -arch ppc -arch i386 -mmacosx-version-min=10.4