[PATCH 1/2] Add XORG_STRICT_OPTION macro for strict compilation option

Alan Coopersmith Alan.Coopersmith at Sun.COM
Tue Sep 1 21:36:29 PDT 2009


I've verified this works correctly with the Sun compilers, so +1
from me.

The one additional thought I have is should this take an optional
argument for the default value, so that maintainers can make it be
on by default in their modules on a case-by-case basis?
(Perhaps with arguments of "yes", "no" (the default), and "git"
  (yes if $(top_srcdir)/.git exists, otherwise no).)

One word of warning to those updating modules to use it - many modules
had the existing CWARNFLAGS added to FOO_CFLAGS in configure, so this
would need to come before that, something I missed on the first attempt
to test.  Better though would be to switch to our current best practice
of adding CWARNFLAGS to the CFLAGS in Makefile.am, so that it's easier
to override on the make command line when needed (though that's a lot
more work for modules like Xorg with dozens of Makefile.am, it's trivial
for most single-directory modules).

	-alan-

Peter Hutterer wrote:
> From: Pauli Nieminen <suokkos at gmail.com>
> 
> Strict compilation option can be used to get rid of warnings that often are
> showing real hidden bug in code. That just waits to cause problems.
> 
> CWARNFLAGS has to be added to AM_C(PP)FLAGS to use strict compilation mode
> in Makefile.am. Automatic addition to compiler flags would cause some configure
> checks fail.
> 
> X.Org Bug 22939 <http://bugs.freedesktop.org/show_bug.cgi?id=22939>
> 
> Signed-off-by: Peter Hutterer <peter.hutterer at who-t.net>
> ---
>  xorg-macros.m4.in |   29 +++++++++++++++++++++++++++++
>  1 files changed, 29 insertions(+), 0 deletions(-)
> 
> diff --git a/xorg-macros.m4.in b/xorg-macros.m4.in
> index 1954714..5c22332 100644
> --- a/xorg-macros.m4.in
> +++ b/xorg-macros.m4.in
> @@ -456,3 +456,32 @@ fi
>  AC_SUBST(CWARNFLAGS)
>  m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
>  ]) # XORG_CWARNFLAGS
> +
> +# XORG_STRICT_OPTION
> +# -----------------------
> +# Minimum version: 1.3.0
> +#
> +# Add configure option to enable strict compilation
> +AC_DEFUN([XORG_STRICT_OPTION], [
> +AC_REQUIRE([AC_PROG_CC])
> +AC_REQUIRE([AC_PROG_CC_C99])
> +AC_REQUIRE([XORG_CWARNFLAGS])
> +
> +AC_ARG_ENABLE(strict-compilation,
> +			  AS_HELP_STRING([--enable-strict-compilation],
> +			  [Enable all warnings from compiler and make them errors (default: disabled)]),
> +			  [STRICT_COMPILE=$enableval], [STRICT_COMPILE=no])
> +if test "x$STRICT_COMPILE" = "xyes"; then
> +	AC_CHECK_DECL([__SUNPRO_C], [SUNCC="yes"], [SUNCC="no"])
> +	AC_CHECK_DECL([__INTEL_COMPILER], [INTELCC="yes"], [INTELCC="no"])
> +	if test "x$GCC" = xyes ; then
> +		STRICT_CFLAGS="-pedantic -Werror"
> +	elif test "x$SUNCC" = "xyes"; then
> +		STRICT_CFLAGS="-errwarn"
> +    elif test "x$INTELCC" = "xyes"; then
> +		STRICT_CFLAGS="-Werror"
> +	fi
> +fi
> +CWARNFLAGS="$CWARNFLAGS $STRICT_CFLAGS"
> +AC_SUBST([CWARNFLAGS])
> +]) # XORG_STRICT_OPTION


-- 
    -Alan Coopersmith-		alan.coopersmith at sun.com
     Sun Microsystems, Inc. - X Window System Engineering


More information about the xorg-devel mailing list