[Mesa-dev] [PATCH] Remove CFLAGS and CXXFLAGS which clang does not support. Fixes: clang-3: warning: argument unused during compilation: '-fno-builtin-memcmp' The checks could be also done where '-fno-builtin-memcmp' become added (lines 217 and 240) but this would not remove it if set by user.

Johannes Obermayr johannesobermayr at gmx.de
Sun Mar 4 03:31:17 PST 2012


Am Samstag, 3. März 2012, 20:29:05 schrieb Kenneth Graunke:
> On 03/03/2012 08:06 AM, Johannes Obermayr wrote:
> > ---
> >   configure.ac |    6 ++++++
> >   1 files changed, 6 insertions(+), 0 deletions(-)
> >
> > diff --git a/configure.ac b/configure.ac
> > index a2d906a..44c4e65 100644
> > --- a/configure.ac
> > +++ b/configure.ac
> > @@ -1946,6 +1946,12 @@ dnl Add user CFLAGS and CXXFLAGS
> >   CFLAGS="$CFLAGS $USER_CFLAGS"
> >   CXXFLAGS="$CXXFLAGS $USER_CXXFLAGS"
> >
> > +dnl Remove CFLAGS and CXXFLAGS which clang does not support
> > +if test "x$acv_mesa_CLANG" = xyes; then
> > +    CFLAGS=`echo $CFLAGS | sed 's/-fno-builtin-memcmp//g'`
> > +    CXXFLAGS=`echo $CXXFLAGS | sed 's/-fno-builtin-memcmp//g'`
> > +fi
> > +
> >   dnl Substitute the config
> >   AC_CONFIG_FILES([configs/autoconf
> >   		src/gallium/drivers/r300/Makefile
> 
> This works, but I wonder if we should instead import something like 
> XORG_TESTSET_CFLAG from xorg-util-macros.  That would allow us to 
> easily, in one line of code, enable flags when they're supported by the 
> underlying compiler.  It would handle this and clean up a bunch of our 
> other flag handling (like warning flags).
> 
> I don't think we can depend on xorg-util-macros, but we could probably 
> copy part of it into Mesa.

# XORG_TESTSET_CFLAG(<variable>, <flag>, [<alternative flag>, ...])
# ---------------
# Minimum version: 1.16.0
#
# Test if the compiler works when passed the given flag as a command line argument.
# If it succeeds, the flag is appeneded to the given variable.  If not, it tries the
# next flag in the list until there are no more options.
#
# Note that this does not guarantee that the compiler supports the flag as some
# compilers will simply ignore arguments that they do not understand, but we do
# attempt to weed out false positives by using -Werror=unknown-warning-option and
# -Werror=unused-command-line-argument
#

"[...] some compilers will simply ignore arguments that they do not understand [...]"

clang ignores it so it is unrewarding:
"checking if clang supports -fno-builtin-memcmp... yes"


More information about the mesa-dev mailing list