diff options
author | Brian Behlendorf <[email protected]> | 2011-06-14 11:02:13 -0700 |
---|---|---|
committer | Brian Behlendorf <[email protected]> | 2011-06-14 14:43:22 -0700 |
commit | 8a7e1ceefa430988c8f888ca708ab307333b4464 (patch) | |
tree | 5368cde4746cbc6886ec599ace454cc9fa0a073a /config | |
parent | 10715a018760e1d862b8348e31dc505e832a0904 (diff) |
Check for -Wno-unused-but-set-variable gcc support
Gcc versions 4.3.2 and earlier do not support the compiler flag
-Wno-unused-but-set-variable. This can lead to build failures
on older Linux platforms such as Debian Lenny. Since this is
an optional build argument this changes add a new autoconf check
for the option. If it is supported by the installed version of
gcc then it is used otherwise it is omited.
See commit's 12c1acde76683108441827ae9affba1872f3afe5 and
79713039a2b6e0ed223d141b4a8a8455f282d2f2 for the reason the
-Wno-unused-but-set-variable options was originally added.
Diffstat (limited to 'config')
-rw-r--r-- | config/Rules.am | 2 | ||||
-rw-r--r-- | config/kernel.m4 | 2 | ||||
-rw-r--r-- | config/user-no-unused-but-set-variable.m4 | 27 | ||||
-rw-r--r-- | config/user.m4 | 1 |
4 files changed, 30 insertions, 2 deletions
diff --git a/config/Rules.am b/config/Rules.am index 2abafcd4d..bd4f0ea60 100644 --- a/config/Rules.am +++ b/config/Rules.am @@ -2,7 +2,7 @@ DEFAULT_INCLUDES = -include ${top_builddir}/zfs_config.h AM_LIBTOOLFLAGS = --silent AM_CFLAGS = -Wall -Wstrict-prototypes -AM_CFLAGS += -fno-strict-aliasing -Wno-unused-but-set-variable ${DEBUG_CFLAGS} +AM_CFLAGS += -fno-strict-aliasing ${NO_UNUSED_BUT_SET_VARIABLE} ${DEBUG_CFLAGS} AM_CFLAGS += -D_GNU_SOURCE -D__EXTENSIONS__ -D_REENTRANT AM_CFLAGS += -D_POSIX_PTHREAD_SEMANTICS -D_FILE_OFFSET_BITS=64 AM_CFLAGS += -D_LARGEFILE64_SOURCE -DTEXT_DOMAIN=\"zfs-linux-user\" diff --git a/config/kernel.m4 b/config/kernel.m4 index 015192b5b..0ccae33fa 100644 --- a/config/kernel.m4 +++ b/config/kernel.m4 @@ -46,7 +46,7 @@ AC_DEFUN([ZFS_AC_CONFIG_KERNEL], [ dnl # -Wall -fno-strict-aliasing -Wstrict-prototypes and other dnl # compiler options are added by the kernel build system. - KERNELCPPFLAGS="$KERNELCPPFLAGS -Wno-unused-but-set-variable" + KERNELCPPFLAGS="$KERNELCPPFLAGS $NO_UNUSED_BUT_SET_VARIABLE" KERNELCPPFLAGS="$KERNELCPPFLAGS -DHAVE_SPL -D_KERNEL" KERNELCPPFLAGS="$KERNELCPPFLAGS -DTEXT_DOMAIN=\\\"zfs-linux-kernel\\\"" diff --git a/config/user-no-unused-but-set-variable.m4 b/config/user-no-unused-but-set-variable.m4 new file mode 100644 index 000000000..ebe4a7594 --- /dev/null +++ b/config/user-no-unused-but-set-variable.m4 @@ -0,0 +1,27 @@ +dnl # +dnl # Check if gcc supports -Wno-unused-but-set-variable option. +dnl # +dnl # We actually invoke gcc with the -Wunused-but-set-variable option +dnl # and infer the 'no-' version does or doesn't exist based upon +dnl # the results. This is required because when checking any of +dnl # no- prefixed options gcc always returns success. +dnl # +AC_DEFUN([ZFS_AC_CONFIG_USER_NO_UNUSED_BUT_SET_VARIABLE], [ + AC_MSG_CHECKING([for -Wno-unused-but-set-variable support]) + + saved_flags="$CFLAGS" + CFLAGS="$CFLAGS -Wunused-but-set-variable" + + AC_RUN_IFELSE(AC_LANG_PROGRAM( [], []), + [ + NO_UNUSED_BUT_SET_VARIABLE=-Wno-unused-but-set-variable + AC_MSG_RESULT([yes]) + ], + [ + NO_UNUSED_BUT_SET_VARIABLE= + AC_MSG_RESULT([no]) + ]) + + CFLAGS="$saved_flags" + AC_SUBST([NO_UNUSED_BUT_SET_VARIABLE]) +]) diff --git a/config/user.m4 b/config/user.m4 index a79deefe8..d12633f39 100644 --- a/config/user.m4 +++ b/config/user.m4 @@ -9,5 +9,6 @@ AC_DEFUN([ZFS_AC_CONFIG_USER], [ ZFS_AC_CONFIG_USER_LIBBLKID ZFS_AC_CONFIG_USER_LIBSELINUX ZFS_AC_CONFIG_USER_FRAME_LARGER_THAN + ZFS_AC_CONFIG_USER_NO_UNUSED_BUT_SET_VARIABLE ZFS_AC_CONFIG_USER_STACK_GUARD ]) |