]> git.proxmox.com Git - mirror_zfs.git/commitdiff
Support -fsanitize=address with --enable-asan
authorBrian Behlendorf <behlendorf1@llnl.gov>
Wed, 10 Jan 2018 18:49:27 +0000 (10:49 -0800)
committerGitHub <noreply@github.com>
Wed, 10 Jan 2018 18:49:27 +0000 (10:49 -0800)
When --enable-asan is provided to configure then build all user
space components with fsanitize=address.  For kernel support
use the Linux KASAN feature instead.

https://github.com/google/sanitizers/wiki/AddressSanitizer

When using gcc version 4.8 any test case which intentionally
generates a core dump will fail when using --enable-asan.
The default behavior is to disable core dumps and only newer
versions allow this behavior to be controled at run time with
the ASAN_OPTIONS environment variable.

Additionally, this patch includes some build system cleanup.

* Rules.am updated to set the minimum AM_CFLAGS, AM_CPPFLAGS,
  and AM_LDFLAGS.  Any additional flags should be added on a
  per-Makefile basic.  The --enable-debug and --enable-asan
  options apply to all user space binaries and libraries.

* Compiler checks consolidated in always-compiler-options.m4
  and renamed for consistency.

* -fstack-check compiler flag was removed, this functionality
  is provided by asan when configured with --enable-asan.

* Split DEBUG_CFLAGS in to DEBUG_CFLAGS, DEBUG_CPPFLAGS, and
  DEBUG_LDFLAGS.

* Moved default kernel build flags in to module/Makefile.in and
  split in to ZFS_MODULE_CFLAGS and ZFS_MODULE_CPPFLAGS.  These
  flags are set with the standard ccflags-y kbuild mechanism.

* -Wframe-larger-than checks applied only to binaries or
  libraries which include source files which are built in
  both user space and kernel space.  This restriction is
  relaxed for user space only utilities.

* -Wno-unused-but-set-variable applied only to libzfs and
  libzpool.  The remaining warnings are the result of an
  ASSERT using a variable when is always declared.

* -D_POSIX_PTHREAD_SEMANTICS and -D__EXTENSIONS__ dropped
  because they are Solaris specific and thus not needed.

* Ensure $GDB is defined as gdb by default in zloop.sh.

Signed-off-by: DHE <git@dehacked.net>
Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Closes #7027

40 files changed:
cmd/raidz_test/Makefile.am
cmd/zdb/Makefile.am
cmd/ztest/Makefile.am
config/Rules.am
config/always-compiler-options.m4 [new file with mode: 0644]
config/always-no-bool-compare.m4 [deleted file]
config/always-no-unused-but-set-variable.m4 [deleted file]
config/kernel.m4
config/user-frame-larger-than.m4 [deleted file]
config/user-no-format-truncation.m4 [deleted file]
config/user.m4
config/zfs-build.m4
lib/libavl/Makefile.am
lib/libefi/Makefile.am
lib/libicp/Makefile.am
lib/libnvpair/Makefile.am
lib/libshare/Makefile.am
lib/libspl/Makefile.am
lib/libtpool/Makefile.am
lib/libunicode/Makefile.am
lib/libuutil/Makefile.am
lib/libzfs/Makefile.am
lib/libzfs_core/Makefile.am
lib/libzpool/Makefile.am
module/Makefile.in
module/avl/Makefile.in
module/icp/Makefile.in
module/nvpair/Makefile.in
module/unicode/Makefile.in
module/zcommon/Makefile.in
module/zfs/Makefile.in
rpm/generic/zfs-kmod.spec.in
rpm/generic/zfs.spec.in
rpm/redhat/zfs-kmod.spec.in
scripts/zloop.sh
tests/zfs-tests/tests/functional/checksum/Makefile.am
tests/zfs-tests/tests/functional/cli_root/zfs/zfs_002_pos.ksh
tests/zfs-tests/tests/functional/cli_root/zpool/zpool_002_pos.ksh
tests/zfs-tests/tests/functional/cli_root/zpool/zpool_003_pos.ksh
tests/zfs-tests/tests/functional/hkdf/Makefile.am

index 02cc746ec9263250a53e5e0c97bd379b49f846fe..a394a0dde3b2036ab0aa58ca5469bfee0cd2733e 100644 (file)
@@ -1,7 +1,10 @@
 include $(top_srcdir)/config/Rules.am
 
-AM_CFLAGS += $(DEBUG_STACKFLAGS) $(FRAME_LARGER_THAN)
-AM_CPPFLAGS += -DDEBUG
+# Includes kernel code, generate warnings for large stack frames
+AM_CFLAGS += $(FRAME_LARGER_THAN)
+
+# Unconditionally enable ASSERTs
+AM_CPPFLAGS += -DDEBUG -UNDEBUG
 
 DEFAULT_INCLUDES += \
        -I$(top_srcdir)/include \
index c1543e86ecdc9214ae24ae7ef72d59db314c43fa..70b60bfaf8602c217213c5f9cc95cd3bb3639ad0 100644 (file)
@@ -1,6 +1,7 @@
 include $(top_srcdir)/config/Rules.am
 
-AM_CPPFLAGS += -DDEBUG
+# Unconditionally enable debugging for zdb
+AM_CPPFLAGS += -DDEBUG -UNDEBUG
 
 DEFAULT_INCLUDES += \
        -I$(top_srcdir)/include \
index cbfb95fd3b3324ed8a628227733333000d073692..489d8b54799cc7162280f7a9362c6a937bfb2f1a 100644 (file)
@@ -1,8 +1,12 @@
 include $(top_srcdir)/config/Rules.am
 
-# -Wnoformat-truncation to get rid of compiler warning for unchecked
-#  truncating snprintfs on gcc 7.1.1.
-AM_CFLAGS += $(DEBUG_STACKFLAGS) $(FRAME_LARGER_THAN) $(NO_FORMAT_TRUNCATION)
+# Get rid of compiler warning for unchecked truncating snprintfs on gcc 7.1.1
+AM_CFLAGS += $(NO_FORMAT_TRUNCATION)
+
+# Includes kernel code, generate warnings for large stack frames
+AM_CFLAGS += $(FRAME_LARGER_THAN)
+
+# Unconditionally enable ASSERTs
 AM_CPPFLAGS += -DDEBUG -UNDEBUG
 
 DEFAULT_INCLUDES += \
index 215f09c34a9ca6e5d86f33569b4b2da989fe1256..9a9dd452ae47424c21415ea80fd9d99077115797 100644 (file)
@@ -1,18 +1,29 @@
+#
+# Default build rules for all user space components, every Makefile.am
+# should include these rules and override or extend them as needed.
+#
+
 DEFAULT_INCLUDES = -include ${top_builddir}/zfs_config.h
 
 AM_LIBTOOLFLAGS = --silent
-AM_CFLAGS  = ${DEBUG_CFLAGS} -Wall -Wstrict-prototypes
-AM_CFLAGS += ${NO_UNUSED_BUT_SET_VARIABLE}
-AM_CFLAGS += ${NO_BOOL_COMPARE}
-AM_CFLAGS += -fno-strict-aliasing
-AM_CFLAGS += -std=gnu99
+
+AM_CFLAGS  = -std=gnu99 -Wall -Wstrict-prototypes -fno-strict-aliasing
+AM_CFLAGS += $(DEBUG_CFLAGS)
+AM_CFLAGS += $(ASAN_CFLAGS)
 AM_CFLAGS += $(CODE_COVERAGE_CFLAGS)
-AM_CPPFLAGS  = -D_GNU_SOURCE -D__EXTENSIONS__ -D_REENTRANT
-AM_CPPFLAGS += -D_POSIX_PTHREAD_SEMANTICS -D_FILE_OFFSET_BITS=64
-AM_CPPFLAGS += -D_LARGEFILE64_SOURCE -DHAVE_LARGE_STACKS=1
+
+AM_CPPFLAGS  = -D_GNU_SOURCE
+AM_CPPFLAGS += -D_REENTRANT
+AM_CPPFLAGS += -D_FILE_OFFSET_BITS=64
+AM_CPPFLAGS += -D_LARGEFILE64_SOURCE
+AM_CPPFLAGS += -DHAVE_LARGE_STACKS=1
 AM_CPPFLAGS += -DTEXT_DOMAIN=\"zfs-linux-user\"
 AM_CPPFLAGS += -DLIBEXECDIR=\"$(libexecdir)\"
 AM_CPPFLAGS += -DRUNSTATEDIR=\"$(runstatedir)\"
 AM_CPPFLAGS += -DSBINDIR=\"$(sbindir)\"
 AM_CPPFLAGS += -DSYSCONFDIR=\"$(sysconfdir)\"
+AM_CPPFLAGS += $(DEBUG_CPPFLAGS)
 AM_CPPFLAGS += $(CODE_COVERAGE_CPPFLAGS)
+
+AM_LDFLAGS  = $(DEBUG_LDFLAGS)
+AM_LDFLAGS += $(ASAN_LDFLAGS)
diff --git a/config/always-compiler-options.m4 b/config/always-compiler-options.m4
new file mode 100644 (file)
index 0000000..fcbbf5e
--- /dev/null
@@ -0,0 +1,141 @@
+dnl #
+dnl # Enabled -fsanitize=address if supported by gcc.
+dnl #
+dnl # LDFLAGS needs -fsanitize=address at all times so libraries compiled with
+dnl # it will be linked successfully. CFLAGS will vary by binary being built.
+dnl #
+dnl # The ASAN_OPTIONS environment variable can be used to further control
+dnl # the behavior of binaries and libraries build with -fsanitize=address.
+dnl #
+AC_DEFUN([ZFS_AC_CONFIG_ALWAYS_CC_ASAN], [
+       AC_MSG_CHECKING([whether to build with -fsanitize=address support])
+       AC_ARG_ENABLE([asan],
+               [AS_HELP_STRING([--enable-asan],
+               [Enable -fsanitize=address support  @<:@default=no@:>@])],
+               [],
+               [enable_asan=no])
+
+       AM_CONDITIONAL([ASAN_ENABLED], [test x$enable_asan = xyes])
+       AC_SUBST([ASAN_ENABLED], [$enable_asan])
+       AC_MSG_RESULT($enable_asan)
+
+       AS_IF([ test "$enable_asan" = "yes" ], [
+               AC_MSG_CHECKING([whether $CC supports -fsanitize=address])
+               saved_cflags="$CFLAGS"
+               CFLAGS="$CFLAGS -fsanitize=address"
+               AC_LINK_IFELSE([
+                       AC_LANG_SOURCE([[ int main() { return 0; } ]])
+               ], [
+                       ASAN_CFLAGS="-fsanitize=address"
+                       ASAN_LDFLAGS="-fsanitize=address"
+                       ASAN_ZFS="_with_asan"
+                       AC_MSG_RESULT([yes])
+               ], [
+                       AC_MSG_ERROR([$CC does not support -fsanitize=address])
+               ])
+               CFLAGS="$saved_cflags"
+       ], [
+               ASAN_CFLAGS=""
+               ASAN_LDFLAGS=""
+               ASAN_ZFS="_without_asan"
+       ])
+
+       AC_SUBST([ASAN_CFLAGS])
+       AC_SUBST([ASAN_LDFLAGS])
+       AC_SUBST([ASAN_ZFS])
+])
+
+dnl #
+dnl # Check if gcc supports -Wframe-larger-than=<size> option.
+dnl #
+AC_DEFUN([ZFS_AC_CONFIG_ALWAYS_CC_FRAME_LARGER_THAN], [
+       AC_MSG_CHECKING([whether $CC supports -Wframe-larger-than=<size>])
+
+       saved_flags="$CFLAGS"
+       CFLAGS="$CFLAGS -Wframe-larger-than=4096"
+
+       AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [])], [
+               FRAME_LARGER_THAN="-Wframe-larger-than=4096"
+               AC_MSG_RESULT([yes])
+       ], [
+               FRAME_LARGER_THAN=""
+               AC_MSG_RESULT([no])
+       ])
+
+       CFLAGS="$saved_flags"
+       AC_SUBST([FRAME_LARGER_THAN])
+])
+
+dnl #
+dnl # Check if gcc supports -Wno-format-truncation option.
+dnl #
+AC_DEFUN([ZFS_AC_CONFIG_ALWAYS_CC_NO_FORMAT_TRUNCATION], [
+       AC_MSG_CHECKING([whether $CC supports -Wno-format-truncation])
+
+       saved_flags="$CFLAGS"
+       CFLAGS="$CFLAGS -Wno-format-truncation"
+
+       AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [])], [
+               NO_FORMAT_TRUNCATION=-Wno-format-truncation
+               AC_MSG_RESULT([yes])
+       ], [
+               NO_FORMAT_TRUNCATION=
+               AC_MSG_RESULT([no])
+       ])
+
+       CFLAGS="$saved_flags"
+       AC_SUBST([NO_FORMAT_TRUNCATION])
+])
+
+
+dnl #
+dnl # Check if gcc supports -Wno-bool-compare option.
+dnl #
+dnl # We actually invoke gcc with the -Wbool-compare option
+dnl # and infer the 'no-' version does or doesn't exist based upon
+dnl # the results.  This is required because when checking any of
+dnl # no- prefixed options gcc always returns success.
+dnl #
+AC_DEFUN([ZFS_AC_CONFIG_ALWAYS_CC_NO_BOOL_COMPARE], [
+       AC_MSG_CHECKING([whether $CC supports -Wno-bool-compare])
+
+       saved_flags="$CFLAGS"
+       CFLAGS="$CFLAGS -Wbool-compare"
+
+       AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [])], [
+               NO_BOOL_COMPARE=-Wno-bool-compare
+               AC_MSG_RESULT([yes])
+       ], [
+               NO_BOOL_COMPARE=
+               AC_MSG_RESULT([no])
+       ])
+
+       CFLAGS="$saved_flags"
+       AC_SUBST([NO_BOOL_COMPARE])
+])
+
+dnl #
+dnl # Check if gcc supports -Wno-unused-but-set-variable option.
+dnl #
+dnl # We actually invoke gcc with the -Wunused-but-set-variable option
+dnl # and infer the 'no-' version does or doesn't exist based upon
+dnl # the results.  This is required because when checking any of
+dnl # no- prefixed options gcc always returns success.
+dnl #
+AC_DEFUN([ZFS_AC_CONFIG_ALWAYS_CC_NO_UNUSED_BUT_SET_VARIABLE], [
+       AC_MSG_CHECKING([whether $CC supports -Wno-unused-but-set-variable])
+
+       saved_flags="$CFLAGS"
+       CFLAGS="$CFLAGS -Wunused-but-set-variable"
+
+       AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [])], [
+               NO_UNUSED_BUT_SET_VARIABLE=-Wno-unused-but-set-variable
+               AC_MSG_RESULT([yes])
+       ], [
+               NO_UNUSED_BUT_SET_VARIABLE=
+               AC_MSG_RESULT([no])
+       ])
+
+       CFLAGS="$saved_flags"
+       AC_SUBST([NO_UNUSED_BUT_SET_VARIABLE])
+])
diff --git a/config/always-no-bool-compare.m4 b/config/always-no-bool-compare.m4
deleted file mode 100644 (file)
index 316b04b..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-dnl #
-dnl # Check if gcc supports -Wno-bool-compare option.
-dnl #
-dnl # We actually invoke gcc with the -Wbool-compare option
-dnl # and infer the 'no-' version does or doesn't exist based upon
-dnl # the results.  This is required because when checking any of
-dnl # no- prefixed options gcc always returns success.
-dnl #
-AC_DEFUN([ZFS_AC_CONFIG_ALWAYS_NO_BOOL_COMPARE], [
-       AC_MSG_CHECKING([for -Wno-bool-compare support])
-
-       saved_flags="$CFLAGS"
-       CFLAGS="$CFLAGS -Wbool-compare"
-
-       AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [])],
-       [
-               NO_BOOL_COMPARE=-Wno-bool-compare
-               AC_MSG_RESULT([yes])
-       ],
-       [
-               NO_BOOL_COMPARE=
-               AC_MSG_RESULT([no])
-       ])
-
-       CFLAGS="$saved_flags"
-       AC_SUBST([NO_BOOL_COMPARE])
-])
diff --git a/config/always-no-unused-but-set-variable.m4 b/config/always-no-unused-but-set-variable.m4
deleted file mode 100644 (file)
index 863c90a..0000000
+++ /dev/null
@@ -1,27 +0,0 @@
-dnl #
-dnl # Check if gcc supports -Wno-unused-but-set-variable option.
-dnl #
-dnl # We actually invoke gcc with the -Wunused-but-set-variable option
-dnl # and infer the 'no-' version does or doesn't exist based upon
-dnl # the results.  This is required because when checking any of
-dnl # no- prefixed options gcc always returns success.
-dnl #
-AC_DEFUN([ZFS_AC_CONFIG_ALWAYS_NO_UNUSED_BUT_SET_VARIABLE], [
-       AC_MSG_CHECKING([for -Wno-unused-but-set-variable support])
-
-       saved_flags="$CFLAGS"
-       CFLAGS="$CFLAGS -Wunused-but-set-variable"
-
-       AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [])],
-       [
-               NO_UNUSED_BUT_SET_VARIABLE=-Wno-unused-but-set-variable
-               AC_MSG_RESULT([yes])
-       ],
-       [
-               NO_UNUSED_BUT_SET_VARIABLE=
-               AC_MSG_RESULT([no])
-       ])
-
-       CFLAGS="$saved_flags"
-       AC_SUBST([NO_UNUSED_BUT_SET_VARIABLE])
-])
index b759ccd39a29826e8b8189726e69b4f8bdeecbdd..f8d81cdc0fb5b3fbdc6d4f56a790fd7287f969a0 100644 (file)
@@ -125,21 +125,10 @@ AC_DEFUN([ZFS_AC_CONFIG_KERNEL], [
        ZFS_AC_KERNEL_VM_NODE_STAT
 
        AS_IF([test "$LINUX_OBJ" != "$LINUX"], [
-               KERNELMAKE_PARAMS="$KERNELMAKE_PARAMS O=$LINUX_OBJ"
+               KERNEL_MAKE="$KERNEL_MAKE O=$LINUX_OBJ"
        ])
-       AC_SUBST(KERNELMAKE_PARAMS)
 
-
-       dnl # -Wall -fno-strict-aliasing -Wstrict-prototypes and other
-       dnl # compiler options are added by the kernel build system.
-       KERNELCPPFLAGS="$KERNELCPPFLAGS -std=gnu99"
-       KERNELCPPFLAGS="$KERNELCPPFLAGS -Wno-declaration-after-statement"
-       KERNELCPPFLAGS="$KERNELCPPFLAGS $NO_UNUSED_BUT_SET_VARIABLE"
-       KERNELCPPFLAGS="$KERNELCPPFLAGS $NO_BOOL_COMPARE"
-       KERNELCPPFLAGS="$KERNELCPPFLAGS -DHAVE_SPL -D_KERNEL"
-       KERNELCPPFLAGS="$KERNELCPPFLAGS -DTEXT_DOMAIN=\\\"zfs-linux-kernel\\\""
-
-       AC_SUBST(KERNELCPPFLAGS)
+       AC_SUBST(KERNEL_MAKE)
 ])
 
 dnl #
diff --git a/config/user-frame-larger-than.m4 b/config/user-frame-larger-than.m4
deleted file mode 100644 (file)
index e0828ec..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-dnl #
-dnl # Check if gcc supports -Wframe-larger-than=<size> option.
-dnl #
-AC_DEFUN([ZFS_AC_CONFIG_USER_FRAME_LARGER_THAN], [
-       AC_MSG_CHECKING([for -Wframe-larger-than=<size> support])
-
-       saved_flags="$CFLAGS"
-       CFLAGS="$CFLAGS -Wframe-larger-than=1024"
-
-       AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [])],
-       [
-               FRAME_LARGER_THAN=-Wframe-larger-than=1024
-               AC_MSG_RESULT([yes])
-       ],
-       [
-               FRAME_LARGER_THAN=
-               AC_MSG_RESULT([no])
-       ])
-
-       CFLAGS="$saved_flags"
-        AC_SUBST([FRAME_LARGER_THAN])
-])
diff --git a/config/user-no-format-truncation.m4 b/config/user-no-format-truncation.m4
deleted file mode 100644 (file)
index 4426907..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-dnl #
-dnl # Check if gcc supports -Wno-format-truncation option.
-dnl #
-AC_DEFUN([ZFS_AC_CONFIG_USER_NO_FORMAT_TRUNCATION], [
-       AC_MSG_CHECKING([for -Wno-format-truncation support])
-
-       saved_flags="$CFLAGS"
-       CFLAGS="$CFLAGS -Wno-format-truncation"
-
-       AC_COMPILE_IFELSE([AC_LANG_PROGRAM([], [])],
-       [
-               NO_FORMAT_TRUNCATION=-Wno-format-truncation
-               AC_MSG_RESULT([yes])
-       ],
-       [
-               NO_FORMAT_TRUNCATION=
-               AC_MSG_RESULT([no])
-       ])
-
-       CFLAGS="$saved_flags"
-       AC_SUBST([NO_FORMAT_TRUNCATION])
-])
index 73f6433a2ea7a498a125145993d68bc21de2d06b..0bada893b4606573e8a23ced4f0f8adecc21c59a 100644 (file)
@@ -14,11 +14,9 @@ AC_DEFUN([ZFS_AC_CONFIG_USER], [
        ZFS_AC_CONFIG_USER_LIBATTR
        ZFS_AC_CONFIG_USER_LIBUDEV
        ZFS_AC_CONFIG_USER_LIBSSL
-       ZFS_AC_CONFIG_USER_FRAME_LARGER_THAN
        ZFS_AC_CONFIG_USER_RUNSTATEDIR
        ZFS_AC_CONFIG_USER_MAKEDEV_IN_SYSMACROS
        ZFS_AC_CONFIG_USER_MAKEDEV_IN_MKDEV
-       ZFS_AC_CONFIG_USER_NO_FORMAT_TRUNCATION
 
        ZFS_AC_TEST_FRAMEWORK
 
index 5eaa49c8759f811c09bf9c27b263302111104f7b..adc99edf592d61c01f63ea908bc8ef34bf6aceea 100644 (file)
@@ -7,27 +7,36 @@ AC_DEFUN([ZFS_AC_LICENSE], [
 ])
 
 AC_DEFUN([ZFS_AC_DEBUG_ENABLE], [
-       KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG -Werror"
-       HOSTCFLAGS="${HOSTCFLAGS} -DDEBUG -Werror"
-       DEBUG_CFLAGS="-DDEBUG -Werror"
-       DEBUG_STACKFLAGS="-fstack-check"
+       DEBUG_CFLAGS="-Werror"
+       DEBUG_CPPFLAGS="-DDEBUG -UNDEBUG"
+       DEBUG_LDFLAGS=""
        DEBUG_ZFS="_with_debug"
        AC_DEFINE(ZFS_DEBUG, 1, [zfs debugging enabled])
+
+       KERNEL_DEBUG_CFLAGS="-Werror"
+       KERNEL_DEBUG_CPPFLAGS="-DDEBUG -UNDEBUG"
 ])
 
 AC_DEFUN([ZFS_AC_DEBUG_DISABLE], [
-       KERNELCPPFLAGS="${KERNELCPPFLAGS} -DNDEBUG "
-       HOSTCFLAGS="${HOSTCFLAGS} -DNDEBUG "
-       DEBUG_CFLAGS="-DNDEBUG"
-       DEBUG_STACKFLAGS=""
+       DEBUG_CFLAGS=""
+       DEBUG_CPPFLAGS="-UDEBUG -DNDEBUG"
+       DEBUG_LDFLAGS=""
        DEBUG_ZFS="_without_debug"
+
+       KERNEL_DEBUG_CFLAGS=""
+       KERNEL_DEBUG_CPPFLAGS="-UDEBUG -DNDEBUG"
 ])
 
+dnl #
+dnl # When debugging is enabled:
+dnl # - Enable all ASSERTs (-DDEBUG)
+dnl # - Promote all compiler warnings to errors (-Werror)
+dnl #
 AC_DEFUN([ZFS_AC_DEBUG], [
        AC_MSG_CHECKING([whether assertion support will be enabled])
        AC_ARG_ENABLE([debug],
                [AS_HELP_STRING([--enable-debug],
-               [Enable assertion support @<:@default=no@:>@])],
+               [Enable compiler and code assertions @<:@default=no@:>@])],
                [],
                [enable_debug=no])
 
@@ -38,18 +47,28 @@ AC_DEFUN([ZFS_AC_DEBUG], [
                [ZFS_AC_DEBUG_DISABLE],
                [AC_MSG_ERROR([Unknown option $enable_debug])])
 
-       AC_SUBST(DEBUG_STACKFLAGS)
+       AC_SUBST(DEBUG_CFLAGS)
+       AC_SUBST(DEBUG_CPPFLAGS)
+       AC_SUBST(DEBUG_LDFLAGS)
        AC_SUBST(DEBUG_ZFS)
+
+       AC_SUBST(KERNEL_DEBUG_CFLAGS)
+       AC_SUBST(KERNEL_DEBUG_CPPFLAGS)
+
        AC_MSG_RESULT([$enable_debug])
 ])
 
-AC_DEFUN([ZFS_AC_DEBUGINFO_KERNEL], [
-       KERNELMAKE_PARAMS="$KERNELMAKE_PARAMS CONFIG_DEBUG_INFO=y"
-       KERNELCPPFLAGS="${KERNELCPPFLAGS} -fno-inline"
+AC_DEFUN([ZFS_AC_DEBUGINFO_ENABLE], [
+       DEBUG_CFLAGS="$DEBUG_CFLAGS -g -fno-inline"
+
+       KERNEL_DEBUG_CFLAGS="$KERNEL_DEBUG_CFLAGS -fno-inline"
+       KERNEL_MAKE="$KERNEL_MAKE CONFIG_DEBUG_INFO=y"
+
+       DEBUGINFO_ZFS="_with_debuginfo"
 ])
 
-AC_DEFUN([ZFS_AC_DEBUGINFO_USER], [
-       DEBUG_CFLAGS="${DEBUG_CFLAGS} -g -fno-inline"
+AC_DEFUN([ZFS_AC_DEBUGINFO_DISABLE], [
+       DEBUGINFO_ZFS="_without_debuginfo"
 ])
 
 AC_DEFUN([ZFS_AC_DEBUGINFO], [
@@ -62,23 +81,26 @@ AC_DEFUN([ZFS_AC_DEBUGINFO], [
 
        AS_CASE(["x$enable_debuginfo"],
                ["xyes"],
-               [ZFS_AC_DEBUGINFO_KERNEL
-               ZFS_AC_DEBUGINFO_USER],
-               ["xkernel"],
-               [ZFS_AC_DEBUGINFO_KERNEL],
-               ["xuser"],
-               [ZFS_AC_DEBUGINFO_USER],
+               [ZFS_AC_DEBUGINFO_ENABLE],
                ["xno"],
-               [],
-               [AC_MSG_ERROR([Unknown option $enable_debug])])
+               [ZFS_AC_DEBUGINFO_DISABLE],
+               [AC_MSG_ERROR([Unknown option $enable_debuginfo])])
 
        AC_SUBST(DEBUG_CFLAGS)
+       AC_SUBST(DEBUGINFO_ZFS)
+
+       AC_SUBST(KERNEL_DEBUG_CFLAGS)
+       AC_SUBST(KERNEL_MAKE)
+
        AC_MSG_RESULT([$enable_debuginfo])
 ])
 
 AC_DEFUN([ZFS_AC_CONFIG_ALWAYS], [
-       ZFS_AC_CONFIG_ALWAYS_NO_UNUSED_BUT_SET_VARIABLE
-       ZFS_AC_CONFIG_ALWAYS_NO_BOOL_COMPARE
+       ZFS_AC_CONFIG_ALWAYS_CC_NO_UNUSED_BUT_SET_VARIABLE
+       ZFS_AC_CONFIG_ALWAYS_CC_NO_BOOL_COMPARE
+       ZFS_AC_CONFIG_ALWAYS_CC_FRAME_LARGER_THAN
+       ZFS_AC_CONFIG_ALWAYS_CC_NO_FORMAT_TRUNCATION
+       ZFS_AC_CONFIG_ALWAYS_CC_ASAN
        ZFS_AC_CONFIG_ALWAYS_TOOLCHAIN_SIMD
        ZFS_AC_CONFIG_ALWAYS_ARCH
 ])
@@ -160,9 +182,23 @@ AC_DEFUN([ZFS_AC_RPM], [
        ])
 
        RPM_DEFINE_COMMON='--define "$(DEBUG_ZFS) 1"'
-       RPM_DEFINE_UTIL='--define "_dracutdir $(dracutdir)" --define "_udevdir $(udevdir)" --define "_udevruledir $(udevruledir)" --define "_initconfdir $(DEFAULT_INITCONF_DIR)" $(DEFINE_INITRAMFS) $(DEFINE_SYSTEMD)'
-       RPM_DEFINE_KMOD='--define "kernels $(LINUX_VERSION)" --define "require_spldir $(SPL)" --define "require_splobj $(SPL_OBJ)" --define "ksrc $(LINUX)" --define "kobj $(LINUX_OBJ)"'
-       RPM_DEFINE_DKMS=
+       RPM_DEFINE_COMMON+=' --define "$(DEBUGINFO_ZFS) 1"'
+       RPM_DEFINE_COMMON+=' --define "$(ASAN_ZFS) 1"'
+
+       RPM_DEFINE_UTIL='--define "_dracutdir $(dracutdir)"'
+       RPM_DEFINE_UTIL+=' --define "_udevdir $(udevdir)"'
+       RPM_DEFINE_UTIL+=' --define "_udevruledir $(udevruledir)"'
+       RPM_DEFINE_UTIL+=' --define "_initconfdir $(DEFAULT_INITCONF_DIR)"'
+       RPM_DEFINE_UTIL+=' $(DEFINE_INITRAMFS)'
+       RPM_DEFINE_UTIL+=' $(DEFINE_SYSTEMD)'
+
+       RPM_DEFINE_KMOD='--define "kernels $(LINUX_VERSION)"'
+       RPM_DEFINE_KMOD+=' --define "require_spldir $(SPL)"'
+       RPM_DEFINE_KMOD+=' --define "require_splobj $(SPL_OBJ)"'
+       RPM_DEFINE_KMOD+=' --define "ksrc $(LINUX)"'
+       RPM_DEFINE_KMOD+=' --define "kobj $(LINUX_OBJ)"'
+
+       RPM_DEFINE_DKMS=''
 
        SRPM_DEFINE_COMMON='--define "build_src_rpm 1"'
        SRPM_DEFINE_UTIL=
index 6a42649b882b3b4624f7b36466eb4bae440efde6..82b30bd80fa0284d81475ab74401d2238fc8af2e 100644 (file)
@@ -2,7 +2,8 @@ include $(top_srcdir)/config/Rules.am
 
 VPATH = $(top_srcdir)/module/avl/
 
-AM_CFLAGS += $(DEBUG_STACKFLAGS) $(FRAME_LARGER_THAN)
+# Includes kernel code, generate warnings for large stack frames
+AM_CFLAGS += $(FRAME_LARGER_THAN)
 
 DEFAULT_INCLUDES += \
        -I$(top_srcdir)/include \
index f0c05ee6c44cc4976b162ad711420e19e0278c7f..9f69e46014571da9b1c5ee1170cfabaeb28cfaad 100644 (file)
@@ -1,7 +1,5 @@
 include $(top_srcdir)/config/Rules.am
 
-AM_CFLAGS += $(DEBUG_STACKFLAGS) $(FRAME_LARGER_THAN)
-
 DEFAULT_INCLUDES += \
        -I$(top_srcdir)/include \
        -I$(top_srcdir)/lib/libspl/include
@@ -11,11 +9,7 @@ noinst_LTLIBRARIES = libefi.la
 USER_C = \
        rdwr_efi.c
 
-KERNEL_C =
-
-nodist_libefi_la_SOURCES = \
-       $(USER_C) \
-       $(KERNEL_C)
+nodist_libefi_la_SOURCES = $(USER_C)
 
 libefi_la_LIBADD = $(LIBUUID)
 
index e1f08c8dd8e54064c5257c160e3dac3238a6f333..d04a99e945baf60d1cd277056a7deb1735d3f061 100644 (file)
@@ -4,7 +4,8 @@ VPATH = \
        $(top_srcdir)/module/icp \
        $(top_srcdir)/lib/libicp
 
-AM_CFLAGS += $(DEBUG_STACKFLAGS) $(FRAME_LARGER_THAN)
+# Includes kernel code, generate warnings for large stack frames
+AM_CFLAGS += $(FRAME_LARGER_THAN)
 
 DEFAULT_INCLUDES += \
        -I$(top_srcdir)/include \
index 6da679fd50fc42d08e9424c039ccd670e35b1ea5..d6ba6f89a71e27d4316e2afde87e564dcc1c4c1c 100644 (file)
@@ -4,7 +4,11 @@ VPATH = \
        $(top_srcdir)/module/nvpair \
        $(top_srcdir)/lib/libnvpair
 
-AM_CFLAGS += $(DEBUG_STACKFLAGS) $(FRAME_LARGER_THAN) $(LIBTIRPC_CFLAGS)
+# Required CFLAGS for libtirpc
+AM_CFLAGS += $(LIBTIRPC_CFLAGS)
+
+# Includes kernel code, generate warnings for large stack frames
+AM_CFLAGS += $(FRAME_LARGER_THAN)
 
 DEFAULT_INCLUDES += \
        -I$(top_srcdir)/include \
index 42bd207be48236fb0ce313cfda11dd4e039b564e..462e333ffcd647ea3ad61f4d59450994b0276ad3 100644 (file)
@@ -14,10 +14,6 @@ USER_C = \
        smb.c \
        smb.h
 
-KERNEL_C =
-
-nodist_libshare_la_SOURCES = \
-       $(USER_C)
-       $(KERNEL_C)
+nodist_libshare_la_SOURCES = $(USER_C)
 
 EXTRA_DIST = $(USER_C)
index 395723af395e434cbbab6180d9a945b7f51b5a5c..e4512700a86aea22727a696eaf8cbe731c588aa0 100644 (file)
@@ -4,8 +4,6 @@ VPATH = \
        $(top_srcdir)/lib/libspl \
        $(top_srcdir)/lib/libspl/$(TARGET_ASM_DIR)
 
-AM_CFLAGS += $(DEBUG_STACKFLAGS) $(FRAME_LARGER_THAN)
-
 SUBDIRS = include $(TARGET_ASM_DIR)
 DIST_SUBDIRS = include asm-generic asm-i386 asm-x86_64
 
@@ -36,12 +34,9 @@ USER_C = \
 
 USER_ASM = atomic.S
 
-KERNEL_C =
-
 nodist_libspl_la_SOURCES = \
        $(USER_C) \
-       $(USER_ASM) \
-       $(KERNEL_C)
+       $(USER_ASM)
 
 libspl_la_LIBADD = -lrt
 
index adbaee6c3dcad8e8edc3a28b5116051f52f4eabd..586eec2ec9e14eb24f3585ad04d379ede459d25f 100644 (file)
@@ -1,7 +1,5 @@
 include $(top_srcdir)/config/Rules.am
 
-AM_CFLAGS += $(DEBUG_STACKFLAGS)
-
 DEFAULT_INCLUDES += \
        -I$(top_srcdir)/include \
        -I$(top_srcdir)/lib/libspl/include
@@ -12,11 +10,7 @@ USER_C = \
        thread_pool.c \
        thread_pool_impl.h
 
-KERNEL_C =
-
-nodist_libtpool_la_SOURCES = \
-       $(USER_C) \
-       $(KERNEL_C)
+nodist_libtpool_la_SOURCES = $(USER_C)
 
 libtpool_la_LIBADD = \
        $(top_builddir)/lib/libspl/libspl.la
index 9bacae25140a1bce1fb4877bd397dd65d113a451..0a4734c037bd2dedff8d729f21a8e342f8b0b4b7 100644 (file)
@@ -2,7 +2,8 @@ include $(top_srcdir)/config/Rules.am
 
 VPATH = $(top_srcdir)/module/unicode
 
-AM_CFLAGS += $(DEBUG_STACKFLAGS) $(FRAME_LARGER_THAN)
+# Includes kernel code, generate warnings for large stack frames
+AM_CFLAGS += $(FRAME_LARGER_THAN)
 
 DEFAULT_INCLUDES += \
        -I$(top_srcdir)/include \
index ed4a30de72bc095f2acc16ae6af40c8260ba932e..09eef792a23581ed6370e56e29ad9ab5dab0fed5 100644 (file)
@@ -1,7 +1,5 @@
 include $(top_srcdir)/config/Rules.am
 
-AM_CFLAGS += $(DEBUG_STACKFLAGS) $(FRAME_LARGER_THAN)
-
 DEFAULT_INCLUDES += \
        -I$(top_srcdir)/include \
        -I$(top_srcdir)/lib/libspl/include
@@ -19,11 +17,7 @@ USER_C = \
        uu_pname.c \
        uu_string.c
 
-KERNEL_C =
-
-nodist_libuutil_la_SOURCES = \
-       $(USER_C) \
-       $(KERNEL_C)
+nodist_libuutil_la_SOURCES = $(USER_C)
 
 libuutil_la_LIBADD = \
        $(top_builddir)/lib/libavl/libavl.la \
index e5b2ce765d1e74099b01bbcfa0de5c49ca46efb1..da40c96ce77bc58081ddb50529355f49b1ac6bb8 100644 (file)
@@ -5,6 +5,9 @@ VPATH = \
        $(top_srcdir)/module/zcommon \
        $(top_srcdir)/lib/libzfs
 
+# Suppress unused but set variable warnings often due to ASSERTs
+AM_CFLAGS += $(NO_UNUSED_BUT_SET_VARIABLE)
+
 libzfs_pcdir = $(datarootdir)/pkgconfig
 libzfs_pc_DATA = libzfs.pc libzfs_core.pc
 
index 5eafc25c057b75371f1ff082439917c1f975d322..8abaebe73005d297b54b3d7fa48b17732f235f27 100644 (file)
@@ -9,11 +9,7 @@ lib_LTLIBRARIES = libzfs_core.la
 USER_C = \
        libzfs_core.c
 
-KERNEL_C =
-
-nodist_libzfs_core_la_SOURCES = \
-       $(USER_C) \
-       $(KERNEL_C)
+nodist_libzfs_core_la_SOURCES = $(USER_C)
 
 libzfs_core_la_LIBADD = \
        $(top_builddir)/lib/libnvpair/libnvpair.la
index 95e2493421a68b3d44ca26a5a5c9445c7e6a7820..06219168b7d30bdf9440a407926973a2f345bad2 100644 (file)
@@ -5,7 +5,11 @@ VPATH = \
        $(top_srcdir)/module/zcommon \
        $(top_srcdir)/lib/libzpool
 
-AM_CFLAGS += $(DEBUG_STACKFLAGS) $(FRAME_LARGER_THAN)
+# Suppress unused but set variable warnings often due to ASSERTs
+AM_CFLAGS += $(NO_UNUSED_BUT_SET_VARIABLE)
+
+# Includes kernel code generate warnings for large stack frames
+AM_CFLAGS += $(FRAME_LARGER_THAN)
 
 DEFAULT_INCLUDES += \
        -I$(top_srcdir)/include \
index 60973ec7d5cfc5dba20461a6721ec59b1270aac5..1ca979f9d115abbb95f22e60edb9f4d7cea8bdcc 100644 (file)
@@ -1,18 +1,25 @@
 subdir-m += avl
+subdir-m += icp
 subdir-m += nvpair
 subdir-m += unicode
 subdir-m += zcommon
 subdir-m += zfs
-subdir-m += icp
 
 INSTALL_MOD_DIR ?= extra
 
+ZFS_MODULE_CFLAGS += -std=gnu99 -Wno-declaration-after-statement
+ZFS_MODULE_CFLAGS += @KERNEL_DEBUG_CFLAGS@
 ZFS_MODULE_CFLAGS += -include @SPL_OBJ@/spl_config.h
 ZFS_MODULE_CFLAGS += -include @abs_top_builddir@/zfs_config.h
 ZFS_MODULE_CFLAGS += -I@abs_top_srcdir@/include -I@SPL@/include -I@SPL@
+
+ZFS_MODULE_CPPFLAGS += -DHAVE_SPL -D_KERNEL
+ZFS_MODULE_CPPFLAGS += @KERNEL_DEBUG_CPPFLAGS@
+
 @CONFIG_QAT_TRUE@ZFS_MODULE_CFLAGS += -I@QAT_SRC@/include
 @CONFIG_QAT_TRUE@KBUILD_EXTRA_SYMBOLS += @QAT_SYMBOLS@
-export ZFS_MODULE_CFLAGS
+
+export ZFS_MODULE_CFLAGS ZFS_MODULE_CPPFLAGS
 
 SUBDIR_TARGETS = icp
 
@@ -35,12 +42,12 @@ modules:
        list='$(SUBDIR_TARGETS)'; for targetdir in $$list; do \
                $(MAKE) -C $$targetdir; \
        done
-       $(MAKE) -C @LINUX_OBJ@ SUBDIRS=`pwd` @KERNELMAKE_PARAMS@ CONFIG_ZFS=m $@
+       $(MAKE) -C @LINUX_OBJ@ SUBDIRS=`pwd` @KERNEL_MAKE@ CONFIG_ZFS=m $@
 
 clean:
        @# Only cleanup the kernel build directories when CONFIG_KERNEL
        @# is defined.  This indicates that kernel modules should be built.
-@CONFIG_KERNEL_TRUE@   $(MAKE) -C @LINUX_OBJ@ SUBDIRS=`pwd` @KERNELMAKE_PARAMS@ $@
+@CONFIG_KERNEL_TRUE@   $(MAKE) -C @LINUX_OBJ@ SUBDIRS=`pwd` @KERNEL_MAKE@ $@
 
        if [ -f @SPL_SYMBOLS@ ]; then $(RM) @SPL_SYMBOLS@; fi
        if [ -f @LINUX_SYMBOLS@ ]; then $(RM) @LINUX_SYMBOLS@; fi
index 98c011e8aa8168c2083e41320ad5623c227e5218..217fa3ca52fe134bc3e32b5f147836e0ae18ab3d 100644 (file)
@@ -3,8 +3,8 @@ obj = @abs_builddir@
 
 MODULE := zavl
 
-EXTRA_CFLAGS = $(ZFS_MODULE_CFLAGS) @KERNELCPPFLAGS@
-
 obj-$(CONFIG_ZFS) := $(MODULE).o
 
+ccflags-y := $(ZFS_MODULE_CFLAGS) $(ZFS_MODULE_CPPFLAGS)
+
 $(MODULE)-objs += avl.o
index 77b2ec1b546ee8daa665156bfaf1d834b6e6d79e..2eb9e6f1f7cdd9f22a4ced391ad07dbae64f110d 100644 (file)
@@ -23,14 +23,11 @@ ifeq ($(TARGET_ASM_DIR), asm-generic)
 ASM_SOURCES :=
 endif
 
-EXTRA_CFLAGS = $(ZFS_MODULE_CFLAGS) @KERNELCPPFLAGS@
-EXTRA_AFLAGS = $(ZFS_MODULE_CFLAGS) @KERNELCPPFLAGS@
-
 obj-$(CONFIG_ZFS) := $(MODULE).o
 
-ccflags-y += -I$(src)/include
-asflags-y += -I$(src)/include
-asflags-y += $(ZFS_MODULE_CFLAGS)
+asflags-y := -I$(src)/include
+ccflags-y := -I$(src)/include
+ccflags-y += $(ZFS_MODULE_CFLAGS) $(ZFS_MODULE_CPPFLAGS)
 
 $(MODULE)-objs += illumos-crypto.o
 $(MODULE)-objs += api/kcf_cipher.o
index a8144452a4b3e63b2e3e600f4c22fb7802ed5602..f420ef98bc8d709632398dd4382cb24b12963614 100644 (file)
@@ -3,10 +3,10 @@ obj = @abs_builddir@
 
 MODULE := znvpair
 
-EXTRA_CFLAGS = $(ZFS_MODULE_CFLAGS) @KERNELCPPFLAGS@
-
 obj-$(CONFIG_ZFS) := $(MODULE).o
 
+ccflags-y := $(ZFS_MODULE_CFLAGS) $(ZFS_MODULE_CPPFLAGS)
+
 $(MODULE)-objs += nvpair.o
 $(MODULE)-objs += fnvpair.o
 $(MODULE)-objs += nvpair_alloc_spl.o
index b26e669274bed89ef2f8ea9a424f9183b8c75702..82c90373a21760f2fdbbc4c4360376b07d5fdf5d 100644 (file)
@@ -3,9 +3,9 @@ obj = @abs_builddir@
 
 MODULE := zunicode
 
-EXTRA_CFLAGS = $(ZFS_MODULE_CFLAGS) @KERNELCPPFLAGS@
-
 obj-$(CONFIG_ZFS) := $(MODULE).o
 
+ccflags-y := $(ZFS_MODULE_CFLAGS) $(ZFS_MODULE_CPPFLAGS)
+
 $(MODULE)-objs += u8_textprep.o
 $(MODULE)-objs += uconv.o
index 86eb8ad3922eb731dc1d65a09362103f515e2145..501fb24e1cd3b06a74a92e2bb0f7ae7de069bddc 100644 (file)
@@ -3,10 +3,10 @@ obj = @abs_builddir@
 
 MODULE := zcommon
 
-EXTRA_CFLAGS = $(ZFS_MODULE_CFLAGS) @KERNELCPPFLAGS@
-
 obj-$(CONFIG_ZFS) := $(MODULE).o
 
+ccflags-y := $(ZFS_MODULE_CFLAGS) $(ZFS_MODULE_CPPFLAGS)
+
 $(MODULE)-objs += zfeature_common.o
 $(MODULE)-objs += zfs_comutil.o
 $(MODULE)-objs += zfs_deleg.o
index 66acc536d82de53d713cd1af6a8af3a6c1fe00c7..cb352bf912648a8818d1b17a395497a30e158dda 100644 (file)
@@ -3,10 +3,13 @@ obj = @abs_builddir@
 
 MODULE := zfs
 
-EXTRA_CFLAGS = $(ZFS_MODULE_CFLAGS) @KERNELCPPFLAGS@
-
 obj-$(CONFIG_ZFS) := $(MODULE).o
 
+ccflags-y := $(ZFS_MODULE_CFLAGS) $(ZFS_MODULE_CPPFLAGS)
+
+# Suppress unused but set variable warnings often due to ASSERTs
+ccflags-y += $(NO_UNUSED_BUT_SET_VARIABLE)
+
 $(MODULE)-objs += abd.o
 $(MODULE)-objs += arc.o
 $(MODULE)-objs += blkptr.o
index 22882627bc6f066977a6dca639bf56d23a9b54d2..e8d91b4e9438d89737182276a63e16638a8c76fa 100644 (file)
@@ -37,6 +37,7 @@
 #define buildforkernels akmod
 
 %bcond_with     debug
+%bcond_with     debuginfo
 
 
 Name:           %{module}-kmod
@@ -116,6 +117,12 @@ bash %{SOURCE10}  --target %{_target_cpu} %{?repo:--repo %{?repo}} --kmodname %{
     %define debug --disable-debug
 %endif
 
+%if %{with debuginfo}
+    %define debuginfo --enable-debuginfo
+%else
+    %define debuginfo --disable-debuginfo
+%endif
+
 #
 # Allow the overriding of spl locations
 #
@@ -156,7 +163,8 @@ for kernel_version in %{?kernel_versions}; do
         --with-linux-obj=%{kobj} \
         --with-spl="%{spldir}" \
         --with-spl-obj="%{splobj}" \
-        %{debug}
+        %{debug} \
+        %{debuginfo}
     make %{?_smp_mflags}
     cd ..
 done
index 20bb36e4eaa53caf45653acbb19e7e510f254b8e..b104e0d8709dadfd634a4742de98f0442d2dbf65 100644 (file)
@@ -34,6 +34,8 @@
 %endif
 
 %bcond_with    debug
+%bcond_with    debuginfo
+%bcond_with    asan
 %bcond_with    systemd
 
 # Generic enable switch for systemd
@@ -223,6 +225,19 @@ image which is ZFS aware.
 %else
     %define debug --disable-debug
 %endif
+
+%if %{with debuginfo}
+    %define debuginfo --enable-debuginfo
+%else
+    %define debuginfo --disable-debuginfo
+%endif
+
+%if %{with asan}
+    %define asan --enable-asan
+%else
+    %define asan --disable-asan
+%endif
+
 %if 0%{?_systemd}
     %define systemd --enable-systemd --with-systemdunitdir=%{_unitdir} --with-systemdpresetdir=%{_presetdir} --disable-sysvinit
     %define systemd_svcs zfs-import-cache.service zfs-import-scan.service zfs-mount.service zfs-share.service zfs-zed.service zfs.target zfs-import.target
@@ -240,6 +255,8 @@ image which is ZFS aware.
     --with-dracutdir=%{_dracutdir} \
     --disable-static \
     %{debug} \
+    %{debuginfo} \
+    %{asan} \
     %{systemd}
 make %{?_smp_mflags}
 
index aedd88eb4257af96d9a4db442afadd0fae3253a3..f43adba7625b8238b208e6cd0a91009f76d3d45e 100644 (file)
@@ -1,4 +1,5 @@
 %bcond_with     debug
+%bcond_with     debuginfo
 
 Name:           @PACKAGE@-kmod
 Version:        @VERSION@
@@ -58,6 +59,12 @@ fi
 %define debug --disable-debug
 %endif
 
+%if %{with debuginfo}
+%define debuginfo --enable-debuginfo
+%else
+%define debuginfo --disable-debuginfo
+%endif
+
 %setup -n %{kmod_name}-%{version}
 %build
 %configure \
@@ -66,7 +73,8 @@ fi
         --with-linux-obj=%{kobj} \
         --with-spl="%{splsrc}" \
         --with-spl-obj="%{splobj}" \
-        %{debug}
+        %{debug} \
+        %{debuginfo}
 make %{?_smp_mflags}
 
 %install
index afcd87f3626d85dfcb2e64507f6b57d5112e819c..b6f6fc994d59308741fc4421c19bb6511f16fe46 100755 (executable)
@@ -30,6 +30,7 @@ fi
 
 # shellcheck disable=SC2034
 PROG=zloop.sh
+GDB=${GDB:-gdb}
 
 DEFAULTWORKDIR=/var/tmp
 DEFAULTCOREDIR=/var/tmp/zloop
@@ -182,6 +183,7 @@ shift $((OPTIND - 1))
 
 # enable core dumps
 ulimit -c unlimited
+export ASAN_OPTIONS=abort_on_error=1:disable_coredump=0
 
 if [[ -f "$(core_file)" ]]; then
        echo -n "There's a core dump here you might want to look at first... "
index 8132ea1d6d545425efa2f1552ebb38fc227b7de5..cacb3c92785c6f7f287e555fc815c4733868b58c 100644 (file)
@@ -1,4 +1,5 @@
 include $(top_srcdir)/config/Rules.am
+
 AM_CPPFLAGS += -I$(top_srcdir)/include
 LDADD = $(top_srcdir)/lib/libicp/libicp.la
 
index 27a429db82195cd83b63fc08f65e24b71c11c3dd..b21b6c657dfe4c3d3a0274a14e0a3e2baca938f9 100755 (executable)
@@ -93,6 +93,7 @@ if is_linux; then
        ulimit -c unlimited
        echo "$corepath/core.zfs" >/proc/sys/kernel/core_pattern
        echo 0 >/proc/sys/kernel/core_uses_pid
+       export ASAN_OPTIONS="abort_on_error=1:disable_coredump=0"
 else
        log_must coreadm -p ${corepath}/core.%f
 fi
index a45e4a88331a205da89e77b274b145eca469bad4..d4abaa5ffea108fea363f5310220ce9855b402ab 100755 (executable)
@@ -89,6 +89,7 @@ if is_linux; then
        ulimit -c unlimited
        echo "$corepath/core.zpool" >/proc/sys/kernel/core_pattern
        echo 0 >/proc/sys/kernel/core_uses_pid
+       export ASAN_OPTIONS="abort_on_error=1:disable_coredump=0"
 else
        coreadm -p ${corepath}/core.%f
 fi
index 8bfbb5fd8634fbc32af630035168d337cfa70fa7..0f04f0c046de203199617e8f7772bea4208949f4 100755 (executable)
@@ -61,9 +61,10 @@ log_mustnot zpool freeze fakepool
 [[ -f core ]] && log_must rm -f core
 
 if is_linux; then
-        ulimit -c unlimited
-        echo "core" >/proc/sys/kernel/core_pattern
-        echo 0 >/proc/sys/kernel/core_uses_pid
+       ulimit -c unlimited
+       echo "core" >/proc/sys/kernel/core_pattern
+       echo 0 >/proc/sys/kernel/core_uses_pid
+       export ASAN_OPTIONS="abort_on_error=1:disable_coredump=0"
 fi
 
 ZFS_ABORT=1; export ZFS_ABORT
index 37fe2ed2cfd472353dadbada059973f4e1a21d2b..d0a68f442fab52bd5fceebe74198803d31e9736a 100644 (file)
@@ -1,4 +1,5 @@
 include $(top_srcdir)/config/Rules.am
+
 AM_CPPFLAGS += -I$(top_srcdir)/include
 AM_CPPFLAGS += -I$(top_srcdir)/lib/libspl/include
 LDADD = $(top_srcdir)/lib/libicp/libicp.la