caab4045fa20627f1602955c53cacc05ea07de24 braney Fri Aug 14 11:01:17 2026 -0700 stop directory makefiles from overriding the tree compiler flags, refs #38094 hg/hgTracks/makefile has carried "COPT = -ggdb" since 2019-02-01. Every directory makefile includes inc/common.mk on its first line, so that assignment came after the tree default and replaced it. The result is that hgTracks itself has shipped with no optimization for seven years, while every library it links against was built with -O3. Building it with the tree default is 17.5% faster over a set of eight sessions, and 1.95x faster on a wide clinical view, with byte identical PNG output. Twenty three makefiles had a COPT or CFLAGS override. All are removed here. hg/visiGene/vgPrepImage keeps its defines, but appends them with += instead of assigning over the tree flags, because the ERMapper JPEG2000 headers need them. Compiling hg/hgTracks with optimization exposed seven errors that only appear under -O3. Four source files are fixed: hgTracks.c used an uninitialized labelfont, expRatioTracks.c and simpleTracks.c had five strncpy calls that could leave a string unterminated, and netTrack.c had two int buffers too small to hold the value written into them. The last two look like real latent bugs, not warning noise. checkCompileFlags.sh is added to stop this from recurring. The topChecks target runs it, so every build path reaches it. It fails the build on any COPT assignment, any CFLAGS assignment that is not +=, and any CFLAGS += carrying an -O flag. The check cannot live in inc/common.mk, because at the point common.mk is parsed the overriding line has not been read yet. A command line override such as "make COPT='-O0 -g'" still works, since the check reads only file contents. The 2026 conversion of the tree to -O3 did not find this. That work was driven by the warnings -O3 produces, and a directory that overrides COPT never receives the flag, so it never warns. Verified: the tree builds at -O3 with no new errors and no new warnings, and 80 rendered images compare pixel identical against the old build. diff --git src/hg/encode/docId/docIdTidy/makefile src/hg/encode/docId/docIdTidy/makefile index 78fef1405cd..8437ff80b8f 100644 --- src/hg/encode/docId/docIdTidy/makefile +++ src/hg/encode/docId/docIdTidy/makefile @@ -1,20 +1,19 @@ kentSrc = ../../../.. -COPT=-ggdb include ../../../../inc/common.mk L += $(MYSQLLIBS) -lm MYLIBDIR = ../../../../lib/${MACHTYPE} MYLIBS = $(MYLIBDIR)/docId.a $(MYLIBDIR)/jkhgap.a ${MYLIBDIR}/jkweb.a A = docIdTidy O = docIdTidy.o docIdTidy: ${O} ${MYLIBS} ${CC} ${COPT} -o ${DESTDIR}${BINDIR}/${A}${EXE} $O ${MYLIBS} $L # ${STRIP} ${DESTDIR}${BINDIR}/${A}${EXE} compile:: ${O} ${CC} ${COPT} -o ${A}${EXE} ${O} ${MYLIBS} $L clean:: rm -f ${A}${EXE} ${O}