When checking for symbol exports, try compiling.

This patch adds a new autoconf function: ZFS_LINUX_TRY_COMPILE_SYMBOL.
This new function does the following:

 - Call LINUX_TRY_COMPILE with the specified parameters.
 - If unsuccessful, return false.
 - If successful and we're configuring with --enable-linux-builtin,
   return true.
 - Else, call CHECK_SYMBOL_EXPORT with the specified parameters and
   return the result.

All calls to CHECK_SYMBOL_EXPORT are converted to
LINUX_TRY_COMPILE_SYMBOL so that the tests work even when configuring
for builtin on a kernel which doesn't have loadable module support, or
hasn't been built yet.

Signed-off-by: Brian Behlendorf <behlendorf1@llnl.gov>
Issue #851
This commit is contained in:
Etienne Dechamps 2012-07-25 14:38:58 -07:00 committed by Brian Behlendorf
parent fc88a6dda9
commit 705741827a
13 changed files with 1911 additions and 664 deletions

View File

@ -5,11 +5,17 @@ dnl # exported by the kernel. This is a trivial helper function but
dnl # using it significantly simplifies the code surrounding setting
dnl # up and tearing down the bdi structure.
dnl #
AC_DEFUN([ZFS_AC_KERNEL_BDI_SETUP_AND_REGISTER], [
ZFS_CHECK_SYMBOL_EXPORT(
[bdi_setup_and_register],
[mm/backing-dev.c],
[AC_DEFINE(HAVE_BDI_SETUP_AND_REGISTER, 1,
[bdi_setup_and_register() is available])],
[])
AC_DEFUN([ZFS_AC_KERNEL_BDI_SETUP_AND_REGISTER],
[AC_MSG_CHECKING([whether bdi_setup_and_register() is available])
ZFS_LINUX_TRY_COMPILE_SYMBOL([
#include <linux/backing-dev.h>
], [
bdi_setup_and_register(NULL, NULL, 0);
], [bdi_setup_and_register], [mm/backing-dev.c], [
AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_BDI_SETUP_AND_REGISTER, 1,
[bdi_setup_and_register() is available])
], [
AC_MSG_RESULT(no)
])
])

View File

@ -3,11 +3,17 @@ dnl # 2.6.38 API change
dnl # open_bdev_exclusive() changed to blkdev_get_by_path()
dnl # close_bdev_exclusive() changed to blkdev_put()
dnl #
AC_DEFUN([ZFS_AC_KERNEL_BLKDEV_GET_BY_PATH], [
ZFS_CHECK_SYMBOL_EXPORT(
[blkdev_get_by_path],
[fs/block_dev.c],
[AC_DEFINE(HAVE_BLKDEV_GET_BY_PATH, 1,
[blkdev_get_by_path() is available])],
[])
AC_DEFUN([ZFS_AC_KERNEL_BLKDEV_GET_BY_PATH],
[AC_MSG_CHECKING([whether blkdev_get_by_path() is available])
ZFS_LINUX_TRY_COMPILE_SYMBOL([
#include <linux/fs.h>
], [
blkdev_get_by_path(NULL, 0, NULL);
], [blkdev_get_by_path], [fs/block_dev.c], [
AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_BLKDEV_GET_BY_PATH, 1,
[blkdev_get_by_path() is available])
], [
AC_MSG_RESULT(no)
])
])

View File

@ -2,11 +2,17 @@ dnl #
dnl # 2.6.28 API change
dnl # Added check_disk_size_change() helper function.
dnl #
AC_DEFUN([ZFS_AC_KERNEL_CHECK_DISK_SIZE_CHANGE], [
ZFS_CHECK_SYMBOL_EXPORT(
[check_disk_size_change],
[fs/block_dev.c],
[AC_DEFINE(HAVE_CHECK_DISK_SIZE_CHANGE, 1,
[check_disk_size_change() is available])],
[])
AC_DEFUN([ZFS_AC_KERNEL_CHECK_DISK_SIZE_CHANGE],
[AC_MSG_CHECKING([whether check_disk_size_change() is available])
ZFS_LINUX_TRY_COMPILE_SYMBOL([
#include <linux/fs.h>
], [
check_disk_size_change(NULL, NULL);
], [check_disk_size_change], [fs/block_dev.c], [
AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_CHECK_DISK_SIZE_CHANGE, 1,
[check_disk_size_change() is available])
], [
AC_MSG_RESULT(no)
])
])

View File

@ -19,11 +19,16 @@ dnl # Therefore, to ensure we have the correct API we only allow the
dnl # clear_inode() compatibility code to be defined iff the evict_inode()
dnl # functionality is also detected.
dnl #
AC_DEFUN([ZFS_AC_KERNEL_CLEAR_INODE], [
ZFS_CHECK_SYMBOL_EXPORT(
[clear_inode],
[fs/inode.c],
[AC_DEFINE(HAVE_CLEAR_INODE, 1,
[clear_inode() is available])],
[])
AC_DEFUN([ZFS_AC_KERNEL_CLEAR_INODE],
[AC_MSG_CHECKING([whether clear_inode() is available])
ZFS_LINUX_TRY_COMPILE_SYMBOL([
#include <linux/fs.h>
], [
clear_inode(NULL);
], [clear_inode], [fs/inode.c], [
AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_CLEAR_INODE, 1, [clear_inode() is available])
], [
AC_MSG_RESULT(no)
])
])

View File

@ -2,11 +2,16 @@ dnl #
dnl # 3.4.0 API change
dnl # Added d_make_root() to replace previous d_alloc_root() function.
dnl #
AC_DEFUN([ZFS_AC_KERNEL_D_MAKE_ROOT], [
ZFS_CHECK_SYMBOL_EXPORT(
[d_make_root],
[fs/dcache.c],
[AC_DEFINE(HAVE_D_MAKE_ROOT, 1,
[d_make_root() is available])],
[])
AC_DEFUN([ZFS_AC_KERNEL_D_MAKE_ROOT],
[AC_MSG_CHECKING([whether d_make_root() is available])
ZFS_LINUX_TRY_COMPILE_SYMBOL([
#include <linux/dcache.h>
], [
d_make_root(NULL);
], [d_make_root], [fs/dcache.c], [
AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_D_MAKE_ROOT, 1, [d_make_root() is available])
], [
AC_MSG_RESULT(no)
])
])

View File

@ -2,11 +2,17 @@ dnl #
dnl # 2.6.28 API change
dnl # Added d_obtain_alias() helper function.
dnl #
AC_DEFUN([ZFS_AC_KERNEL_D_OBTAIN_ALIAS], [
ZFS_CHECK_SYMBOL_EXPORT(
[d_obtain_alias],
[fs/dcache.c],
[AC_DEFINE(HAVE_D_OBTAIN_ALIAS, 1,
[d_obtain_alias() is available])],
[])
AC_DEFUN([ZFS_AC_KERNEL_D_OBTAIN_ALIAS],
[AC_MSG_CHECKING([whether d_obtain_alias() is available])
ZFS_LINUX_TRY_COMPILE_SYMBOL([
#include <linux/dcache.h>
], [
d_obtain_alias(NULL);
], [d_obtain_alias], [fs/dcache.c], [
AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_D_OBTAIN_ALIAS, 1,
[d_obtain_alias() is available])
], [
AC_MSG_RESULT(no)
])
])

View File

@ -1,11 +1,17 @@
dnl #
dnl # 2.6.34 API change
dnl # Verify the get_gendisk() symbol is exported.
dnl # Verify the get_gendisk() symbol is available.
dnl #
AC_DEFUN([ZFS_AC_KERNEL_GET_GENDISK], [
ZFS_CHECK_SYMBOL_EXPORT(
[get_gendisk],
[block/genhd.c],
[AC_DEFINE(HAVE_GET_GENDISK, 1, [get_gendisk() is available])],
[])
AC_DEFUN([ZFS_AC_KERNEL_GET_GENDISK],
[AC_MSG_CHECKING([whether get_gendisk() is available])
ZFS_LINUX_TRY_COMPILE_SYMBOL([
#include <linux/genhd.h>
], [
get_gendisk(0, NULL);
], [get_gendisk], [block/genhd.c], [
AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_GET_GENDISK, 1, [get_gendisk() is available])
], [
AC_MSG_RESULT(no)
])
])

View File

@ -2,11 +2,17 @@ dnl #
dnl # 2.6.28 API change
dnl # Added insert_inode_locked() helper function.
dnl #
AC_DEFUN([ZFS_AC_KERNEL_INSERT_INODE_LOCKED], [
ZFS_CHECK_SYMBOL_EXPORT(
[insert_inode_locked],
[fs/inode.c],
[AC_DEFINE(HAVE_INSERT_INODE_LOCKED, 1,
[insert_inode_locked() is available])],
[])
AC_DEFUN([ZFS_AC_KERNEL_INSERT_INODE_LOCKED],
[AC_MSG_CHECKING([whether insert_inode_locked() is available])
ZFS_LINUX_TRY_COMPILE_SYMBOL([
#include <linux/fs.h>
], [
insert_inode_locked(NULL);
], [insert_inode_locked], [fs/inode.c], [
AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_INSERT_INODE_LOCKED, 1,
[insert_inode_locked() is available])
], [
AC_MSG_RESULT(no)
])
])

View File

@ -5,11 +5,16 @@ dnl # in the file_system_type structure. When using the new
dnl # interface the caller must now use the mount_nodev() helper.
dnl # This updated callback and helper no longer pass the vfsmount.
dnl #
AC_DEFUN([ZFS_AC_KERNEL_MOUNT_NODEV], [
ZFS_CHECK_SYMBOL_EXPORT(
[mount_nodev],
[fs/super.c],
[AC_DEFINE(HAVE_MOUNT_NODEV, 1,
[mount_nodev() is available])],
[])
AC_DEFUN([ZFS_AC_KERNEL_MOUNT_NODEV],
[AC_MSG_CHECKING([whether mount_nodev() is available])
ZFS_LINUX_TRY_COMPILE_SYMBOL([
#include <linux/fs.h>
], [
mount_nodev(NULL, 0, NULL, NULL);
], [mount_nodev], [fs/super.c], [
AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_MOUNT_NODEV, 1, [mount_nodev() is available])
], [
AC_MSG_RESULT(no)
])
])

View File

@ -2,11 +2,17 @@ dnl #
dnl # 2.6.28 API change
dnl # open/close_bdev_excl() renamed to open/close_bdev_exclusive()
dnl #
AC_DEFUN([ZFS_AC_KERNEL_OPEN_BDEV_EXCLUSIVE], [
ZFS_CHECK_SYMBOL_EXPORT(
[open_bdev_exclusive],
[fs/block_dev.c],
[AC_DEFINE(HAVE_OPEN_BDEV_EXCLUSIVE, 1,
[open_bdev_exclusive() is available])],
[])
AC_DEFUN([ZFS_AC_KERNEL_OPEN_BDEV_EXCLUSIVE],
[AC_MSG_CHECKING([whether open_bdev_exclusive() is available])
ZFS_LINUX_TRY_COMPILE_SYMBOL([
#include <linux/fs.h>
], [
open_bdev_exclusive(NULL, 0, NULL);
], [open_bdev_exclusive], [fs/block_dev.c], [
AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_OPEN_BDEV_EXCLUSIVE, 1,
[open_bdev_exclusive() is available])
], [
AC_MSG_RESULT(no)
])
])

View File

@ -2,11 +2,17 @@ dnl #
dnl # 2.6.35 API change
dnl # Added truncate_setsize() helper function.
dnl #
AC_DEFUN([ZFS_AC_KERNEL_TRUNCATE_SETSIZE], [
ZFS_CHECK_SYMBOL_EXPORT(
[truncate_setsize],
[mm/truncate.c],
[AC_DEFINE(HAVE_TRUNCATE_SETSIZE, 1,
[truncate_setsize() is available])],
[])
AC_DEFUN([ZFS_AC_KERNEL_TRUNCATE_SETSIZE],
[AC_MSG_CHECKING([whether truncate_setsize() is available])
ZFS_LINUX_TRY_COMPILE_SYMBOL([
#include <linux/mm.h>
], [
truncate_setsize(NULL, 0);
], [truncate_setsize], [mm/truncate.c], [
AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_TRUNCATE_SETSIZE, 1,
[truncate_setsize() is available])
], [
AC_MSG_RESULT(no)
])
])

View File

@ -159,7 +159,7 @@ AC_DEFUN([ZFS_AC_KERNEL], [
], [test -d ${kernelsrc}-obj/${target_cpu}/${target_cpu}], [
kernelbuild=${kernelsrc}-obj/${target_cpu}/${target_cpu}
], [test -d ${kernelsrc}-obj/${target_cpu}/default], [
kernelbuild=${kernelsrc}-obj/${target_cpu}/default
kernelbuild=${kernelsrc}-obj/${target_cpu}/default
], [test -d `dirname ${kernelsrc}`/build-${target_cpu}], [
kernelbuild=`dirname ${kernelsrc}`/build-${target_cpu}
], [
@ -491,30 +491,48 @@ dnl #
dnl # ZFS_CHECK_SYMBOL_EXPORT
dnl # check symbol exported or not
dnl #
AC_DEFUN([ZFS_CHECK_SYMBOL_EXPORT],
[AC_MSG_CHECKING([whether symbol $1 is exported])
AC_DEFUN([ZFS_CHECK_SYMBOL_EXPORT], [
grep -q -E '[[[:space:]]]$1[[[:space:]]]' \
$LINUX_OBJ/$LINUX_SYMBOLS 2>/dev/null
rc=$?
AS_IF([test $rc -ne 0], [
if test $rc -ne 0; then
export=0
for file in $2; do
grep -q -E "EXPORT_SYMBOL.*($1)" "$LINUX/$file" 2>/dev/null
grep -q -E "EXPORT_SYMBOL.*($1)" \
"$LINUX/$file" 2>/dev/null
rc=$?
AS_IF([test $rc -eq 0], [
if test $rc -eq 0; then
export=1
break;
])
fi
done
AS_IF([test $export -eq 0], [
AC_MSG_RESULT([no])
if test $export -eq 0; then :
$4
], [
AC_MSG_RESULT([yes])
else :
$3
])
], [
AC_MSG_RESULT([yes])
fi
else :
$3
])
fi
])
dnl #
dnl # ZFS_LINUX_TRY_COMPILE_SYMBOL
dnl # like ZFS_LINUX_TRY_COMPILE, except ZFS_CHECK_SYMBOL_EXPORT
dnl # is called if not compiling for builtin
dnl #
AC_DEFUN([ZFS_LINUX_TRY_COMPILE_SYMBOL], [
ZFS_LINUX_TRY_COMPILE([$1], [$2], [rc=0], [rc=1])
if test $rc -ne 0; then :
$6
else
if test "x$enable_linux_builtin" != xyes; then
ZFS_CHECK_SYMBOL_EXPORT([$3], [$4], [rc=0], [rc=1])
fi
if test $rc -ne 0; then :
$6
else :
$5
fi
fi
])

2310
configure vendored

File diff suppressed because it is too large Load Diff