From 4aa2fbe5483de25e228360ee600fa7faac0de69e Mon Sep 17 00:00:00 2001 From: Rich Ercolani Date: Thu, 3 Jun 2021 01:08:58 -0400 Subject: [PATCH] Force --enable-debug on FreeBSD if INVARIANTS is set There's already logic to force INVARIANTS on for building if it's present in the running kernel; however, not having DEBUG enabled when DEBUG and INVARIANTS are can cause strange panics. Closes: #12163 Signed-off-by: Rich Ercolani --- config/zfs-build.m4 | 14 ++++++++++++-- configure.ac | 2 +- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/config/zfs-build.m4 b/config/zfs-build.m4 index cee5c87e770c..81c69460cef8 100644 --- a/config/zfs-build.m4 +++ b/config/zfs-build.m4 @@ -49,6 +49,11 @@ AC_DEFUN([ZFS_AC_DEBUG], [ [ZFS_AC_DEBUG_DISABLE], [AC_MSG_ERROR([Unknown option $enable_debug])]) + AS_CASE(["x$FORCE_DEBUG"], + ["xtrue"], + [ZFS_AC_DEBUG_ENABLE], + ["x"],[],[]) + AC_SUBST(DEBUG_CFLAGS) AC_SUBST(DEBUG_CPPFLAGS) AC_SUBST(DEBUG_LDFLAGS) @@ -173,6 +178,8 @@ 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 # +dnl # (If INVARIANTS is detected, we need to force DEBUG, or strange panics +dnl # can ensue.) AC_DEFUN([ZFS_AC_DEBUG_INVARIANTS], [ AC_MSG_CHECKING([whether FreeBSD kernel INVARIANTS checks are enabled]) AC_ARG_ENABLE([invariants], @@ -181,9 +188,12 @@ AC_DEFUN([ZFS_AC_DEBUG_INVARIANTS], [ [], [ZFS_AC_DEBUG_INVARIANTS_DETECT]) AS_IF([test "x$enable_invariants" = xyes], - [WITH_INVARIANTS="true"], - [WITH_INVARIANTS=""]) + [WITH_INVARIANTS="true" + FORCE_DEBUG="true"], + [WITH_INVARIANTS="" + FORCE_DEBUG=""]) AC_SUBST(WITH_INVARIANTS) + AC_SUBST(FORCE_DEBUG) AC_MSG_RESULT([$enable_invariants]) ]) diff --git a/configure.ac b/configure.ac index 077ad7c43f4d..81595062fbbc 100644 --- a/configure.ac +++ b/configure.ac @@ -58,11 +58,11 @@ _AM_PROG_TAR(pax) ZFS_AC_LICENSE ZFS_AC_CONFIG ZFS_AC_PACKAGE +ZFS_AC_DEBUG_INVARIANTS ZFS_AC_DEBUG ZFS_AC_DEBUGINFO ZFS_AC_DEBUG_KMEM ZFS_AC_DEBUG_KMEM_TRACKING -ZFS_AC_DEBUG_INVARIANTS AC_CONFIG_FILES([ Makefile