summaryrefslogtreecommitdiffstats
path: root/config
diff options
context:
space:
mode:
authorRyan Moeller <[email protected]>2021-03-05 15:16:41 -0500
committerGitHub <[email protected]>2021-03-05 12:16:41 -0800
commitba74de88c0891f4f40a6841db97668dfdac07b18 (patch)
treeeba1a07bacd98a89eeddb1349aa12d66d8d151f4 /config
parentfd1c366f822ecadc3a011340133e2f481803009f (diff)
FreeBSD module --enable-debug --enable-invariants
Wire up the --enable-debug flag for configure to the FreeBSD module build. Add --enable-invariants. The running FreeBSD kernel config is used to detect whether to enable INVARIANTS if not explicitly specified with --enable-invariants or --disable-invariants. Reviewed-by: Brian Behlendorf <[email protected]> Signed-off-by: Ryan Moeller <[email protected]> Closes #11678
Diffstat (limited to 'config')
-rw-r--r--config/zfs-build.m436
1 files changed, 36 insertions, 0 deletions
diff --git a/config/zfs-build.m4 b/config/zfs-build.m4
index 305d0c693..cd5996c04 100644
--- a/config/zfs-build.m4
+++ b/config/zfs-build.m4
@@ -11,6 +11,7 @@ AC_DEFUN([ZFS_AC_DEBUG_ENABLE], [
DEBUG_CPPFLAGS="-DDEBUG -UNDEBUG"
DEBUG_LDFLAGS=""
DEBUG_ZFS="_with_debug"
+ WITH_DEBUG="true"
AC_DEFINE(ZFS_DEBUG, 1, [zfs debugging enabled])
KERNEL_DEBUG_CFLAGS="-Werror"
@@ -22,6 +23,7 @@ AC_DEFUN([ZFS_AC_DEBUG_DISABLE], [
DEBUG_CPPFLAGS="-UDEBUG -DNDEBUG"
DEBUG_LDFLAGS=""
DEBUG_ZFS="_without_debug"
+ WITH_DEBUG=""
KERNEL_DEBUG_CFLAGS=""
KERNEL_DEBUG_CPPFLAGS="-UDEBUG -DNDEBUG"
@@ -51,6 +53,7 @@ AC_DEFUN([ZFS_AC_DEBUG], [
AC_SUBST(DEBUG_CPPFLAGS)
AC_SUBST(DEBUG_LDFLAGS)
AC_SUBST(DEBUG_ZFS)
+ AC_SUBST(WITH_DEBUG)
AC_SUBST(KERNEL_DEBUG_CFLAGS)
AC_SUBST(KERNEL_DEBUG_CPPFLAGS)
@@ -152,6 +155,39 @@ AC_DEFUN([ZFS_AC_DEBUG_KMEM_TRACKING], [
AC_MSG_RESULT([$enable_debug_kmem_tracking])
])
+AC_DEFUN([ZFS_AC_DEBUG_INVARIANTS_DETECT_FREEBSD], [
+ AS_IF([sysctl -n kern.conftxt | fgrep -qx $'options\tINVARIANTS'],
+ [enable_invariants="yes"],
+ [enable_invariants="no"])
+])
+
+AC_DEFUN([ZFS_AC_DEBUG_INVARIANTS_DETECT], [
+ AM_COND_IF([BUILD_FREEBSD],
+ [ZFS_AC_DEBUG_INVARIANTS_DETECT_FREEBSD],
+ [enable_invariants="no"])
+])
+
+dnl #
+dnl # Detected for the running kernel by default, enables INVARIANTS features
+dnl # in the FreeBSD kernel module. This feature must be used when building
+dnl # for a FreeBSD kernel with "options INVARIANTS" in the KERNCONF and must
+dnl # not be used when the INVARIANTS option is absent.
+dnl #
+AC_DEFUN([ZFS_AC_DEBUG_INVARIANTS], [
+ AC_MSG_CHECKING([whether FreeBSD kernel INVARIANTS checks are enabled])
+ AC_ARG_ENABLE([invariants],
+ [AS_HELP_STRING([--enable-invariants],
+ [Enable FreeBSD kernel INVARIANTS checks [[default: detect]]])],
+ [], [ZFS_AC_DEBUG_INVARIANTS_DETECT])
+
+ AS_IF([test "x$enable_invariants" = xyes],
+ [WITH_INVARIANTS="true"],
+ [WITH_INVARIANTS=""])
+ AC_SUBST(WITH_INVARIANTS)
+
+ AC_MSG_RESULT([$enable_invariants])
+])
+
AC_DEFUN([ZFS_AC_CONFIG_ALWAYS], [
AX_COUNT_CPUS([])
AC_SUBST(CPU_COUNT)