git: 4773d3425e62 - main - stand: Add comments on ZFS build

From: Warner Losh <imp_at_FreeBSD.org>
Date: Sat, 09 Jul 2022 05:03:34 UTC
The branch main has been updated by imp:

URL: https://cgit.FreeBSD.org/src/commit/?id=4773d3425e62bda14f0dd91c4e3de5009dba388f

commit 4773d3425e62bda14f0dd91c4e3de5009dba388f
Author:     Warner Losh <imp@FreeBSD.org>
AuthorDate: 2022-07-08 23:35:11 +0000
Commit:     Warner Losh <imp@FreeBSD.org>
CommitDate: 2022-07-09 05:01:59 +0000

    stand: Add comments on ZFS build
    
    Add comments describing the weird nesting things we have to do to live
    inside the ZFS world. Also fix a stale comment by moving nvlist.c to an
    early user.
    
    Sponsored by:           Netflix
---
 stand/libsa/zfs/Makefile.inc | 23 ++++++++++++++++++++---
 1 file changed, 20 insertions(+), 3 deletions(-)

diff --git a/stand/libsa/zfs/Makefile.inc b/stand/libsa/zfs/Makefile.inc
index 314f74c903f1..9de1a1f00c24 100644
--- a/stand/libsa/zfs/Makefile.inc
+++ b/stand/libsa/zfs/Makefile.inc
@@ -27,11 +27,27 @@ CFLAGS+=	-I${LDRSRC}
 CFLAGS+=	-I${SYSDIR}/cddl/boot/zfs
 CFLAGS+=	-I${SYSDIR}/crypto/skein
 
+#
+# Any file that needs the FreeBSD overrides that are in
+# include/os/freebssd/spl/XXX needs to have these added to
+# CFLAGS_EARLY.file.c. In general, we try to build out of the OpenZFS tree
+# unaltered. There's a problem, though, that since we're building for a
+# standalone environment that's neither userland nor kernel, we sometimes need
+# special code and that's handled by the 'nested' includes where we either setup
+# something just-so before we include the include/XXX file, or if we need to
+# tweak something defined in that file.
+#
+
 ZFS_EARLY=	-I${ZFSSRC}/spl					\
 		-I${ZFSOSINC}					\
 		-I${ZFSOSINC}/spl				\
 		-I${ZFSOSINC}/zfs
 
+#
+# For all files, though, we prepend the sys/ccompile.h file to the build which
+# has a bunch of defines that are present in OpenSolaris / Illumos, but missing
+# from FreeBSD.
+#
 .for i in ${ZFS_SRC} ${ZSTD_SRC}
 CFLAGS.$i+=	-include ${ZFSOSINC}/spl/sys/ccompile.h -Wformat -Wall -I${OZFS}/include \
 	-DNEED_SOLARIS_BOOLEAN
@@ -42,11 +58,12 @@ CFLAGS_EARLY.blake3_generic.c+= ${ZFS_EARLY}
 CFLAGS_EARLY.blake3_impl_hack.c+= ${ZFS_EARLY}
 CFLAGS_EARLY.list.c+= ${ZFS_EARLY}
 CFLAGS_EARLY.zfs_zstd.c+= ${ZFS_EARLY}
+CFLAGS_EARLY.nvlist.c+= ${ZFS_EARLY}
 
 # Can't use the early flags because there's two conflicting definitions of boolean_t in
-# the zfs code that need to be unified.
-CFLAGS.nvlist.c+= -I${ZFSOSINC}/spl
-CFLAGS.zfs.c+=	-I${ZFSOSINC}/spl 				\
+# the zfs code that need to be unified, as well as a number of other hacks for pre-openzfs
+# code still in the tree that needs to be fixed.
+CFLAGS.zfs.c+=	-I${ZFSOSINC}/spl				\
 		-I${SRCTOP}/sys/cddl/contrib/opensolaris/common/lz4 \
 		-I${ZFSOSINC}/zfs				\
 		-I${OZFS}/include