af126b8f0cf9ddc553a78869a3c820a4bd4fdc59 braney Mon Aug 17 13:36:13 2026 -0700 build: link the browser against zlib-ng instead of the system zlib, refs #38125 Adds zlib-ng as a second git submodule, alongside htslib, and points ZLIB at it. It is built with --zlib-compat, so the header and the symbol names are the ordinary zlib ones and no calling code has to change. Measured over the eight Recommended Track Set pages, hgTracks uses 29 percent less processor time and 26 percent less wall clock, and the image it produces is pixel identical. Writing the PNG is about three times faster and reading a bigBed data block about twice as fast, which is why the gain is larger than the image work alone would give. This also makes the platforms agree. x86_64 was linking a static /lib64/libz.a only because that file happened to be present, the arm64 Docker build fell through to a shared -lz, and Darwin was taking MacPorts zlib. All three now use the submodule. Verified on x86_64 Linux, aarch64 Linux and Apple silicon: zlib-ng builds, its own test suite passes, the makefiles pick it up, and bigBedToBed output is byte identical to before the change. diff --git src/inc/common.mk src/inc/common.mk index f16671ddcf0..0a78054e177 100644 --- src/inc/common.mk +++ src/inc/common.mk @@ -56,51 +56,54 @@ endif L = ${STATIC_PRE} ifeq (${HOSTNAME},hgwdev) IS_HGWDEV = yes OURSTUFF = /cluster/software/r9 else ifeq (${HOSTNAME},hgwdev-old.gi.ucsc.edu) IS_HGWDEV = yes OURSTUFF = /cluster/software else IS_HGWDEV = no endif endif +# zlib comes from the zlib-ng submodule in submodules/zlib-ng, built in +# zlib-compat mode so the header and the symbols are the ordinary zlib ones, and +# linked statically the way htslib is. zlib-ng writes a PNG about three times +# faster and reads a bigBed block about twice as fast, and its output is ordinary +# deflate that any zlib can read. Building it here also makes the platforms +# agree: before this, x86_64 happened to find a static /lib64/libz.a while the +# arm64 build fell through to a shared -lz. Override on the make command line +# with ZLIB=... to link some other zlib. refs #38125 ifeq (${ZLIB},) - ifneq ($(wildcard /lib64/libz.a),) - ZLIB=/lib64/libz.a - else - ZLIB=-lz - endif + ZLIB=$(kentSrc)/submodules/zlib-ng/libz.a endif # for Darwin (Mac OSX), use static libs when they can be found ifeq ($(UNAME_S),Darwin) ifneq ($(wildcard /opt/local/include/openssl/ssl.h),) HG_INC += -I/opt/local/include endif # on M1, the directory changed ifneq ($(wildcard /opt/homebrew/include/openssl/ssl.h),) HG_INC += -I/opt/homebrew/include L += -L/opt/homebrew/lib/ endif - ifneq ($(wildcard /opt/local/lib/libz.a),) - ZLIB = /opt/local/lib/libz.a - endif + # no ZLIB line here: Darwin uses the zlib-ng submodule like every other + # platform. refs #38125 ifneq ($(wildcard /opt/local/lib/libpng.a),) PNGLIB = /opt/local/lib/libpng.a endif ifeq (${BZ2LIB},) ifneq ($(wildcard /opt/local/lib/libbz2.a),) BZ2LIB=/opt/local/lib/libbz2.a endif endif ifneq ($(wildcard /opt/local/lib/libfreetype.a),) FREETYPELIBS = /opt/local/lib/libfreetype.a endif ifneq ($(wildcard /opt/local/lib/libbrotlidec.a),) FREETYPELIBS += /opt/local/lib/libbrotlidec.a /opt/local/lib/libbrotlicommon.a else ifneq ($(wildcard /usr/local/Cellar/brotli/1.1.0/lib/libbrotlidec.a),)