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 # using it significantly simplifies the code surrounding setting
dnl # up and tearing down the bdi structure. dnl # up and tearing down the bdi structure.
dnl # dnl #
AC_DEFUN([ZFS_AC_KERNEL_BDI_SETUP_AND_REGISTER], [ AC_DEFUN([ZFS_AC_KERNEL_BDI_SETUP_AND_REGISTER],
ZFS_CHECK_SYMBOL_EXPORT( [AC_MSG_CHECKING([whether bdi_setup_and_register() is available])
[bdi_setup_and_register], ZFS_LINUX_TRY_COMPILE_SYMBOL([
[mm/backing-dev.c], #include <linux/backing-dev.h>
[AC_DEFINE(HAVE_BDI_SETUP_AND_REGISTER, 1, ], [
[bdi_setup_and_register() is available])], 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 # open_bdev_exclusive() changed to blkdev_get_by_path()
dnl # close_bdev_exclusive() changed to blkdev_put() dnl # close_bdev_exclusive() changed to blkdev_put()
dnl # dnl #
AC_DEFUN([ZFS_AC_KERNEL_BLKDEV_GET_BY_PATH], [ AC_DEFUN([ZFS_AC_KERNEL_BLKDEV_GET_BY_PATH],
ZFS_CHECK_SYMBOL_EXPORT( [AC_MSG_CHECKING([whether blkdev_get_by_path() is available])
[blkdev_get_by_path], ZFS_LINUX_TRY_COMPILE_SYMBOL([
[fs/block_dev.c], #include <linux/fs.h>
[AC_DEFINE(HAVE_BLKDEV_GET_BY_PATH, 1, ], [
[blkdev_get_by_path() is available])], 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 # 2.6.28 API change
dnl # Added check_disk_size_change() helper function. dnl # Added check_disk_size_change() helper function.
dnl # dnl #
AC_DEFUN([ZFS_AC_KERNEL_CHECK_DISK_SIZE_CHANGE], [ AC_DEFUN([ZFS_AC_KERNEL_CHECK_DISK_SIZE_CHANGE],
ZFS_CHECK_SYMBOL_EXPORT( [AC_MSG_CHECKING([whether check_disk_size_change() is available])
[check_disk_size_change], ZFS_LINUX_TRY_COMPILE_SYMBOL([
[fs/block_dev.c], #include <linux/fs.h>
[AC_DEFINE(HAVE_CHECK_DISK_SIZE_CHANGE, 1, ], [
[check_disk_size_change() is available])], 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 # clear_inode() compatibility code to be defined iff the evict_inode()
dnl # functionality is also detected. dnl # functionality is also detected.
dnl # dnl #
AC_DEFUN([ZFS_AC_KERNEL_CLEAR_INODE], [ AC_DEFUN([ZFS_AC_KERNEL_CLEAR_INODE],
ZFS_CHECK_SYMBOL_EXPORT( [AC_MSG_CHECKING([whether clear_inode() is available])
[clear_inode], ZFS_LINUX_TRY_COMPILE_SYMBOL([
[fs/inode.c], #include <linux/fs.h>
[AC_DEFINE(HAVE_CLEAR_INODE, 1, ], [
[clear_inode() is available])], 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 # 3.4.0 API change
dnl # Added d_make_root() to replace previous d_alloc_root() function. dnl # Added d_make_root() to replace previous d_alloc_root() function.
dnl # dnl #
AC_DEFUN([ZFS_AC_KERNEL_D_MAKE_ROOT], [ AC_DEFUN([ZFS_AC_KERNEL_D_MAKE_ROOT],
ZFS_CHECK_SYMBOL_EXPORT( [AC_MSG_CHECKING([whether d_make_root() is available])
[d_make_root], ZFS_LINUX_TRY_COMPILE_SYMBOL([
[fs/dcache.c], #include <linux/dcache.h>
[AC_DEFINE(HAVE_D_MAKE_ROOT, 1, ], [
[d_make_root() is available])], 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 # 2.6.28 API change
dnl # Added d_obtain_alias() helper function. dnl # Added d_obtain_alias() helper function.
dnl # dnl #
AC_DEFUN([ZFS_AC_KERNEL_D_OBTAIN_ALIAS], [ AC_DEFUN([ZFS_AC_KERNEL_D_OBTAIN_ALIAS],
ZFS_CHECK_SYMBOL_EXPORT( [AC_MSG_CHECKING([whether d_obtain_alias() is available])
[d_obtain_alias], ZFS_LINUX_TRY_COMPILE_SYMBOL([
[fs/dcache.c], #include <linux/dcache.h>
[AC_DEFINE(HAVE_D_OBTAIN_ALIAS, 1, ], [
[d_obtain_alias() is available])], 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 #
dnl # 2.6.34 API change dnl # 2.6.34 API change
dnl # Verify the get_gendisk() symbol is exported. dnl # Verify the get_gendisk() symbol is available.
dnl # dnl #
AC_DEFUN([ZFS_AC_KERNEL_GET_GENDISK], [ AC_DEFUN([ZFS_AC_KERNEL_GET_GENDISK],
ZFS_CHECK_SYMBOL_EXPORT( [AC_MSG_CHECKING([whether get_gendisk() is available])
[get_gendisk], ZFS_LINUX_TRY_COMPILE_SYMBOL([
[block/genhd.c], #include <linux/genhd.h>
[AC_DEFINE(HAVE_GET_GENDISK, 1, [get_gendisk() is available])], ], [
[]) 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 # 2.6.28 API change
dnl # Added insert_inode_locked() helper function. dnl # Added insert_inode_locked() helper function.
dnl # dnl #
AC_DEFUN([ZFS_AC_KERNEL_INSERT_INODE_LOCKED], [ AC_DEFUN([ZFS_AC_KERNEL_INSERT_INODE_LOCKED],
ZFS_CHECK_SYMBOL_EXPORT( [AC_MSG_CHECKING([whether insert_inode_locked() is available])
[insert_inode_locked], ZFS_LINUX_TRY_COMPILE_SYMBOL([
[fs/inode.c], #include <linux/fs.h>
[AC_DEFINE(HAVE_INSERT_INODE_LOCKED, 1, ], [
[insert_inode_locked() is available])], 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 # interface the caller must now use the mount_nodev() helper.
dnl # This updated callback and helper no longer pass the vfsmount. dnl # This updated callback and helper no longer pass the vfsmount.
dnl # dnl #
AC_DEFUN([ZFS_AC_KERNEL_MOUNT_NODEV], [ AC_DEFUN([ZFS_AC_KERNEL_MOUNT_NODEV],
ZFS_CHECK_SYMBOL_EXPORT( [AC_MSG_CHECKING([whether mount_nodev() is available])
[mount_nodev], ZFS_LINUX_TRY_COMPILE_SYMBOL([
[fs/super.c], #include <linux/fs.h>
[AC_DEFINE(HAVE_MOUNT_NODEV, 1, ], [
[mount_nodev() is available])], 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 # 2.6.28 API change
dnl # open/close_bdev_excl() renamed to open/close_bdev_exclusive() dnl # open/close_bdev_excl() renamed to open/close_bdev_exclusive()
dnl # dnl #
AC_DEFUN([ZFS_AC_KERNEL_OPEN_BDEV_EXCLUSIVE], [ AC_DEFUN([ZFS_AC_KERNEL_OPEN_BDEV_EXCLUSIVE],
ZFS_CHECK_SYMBOL_EXPORT( [AC_MSG_CHECKING([whether open_bdev_exclusive() is available])
[open_bdev_exclusive], ZFS_LINUX_TRY_COMPILE_SYMBOL([
[fs/block_dev.c], #include <linux/fs.h>
[AC_DEFINE(HAVE_OPEN_BDEV_EXCLUSIVE, 1, ], [
[open_bdev_exclusive() is available])], 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 # 2.6.35 API change
dnl # Added truncate_setsize() helper function. dnl # Added truncate_setsize() helper function.
dnl # dnl #
AC_DEFUN([ZFS_AC_KERNEL_TRUNCATE_SETSIZE], [ AC_DEFUN([ZFS_AC_KERNEL_TRUNCATE_SETSIZE],
ZFS_CHECK_SYMBOL_EXPORT( [AC_MSG_CHECKING([whether truncate_setsize() is available])
[truncate_setsize], ZFS_LINUX_TRY_COMPILE_SYMBOL([
[mm/truncate.c], #include <linux/mm.h>
[AC_DEFINE(HAVE_TRUNCATE_SETSIZE, 1, ], [
[truncate_setsize() is available])], 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

@ -491,30 +491,48 @@ dnl #
dnl # ZFS_CHECK_SYMBOL_EXPORT dnl # ZFS_CHECK_SYMBOL_EXPORT
dnl # check symbol exported or not dnl # check symbol exported or not
dnl # dnl #
AC_DEFUN([ZFS_CHECK_SYMBOL_EXPORT], AC_DEFUN([ZFS_CHECK_SYMBOL_EXPORT], [
[AC_MSG_CHECKING([whether symbol $1 is exported])
grep -q -E '[[[:space:]]]$1[[[:space:]]]' \ grep -q -E '[[[:space:]]]$1[[[:space:]]]' \
$LINUX_OBJ/$LINUX_SYMBOLS 2>/dev/null $LINUX_OBJ/$LINUX_SYMBOLS 2>/dev/null
rc=$? rc=$?
AS_IF([test $rc -ne 0], [ if test $rc -ne 0; then
export=0 export=0
for file in $2; do 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=$? rc=$?
AS_IF([test $rc -eq 0], [ if test $rc -eq 0; then
export=1 export=1
break; break;
]) fi
done done
AS_IF([test $export -eq 0], [ if test $export -eq 0; then :
AC_MSG_RESULT([no])
$4 $4
], [ else :
AC_MSG_RESULT([yes])
$3 $3
]) fi
], [ else :
AC_MSG_RESULT([yes])
$3 $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
]) ])

2058
configure vendored

File diff suppressed because it is too large Load Diff