Skip to content

Commit

Permalink
Fix dtrace tools bootstrap on non-FreeBSD after OpenZFS import
Browse files Browse the repository at this point in the history
This required surprisingly few build system changes and only two changes to the
openZFS compat headers which have been upstreamed as
openzfs/zfs#10863

Reviewed By:	#zfs, freqlabs
Differential Revision: https://reviews.freebsd.org/D26193
  • Loading branch information
arichardson committed Sep 19, 2020
1 parent b8bfffc commit 79e0214
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 54 deletions.
6 changes: 4 additions & 2 deletions cddl/lib/libspl/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,14 @@ SRCS = \
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 \
Expand All @@ -38,6 +39,7 @@ SRCS += atomic.S
.PATH: ${SRCTOP}/sys/contrib/openzfs/lib/libspl/asm-generic
SRCS += atomic.c
.endif
.endif


WARNS?= 2
Expand Down
4 changes: 4 additions & 0 deletions tools/build/cross-build/include/common/string.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@
*/
#pragma once

/* Avoid incompatible opensolaris redeclarations (without _FORTIFY_SOURCE). */
#define HAVE_STRLCAT 1
#define HAVE_STRLCPY 1

#include_next <string.h>
/*
* FreeBSD string.h #includes strings.h and all libmd code depends on
Expand Down
8 changes: 8 additions & 0 deletions tools/build/cross-build/include/common/sys/cdefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -276,3 +276,11 @@ typedef unsigned long u_long;
#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
51 changes: 0 additions & 51 deletions tools/build/cross-build/include/common/sys/uio.h

This file was deleted.

3 changes: 3 additions & 0 deletions tools/build/cross-build/include/linux/sys/stat.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,6 @@
#ifndef S_ISTXT
#define S_ISTXT S_ISVTX
#endif

/* This include is needed for OpenZFS bootstrap */
#include <sys/mount.h>
2 changes: 2 additions & 0 deletions tools/build/cross-build/include/mac/sys/_types.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,5 @@
* __darwin_ct_rune_t exists.
*/
typedef __darwin_ct_rune_t __ct_rune_t;
/* Needed for opensolaris compat. */
typedef __int64_t off64_t;
1 change: 0 additions & 1 deletion tools/build/mk/Makefile.boot
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ LIBELF:=${WORLDTMP}/legacy/usr/lib/libelf.a
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:
Expand Down

0 comments on commit 79e0214

Please sign in to comment.