Extend CONFIG_DEBUG_LOCK_ALLOC check

The CONFIG_DEBUG_LOCK_ALLOC check at configure time was added to
detect when mutex_lock() is defined as a GPL-only symbol.  However,
the check as written only inferred this from this configuration
setting, it never actually checked.  This change introduces that
missing check to prevent false positives.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
This commit is contained in:
Brian Behlendorf 2012-05-21 12:59:58 -07:00
parent c421831192
commit e5b8562277
2 changed files with 244 additions and 66 deletions

View File

@ -311,34 +311,74 @@ dnl # Certain kernel build options are not supported. These must be
dnl # detected at configure time and cause a build failure. Otherwise dnl # detected at configure time and cause a build failure. Otherwise
dnl # modules may be successfully built that behave incorrectly. dnl # modules may be successfully built that behave incorrectly.
dnl # dnl #
dnl # CONFIG_PREEMPT - Preempt kernels require special handling.
dnl #
dnl # There are certain kernel build options which when enabled are
dnl # completely incompatible with non GPL kernel modules. It is best
dnl # to detect these at configure time and fail with a clear error
dnl # rather than build everything and fail during linking.
dnl #
dnl # CONFIG_DEBUG_LOCK_ALLOC - Maps mutex_lock() to mutex_lock_nested()
dnl #
AC_DEFUN([ZFS_AC_KERNEL_CONFIG], [ AC_DEFUN([ZFS_AC_KERNEL_CONFIG], [
ZFS_LINUX_CONFIG([PREEMPT],
AC_MSG_ERROR([
*** Kernel built with CONFIG_PREEMPT which is not supported.
*** You must rebuild your kernel without this option.]), [])
AS_IF([test "$ZFS_META_LICENSE" = CDDL], [
ZFS_LINUX_CONFIG([DEBUG_LOCK_ALLOC],
AC_MSG_ERROR([
*** Kernel built with CONFIG_DEBUG_LOCK_ALLOC which is
*** incompatible with the CDDL license. You must rebuild
*** your kernel without this option.]), [])
])
AS_IF([test "$ZFS_META_LICENSE" = GPL], [ AS_IF([test "$ZFS_META_LICENSE" = GPL], [
AC_DEFINE([HAVE_GPL_ONLY_SYMBOLS], [1], AC_DEFINE([HAVE_GPL_ONLY_SYMBOLS], [1],
[Define to 1 if licensed under the GPL]) [Define to 1 if licensed under the GPL])
]) ])
ZFS_AC_KERNEL_CONFIG_PREEMPT
ZFS_AC_KERNEL_CONFIG_DEBUG_LOCK_ALLOC
])
dnl #
dnl # Check CONFIG_PREEMPT
dnl #
dnl # Premptible kernels will be supported in the future. But at the
dnl # moment there are a few places in the code which need to be updated
dnl # to accomidate them. Until that work occurs we should detect this
dnl # at configure time and fail with a sensible message. Otherwise,
dnl # people will be able to build successfully, however they will have
dnl # stability problems. See https://github.com/zfsonlinux/zfs/issues/83
dnl #
AC_DEFUN([ZFS_AC_KERNEL_CONFIG_PREEMPT], [
ZFS_LINUX_CONFIG([PREEMPT],
AC_MSG_ERROR([
*** Kernel built with CONFIG_PREEMPT which is not supported.
*** You must rebuild your kernel without this option.]), [])
])
dnl #
dnl # Check CONFIG_DEBUG_LOCK_ALLOC
dnl #
dnl # This is typically only set for debug kernels because it comes with
dnl # a performance penalty. However, when it is set it maps the non-GPL
dnl # symbol mutex_lock() to the GPL-only mutex_lock_nested() symbol.
dnl # This will cause a failure at link time which we'd rather know about
dnl # at compile time.
dnl #
dnl # Since we plan to pursue making mutex_lock_nested() a non-GPL symbol
dnl # with the upstream community we add a check to detect this case.
dnl #
AC_DEFUN([ZFS_AC_KERNEL_CONFIG_DEBUG_LOCK_ALLOC], [
ZFS_LINUX_CONFIG([DEBUG_LOCK_ALLOC], [
AC_MSG_CHECKING([whether mutex_lock() is GPL-only])
tmp_flags="$EXTRA_KCFLAGS"
ZFS_LINUX_TRY_COMPILE([
#include <linux/module.h>
#include <linux/mutex.h>
MODULE_LICENSE("$ZFS_META_LICENSE");
],[
struct mutex lock;
mutex_init(&lock);
mutex_lock(&lock);
mutex_unlock(&lock);
],[
AC_MSG_RESULT(no)
],[
AC_MSG_RESULT(yes)
AC_MSG_ERROR([
*** Kernel built with CONFIG_DEBUG_LOCK_ALLOC which is incompatible
*** with the CDDL license. You must rebuild your kernel without
*** this option enabled.])
])
EXTRA_KCFLAGS="$tmp_flags"
], [])
]) ])
dnl # dnl #

218
configure vendored
View File

@ -12396,6 +12396,19 @@ $as_echo "$SPL_SYMBOLS" >&6; }
if test "$ZFS_META_LICENSE" = GPL; then
cat >>confdefs.h <<\_ACEOF
#define HAVE_GPL_ONLY_SYMBOLS 1
_ACEOF
fi
{ $as_echo "$as_me:$LINENO: checking whether Linux was built with CONFIG_PREEMPT" >&5 { $as_echo "$as_me:$LINENO: checking whether Linux was built with CONFIG_PREEMPT" >&5
$as_echo_n "checking whether Linux was built with CONFIG_PREEMPT... " >&6; } $as_echo_n "checking whether Linux was built with CONFIG_PREEMPT... " >&6; }
@ -12466,7 +12479,7 @@ fi
if test "$ZFS_META_LICENSE" = CDDL; then
{ $as_echo "$as_me:$LINENO: checking whether Linux was built with CONFIG_DEBUG_LOCK_ALLOC" >&5 { $as_echo "$as_me:$LINENO: checking whether Linux was built with CONFIG_DEBUG_LOCK_ALLOC" >&5
$as_echo_n "checking whether Linux was built with CONFIG_DEBUG_LOCK_ALLOC... " >&6; } $as_echo_n "checking whether Linux was built with CONFIG_DEBUG_LOCK_ALLOC... " >&6; }
@ -12511,18 +12524,87 @@ _ACEOF
$as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then (exit $ac_status); }; }; then
{ $as_echo "$as_me:$LINENO: result: yes" >&5
$as_echo "yes" >&6; }
{ $as_echo "$as_me:$LINENO: checking whether mutex_lock() is GPL-only" >&5
$as_echo_n "checking whether mutex_lock() is GPL-only... " >&6; }
tmp_flags="$EXTRA_KCFLAGS"
cat confdefs.h - <<_ACEOF >conftest.c
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
#include <linux/module.h>
#include <linux/mutex.h>
MODULE_LICENSE("$ZFS_META_LICENSE");
int
main (void)
{
struct mutex lock;
mutex_init(&lock);
mutex_lock(&lock);
mutex_unlock(&lock);
;
return 0;
}
_ACEOF
rm -Rf build && mkdir -p build
echo "obj-m := conftest.o" >build/Makefile
if { ac_try='cp conftest.c build && make modules -C $LINUX_OBJ EXTRA_CFLAGS="-Werror-implicit-function-declaration $EXTRA_KCFLAGS" $ARCH_UM M=$PWD/build'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
$as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; } >/dev/null && { ac_try='test -s build/conftest.o'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
$as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
{ $as_echo "$as_me:$LINENO: result: no" >&5
$as_echo "no" >&6; }
else
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
{ $as_echo "$as_me:$LINENO: result: yes" >&5 { $as_echo "$as_me:$LINENO: result: yes" >&5
$as_echo "yes" >&6; } $as_echo "yes" >&6; }
{ { $as_echo "$as_me:$LINENO: error: { { $as_echo "$as_me:$LINENO: error:
*** Kernel built with CONFIG_DEBUG_LOCK_ALLOC which is *** Kernel built with CONFIG_DEBUG_LOCK_ALLOC which is incompatible
*** incompatible with the CDDL license. You must rebuild *** with the CDDL license. You must rebuild your kernel without
*** your kernel without this option." >&5 *** this option enabled." >&5
$as_echo "$as_me: error: $as_echo "$as_me: error:
*** Kernel built with CONFIG_DEBUG_LOCK_ALLOC which is *** Kernel built with CONFIG_DEBUG_LOCK_ALLOC which is incompatible
*** incompatible with the CDDL license. You must rebuild *** with the CDDL license. You must rebuild your kernel without
*** your kernel without this option." >&2;} *** this option enabled." >&2;}
{ (exit 1); exit 1; }; } { (exit 1); exit 1; }; }
fi
rm -Rf build
EXTRA_KCFLAGS="$tmp_flags"
else else
$as_echo "$as_me: failed program was:" >&5 $as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5 sed 's/^/| /' conftest.$ac_ext >&5
@ -12540,19 +12622,6 @@ fi
fi
if test "$ZFS_META_LICENSE" = GPL; then
cat >>confdefs.h <<\_ACEOF
#define HAVE_GPL_ONLY_SYMBOLS 1
_ACEOF
fi
{ $as_echo "$as_me:$LINENO: checking block device operation prototypes" >&5 { $as_echo "$as_me:$LINENO: checking block device operation prototypes" >&5
@ -18420,6 +18489,19 @@ $as_echo "$SPL_SYMBOLS" >&6; }
if test "$ZFS_META_LICENSE" = GPL; then
cat >>confdefs.h <<\_ACEOF
#define HAVE_GPL_ONLY_SYMBOLS 1
_ACEOF
fi
{ $as_echo "$as_me:$LINENO: checking whether Linux was built with CONFIG_PREEMPT" >&5 { $as_echo "$as_me:$LINENO: checking whether Linux was built with CONFIG_PREEMPT" >&5
$as_echo_n "checking whether Linux was built with CONFIG_PREEMPT... " >&6; } $as_echo_n "checking whether Linux was built with CONFIG_PREEMPT... " >&6; }
@ -18490,7 +18572,7 @@ fi
if test "$ZFS_META_LICENSE" = CDDL; then
{ $as_echo "$as_me:$LINENO: checking whether Linux was built with CONFIG_DEBUG_LOCK_ALLOC" >&5 { $as_echo "$as_me:$LINENO: checking whether Linux was built with CONFIG_DEBUG_LOCK_ALLOC" >&5
$as_echo_n "checking whether Linux was built with CONFIG_DEBUG_LOCK_ALLOC... " >&6; } $as_echo_n "checking whether Linux was built with CONFIG_DEBUG_LOCK_ALLOC... " >&6; }
@ -18535,18 +18617,87 @@ _ACEOF
$as_echo "$as_me:$LINENO: \$? = $ac_status" >&5 $as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then (exit $ac_status); }; }; then
{ $as_echo "$as_me:$LINENO: result: yes" >&5
$as_echo "yes" >&6; }
{ $as_echo "$as_me:$LINENO: checking whether mutex_lock() is GPL-only" >&5
$as_echo_n "checking whether mutex_lock() is GPL-only... " >&6; }
tmp_flags="$EXTRA_KCFLAGS"
cat confdefs.h - <<_ACEOF >conftest.c
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
#include <linux/module.h>
#include <linux/mutex.h>
MODULE_LICENSE("$ZFS_META_LICENSE");
int
main (void)
{
struct mutex lock;
mutex_init(&lock);
mutex_lock(&lock);
mutex_unlock(&lock);
;
return 0;
}
_ACEOF
rm -Rf build && mkdir -p build
echo "obj-m := conftest.o" >build/Makefile
if { ac_try='cp conftest.c build && make modules -C $LINUX_OBJ EXTRA_CFLAGS="-Werror-implicit-function-declaration $EXTRA_KCFLAGS" $ARCH_UM M=$PWD/build'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
$as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; } >/dev/null && { ac_try='test -s build/conftest.o'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
$as_echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
{ $as_echo "$as_me:$LINENO: result: no" >&5
$as_echo "no" >&6; }
else
$as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
{ $as_echo "$as_me:$LINENO: result: yes" >&5 { $as_echo "$as_me:$LINENO: result: yes" >&5
$as_echo "yes" >&6; } $as_echo "yes" >&6; }
{ { $as_echo "$as_me:$LINENO: error: { { $as_echo "$as_me:$LINENO: error:
*** Kernel built with CONFIG_DEBUG_LOCK_ALLOC which is *** Kernel built with CONFIG_DEBUG_LOCK_ALLOC which is incompatible
*** incompatible with the CDDL license. You must rebuild *** with the CDDL license. You must rebuild your kernel without
*** your kernel without this option." >&5 *** this option enabled." >&5
$as_echo "$as_me: error: $as_echo "$as_me: error:
*** Kernel built with CONFIG_DEBUG_LOCK_ALLOC which is *** Kernel built with CONFIG_DEBUG_LOCK_ALLOC which is incompatible
*** incompatible with the CDDL license. You must rebuild *** with the CDDL license. You must rebuild your kernel without
*** your kernel without this option." >&2;} *** this option enabled." >&2;}
{ (exit 1); exit 1; }; } { (exit 1); exit 1; }; }
fi
rm -Rf build
EXTRA_KCFLAGS="$tmp_flags"
else else
$as_echo "$as_me: failed program was:" >&5 $as_echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5 sed 's/^/| /' conftest.$ac_ext >&5
@ -18564,19 +18715,6 @@ fi
fi
if test "$ZFS_META_LICENSE" = GPL; then
cat >>confdefs.h <<\_ACEOF
#define HAVE_GPL_ONLY_SYMBOLS 1
_ACEOF
fi
{ $as_echo "$as_me:$LINENO: checking block device operation prototypes" >&5 { $as_echo "$as_me:$LINENO: checking block device operation prototypes" >&5