Skip to content

Commit 4aa2fbe

Browse files
committed
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 <[email protected]>
1 parent d484a72 commit 4aa2fbe

File tree

2 files changed

+13
-3
lines changed

2 files changed

+13
-3
lines changed

config/zfs-build.m4

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@ AC_DEFUN([ZFS_AC_DEBUG], [
4949
[ZFS_AC_DEBUG_DISABLE],
5050
[AC_MSG_ERROR([Unknown option $enable_debug])])
5151
52+
AS_CASE(["x$FORCE_DEBUG"],
53+
["xtrue"],
54+
[ZFS_AC_DEBUG_ENABLE],
55+
["x"],[],[])
56+
5257
AC_SUBST(DEBUG_CFLAGS)
5358
AC_SUBST(DEBUG_CPPFLAGS)
5459
AC_SUBST(DEBUG_LDFLAGS)
@@ -173,6 +178,8 @@ dnl # in the FreeBSD kernel module. This feature must be used when building
173178
dnl # for a FreeBSD kernel with "options INVARIANTS" in the KERNCONF and must
174179
dnl # not be used when the INVARIANTS option is absent.
175180
dnl #
181+
dnl # (If INVARIANTS is detected, we need to force DEBUG, or strange panics
182+
dnl # can ensue.)
176183
AC_DEFUN([ZFS_AC_DEBUG_INVARIANTS], [
177184
AC_MSG_CHECKING([whether FreeBSD kernel INVARIANTS checks are enabled])
178185
AC_ARG_ENABLE([invariants],
@@ -181,9 +188,12 @@ AC_DEFUN([ZFS_AC_DEBUG_INVARIANTS], [
181188
[], [ZFS_AC_DEBUG_INVARIANTS_DETECT])
182189
183190
AS_IF([test "x$enable_invariants" = xyes],
184-
[WITH_INVARIANTS="true"],
185-
[WITH_INVARIANTS=""])
191+
[WITH_INVARIANTS="true"
192+
FORCE_DEBUG="true"],
193+
[WITH_INVARIANTS=""
194+
FORCE_DEBUG=""])
186195
AC_SUBST(WITH_INVARIANTS)
196+
AC_SUBST(FORCE_DEBUG)
187197
188198
AC_MSG_RESULT([$enable_invariants])
189199
])

configure.ac

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,11 @@ _AM_PROG_TAR(pax)
5858
ZFS_AC_LICENSE
5959
ZFS_AC_CONFIG
6060
ZFS_AC_PACKAGE
61+
ZFS_AC_DEBUG_INVARIANTS
6162
ZFS_AC_DEBUG
6263
ZFS_AC_DEBUGINFO
6364
ZFS_AC_DEBUG_KMEM
6465
ZFS_AC_DEBUG_KMEM_TRACKING
65-
ZFS_AC_DEBUG_INVARIANTS
6666

6767
AC_CONFIG_FILES([
6868
Makefile

0 commit comments

Comments
 (0)