diff --git a/cddl/lib/libspl/Makefile b/cddl/lib/libspl/Makefile index 64317c41b730..8088ef497d46 100644 --- a/cddl/lib/libspl/Makefile +++ b/cddl/lib/libspl/Makefile @@ -1,56 +1,58 @@ # $FreeBSD$ .PATH: ${SRCTOP}/sys/contrib/openzfs/lib/libspl .PATH: ${SRCTOP}/sys/contrib/openzfs/lib/libspl/os/freebsd .PATH: ${SRCTOP}/sys/contrib/openzfs/include LIB= spl LIBADD= PACKAGE= runtime SRCS = \ assert.c \ list.c \ mkdirp.c \ page.c \ - strlcat.c \ - strlcpy.c \ timestamp.c \ zone.c \ include/sys/list.h \ include/sys/list_impl.h +# These functions are not required when bootstrapping and the atomic code +# will not compile when building on macOS. +.if !defined(BOOTSTRAPPING) SRCS += \ getexecname.c \ gethostid.c \ getmntany.c \ mnttab.c .if ${MACHINE_ARCH} == "amd64" .PATH: ${SRCTOP}/sys/contrib/openzfs/lib/libspl/asm-x86_64 SRCS += atomic.S .elif ${MACHINE_ARCH} == "i386" .PATH: ${SRCTOP}/sys/contrib/openzfs/lib/libspl/asm-i386 SRCS += atomic.S .else .PATH: ${SRCTOP}/sys/contrib/openzfs/lib/libspl/asm-generic SRCS += atomic.c .endif +.endif WARNS?= 2 CSTD= c99 CFLAGS+= -DIN_BASE CFLAGS+= -I${SRCTOP}/sys/contrib/openzfs/include CFLAGS+= -I${SRCTOP}/sys/contrib/openzfs/lib/libspl/include/ CFLAGS+= -I${SRCTOP}/sys/contrib/openzfs/lib/libspl/include/os/freebsd CFLAGS+= -I${SRCTOP}/cddl/compat/opensolaris/include CFLAGS+= -I${SRCTOP}/sys/contrib/openzfs/module/icp/include CFLAGS+= -include ${SRCTOP}/sys/contrib/openzfs/include/os/freebsd/spl/sys/ccompile.h CFLAGS+= -DHAVE_ISSETUGID CFLAGS+= -include ${SRCTOP}/sys/modules/zfs/zfs_config.h CFLAGS.atomic.S+= -DLOCORE .include diff --git a/tools/build/cross-build/include/common/string.h b/tools/build/cross-build/include/common/string.h index 949f3fe10a5d..dd039d54583e 100644 --- a/tools/build/cross-build/include/common/string.h +++ b/tools/build/cross-build/include/common/string.h @@ -1,45 +1,49 @@ /*- * SPDX-License-Identifier: BSD-2-Clause * * Copyright 2018-2020 Alex Richardson * * This software was developed by SRI International and the University of * Cambridge Computer Laboratory (Department of Computer Science and * Technology) under DARPA contract HR0011-18-C-0016 ("ECATS"), as part of the * DARPA SSITH research programme. * * This software was developed by SRI International and the University of * Cambridge Computer Laboratory under DARPA/AFRL contract (FA8750-10-C-0237) * ("CTSRD"), as part of the DARPA CRASH research programme. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * $FreeBSD$ */ #pragma once +/* Avoid incompatible opensolaris redeclarations (without _FORTIFY_SOURCE). */ +#define HAVE_STRLCAT 1 +#define HAVE_STRLCPY 1 + #include_next /* * FreeBSD string.h #includes strings.h and all libmd code depends on * string.h providing explicit_bzero. */ #include diff --git a/tools/build/cross-build/include/common/sys/cdefs.h b/tools/build/cross-build/include/common/sys/cdefs.h index 6114fcbb9638..2bd57eef908d 100644 --- a/tools/build/cross-build/include/common/sys/cdefs.h +++ b/tools/build/cross-build/include/common/sys/cdefs.h @@ -1,278 +1,286 @@ /*- * SPDX-License-Identifier: BSD-2-Clause * * Copyright 2018-2020 Alex Richardson * * This software was developed by SRI International and the University of * Cambridge Computer Laboratory (Department of Computer Science and * Technology) under DARPA contract HR0011-18-C-0016 ("ECATS"), as part of the * DARPA SSITH research programme. * * This software was developed by SRI International and the University of * Cambridge Computer Laboratory under DARPA/AFRL contract (FA8750-10-C-0237) * ("CTSRD"), as part of the DARPA CRASH research programme. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * $FreeBSD$ */ #pragma once /* musl libc does not provide a sys/cdefs.h header */ #if __has_include_next() #include_next #else /* No sys/cdefs.h header exists so we have to provide some basic macros */ #ifdef __cplusplus #define __BEGIN_DECLS extern "C" { #define __END_DECLS } #else #define __BEGIN_DECLS #define __END_DECLS #endif #endif #ifndef __FBSDID #define __FBSDID(id) #endif #ifndef __IDSTRING #define __IDSTRING(name, string) #endif #ifndef rounddown #define rounddown(x, y) (((x) / (y)) * (y)) #define rounddown2(x, y) ((x) & (~((y)-1))) /* if y is power of two */ #define roundup(x, y) ((((x) + ((y)-1)) / (y)) * (y)) /* to any y */ #define roundup2(x, y) \ (((x) + ((y)-1)) & (~((y)-1))) /* if y is powers of two */ #define powerof2(x) ((((x)-1) & (x)) == 0) #endif #ifndef __pure #define __pure __attribute__((__pure__)) #endif #ifndef __packed #define __packed __attribute__((__packed__)) #endif #ifndef __dead2 #define __dead2 __attribute__((__noreturn__)) #endif #ifndef __pure2 #define __pure2 __attribute__((__const__)) #endif #ifndef __used #define __used __attribute__((__used__)) #endif #ifndef __aligned #define __aligned(x) __attribute__((__aligned__(x))) #endif #ifndef __section #define __section(x) __attribute__((__section__(x))) #endif #ifndef __alloc_size #define __alloc_size(...) __attribute__((__alloc_size__(__VA_ARGS__))) #endif #ifndef __alloc_size2 #define __alloc_size2(n, x) __attribute__((__alloc_size__(n, x))) #endif #ifndef __alloc_align #define __alloc_align(x) __attribute__((__alloc_align__(x))) #endif #ifndef __result_use_check #define __result_use_check __attribute__((__warn_unused_result__)) #endif #ifndef __printflike #define __printflike(fmtarg, firstvararg) \ __attribute__((__format__(__printf__, fmtarg, firstvararg))) #endif #ifndef __printf0like #define __printf0like(fmtarg, firstvararg) \ __attribute__((__format__(__printf0__, fmtarg, firstvararg))) #endif #ifndef __predict_true #define __predict_true(exp) __builtin_expect((exp), 1) #endif #ifndef __predict_false #define __predict_false(exp) __builtin_expect((exp), 0) #endif #ifndef __weak_reference #ifdef __ELF__ #define __weak_reference(sym, alias) \ __asm__(".weak " #alias); \ __asm__(".equ " #alias ", " #sym) #else #define __weak_reference(sym, alias) \ static int alias() __attribute__((weakref(#sym))); #endif #endif /* Some files built as part of the bootstrap libegacy use these macros, but * since we aren't actually building libc.so, we can defined them to be empty */ #ifndef __sym_compat #define __sym_compat(sym, impl, verid) /* not needed for bootstrapping */ #endif #ifndef __sym_default #define __sym_default(sym, impl, verid) /* not needed for bootstrapping */ #endif #ifndef __sym_default #define __warn_references(sym, msg) /* not needed for bootstrapping */ #endif #ifndef __malloc_like #define __malloc_like __attribute__((__malloc__)) #endif #ifndef nitems // https://stackoverflow.com/questions/1598773/is-there-a-standard-function-in-c-that-would-return-the-length-of-an-array/1598827#1598827 #define nitems(x) \ ((sizeof(x) / sizeof(0 [x])) / ((size_t)(!(sizeof(x) % sizeof(0 [x]))))) #endif #ifndef __min_size #if !defined(__cplusplus) #define __min_size(x) static(x) #else #define __min_size(x) (x) #endif #endif #ifndef __unused #define __unused __attribute__((unused)) #endif #define __format_arg(fmtarg) __attribute__((__format_arg__(fmtarg))) #ifndef __exported #define __exported __attribute__((__visibility__("default"))) #endif #ifndef __hidden #define __hidden __attribute__((__visibility__("hidden"))) #endif #ifndef __unreachable #define __unreachable() __builtin_unreachable() #endif #ifndef __clang__ /* GCC doesn't like the printf0 format specifier. Clang treats it the same as * printf so add the compatibility macro here. */ #define __printf0__ __printf__ #endif /* * These should probably be in sys/types.h but mtree expects them to exist * without including */ typedef unsigned char u_char; typedef unsigned short u_short; typedef unsigned int u_int; typedef unsigned long u_long; /* This is needed so that BSNMP doesn't redeclare an incompatible version */ #define HAVE_STRLCPY 1 /* The compiler supports __func__ */ #define HAVE_DECL___FUNC__ 1 /* On MacOS __CONCAT is defined as x ## y, which won't expand macros */ #undef __CONCAT #define __CONCAT1(x, y) x##y #define __CONCAT(x, y) __CONCAT1(x, y) #ifndef __STRING #define __STRING(x) #x /* stringify without expanding x */ #endif #ifndef __XSTRING #define __XSTRING(x) __STRING(x) /* expand x, then stringify */ #endif #ifndef __has_feature #define __has_feature(...) 0 #endif #ifndef __has_builtin #define __has_builtin(...) 0 #endif /* * Nullability qualifiers: currently only supported by Clang. */ #if !(defined(__clang__) && __has_feature(nullability)) #define _Nonnull #define _Nullable #define _Null_unspecified #define __NULLABILITY_PRAGMA_PUSH #define __NULLABILITY_PRAGMA_POP #else #define __NULLABILITY_PRAGMA_PUSH \ _Pragma("clang diagnostic push") \ _Pragma("clang diagnostic ignored \"-Wnullability-completeness\"") #define __NULLABILITY_PRAGMA_POP _Pragma("clang diagnostic pop") #endif #ifndef __offsetof #define __offsetof(type, field) __builtin_offsetof(type, field) #endif #define __rangeof(type, start, end) \ (__offsetof(type, end) - __offsetof(type, start)) #ifndef __containerof #define __containerof(x, s, m) \ ({ \ const volatile __typeof(((s *)0)->m) *__x = (x); \ __DEQUALIFY( \ s *, (const volatile char *)__x - __offsetof(s, m)); \ }) #endif #ifndef __RCSID #define __RCSID(x) #endif #ifndef __FBSDID #define __FBSDID(x) #endif #ifndef __RCSID #define __RCSID(x) #endif #ifndef __RCSID_SOURCE #define __RCSID_SOURCE(x) #endif #ifndef __SCCSID #define __SCCSID(x) #endif #ifndef __COPYRIGHT #define __COPYRIGHT(x) #endif #ifndef __DECONST #define __DECONST(type, var) ((type)(__uintptr_t)(const void *)(var)) #endif #ifndef __DEVOLATILE #define __DEVOLATILE(type, var) ((type)(__uintptr_t)(volatile void *)(var)) #endif #ifndef __DEQUALIFY #define __DEQUALIFY(type, var) ((type)(__uintptr_t)(const volatile void *)(var)) #endif + + +/* Expose all declarations when using FreeBSD headers */ +#define __POSIX_VISIBLE 200809 +#define __XSI_VISIBLE 700 +#define __BSD_VISIBLE 1 +#define __ISO_C_VISIBLE 2011 +#define __EXT1_VISIBLE 1 diff --git a/tools/build/cross-build/include/common/sys/uio.h b/tools/build/cross-build/include/common/sys/uio.h deleted file mode 100644 index f670ded03c04..000000000000 --- a/tools/build/cross-build/include/common/sys/uio.h +++ /dev/null @@ -1,51 +0,0 @@ -/*- - * SPDX-License-Identifier: BSD-2-Clause - * - * Copyright 2018-2020 Alex Richardson - * - * This software was developed by SRI International and the University of - * Cambridge Computer Laboratory (Department of Computer Science and - * Technology) under DARPA contract HR0011-18-C-0016 ("ECATS"), as part of the - * DARPA SSITH research programme. - * - * This software was developed by SRI International and the University of - * Cambridge Computer Laboratory under DARPA/AFRL contract (FA8750-10-C-0237) - * ("CTSRD"), as part of the DARPA CRASH research programme. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * 1. Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * 2. Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND - * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE - * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL - * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS - * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) - * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT - * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY - * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - * - * $FreeBSD$ - */ -#pragma once -#include_next - -/* needed by opensolaris: */ -#ifdef __linux__ -enum uio_rw { UIO_READ, UIO_WRITE }; - -/* Segment flag values. */ -enum uio_seg { - UIO_USERSPACE, /* from user data space */ - UIO_SYSSPACE, /* from system space */ - UIO_NOCOPY /* don't copy, already in object */ -}; -#endif diff --git a/tools/build/cross-build/include/linux/sys/stat.h b/tools/build/cross-build/include/linux/sys/stat.h index 04f8dc19e468..72c6bb950ce9 100644 --- a/tools/build/cross-build/include/linux/sys/stat.h +++ b/tools/build/cross-build/include/linux/sys/stat.h @@ -1,61 +1,64 @@ /*- * SPDX-License-Identifier: BSD-2-Clause * * Copyright 2018-2020 Alex Richardson * * This software was developed by SRI International and the University of * Cambridge Computer Laboratory (Department of Computer Science and * Technology) under DARPA contract HR0011-18-C-0016 ("ECATS"), as part of the * DARPA SSITH research programme. * * This software was developed by SRI International and the University of * Cambridge Computer Laboratory under DARPA/AFRL contract (FA8750-10-C-0237) * ("CTSRD"), as part of the DARPA CRASH research programme. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * $FreeBSD$ */ #pragma once /* * glibc shipped with Ubuntu 16.04 doesn't include a definition of * struct timespec when sys/stat.h is included. */ #define __need_timespec #include /* contains a member named __unused. */ #include "../__unused_workaround_start.h" #include_next #include "../__unused_workaround_end.h" #define st_atimensec st_atim.tv_nsec #define st_mtimensec st_mtim.tv_nsec #define st_ctimensec st_ctim.tv_nsec #define st_atimespec st_atim #define st_mtimespec st_mtim #define st_ctimespec st_ctim #ifndef S_ISTXT #define S_ISTXT S_ISVTX #endif + +/* This include is needed for OpenZFS bootstrap */ +#include diff --git a/tools/build/cross-build/include/mac/sys/_types.h b/tools/build/cross-build/include/mac/sys/_types.h index 9dd6616a59fd..fd14a7836792 100644 --- a/tools/build/cross-build/include/mac/sys/_types.h +++ b/tools/build/cross-build/include/mac/sys/_types.h @@ -1,45 +1,47 @@ /*- * SPDX-License-Identifier: BSD-2-Clause * * Copyright 2018-2020 Alex Richardson * * This software was developed by SRI International and the University of * Cambridge Computer Laboratory (Department of Computer Science and * Technology) under DARPA contract HR0011-18-C-0016 ("ECATS"), as part of the * DARPA SSITH research programme. * * This software was developed by SRI International and the University of * Cambridge Computer Laboratory under DARPA/AFRL contract (FA8750-10-C-0237) * ("CTSRD"), as part of the DARPA CRASH research programme. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright * notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright * notice, this list of conditions and the following disclaimer in the * documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. * * $FreeBSD$ */ #pragma once #include_next /* * Bootstrapping localedef needs a __ct_rune_t typedef, but on macos only * __darwin_ct_rune_t exists. */ typedef __darwin_ct_rune_t __ct_rune_t; +/* Needed for opensolaris compat. */ +typedef __int64_t off64_t; diff --git a/tools/build/mk/Makefile.boot b/tools/build/mk/Makefile.boot index b83f417b524f..ada14e6112f4 100644 --- a/tools/build/mk/Makefile.boot +++ b/tools/build/mk/Makefile.boot @@ -1,101 +1,100 @@ # $FreeBSD$ CFLAGS+= -I${WORLDTMP}/legacy/usr/include DPADD+= ${WORLDTMP}/legacy/usr/lib/libegacy.a LDADD+= -legacy LDFLAGS+= -L${WORLDTMP}/legacy/usr/lib .if ${.MAKE.OS} != "FreeBSD" # On MacOS using a non-mac ar will fail the build, similarly on Linux using # nm may not work as expected if the nm for the target architecture comes in # $PATH before a nm that supports the host architecture. # To ensure that host binary compile as expected we use the tools from /usr/bin. AR:= /usr/bin/ar RANLIB:= /usr/bin/ranlib NM:= /usr/bin/nm # Don't use lorder and tsort since lorder is not installed by default on most # Linux systems and the FreeBSD lorder does not work on Linux. For the bootstrap # tools the order of the .o files should not matter since we only care about # a few individual files (and might soon require linking with lld anyway) LORDER:=echo TSORT:=cat # When using cat as tsort we can't pass -q: TSORTFLAGS:= # Avoid stale dependecy warnings: LIBC:= LIBZ:= LIBM:= LIBUTIL:= LIBCPLUSPLUS:= LIBARCHIVE:= LIBPTHREAD:= LIBMD:=${WORLDTMP}/legacy/usr/lib/libmd.a LIBNV:=${WORLDTMP}/legacy/usr/lib/libmd.a LIBSBUF:=${WORLDTMP}/legacy/usr/lib/libsbuf.a LIBY:=${WORLDTMP}/legacy/usr/lib/liby.a LIBL:=${WORLDTMP}/legacy/usr/lib/libl.a LIBROKEN:=${WORLDTMP}/legacy/usr/lib/libroken.a LIBDWARF:=${WORLDTMP}/legacy/usr/lib/libdwarf.a LIBELF:=${WORLDTMP}/legacy/usr/lib/libelf.a # Add various -Werror flags to catch missing function declarations CFLAGS+= -Werror=implicit-function-declaration -Werror=implicit-int \ -Werror=return-type -Wundef CFLAGS+= -DHAVE_NBTOOL_CONFIG_H=1 -CFLAGS+= -D__BSD_VISIBLE=1 CFLAGS+= -I${SRCTOP}/tools/build/cross-build/include/common # b64_pton and b64_ntop is in libresolv on MacOS and Linux: # TODO: only needed for uuencode and uudecode LDADD+=-lresolv .if ${.MAKE.OS} == "Linux" CFLAGS+= -I${SRCTOP}/tools/build/cross-build/include/linux CFLAGS+= -std=gnu99 -D_GNU_SOURCE=1 # Needed for sem_init, etc. on Linux (used by usr.bin/sort) LDADD+= -pthread .elif ${.MAKE.OS} == "Darwin" CFLAGS+= -D_DARWIN_C_SOURCE=1 CFLAGS+= -I${SRCTOP}/tools/build/cross-build/include/mac # The macOS ar and ranlib don't understand all the flags supported by the # FreeBSD and Linux ar/ranlib ARFLAGS:= -crs RANLIBFLAGS:= # to get libarchive (needed for elftoolchain) # MacOS ships /usr/lib/libarchive.dylib but doesn't provide the headers CFLAGS+= -idirafter ${SRCTOP}/contrib/libarchive/libarchive .else .error "Unsupported build OS: ${.MAKE.OS}" .endif .endif # ${.MAKE.OS} != "FreeBSD" # we do not want to capture dependencies referring to the above UPDATE_DEPENDFILE= no # When building host tools we should never pull in headers from the source sys # directory to avoid any ABI issues that might cause the built binary to crash. # The only exceptions to this are sys/cddl/compat for dtrace bootstrap tools and # sys/crypto for libmd bootstrap. # We have to skip this check during make obj since bsd.crunchgen.mk will run # make obj on every directory during the build-tools phase. .if !make(obj) .if !empty(CFLAGS:M*${SRCTOP}/sys) .error Do not include $${SRCTOP}/sys when building bootstrap tools. \ Copy the header to $${WORLDTMP}/legacy in tools/build/Makefile instead. \ Error was caused by Makefile in ${.CURDIR} .endif # ${SRCTOP}/include should also never be used to avoid ABI issues .if !empty(CFLAGS:M*${SRCTOP}/include*) .error Do not include $${SRCTOP}/include when building bootstrap tools. \ Copy the header to $${WORLDTMP}/legacy in tools/build/Makefile instead. \ Error was caused by Makefile in ${.CURDIR} .endif .endif # GCC doesn't allow silencing warn_unused_result calls with (void) casts. CFLAGS.gcc+=-Wno-unused-result