git: 53811ed62379 - main - loader: Add defines for ZLIB_CFLAGS, BZIP2_CFLAGS and ZSTD_CFLAGS
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Fri, 26 Jun 2026 14:59:16 UTC
The branch main has been updated by imp:
URL: https://cgit.FreeBSD.org/src/commit/?id=53811ed6237972f92a80627ea2c17ece212315a7
commit 53811ed6237972f92a80627ea2c17ece212315a7
Author: Warner Losh <imp@FreeBSD.org>
AuthorDate: 2026-06-26 14:45:42 +0000
Commit: Warner Losh <imp@FreeBSD.org>
CommitDate: 2026-06-26 14:54:35 +0000
loader: Add defines for ZLIB_CFLAGS, BZIP2_CFLAGS and ZSTD_CFLAGS
These are scattered in several places, so centralize the setting of
these flags.
Sponsored by: Netflix
Differential Revision: https://reviews.freebsd.org/D57861
---
stand/defs.mk | 9 +++++++++
stand/efi/gptboot/Makefile | 2 +-
stand/efi/loader/Makefile | 3 ++-
stand/i386/gptboot/Makefile | 2 +-
stand/i386/gptzfsboot/Makefile | 2 +-
stand/i386/loader/Makefile | 2 +-
stand/libsa/Makefile | 3 +--
stand/loader.mk | 2 +-
stand/uboot/Makefile | 2 +-
9 files changed, 18 insertions(+), 9 deletions(-)
diff --git a/stand/defs.mk b/stand/defs.mk
index ac4f38451111..05108404c538 100644
--- a/stand/defs.mk
+++ b/stand/defs.mk
@@ -181,6 +181,15 @@ CFLAGS+= -fPIC
CFLAGS+= -mno-relax
.endif
+# ZLIB flags
+ZLIB_CFLAGS=-DHAVE_MEMCPY -I${SYSDIR}/contrib/zlib ${NO_WDEPRECATED_NON_PROTOTYPE}
+
+# BZIP2 flags
+BZIP2_CFLAGS=-I${SRCTOP}/contrib/bzip2 -DBZ_NO_STDIO -DBZ_NO_COMPRESS
+
+# ZSTD client cflags
+ZSTD_CFLAGS=-I${SYSDIR}/contrib/zstd/lib
+
# The boot loader build uses dd status=none, where possible, for reproducible
# build output (since performance varies from run to run). Trouble is that
# option was recently (10.3) added to FreeBSD and is non-standard. Only use it
diff --git a/stand/efi/gptboot/Makefile b/stand/efi/gptboot/Makefile
index 7d4c225bc5d4..a3c9c36597ff 100644
--- a/stand/efi/gptboot/Makefile
+++ b/stand/efi/gptboot/Makefile
@@ -11,7 +11,7 @@ MAN= gptboot.efi.8
CFLAGS+= -I${SRCTOP}/stand/efi/boot1
CFLAGS+= -I${.CURDIR}
CFLAGS+= -DBOOTPROG=\"gptboot.efi\"
-CFLAGS+= -DHAVE_MEMCPY -I${SRCTOP}/sys/contrib/zlib
+CFLAGS+= ${ZLIB_CFLAGS}
SRCS+= gpt.c
CWARNFLAGS.gpt.c+= -Wno-sign-compare -Wno-cast-align
WARNS?=6
diff --git a/stand/efi/loader/Makefile b/stand/efi/loader/Makefile
index addb7652249d..44d7347ee7dd 100644
--- a/stand/efi/loader/Makefile
+++ b/stand/efi/loader/Makefile
@@ -45,6 +45,7 @@ HAVE_ZFS= yes
CFLAGS.bootinfo.c += -I$(SRCTOP)/sys/teken
CFLAGS.bootinfo.c += -I${SRCTOP}/contrib/pnglite
+CFLAGS.decompress.c += ${ZLIB_CFLAGS} ${BZIP2_CFLAGS} ${ZSTD_CFLAGS}
CFLAGS.framebuffer.c += -I$(SRCTOP)/sys/teken
CFLAGS.framebuffer.c += -I${SRCTOP}/contrib/pnglite
CFLAGS.main.c += -I$(SRCTOP)/sys/teken
@@ -52,7 +53,7 @@ CFLAGS.main.c += -I${SRCTOP}/contrib/pnglite
CFLAGS.gfx_fb.c += -I$(SRCTOP)/sys/teken
CFLAGS.gfx_fb.c += -I${SRCTOP}/sys/cddl/contrib/opensolaris/common/lz4
CFLAGS.gfx_fb.c += -I${SRCTOP}/contrib/pnglite
-CFLAGS.gfx_fb.c += -DHAVE_MEMCPY -I${SRCTOP}/sys/contrib/zlib
+CFLAGS.gfx_fb.c += ${ZLIB_CFLAGS}
# We implement a slightly non-standard %S in that it always takes a
# CHAR16 that's common in UEFI-land instead of a wchar_t. This only
diff --git a/stand/i386/gptboot/Makefile b/stand/i386/gptboot/Makefile
index 366d82497819..d599c4f6b250 100644
--- a/stand/i386/gptboot/Makefile
+++ b/stand/i386/gptboot/Makefile
@@ -28,7 +28,7 @@ CFLAGS+=-DBOOTPROG=\"gptboot\" \
-I${LDRSRC} \
-I${BOOTSRC}/i386/common \
-I${BOOTSRC}/i386/boot2 \
- -DHAVE_MEMCPY -I${SRCTOP}/sys/contrib/zlib \
+ ${ZLIB_CFLAGS} \
-Wall -Waggregate-return -Wbad-function-cast -Wno-cast-align \
-Wmissing-declarations -Wmissing-prototypes -Wnested-externs \
-Wpointer-arith -Wshadow -Wstrict-prototypes -Wwrite-strings \
diff --git a/stand/i386/gptzfsboot/Makefile b/stand/i386/gptzfsboot/Makefile
index 2b3b5422031b..3ac711c6212f 100644
--- a/stand/i386/gptzfsboot/Makefile
+++ b/stand/i386/gptzfsboot/Makefile
@@ -36,7 +36,7 @@ CFLAGS+=-DBOOTPROG=\"gptzfsboot\" \
-I${SYSDIR}/cddl/contrib/opensolaris/common/lz4 \
-I${BOOTSRC}/i386/btx/lib \
-I${BOOTSRC}/i386/boot2 \
- -DHAVE_MEMCPY -I${SRCTOP}/sys/contrib/zlib \
+ ${ZLIB_CFLAGS} \
-Wall -Waggregate-return -Wbad-function-cast \
-Wmissing-declarations -Wmissing-prototypes -Wnested-externs \
-Wpointer-arith -Wshadow -Wstrict-prototypes -Wwrite-strings \
diff --git a/stand/i386/loader/Makefile b/stand/i386/loader/Makefile
index 96ad50a75509..fde389b9940e 100644
--- a/stand/i386/loader/Makefile
+++ b/stand/i386/loader/Makefile
@@ -56,7 +56,7 @@ CFLAGS.gfx_fb.c += -I${.CURDIR}/../libi386
CFLAGS.gfx_fb.c += -I$(SRCTOP)/sys/teken
CFLAGS.gfx_fb.c += -I${SRCTOP}/sys/cddl/contrib/opensolaris/common/lz4
CFLAGS.gfx_fb.c += -I${SRCTOP}/contrib/pnglite
-CFLAGS.gfx_fb.c += -DHAVE_MEMCPY -I${SRCTOP}/sys/contrib/zlib
+CFLAGS.gfx_fb.c += ${ZLIB_CFLAGS}
CFLAGS.gfx_bios.c += -I$(SRCTOP)/sys/teken
CFLAGS.gfx_bios.c += -I${SRCTOP}/contrib/pnglite
.else
diff --git a/stand/libsa/Makefile b/stand/libsa/Makefile
index 11896cf1a2ab..a0bc47f343b5 100644
--- a/stand/libsa/Makefile
+++ b/stand/libsa/Makefile
@@ -100,7 +100,6 @@ SRCS+=${i}
# https://github.com/madler/zlib/issues/633 documents why we suppress deprecated
# prototype warnings.
.PATH: ${SRCTOP}/sys/contrib/zlib
-ZLIB_CFLAGS=-DHAVE_MEMCPY -I${SRCTOP}/sys/contrib/zlib ${NO_WDEPRECATED_NON_PROTOTYPE}
.for i in adler32.c crc32.c infback.c inffast.c inflate.c inftrees.c zutil.c
CFLAGS.${i}+=${ZLIB_CFLAGS}
SRCS+= ${i}
@@ -161,7 +160,7 @@ CFLAGS.ffs_subr.c+= -DSTANDALONE_SMALL
CFLAGS.gzipfs.c+= ${ZLIB_CFLAGS}
CFLAGS.pkgfs.c+= ${ZLIB_CFLAGS}
-CFLAGS.bzipfs.c+= -I${SRCTOP}/contrib/bzip2 -DBZ_NO_STDIO -DBZ_NO_COMPRESS
+CFLAGS.bzipfs.c+= ${BZIP2_CFLAGS}
# explicit_bzero and calculate_crc32c
.PATH: ${SYSDIR}/libkern
diff --git a/stand/loader.mk b/stand/loader.mk
index 0d94ed3e6263..b34ba08a8e5d 100644
--- a/stand/loader.mk
+++ b/stand/loader.mk
@@ -57,7 +57,7 @@ SRCS+= metadata.c
#
.if ${LOADER_DISK_SUPPORT:Uyes} == "yes"
-CFLAGS.part.c+= -DHAVE_MEMCPY -I${SRCTOP}/sys/contrib/zlib
+CFLAGS.part.c+= ${ZLIB_CFLAGS}
SRCS+= disk.c part.c vdisk.c
.endif
diff --git a/stand/uboot/Makefile b/stand/uboot/Makefile
index becca47944da..c0a349a2e29a 100644
--- a/stand/uboot/Makefile
+++ b/stand/uboot/Makefile
@@ -49,7 +49,7 @@ SRCS+= copy.c devicename.c elf_freebsd.c glue.c
SRCS+= net.c reboot.c time.c
SRCS+= uboot_console.c uboot_disk.c uboot_fdt.c uboot_module.c
-CFLAGS.glue.c+= -DHAVE_MEMCPY -I${SRCTOP}/sys/contrib/zlib
+CFLAGS.glue.c+= ${ZLIB_CFLAGS}
CFLAGS+= -I${BOOTSRC}/common
CFLAGS+= -I${.CURDIR}