0939cd926f6ff4d587eafff011363540d2b05b53
braney
  Mon Jun 22 10:50:23 2026 -0700
Add -g to the default COPT so production -O3 builds keep debug symbols

Default COPT becomes "-O3 -g".  -g only emits DWARF debug sections; it does not
change code generation, so optimization is unaffected and the binary keeps gdb
symbols and meaningful apache stack traces.  An explicit COPT on the command
line or in the environment still overrides it.

Validated on hgwbeta by rendering a heavy Recommended Track Set session
(Non_Coding_SNVs hg38) at two ranges with -O3 vs -O3 -g binaries, 12 interleaved
iterations each: the two straddle each other within run-to-run noise (O3g 2.5%
faster on one range, 0.9% slower on the other), i.e. no measurable slowdown.

refs #37767 refs #37761

diff --git src/inc/common.mk src/inc/common.mk
index d16dacb8c2a..f16671ddcf0 100644
--- src/inc/common.mk
+++ src/inc/common.mk
@@ -9,31 +9,31 @@
 # 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
+    COPT=-O3 -g
 endif
 ifeq (${MACHTYPE},)
     MACHTYPE:=$(shell uname -m)
 #    $(info MACHTYPE was empty, set to: ${MACHTYPE})
 endif
 ifneq (,$(findstring -,$(MACHTYPE)))
 #    $(info MACHTYPE has - sign ${MACHTYPE})
     MACHTYPE:=$(shell uname -m)
 #    $(info MACHTYPE has - sign set to: ${MACHTYPE})
 endif
 
 HG_DEFS=-D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_GNU_SOURCE -DMACHTYPE_${MACHTYPE}
 HG_INC+=-I../inc -I../../inc -I../../../inc -I../../../../inc -I../../../../../inc -I$(kentSrc)/submodules/htslib
 
 # to check for Mac OSX Darwin specifics: