37ea1c69ef1e3101a3fea67043162744ea57666d
braney
  Fri Jun 12 14:10:17 2026 -0700
common.mk: add -fno-strict-aliasing

The tree has long-standing type-punning idioms that violate strict aliasing,
notably the dlList sentinel trick in lib/dlist.c (which overlays struct dlNode
on struct dlList).  These were harmless under the old -O -g (-O1) default
because GCC does not enable -fstrict-aliasing until -O2.  With the -O3 default
they get miscompiled: blat, which uses dlList for stitching, silently produced
fragmented alignments and failed blat/test until -fno-strict-aliasing was added.
dlist is unlikely to be the only such violation, so disable the optimization
tree-wide rather than patch individual idioms.

refs #37761

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

diff --git src/inc/common.mk src/inc/common.mk
index 1264811397b..d16dacb8c2a 100644
--- src/inc/common.mk
+++ src/inc/common.mk
@@ -1,19 +1,25 @@
 # if CC is undefined, set it to gcc
 CC?=gcc
 # allow the somewhat more modern C syntax, e.g. 'for (int i=5; i<10, i++)'
 CFLAGS += -std=c99
+# Several long-standing idioms in the tree alias memory through incompatible
+# types (e.g. the dlList sentinel trick in lib/dlist.c, which overlays
+# struct dlNode on struct dlList).  -fstrict-aliasing (on at -O2 and above, but
+# not at -O1) miscompiles these, silently corrupting results.  Disable it so the
+# higher -O levels are safe.  refs #37761
+CFLAGS += -fno-strict-aliasing
 
 # This is required to get the cgiLoader.mk compile target to work.  for some
 # reason, make's %.o: %.c overrides the rule below, cause the compiles to fail
 # due to lack of -I flags in rule.  Running with make -r to not use built-in
 # rules fixes, however MAKEFLAGS += -r doesn't do the trick, this does.
 # make is a very mysterious fellow traveler.
 GNUMAKEFLAGS += -r
 
 # add additional library paths
 L += ${LDFLAGS}
 
 # to build on sundance: CC=gcc -mcpu=v9 -m64
 ifeq (${COPT},)
     COPT=-O3
 endif