Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

patchset for compatibility with musl libc #2604

Closed
wants to merge 11 commits into from
3 changes: 2 additions & 1 deletion cmd/mount_zfs/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -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)
1 change: 1 addition & 0 deletions cmd/mount_zfs/mount_zfs.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include <sys/stat.h>
#include <libzfs.h>
#include <locale.h>
#include <fcntl.h>

libzfs_handle_t *g_zfs;

Expand Down
2 changes: 1 addition & 1 deletion cmd/zdb/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -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)
3 changes: 2 additions & 1 deletion cmd/zed/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion cmd/zfs/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion cmd/zhack/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -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)
3 changes: 2 additions & 1 deletion cmd/zinject/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -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)
2 changes: 1 addition & 1 deletion cmd/zpool/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -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)
2 changes: 1 addition & 1 deletion cmd/zstreamdump/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -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)
2 changes: 1 addition & 1 deletion cmd/ztest/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -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)
19 changes: 19 additions & 0 deletions config/musl.m4
Original file line number Diff line number Diff line change
@@ -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])
])
1 change: 1 addition & 0 deletions config/user.m4
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down
6 changes: 5 additions & 1 deletion include/sys/zfs_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,10 @@
#include <sys/sunddi.h>
#include <sys/debug.h>

#ifndef RLIM64_INFINITY
#define RLIM64_INFINITY (~0ULL)
#endif

/*
* Stack
*/
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/libnvpair/Makefile.am
Original file line number Diff line number Diff line change
@@ -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 \
Expand Down
6 changes: 3 additions & 3 deletions lib/libspl/Makefile.am
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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)
13 changes: 11 additions & 2 deletions lib/libspl/include/assert.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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); \
Expand Down
5 changes: 5 additions & 0 deletions lib/libspl/include/devid.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@

#include <stdlib.h>

#ifndef __dev_t_defined
#define __NEED_dev_t
#include <bits/alltypes.h>
#endif

typedef int ddi_devid_t;

typedef struct devid_nmlist {
Expand Down
2 changes: 2 additions & 0 deletions lib/libspl/include/rpc/xdr.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 4 additions & 0 deletions lib/libspl/include/sys/inttypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,9 @@
#include <inttypes.h>

#define _INT64_TYPE
#ifndef RLIM64_INFINITY
#define RLIM64_INFINITY (~0ULL)
#endif


#endif
5 changes: 5 additions & 0 deletions lib/libspl/include/sys/time.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 *);

Expand Down
4 changes: 3 additions & 1 deletion lib/libspl/include/sys/types.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
#include <sys/isa_defs.h>
#include <sys/feature_tests.h>
#include_next <sys/types.h>
#include <sys/param.h> /* for NBBY */
#include <sys/types32.h>
#include <sys/va_list.h>

Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -96,4 +96,6 @@ typedef union {
} lloff_t;
#endif

#include <sys/param.h> /* for NBBY */

#endif
4 changes: 4 additions & 0 deletions lib/libspl/timestamp.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,10 @@
#include <langinfo.h>
#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).
Expand Down
2 changes: 2 additions & 0 deletions lib/libspl/xdr.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
* under license from the Regents of the University of California.
*/

#ifndef HAVE_TIRPC
#include <rpc/xdr.h>

/*
Expand Down Expand Up @@ -76,3 +77,4 @@ xdr_control(XDR *xdrs, int request, void *info)
}
return (FALSE);
}
#endif
4 changes: 4 additions & 0 deletions module/nvpair/nvpair.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions module/zcommon/zfs_uio.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
*/
#ifdef _KERNEL

#include <sys/param.h>
#include <sys/types.h>
#include <sys/uio_impl.h>

Expand Down
1 change: 1 addition & 0 deletions module/zfs/arc.c
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@
#include <sys/vdev.h>
#include <sys/vdev_impl.h>
#include <sys/dsl_pool.h>
#include <linux/param.h>
#ifdef _KERNEL
#include <sys/vmsystm.h>
#include <vm/anon.h>
Expand Down