git: 944a4eb089b3 - main - stand/libsa/zfs: disable ZSTD_TRACE and DYNAMIC_BMI2 code paths

From: Ryan Libby <rlibby_at_FreeBSD.org>
Date: Thu, 07 May 2026 17:32:08 UTC
The branch main has been updated by rlibby:

URL: https://cgit.FreeBSD.org/src/commit/?id=944a4eb089b33241b21979253e0a373ce0bdf984

commit 944a4eb089b33241b21979253e0a373ce0bdf984
Author:     Ryan Libby <rlibby@FreeBSD.org>
AuthorDate: 2026-05-07 17:30:05 +0000
Commit:     Ryan Libby <rlibby@FreeBSD.org>
CommitDate: 2026-05-07 17:30:05 +0000

    stand/libsa/zfs: disable ZSTD_TRACE and DYNAMIC_BMI2 code paths
    
    Enabling ZSTD_TRACE leaves behind undefined weak symbols, which causes a
    problem for gcc builds.  The bfd linker emits an obscure error about
    overlapping FDEs.  We don't need ZSTD_TRACE for libsa, so just disable
    it.
    
    Also disable BMI2 instruction optimizations.  The addition of the
    optional BMI2 code paths caused the boot loader binaries to grow larger
    (28 KiB for clang, 32 KiB for gcc).  The boot loader binaries are size
    constrained, and this pushed the gcc-generated lua_loader.bin over the
    500000 byte limit, and the clang one to within 4k of the limit.
    
    Fixes:  8a62a2a5659d ("zfs: merge openzfs/zfs@f8e5af53e")
    Reviewed by:    delphij, imp, mm
    Differential Revision:  https://reviews.freebsd.org/D56866
---
 stand/libsa/zfs/Makefile.inc | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/stand/libsa/zfs/Makefile.inc b/stand/libsa/zfs/Makefile.inc
index 3df6779559c9..540635d144ef 100644
--- a/stand/libsa/zfs/Makefile.inc
+++ b/stand/libsa/zfs/Makefile.inc
@@ -75,9 +75,13 @@ CFLAGS.zfs.c+=	-DHAS_ZSTD_ZFS					\
 #
 # ZSTD coding style has some issues, so suppress clang's warnings. Also, zstd's
 # use of BMI instrucitons is broken in this environment, so avoid them.
+# Avoid generating the DYNAMIC_BMI2 code paths because the code duplication
+# inflates the resulting binaries.  Disable ZSTD_TRACE because we don't need it
+# and the bfd linker trips over the weak undefined symbols it generates.
 #
 .for i in ${ZSTD_SRC}
-CFLAGS.$i+=	-U__BMI__ ${NO_WBITWISE_INSTEAD_OF_LOGICAL}
+CFLAGS.$i+=	-U__BMI__ -DDYNAMIC_BMI2=0 -DZSTD_TRACE=0	\
+		${NO_WBITWISE_INSTEAD_OF_LOGICAL}
 .endfor
 
 CFLAGS.zfs_zstd.c+= -DIN_BASE -DIN_LIBSA