Only make compiler warnings fatal with --enable-debug

While in theory I like the idea of compiler warnings always being
fatal.  In practice this causes problems when small harmless errors
cause build failures for end users.  To handle this I've updated
the build system such that -Werror is only used when --enable-debug
is passed to configure.  This is how I always build when developing
so I'll catch all build warnings and end users will not get stuck
by minor issues.
This commit is contained in:
Brian Behlendorf 2010-07-14 10:25:54 -07:00
parent 99694a2e81
commit dccff58e11
3 changed files with 19 additions and 26 deletions

View File

@ -1,7 +1,7 @@
DEFAULT_INCLUDES = -include ${top_srcdir}/zfs_config.h DEFAULT_INCLUDES = -include ${top_srcdir}/zfs_config.h
AM_LIBTOOLFLAGS = --silent AM_LIBTOOLFLAGS = --silent
AM_CFLAGS = -Wall -Wstrict-prototypes -fno-strict-aliasing -Werror AM_CFLAGS = -Wall -Wstrict-prototypes -fno-strict-aliasing ${DEBUG_CFLAGS}
AM_CFLAGS += -D_GNU_SOURCE -D__EXTENSIONS__ -D_REENTRANT AM_CFLAGS += -D_GNU_SOURCE -D__EXTENSIONS__ -D_REENTRANT
AM_CFLAGS += -D_POSIX_PTHREAD_SEMANTICS -D_FILE_OFFSET_BITS=64 AM_CFLAGS += -D_POSIX_PTHREAD_SEMANTICS -D_FILE_OFFSET_BITS=64
AM_CFLAGS += -D_LARGEFILE64_SOURCE -DTEXT_DOMAIN=\"zfs-linux-user\" AM_CFLAGS += -D_LARGEFILE64_SOURCE -DTEXT_DOMAIN=\"zfs-linux-user\"

View File

@ -25,7 +25,7 @@ AC_DEFUN([ZFS_AC_CONFIG_KERNEL], [
dnl # -Wall -fno-strict-aliasing -Wstrict-prototypes and other dnl # -Wall -fno-strict-aliasing -Wstrict-prototypes and other
dnl # compiler options are added by the kernel build system. dnl # compiler options are added by the kernel build system.
KERNELCPPFLAGS="$KERNELCPPFLAGS -Werror -DHAVE_SPL -D_KERNEL" KERNELCPPFLAGS="$KERNELCPPFLAGS -DHAVE_SPL -D_KERNEL"
KERNELCPPFLAGS="$KERNELCPPFLAGS -DTEXT_DOMAIN=\\\"zfs-linux-kernel\\\"" KERNELCPPFLAGS="$KERNELCPPFLAGS -DTEXT_DOMAIN=\\\"zfs-linux-kernel\\\""
KERNELCPPFLAGS="$KERNELCPPFLAGS -I$SPL" KERNELCPPFLAGS="$KERNELCPPFLAGS -I$SPL"
KERNELCPPFLAGS="$KERNELCPPFLAGS -I$SPL/include" KERNELCPPFLAGS="$KERNELCPPFLAGS -I$SPL/include"

View File

@ -8,33 +8,26 @@ AC_DEFUN([ZFS_AC_LICENSE], [
AC_DEFUN([ZFS_AC_DEBUG], [ AC_DEFUN([ZFS_AC_DEBUG], [
AC_MSG_CHECKING([whether debugging is enabled]) AC_MSG_CHECKING([whether debugging is enabled])
AC_ARG_ENABLE( [debug], AC_ARG_ENABLE([debug],
AS_HELP_STRING([--enable-debug], [AS_HELP_STRING([--enable-debug],
[Enable generic debug support (default off)]), [Enable generic debug support @<:@default=no@:>@])],
[ case "$enableval" in [],
yes) zfs_ac_debug=yes ;; [enable_debug=no])
no) zfs_ac_debug=no ;;
*) AC_MSG_RESULT([Error!]) AS_IF([test "x$enable_debug" = xyes],
AC_MSG_ERROR([Bad value "$enableval" for --enable-debug]) ;; [
esac ] KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG -Werror"
) HOSTCFLAGS="${HOSTCFLAGS} -DDEBUG -Werror"
if test "$zfs_ac_debug" = yes; then DEBUG_CFLAGS="-DDEBUG -Werror -fstack-check"
AC_MSG_RESULT([yes]) ],
AC_DEFINE([DEBUG], [1], [
[Define to 1 to enable debug tracing])
KERNELCPPFLAGS="${KERNELCPPFLAGS} -DDEBUG "
HOSTCFLAGS="${HOSTCFLAGS} -DDEBUG "
USERDEBUG="-DDEBUG -fstack-check"
else
AC_MSG_RESULT([no])
AC_DEFINE([NDEBUG], [1],
[Define to 1 to disable debug tracing])
KERNELCPPFLAGS="${KERNELCPPFLAGS} -DNDEBUG " KERNELCPPFLAGS="${KERNELCPPFLAGS} -DNDEBUG "
HOSTCFLAGS="${HOSTCFLAGS} -DNDEBUG " HOSTCFLAGS="${HOSTCFLAGS} -DNDEBUG "
USERDEBUG="-DNDEBUG" DEBUG_CFLAGS="-DNDEBUG"
fi ])
AC_SUBST(USERDEBUG) AC_SUBST(DEBUG_CFLAGS)
AC_MSG_RESULT([$enable_debug])
]) ])
AC_DEFUN([ZFS_AC_CONFIG_SCRIPT], [ AC_DEFUN([ZFS_AC_CONFIG_SCRIPT], [