Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F143907981
D39541.id120237.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
14 KB
Referenced Files
None
Subscribers
None
D39541.id120237.diff
View Options
diff --git a/contrib/libarchive/tar/bsdtar.c b/contrib/libarchive/tar/bsdtar.c
--- a/contrib/libarchive/tar/bsdtar.c
+++ b/contrib/libarchive/tar/bsdtar.c
@@ -203,7 +203,7 @@
if (setlocale(LC_ALL, "") == NULL)
lafe_warnc(0, "Failed to set default locale");
#endif
-#if defined(HAVE_NL_LANGINFO) && defined(HAVE_D_MD_ORDER)
+#if defined(HAVE_NL_LANGINFO) && defined(D_MD_ORDER)
bsdtar->day_first = (*nl_langinfo(D_MD_ORDER) == 'd');
#endif
possible_help_request = 0;
diff --git a/contrib/libc-vis/vis.c b/contrib/libc-vis/vis.c
--- a/contrib/libc-vis/vis.c
+++ b/contrib/libc-vis/vis.c
@@ -135,25 +135,27 @@
#if !HAVE_NBTOOL_CONFIG_H
#ifndef __NetBSD__
-/*
- * On NetBSD MB_LEN_MAX is currently 32 which does not fit on any integer
- * integral type and it is probably wrong, since currently the maximum
- * number of bytes and character needs is 6. Until this is fixed, the
- * loops below are using sizeof(uint64_t) - 1 instead of MB_LEN_MAX, and
- * the assertion is commented out.
- */
-#ifdef __FreeBSD__
/*
* On FreeBSD including <sys/systm.h> for CTASSERT only works in kernel
* mode.
+ * On Linux and macOS there is no notion of CTASSERT at all.
*/
#ifndef CTASSERT
#define CTASSERT(x) _CTASSERT(x, __LINE__)
#define _CTASSERT(x, y) __CTASSERT(x, y)
#define __CTASSERT(x, y) typedef char __assert ## y[(x) ? 1 : -1]
#endif
-#endif /* __FreeBSD__ */
+/*
+ * On NetBSD MB_LEN_MAX is currently 32 which does not fit on any integer
+ * integral type and it is probably wrong, since currently the maximum
+ * number of bytes and character needs is 6. Likewise, glibc (Linux) defines
+ * MB_LEN_MAX as 16 which does not fit on any integer integral type. Until
+ * these are fixed, the loops below are using sizeof(wmsk <aka, uint64_t>) - 1
+ * instead of MB_LEN_MAX, and the assertion is commented out.
+ */
+#if defined(__FreeBSD__) || defined(__ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__)
CTASSERT(MB_LEN_MAX <= sizeof(uint64_t));
+#endif /* __FreeBSD__ || macOS */
#endif /* !__NetBSD__ */
#endif
diff --git a/contrib/mtree/extern.h b/contrib/mtree/extern.h
--- a/contrib/mtree/extern.h
+++ b/contrib/mtree/extern.h
@@ -35,10 +35,12 @@
#if HAVE_NBTOOL_CONFIG_H
#include "nbtool_config.h"
-#else
+#else
+#ifndef HAVE_STRUCT_STAT_ST_FLAGS
#define HAVE_STRUCT_STAT_ST_FLAGS 1
#endif
-
+#endif
+
#include <err.h>
#include <fts.h>
#include <util.h>
diff --git a/lib/libc/db/Makefile.inc b/lib/libc/db/Makefile.inc
--- a/lib/libc/db/Makefile.inc
+++ b/lib/libc/db/Makefile.inc
@@ -3,11 +3,15 @@
#
CFLAGS+=-D__DBINTERFACE_PRIVATE
+.if ${MACHINE:Nhost*} != "" && ${.MAKE.OS} != "FreeBSD"
.include "${LIBC_SRCTOP}/db/btree/Makefile.inc"
+.endif
.include "${LIBC_SRCTOP}/db/db/Makefile.inc"
.include "${LIBC_SRCTOP}/db/hash/Makefile.inc"
.include "${LIBC_SRCTOP}/db/man/Makefile.inc"
+.if ${MACHINE:Nhost*} != "" && ${.MAKE.OS} != "FreeBSD"
.include "${LIBC_SRCTOP}/db/mpool/Makefile.inc"
.include "${LIBC_SRCTOP}/db/recno/Makefile.inc"
+.endif
SYM_MAPS+=${LIBC_SRCTOP}/db/Symbol.map
diff --git a/share/mk/local.init.mk b/share/mk/local.init.mk
--- a/share/mk/local.init.mk
+++ b/share/mk/local.init.mk
@@ -19,7 +19,8 @@
CXXFLAGS_LAST+= --sysroot=${SYSROOT}
LDADD+= --sysroot=${SYSROOT}
.elif ${MK_STAGING} == "yes"
-CFLAGS+= -isystem ${STAGE_INCLUDEDIR}
+ISYSTEM?= ${STAGE_INCLUDEDIR}
+CFLAGS+= -isystem${ISYSTEM}
# XXX: May be needed for GCC to build with libc++ rather than libstdc++. See Makefile.inc1
#CXXFLAGS+= -std=gnu++11
#LDADD+= -L${STAGE_LIBDIR}/libc++
@@ -38,4 +39,8 @@
.-include "src.init.mk"
.-include <site.init.mk>
.-include "${.CURDIR}/local.init.mk"
+
+.if !empty(HAVE_FLAGS)
+CFLAGS+= ${HAVE_FLAGS:U:@F@-D${F}=${$F:U1}@}
+.endif
.endif
diff --git a/share/mk/src.init.linux.mk b/share/mk/src.init.linux.mk
new file mode 100644
--- /dev/null
+++ b/share/mk/src.init.linux.mk
@@ -0,0 +1,36 @@
+# We want to build some host tools (eg makefs, mkimg) for Linux
+
+.if ${MACHINE:Nhost*} == ""
+
+CFLAGS+= -I${SRCTOP}/tools/build/cross-build/include/linux
+
+WARNS= 0
+
+CFLAGS+= -DEFTYPE=EINVAL
+
+.ifdef PROG
+LOCAL_LIBRARIES+= bsd egacy
+LIBADD+= egacy m
+# static linking does not work
+NO_SHARED= no
+.endif
+
+LDFLAGS_LAST+= -Wl,--dynamic-linker="/lib64/ld-linux-x86-64.so.2"
+
+MK_TESTS= no
+MK_MAN= no
+
+# override some HAVE_FLAGS
+HAVE_STRUCT_DINODE_DI_SHORTLINK= 0
+HAVE_STRUCT_STAT_ST_FLAGS= 0
+
+# someone used __unused for struct padding on Linux
+# we don't care enough about linux/sysctl.h to work around it
+CFLAGS+= -D__unused= -D_LINUX_SYSCTL_H
+
+# avoid type conflicts
+CFLAGS+= -D__va_list=__builtin_va_list
+
+CFLAGS+= -D_DEFAULT_SOURCE -D_GNU_SOURCE -D_XOPEN_SOURCE
+
+.endif
diff --git a/share/mk/src.init.mk b/share/mk/src.init.mk
--- a/share/mk/src.init.mk
+++ b/share/mk/src.init.mk
@@ -8,4 +8,13 @@
${_+_}@env BUILDENV_DIR=${.CURDIR} ${MAKE} -C ${SRCTOP} buildenv
.endif
+.if ${MACHINE:Nhost*} == ""
+.-include <src.init.${.MAKE.OS:tl}.mk>
+.endif
+
+.if ${MACHINE:Nhost*} == ""
+ISYSTEM= /usr/include
+CFLAGS+= -I${STAGE_INCLUDEDIR}
+.endif
+
.endif # !target(__<src.init.mk>__)
diff --git a/share/mk/src.sys.env.mk b/share/mk/src.sys.env.mk
--- a/share/mk/src.sys.env.mk
+++ b/share/mk/src.sys.env.mk
@@ -24,7 +24,7 @@
RELSRCTOP?= ${RELTOP}
.if !defined(OS_REVISION)
-OS_REVISION!=eval `sh ${SRCTOP}/sys/conf/newvers.sh -V REVISION` && echo $$REVISION || echo
+OS_REVISION!=eval `sh ${SRCTOP}/sys/conf/newvers.sh -V REVISION 2> /dev/null` && echo $$REVISION || echo
.export OS_REVISION
.endif
diff --git a/targets/pseudo/host-tools/Makefile b/targets/pseudo/host-tools/Makefile
new file mode 100644
--- /dev/null
+++ b/targets/pseudo/host-tools/Makefile
@@ -0,0 +1 @@
+.include "../Makefile.inc"
diff --git a/targets/pseudo/host-tools/Makefile.depend.host b/targets/pseudo/host-tools/Makefile.depend.host
new file mode 100644
--- /dev/null
+++ b/targets/pseudo/host-tools/Makefile.depend.host
@@ -0,0 +1,7 @@
+DIRDEPS= \
+ usr.sbin/makefs \
+ tools/build/cross-build/mkimg \
+ usr.bin/tar \
+
+.include <dirdeps.mk>
+
diff --git a/targets/pseudo/stage/Makefile b/targets/pseudo/stage/Makefile
--- a/targets/pseudo/stage/Makefile
+++ b/targets/pseudo/stage/Makefile
@@ -4,6 +4,7 @@
# distrib-dirs can be done in STAGE_OBJTOP
all:
+.if ${.MAKE.OS} == "FreeBSD"
# mtree makes a lot of noise if we are not root,
# we don't need to see it.
stage-distrib-dirs: .META ${META_DEPS}
@@ -11,6 +12,22 @@
INSTALL="sh ${SRCTOP}/tools/install.sh" ${.MAKE} -C ${SRCTOP}/etc \
distrib-dirs -DNO_FSCHG -DWITH_TESTS DESTDIR=${STAGE_OBJTOP}
+.else
+std_dirs= \
+ /bin \
+ /etc \
+ /sbin \
+ /usr/bin \
+ /usr/include/arpa \
+ /usr/include/sys \
+ /usr/lib \
+ /usr/sbin \
+
+stage-distrib-dirs: .META
+ mkdir -p ${std_dirs:@d@${STAGE_OBJTOP}$d@}
+
+.endif
+
.include <bsd.prog.mk>
.if ${.MAKE.LEVEL} > 0 && ${MK_STAGING} == "yes"
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:Nhost*} == ""
+_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,15 @@
.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 \
+
# Needed by our sys/types.h wrapper
SYSINCS+= ${SRCTOP}/sys/sys/bitcount.h
@@ -191,10 +207,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 <sys/types.h>
#include <string.h>
#include <unistd.h>
diff --git a/tools/build/cross-build/include/README b/tools/build/cross-build/include/README
new file mode 100644
--- /dev/null
+++ b/tools/build/cross-build/include/README
@@ -0,0 +1,8 @@
+The design of header inclusion for cross-building is:
+
+1. The FreeBSD sys/sys/_types.h should not be included
+ Any <sys/_types.h> on the native build host should be used instead.
+
+2. to-dop
+
+3. to-do
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,2 @@
+#include <bits/types.h>
+
diff --git a/tools/build/cross-build/include/linux/sys/types.h b/tools/build/cross-build/include/linux/sys/types.h
--- a/tools/build/cross-build/include/linux/sys/types.h
+++ b/tools/build/cross-build/include/linux/sys/types.h
@@ -39,6 +39,9 @@
#include_next <sys/types.h>
+/* For minor(). */
+#include <sys/sysmacros.h>
+
#ifndef __size_t
typedef __SIZE_TYPE__ __size_t;
#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 <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.bin/tar/Makefile b/usr.bin/tar/Makefile
--- a/usr.bin/tar/Makefile
+++ b/usr.bin/tar/Makefile
@@ -35,6 +35,11 @@
SYMLINKS= bsdtar ${BINDIR}/tar
MLINKS= bsdtar.1 tar.1
+.if ${.MAKE.OS} == "Linux"
+LIBADD+= bsd
+MK_TESTS= no
+.endif
+
HAS_TESTS=
SUBDIR.${MK_TESTS}+= tests
diff --git a/usr.sbin/makefs/Makefile b/usr.sbin/makefs/Makefile
--- a/usr.sbin/makefs/Makefile
+++ b/usr.sbin/makefs/Makefile
@@ -34,7 +34,9 @@
.include "${SRCDIR}/ffs/Makefile.inc"
.include "${SRCDIR}/msdos/Makefile.inc"
-CFLAGS+=-DHAVE_STRUCT_STAT_ST_FLAGS=1
+HAVE_FLAGS+= \
+ HAVE_STRUCT_DINODE_DI_SHORTLINK \
+ HAVE_STRUCT_STAT_ST_FLAGS \
.PATH: ${SRCTOP}/contrib/mtree
CFLAGS+=-I${SRCTOP}/contrib/mtree
diff --git a/usr.sbin/makefs/Makefile.depend.host b/usr.sbin/makefs/Makefile.depend.host
new file mode 100644
--- /dev/null
+++ b/usr.sbin/makefs/Makefile.depend.host
@@ -0,0 +1,12 @@
+# $FreeBSD$
+# Autogenerated - do NOT edit!
+
+DIRDEPS = \
+ lib/libnetbsd \
+
+
+.include <dirdeps.mk>
+
+.if ${DEP_RELDIR} == ${_DEP_RELDIR}
+# local dependencies - needed for -jN in clean tree
+.endif
diff --git a/usr.sbin/makefs/ffs.c b/usr.sbin/makefs/ffs.c
--- a/usr.sbin/makefs/ffs.c
+++ b/usr.sbin/makefs/ffs.c
@@ -714,7 +714,11 @@
} else if (S_ISLNK(cur->type)) { /* symlink */
slen = strlen(cur->symlink);
if (slen < UFS1_MAXSYMLINKLEN) { /* short link */
+#ifdef HAVE_STRUCT_DINODE_DI_SHORTLINK
memcpy(dinp->di_shortlink, cur->symlink, slen);
+#else
+ memcpy(dinp->di_db, cur->symlink, slen);
+#endif
} else
membuf = cur->symlink;
dinp->di_size = slen;
@@ -773,7 +777,11 @@
} else if (S_ISLNK(cur->type)) { /* symlink */
slen = strlen(cur->symlink);
if (slen < UFS2_MAXSYMLINKLEN) { /* short link */
+#ifdef HAVE_STRUCT_DINODE_DI_SHORTLINK
memcpy(dinp->di_shortlink, cur->symlink, slen);
+#else
+ memcpy(dinp->di_db, cur->symlink, slen);
+#endif
} else
membuf = cur->symlink;
dinp->di_size = slen;
diff --git a/usr.sbin/makefs/mtree.c b/usr.sbin/makefs/mtree.c
--- a/usr.sbin/makefs/mtree.c
+++ b/usr.sbin/makefs/mtree.c
@@ -1057,9 +1057,12 @@
mtree_global_inode.st.st_mtime = time(NULL);
errors = warnings = 0;
+#if HAVE_SETGROUPENT
setgroupent(1);
+#endif
+#if HAVE_SETPASSENT
setpassent(1);
-
+#endif
mtree_root = node;
mtree_current = node;
do {
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Mon, Feb 2, 7:50 PM (15 h, 1 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
28417002
Default Alt Text
D39541.id120237.diff (14 KB)
Attached To
Mode
D39541: Simplify building host tools for non-FreeBSD hosts
Attached
Detach File
Event Timeline
Log In to Comment