diff --git a/cmd/mount_zfs/Makefile.am b/cmd/mount_zfs/Makefile.am index e5f3d083b0a4..5c40ab6101d0 100644 --- a/cmd/mount_zfs/Makefile.am +++ b/cmd/mount_zfs/Makefile.am @@ -19,4 +19,5 @@ mount_zfs_LDADD = \ $(top_builddir)/lib/libuutil/libuutil.la \ $(top_builddir)/lib/libzpool/libzpool.la \ $(top_builddir)/lib/libzfs/libzfs.la \ - $(top_builddir)/lib/libzfs_core/libzfs_core.la + $(top_builddir)/lib/libzfs_core/libzfs_core.la \ + $(TIRPC_LIBS) diff --git a/cmd/mount_zfs/mount_zfs.c b/cmd/mount_zfs/mount_zfs.c index 6cb23d1c6d0a..cf92b86e1944 100644 --- a/cmd/mount_zfs/mount_zfs.c +++ b/cmd/mount_zfs/mount_zfs.c @@ -31,6 +31,7 @@ #include #include #include +#include libzfs_handle_t *g_zfs; diff --git a/cmd/zdb/Makefile.am b/cmd/zdb/Makefile.am index 854fbab26268..a177f4d0d50c 100644 --- a/cmd/zdb/Makefile.am +++ b/cmd/zdb/Makefile.am @@ -17,4 +17,4 @@ zdb_LDADD = \ $(top_builddir)/lib/libzfs/libzfs.la \ $(top_builddir)/lib/libzfs_core/libzfs_core.la -zdb_LDADD += $(ZLIB) +zdb_LDADD += $(ZLIB) $(TIRPC_LIBS) diff --git a/cmd/zed/Makefile.am b/cmd/zed/Makefile.am index b13288420ee3..c1fad2757ace 100644 --- a/cmd/zed/Makefile.am +++ b/cmd/zed/Makefile.am @@ -27,7 +27,8 @@ zed_LDADD = \ $(top_builddir)/lib/libnvpair/libnvpair.la \ $(top_builddir)/lib/libspl/libspl.la \ $(top_builddir)/lib/libzfs/libzfs.la \ - $(top_builddir)/lib/libzfs_core/libzfs_core.la + $(top_builddir)/lib/libzfs_core/libzfs_core.la \ + $(TIRPC_LIBS) zedconfdir = $(sysconfdir)/zfs/zed.d diff --git a/cmd/zfs/Makefile.am b/cmd/zfs/Makefile.am index 08580c92de52..ed7d5d69da19 100644 --- a/cmd/zfs/Makefile.am +++ b/cmd/zfs/Makefile.am @@ -19,5 +19,5 @@ zfs_LDADD = \ $(top_builddir)/lib/libzfs/libzfs.la \ $(top_builddir)/lib/libzfs_core/libzfs_core.la -zfs_LDADD += $(ZLIB) +zfs_LDADD += $(ZLIB) $(TIRPC_LIBS) zfs_LDFLAGS = -pthread diff --git a/cmd/zhack/Makefile.am b/cmd/zhack/Makefile.am index 922aef971426..485ade997404 100644 --- a/cmd/zhack/Makefile.am +++ b/cmd/zhack/Makefile.am @@ -16,4 +16,4 @@ zhack_LDADD = \ $(top_builddir)/lib/libzfs/libzfs.la \ $(top_builddir)/lib/libzfs_core/libzfs_core.la -zhack_LDADD += $(ZLIB) +zhack_LDADD += $(ZLIB) $(TIRPC_LIBS) diff --git a/cmd/zinject/Makefile.am b/cmd/zinject/Makefile.am index 4adef11baaf6..e8890836cf34 100644 --- a/cmd/zinject/Makefile.am +++ b/cmd/zinject/Makefile.am @@ -16,4 +16,5 @@ zinject_LDADD = \ $(top_builddir)/lib/libuutil/libuutil.la \ $(top_builddir)/lib/libzpool/libzpool.la \ $(top_builddir)/lib/libzfs/libzfs.la \ - $(top_builddir)/lib/libzfs_core/libzfs_core.la + $(top_builddir)/lib/libzfs_core/libzfs_core.la \ + $(TIRPC_LIBS) diff --git a/cmd/zpool/Makefile.am b/cmd/zpool/Makefile.am index a39a2405f26d..b15ca25985d2 100644 --- a/cmd/zpool/Makefile.am +++ b/cmd/zpool/Makefile.am @@ -19,4 +19,4 @@ zpool_LDADD = \ $(top_builddir)/lib/libzpool/libzpool.la \ $(top_builddir)/lib/libzfs/libzfs.la \ $(top_builddir)/lib/libzfs_core/libzfs_core.la \ - $(LIBBLKID) + $(LIBBLKID) $(TIRPC_LIBS) diff --git a/cmd/zstreamdump/Makefile.am b/cmd/zstreamdump/Makefile.am index d6c64f5126ed..aedb909ed7ba 100644 --- a/cmd/zstreamdump/Makefile.am +++ b/cmd/zstreamdump/Makefile.am @@ -16,4 +16,4 @@ zstreamdump_LDADD = \ $(top_builddir)/lib/libzfs/libzfs.la \ $(top_builddir)/lib/libzfs_core/libzfs_core.la -zstreamdump_LDADD += $(ZLIB) +zstreamdump_LDADD += $(ZLIB) $(TIRPC_LIBS) diff --git a/cmd/ztest/Makefile.am b/cmd/ztest/Makefile.am index a3cd83496f28..8cccc17fdf51 100644 --- a/cmd/ztest/Makefile.am +++ b/cmd/ztest/Makefile.am @@ -18,4 +18,4 @@ ztest_LDADD = \ $(top_builddir)/lib/libzfs/libzfs.la \ $(top_builddir)/lib/libzfs_core/libzfs_core.la -ztest_LDADD += -lm -ldl +ztest_LDADD += -lm -ldl $(TIRPC_LIBS) diff --git a/config/musl.m4 b/config/musl.m4 new file mode 100644 index 000000000000..fb4d2c463b7f --- /dev/null +++ b/config/musl.m4 @@ -0,0 +1,19 @@ +dnl +dnl musl support +dnl + +AC_DEFUN([ZFS_AC_CONFIG_USER_MUSL], [ +AH_TEMPLATE([HAVE_MUSL], + [Define to 1 if musl is being used as the C library]) +AH_TEMPLATE([HAVE_TIRPC], + [Define to 1 if libtirpc is being used as the RPC library]) +AC_ARG_ENABLE(musl, +AC_HELP_STRING([--enable-musl], [compile with musl as the C library]), +[if test x$enableval = xyes; then + AC_DEFINE([HAVE_MUSL], 1, [Define if you have musl]) + PKG_CHECK_MODULES([TIRPC],[libtirpc]) + AC_DEFINE([HAVE_TIRPC], 1, [Define if you have libtirpc]) + AC_SUBST(TIRPC_CFLAGS) + AC_SUBST(TIRPC_LIBS) +fi]) +]) diff --git a/config/user.m4 b/config/user.m4 index 38024370bbb4..db2e7c6699b1 100644 --- a/config/user.m4 +++ b/config/user.m4 @@ -13,6 +13,7 @@ AC_DEFUN([ZFS_AC_CONFIG_USER], [ ZFS_AC_CONFIG_USER_LIBBLKID ZFS_AC_CONFIG_USER_FRAME_LARGER_THAN ZFS_AC_CONFIG_USER_RUNSTATEDIR + ZFS_AC_CONFIG_USER_MUSL dnl # dnl # Checks for library functions AC_CHECK_FUNCS([mlockall]) diff --git a/include/sys/zfs_context.h b/include/sys/zfs_context.h index bbb8a0463d93..2839dbdf9df6 100644 --- a/include/sys/zfs_context.h +++ b/include/sys/zfs_context.h @@ -118,6 +118,10 @@ #include #include +#ifndef RLIM64_INFINITY +#define RLIM64_INFINITY (~0ULL) +#endif + /* * Stack */ @@ -614,7 +618,7 @@ extern void delay(clock_t ticks); #define minclsyspri 60 #define maxclsyspri 99 -#define CPU_SEQID (pthread_self() & (max_ncpus - 1)) +#define CPU_SEQID ((long long)pthread_self() & (max_ncpus - 1)) #define kcred NULL #define CRED() NULL diff --git a/lib/libnvpair/Makefile.am b/lib/libnvpair/Makefile.am index 7a8f96a05012..8275f68cb6c9 100644 --- a/lib/libnvpair/Makefile.am +++ b/lib/libnvpair/Makefile.am @@ -1,6 +1,6 @@ include $(top_srcdir)/config/Rules.am -AM_CFLAGS += $(DEBUG_STACKFLAGS) $(FRAME_LARGER_THAN) +AM_CFLAGS += $(DEBUG_STACKFLAGS) $(FRAME_LARGER_THAN) $(TIRPC_CFLAGS) DEFAULT_INCLUDES += \ -I$(top_srcdir)/include \ diff --git a/lib/libspl/Makefile.am b/lib/libspl/Makefile.am index dbf85c40fe39..15d7cf5f83be 100644 --- a/lib/libspl/Makefile.am +++ b/lib/libspl/Makefile.am @@ -1,12 +1,12 @@ include $(top_srcdir)/config/Rules.am -AM_CFLAGS += $(DEBUG_STACKFLAGS) $(FRAME_LARGER_THAN) +AM_CFLAGS += $(DEBUG_STACKFLAGS) $(FRAME_LARGER_THAN) $(TIRPC_CFLAGS) SUBDIRS = include $(TARGET_ASM_DIR) DIST_SUBDIRS = include asm-generic asm-i386 asm-x86_64 DEFAULT_INCLUDES += \ - -I$(top_srcdir)/lib/libspl/include + -I$(top_srcdir)/lib/libspl/include $(TIRPC_CFLAGS) AM_CCASFLAGS = \ -I$(top_srcdir)/lib/libspl/include @@ -30,4 +30,4 @@ libspl_la_SOURCES = \ $(top_srcdir)/lib/libspl/include/sys/list.h \ $(top_srcdir)/lib/libspl/include/sys/list_impl.h -libspl_la_LIBADD = -lrt +libspl_la_LIBADD = -lrt $(TIRPC_LDFLAGS) diff --git a/lib/libspl/include/assert.h b/lib/libspl/include/assert.h index d749d1e9c3bf..4791dcf820f0 100644 --- a/lib/libspl/include/assert.h +++ b/lib/libspl/include/assert.h @@ -42,6 +42,17 @@ __assert_c99(const char *expr, const char *file, int line, const char *func) } #endif /* __assert_c99 */ +#ifndef __assert +static inline void +__assert(const char *expr, const char *file, int line) +{ + fprintf(stderr, "%s:%i: %s: Assertion failed.\n", file, line, expr); + abort(); +} +#else +extern void __assert(const char *, const char *, int); +#endif + #ifndef verify #if defined(__STDC__) #if __STDC_VERSION__ - 0 >= 199901L @@ -61,8 +72,6 @@ __assert_c99(const char *expr, const char *file, int line, const char *func) #define VERIFY verify #define ASSERT assert -extern void __assert(const char *, const char *, int); - /* BEGIN CSTYLED */ #define VERIFY3_IMPL(LEFT, OP, RIGHT, TYPE) do { \ const TYPE __left = (TYPE)(LEFT); \ diff --git a/lib/libspl/include/devid.h b/lib/libspl/include/devid.h index 5406c33b5283..306098fa05af 100644 --- a/lib/libspl/include/devid.h +++ b/lib/libspl/include/devid.h @@ -29,6 +29,11 @@ #include +#ifndef __dev_t_defined +#define __NEED_dev_t +#include +#endif + typedef int ddi_devid_t; typedef struct devid_nmlist { diff --git a/lib/libspl/include/rpc/xdr.h b/lib/libspl/include/rpc/xdr.h index 99500d657ba2..27e7590a88bd 100644 --- a/lib/libspl/include/rpc/xdr.h +++ b/lib/libspl/include/rpc/xdr.h @@ -60,6 +60,8 @@ typedef struct xdr_bytesrec { #define XDR_RDMAGET 4 #define XDR_RDMASET 5 +#ifndef HAVE_TIRPC extern bool_t xdr_control(XDR *xdrs, int request, void *info); +#endif #endif diff --git a/lib/libspl/include/sys/inttypes.h b/lib/libspl/include/sys/inttypes.h index d7d063985316..9707fa282414 100644 --- a/lib/libspl/include/sys/inttypes.h +++ b/lib/libspl/include/sys/inttypes.h @@ -30,5 +30,9 @@ #include #define _INT64_TYPE +#ifndef RLIM64_INFINITY +#define RLIM64_INFINITY (~0ULL) +#endif + #endif diff --git a/lib/libspl/include/sys/time.h b/lib/libspl/include/sys/time.h index f0da440a288c..aa96c39815cd 100644 --- a/lib/libspl/include/sys/time.h +++ b/lib/libspl/include/sys/time.h @@ -58,6 +58,11 @@ #define NSEC2MSEC(n) ((n) / (NANOSEC / MILLISEC)) #endif +#ifndef HAVE_HR_TYPES +typedef long long longlong_t; +typedef longlong_t hrtime_t; +typedef struct timespec timestruc_t; +#endif extern hrtime_t gethrtime(void); extern void gethrestime(timestruc_t *); diff --git a/lib/libspl/include/sys/types.h b/lib/libspl/include/sys/types.h index bd34dec32108..ede130526374 100644 --- a/lib/libspl/include/sys/types.h +++ b/lib/libspl/include/sys/types.h @@ -30,7 +30,6 @@ #include #include #include_next -#include /* for NBBY */ #include #include @@ -60,6 +59,7 @@ typedef long spgcnt_t; /* signed number of pages */ typedef longlong_t hrtime_t; typedef struct timespec timestruc_t; typedef struct timespec timespec_t; +#define HAVE_HR_TYPES typedef short pri_t; @@ -96,4 +96,6 @@ typedef union { } lloff_t; #endif +#include /* for NBBY */ + #endif diff --git a/lib/libspl/timestamp.c b/lib/libspl/timestamp.c index a4f4cf4e47e0..a1772703c76f 100644 --- a/lib/libspl/timestamp.c +++ b/lib/libspl/timestamp.c @@ -28,6 +28,10 @@ #include #include "statcommon.h" +#ifndef _DATE_FMT +#define _DATE_FMT D_FMT +#endif + /* * Print timestamp as decimal reprentation of time_t value (-T u was specified) * or in date(1) format (-T d was specified). diff --git a/lib/libspl/xdr.c b/lib/libspl/xdr.c index 288a338a1214..c8a6fe30c864 100644 --- a/lib/libspl/xdr.c +++ b/lib/libspl/xdr.c @@ -29,6 +29,7 @@ * under license from the Regents of the University of California. */ +#ifndef HAVE_TIRPC #include /* @@ -76,3 +77,4 @@ xdr_control(XDR *xdrs, int request, void *info) } return (FALSE); } +#endif diff --git a/module/nvpair/nvpair.c b/module/nvpair/nvpair.c index f5c31663a70c..750556b06a06 100644 --- a/module/nvpair/nvpair.c +++ b/module/nvpair/nvpair.c @@ -3251,8 +3251,12 @@ nvs_xdr_nvpair(nvstream_t *nvs, nvpair_t *nvp, size_t *size) return (0); /* sanity check the size parameter */ +#ifndef HAVE_TIRPC if (!xdr_control(xdr, XDR_GET_BYTES_AVAIL, &bytesrec)) return (EFAULT); +#else + xdr_control(xdr, XDR_GET_BYTES_AVAIL, &bytesrec); +#endif if (*size > NVS_XDR_MAX_LEN(bytesrec.xc_num_avail)) return (EFAULT); diff --git a/module/zcommon/zfs_uio.c b/module/zcommon/zfs_uio.c index 90376f2acf57..a1f2a3d5f644 100644 --- a/module/zcommon/zfs_uio.c +++ b/module/zcommon/zfs_uio.c @@ -44,6 +44,7 @@ */ #ifdef _KERNEL +#include #include #include diff --git a/module/zfs/arc.c b/module/zfs/arc.c index 27b004132a6c..e16bfd63a420 100644 --- a/module/zfs/arc.c +++ b/module/zfs/arc.c @@ -135,6 +135,7 @@ #include #include #include +#include #ifdef _KERNEL #include #include