git: bb8580e7a6a8 - main - zfs: fix cross-build after openzfs/zfs@e63d026b9d

From: Martin Matuska <mm_at_FreeBSD.org>
Date: Mon, 17 Nov 2025 16:12:40 UTC
The branch main has been updated by mm:

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

commit bb8580e7a6a8c54481d0fd19cac43e84a485f45b
Author:     Martin Matuska <mm@FreeBSD.org>
AuthorDate: 2025-11-17 11:34:01 +0000
Commit:     Martin Matuska <mm@FreeBSD.org>
CommitDate: 2025-11-17 16:12:03 +0000

    zfs: fix cross-build after openzfs/zfs@e63d026b9d
    
    Workaround multiple cross-build issues in OpenZFS code
    
    TBD: discuss long-term fix with OpenZFS
---
 cddl/lib/libspl/Makefile                                      | 6 +++---
 sys/contrib/openzfs/lib/libspl/include/os/freebsd/sys/fcntl.h | 2 ++
 sys/contrib/openzfs/lib/libspl/include/os/freebsd/sys/mount.h | 2 ++
 sys/contrib/openzfs/lib/libspl/include/sys/random.h           | 2 ++
 sys/contrib/openzfs/lib/libspl/include/sys/sysmacros.h        | 2 ++
 5 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/cddl/lib/libspl/Makefile b/cddl/lib/libspl/Makefile
index 2c56348cdf9c..173e9116e284 100644
--- a/cddl/lib/libspl/Makefile
+++ b/cddl/lib/libspl/Makefile
@@ -14,9 +14,7 @@ SRCS = \
         assert.c \
 	backtrace.c \
 	condvar.c \
-	cred.c \
 	kmem.c \
-	kstat.c \
 	libspl.c \
         list.c \
         mkdirp.c \
@@ -28,7 +26,6 @@ SRCS = \
 	rwlock.c \
 	sid.c \
 	taskq.c \
-	thread.c \
         timestamp.c \
         include/sys/list.h \
         include/sys/list_impl.h
@@ -38,7 +35,10 @@ SRCS = \
 .if !defined(BOOTSTRAPPING)
 SRCS += \
         atomic.c \
+	cred.c \
         getexecname.c \
+	kstat.c \
+	thread.c \
         tunables.c \
         os/freebsd/getexecname.c \
         os/freebsd/gethostid.c \
diff --git a/sys/contrib/openzfs/lib/libspl/include/os/freebsd/sys/fcntl.h b/sys/contrib/openzfs/lib/libspl/include/os/freebsd/sys/fcntl.h
index 64dd4d7ebe45..04fcc9f85c91 100644
--- a/sys/contrib/openzfs/lib/libspl/include/os/freebsd/sys/fcntl.h
+++ b/sys/contrib/openzfs/lib/libspl/include/os/freebsd/sys/fcntl.h
@@ -27,7 +27,9 @@
 #ifndef _LIBSPL_SYS_FCNTL_H_
 #define	_LIBSPL_SYS_FCNTL_H_
 
+#if !defined(__linux__) || !defined(IN_BASE)
 #include_next <sys/fcntl.h>
+#endif
 
 #define	O_LARGEFILE	0
 #define	O_RSYNC		0
diff --git a/sys/contrib/openzfs/lib/libspl/include/os/freebsd/sys/mount.h b/sys/contrib/openzfs/lib/libspl/include/os/freebsd/sys/mount.h
index 231c250d3410..5548ad7d22b2 100644
--- a/sys/contrib/openzfs/lib/libspl/include/os/freebsd/sys/mount.h
+++ b/sys/contrib/openzfs/lib/libspl/include/os/freebsd/sys/mount.h
@@ -29,8 +29,10 @@
 #ifndef _LIBSPL_SYS_MOUNT_H
 #define	_LIBSPL_SYS_MOUNT_H
 
+#if !defined(__linux__) || !defined(IN_BASE)
 #undef _SYS_MOUNT_H_
 #include_next <sys/mount.h>
+#endif
 
 #include <assert.h>
 #include <string.h>
diff --git a/sys/contrib/openzfs/lib/libspl/include/sys/random.h b/sys/contrib/openzfs/lib/libspl/include/sys/random.h
index d11580829ed2..09ca0662d1a3 100644
--- a/sys/contrib/openzfs/lib/libspl/include/sys/random.h
+++ b/sys/contrib/openzfs/lib/libspl/include/sys/random.h
@@ -39,7 +39,9 @@ random_in_range(uint32_t range)
 {
 	uint32_t r;
 
+#if !defined(__APPLE__) || !defined(IN_BASE)
 	ASSERT(range != 0);
+#endif
 
 	if (range == 1)
 		return (0);
diff --git a/sys/contrib/openzfs/lib/libspl/include/sys/sysmacros.h b/sys/contrib/openzfs/lib/libspl/include/sys/sysmacros.h
index cc6edf25a7bc..f67b081c42fa 100644
--- a/sys/contrib/openzfs/lib/libspl/include/sys/sysmacros.h
+++ b/sys/contrib/openzfs/lib/libspl/include/sys/sysmacros.h
@@ -38,8 +38,10 @@
  * have this header, so include_next won't find it and will abort. So, we
  * protect it with a platform check.
  */
+#ifndef IN_BASE
 #include_next <sys/sysmacros.h>
 #endif
+#endif
 
 #ifdef __FreeBSD__
 #include <sys/param.h>