diff --git a/tools/build/Makefile b/tools/build/Makefile --- a/tools/build/Makefile +++ b/tools/build/Makefile @@ -50,6 +50,9 @@ .PATH: ${.CURDIR}/../../contrib/libc-pwcache CFLAGS.pwcache.c+= -I${.CURDIR}/../../contrib/libc-pwcache SRCS+= pwcache.c +INCS+= ${.CURDIR}/cross-build/include/common/grp.h +# static inline does not work for this +CFLAGS.pwcache.c+= -DSETGROUPENT_IMPL .endif _WITH_STRSVIS!= grep -c strsvis ${HOST_INCLUDE_ROOT}/vis.h 2>/dev/null || true @@ -125,7 +128,11 @@ CHACHA20INCS+= ${SRCTOP}/sys/crypto/chacha20/_chacha.h \ ${SRCTOP}/sys/crypto/chacha20/chacha.h +.if ${MACHINE} == "host" +_host_arch= ${_HOST_ARCH} +.else _host_arch=${MACHINE} +.endif .if ${_host_arch} == "x86_64" # bmake on Linux/mac often prints that instead of amd64 _host_arch=amd64 @@ -163,6 +170,16 @@ .if ${.MAKE.OS} != "FreeBSD" .PATH: ${.CURDIR}/cross-build +INCS+= \ + ${.CURDIR}/cross-build/include/common/osreldate.h \ + ${SRCTOP}/include/readpassphrase.h \ + +SYSINCS+= \ + ${.CURDIR}/cross-build/include/common/sys/cdefs.h \ + ${.CURDIR}/cross-build/include/common/sys/param.h \ + ${.CURDIR}/cross-build/include/common/sys/_types.h \ + ${.CURDIR}/cross-build/include/common/sys/types.h \ + # Needed by our sys/types.h wrapper SYSINCS+= ${SRCTOP}/sys/sys/bitcount.h @@ -191,10 +208,10 @@ SRCS+= rpmatch.c .if ${.MAKE.OS} == "Linux" -# On Linux, glibc does not provide strlcpy,strlcat or strmode. +# glibc does not provide strlcpy, strlcat, or strmode. .PATH: ${LIBC_SRCTOP}/string SRCS+= strlcpy.c strlcat.c strmode.c -# On Linux, glibc provides ffs* but not fls* +# glibc provides ffs*, but not fls* SRCS+= fls.c flsl.c flsll.c # Compile the fgetln/fgetwln/closefrom fallback code from libbsd: SRCS+= fgetln_fallback.c fgetwln_fallback.c closefrom.c diff --git a/tools/build/cross-build/fflags.c b/tools/build/cross-build/fflags.c --- a/tools/build/cross-build/fflags.c +++ b/tools/build/cross-build/fflags.c @@ -37,6 +37,7 @@ * SUCH DAMAGE. */ +#include #include #include diff --git a/tools/build/cross-build/include/common/grp.h b/tools/build/cross-build/include/common/grp.h --- a/tools/build/cross-build/include/common/grp.h +++ b/tools/build/cross-build/include/common/grp.h @@ -50,10 +50,29 @@ const char *group_from_gid(gid_t gid, int noname); #ifdef __linux__ + +#ifdef SETGROUPENT_IMPL +int setgroupent(int); +int +#else static inline int +#endif setgroupent(int stayopen __unused) { setgrent(); return (1); } + +#ifdef SETGROUPENT_IMPL +int setpassent(int); +int +#else +static inline int +#endif +setpassent(int stayopen __unused) +{ + setgrent(); + return (1); +} + #endif diff --git a/tools/build/cross-build/include/common/sys/cdefs.h b/tools/build/cross-build/include/common/sys/cdefs.h --- a/tools/build/cross-build/include/common/sys/cdefs.h +++ b/tools/build/cross-build/include/common/sys/cdefs.h @@ -259,6 +259,35 @@ #define __ISO_C_VISIBLE 2011 #define __EXT1_VISIBLE 1 +/* + * Nullability qualifiers: currently only supported by Clang. + */ +#if !(defined(__clang__) && __has_feature(nullability)) +#ifndef _Nonnull +#define _Nonnull +#endif +#ifndef _Nullable +#define _Nullable +#endif +#ifndef _Null_unspecified +#define _Null_unspecified +#endif +#ifndef __NULLABILITY_PRAGMA_PUSH +#define __NULLABILITY_PRAGMA_PUSH +#endif +#ifndef __NULLABILITY_PRAGMA_POP +#define __NULLABILITY_PRAGMA_POP +#endif +#else +#ifndef __NULLABILITY_PRAGMA_PUSH +#define __NULLABILITY_PRAGMA_PUSH _Pragma("clang diagnostic push") \ + _Pragma("clang diagnostic ignored \"-Wnullability-completeness\"") +#endif +#ifndef __NULLABILITY_PRAGMA_POP +#define __NULLABILITY_PRAGMA_POP _Pragma("clang diagnostic pop") +#endif +#endif + /* Alignment builtins for better type checking and improved code generation. */ /* Provide fallback versions for other compilers (GCC/Clang < 10): */ #if !__has_builtin(__builtin_is_aligned) diff --git a/tools/build/cross-build/include/linux/sys/_types.h b/tools/build/cross-build/include/linux/sys/_types.h new file mode 100644 --- /dev/null +++ b/tools/build/cross-build/include/linux/sys/_types.h @@ -0,0 +1,5 @@ +#include +#if __has_include_next() +#include_next +#endif + diff --git a/tools/build/cross-build/mkimg/Makefile b/tools/build/cross-build/mkimg/Makefile --- a/tools/build/cross-build/mkimg/Makefile +++ b/tools/build/cross-build/mkimg/Makefile @@ -17,7 +17,6 @@ .endif -MK_STAGING=no MK_TESTS= no .include <${MKIMG_SRC}/Makefile> diff --git a/tools/build/cross-build/mkimg/Makefile.depend.host b/tools/build/cross-build/mkimg/Makefile.depend.host new file mode 100644 --- /dev/null +++ b/tools/build/cross-build/mkimg/Makefile.depend.host @@ -0,0 +1,11 @@ +# $FreeBSD$ +# Autogenerated - do NOT edit! + +DIRDEPS = \ + + +.include + +.if ${DEP_RELDIR} == ${_DEP_RELDIR} +# local dependencies - needed for -jN in clean tree +.endif