git: e9ba1fd5eda2 - main - tools/build: Provide FreeBSD's bitstring API when cross-building

From: Jessica Clarke <jrtc27_at_FreeBSD.org>
Date: Thu, 18 Aug 2022 01:46:44 UTC
The branch main has been updated by jrtc27:

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

commit e9ba1fd5eda2c0bc22edafa75b2ef10222bf24e6
Author:     Jessica Clarke <jrtc27@FreeBSD.org>
AuthorDate: 2022-08-18 01:46:27 +0000
Commit:     Jessica Clarke <jrtc27@FreeBSD.org>
CommitDate: 2022-08-18 01:46:27 +0000

    tools/build: Provide FreeBSD's bitstring API when cross-building
    
    This is needed for building makefs as a cross-tool since the ZFS code
    uses these APIs.
    
    Reviewed by:    emaste
    Fixes:          240afd8c1fcc ("makefs: Add ZFS support")
    Differential Revision:  https://reviews.freebsd.org/D36133
---
 tools/build/Makefile                               | 9 +++++++++
 tools/build/cross-build/include/common/sys/types.h | 4 ++++
 2 files changed, 13 insertions(+)

diff --git a/tools/build/Makefile b/tools/build/Makefile
index 49223f9d9d42..75dc6ab60553 100644
--- a/tools/build/Makefile
+++ b/tools/build/Makefile
@@ -153,6 +153,15 @@ SYSINCS+=	${SRCTOP}/sys/sys/nlist_aout.h
 
 .if ${.MAKE.OS} != "FreeBSD"
 .PATH: ${.CURDIR}/cross-build
+
+# Needed by our sys/types.h wrapper
+SYSINCS+=	${SRCTOP}/sys/sys/bitcount.h
+
+# macOS's bitstring lacks FreeBSD-specific additions used by makefs's ZFS code
+# and Linux doesn't have it at all.
+INCS+=	${SRCTOP}/include/bitstring.h
+SYSINCS+=	${SRCTOP}/sys/sys/bitstring.h
+
 # dbopen() behaves differently on Linux and FreeBSD so we ensure that we
 # bootstrap the FreeBSD db code. The cross-build headers #define dbopen() to
 # __freebsd_dbopen() so that we don't ever use the host version
diff --git a/tools/build/cross-build/include/common/sys/types.h b/tools/build/cross-build/include/common/sys/types.h
index 044ca6bed4f8..82436e7e9224 100644
--- a/tools/build/cross-build/include/common/sys/types.h
+++ b/tools/build/cross-build/include/common/sys/types.h
@@ -68,4 +68,8 @@ typedef unsigned long cap_ioctl_t;
 struct cap_rights;
 
 typedef struct cap_rights cap_rights_t;
+
+/* Needed for bitstring */
+#include <sys/bitcount.h>
+
 #endif