Skip to content

Commit

Permalink
Force --enable-debug on FreeBSD if INVARIANTS is set
Browse files Browse the repository at this point in the history
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: openzfs#12163

Signed-off-by: Rich Ercolani <rincebrain@gmail.com>
  • Loading branch information
rincebrain committed Jun 3, 2021
1 parent d484a72 commit 4aa2fbe
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
14 changes: 12 additions & 2 deletions config/zfs-build.m4
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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],
Expand All @@ -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])
])
Expand Down
2 changes: 1 addition & 1 deletion configure.ac
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 4aa2fbe

Please sign in to comment.