[Mesa-dev] [PATCH] configure: Don't override user -g or -O options for debug builds

Ian Romanick idr at freedesktop.org
Mon Jul 14 16:53:02 PDT 2014


On 07/14/2014 01:41 PM, Matt Turner wrote:
> On Mon, Jul 14, 2014 at 11:49 AM, Ian Romanick <idr at freedesktop.org> wrote:
>> From: Ian Romanick <ian.d.romanick at intel.com>
>>
>> I already pass '-ggdb3 -O1' or '-ggdb3 -Og' for CFLAGS, and I don't want
>> configure to change them for me.
>>
>> Signed-off-by: Ian Romanick <ian.d.romanick at intel.com>
>> ---
>>  configure.ac | 14 ++++++++++++--
>>  1 file changed, 12 insertions(+), 2 deletions(-)
>>
>> diff --git a/configure.ac b/configure.ac
>> index 4646212..04abcc0 100644
>> --- a/configure.ac
>> +++ b/configure.ac
>> @@ -308,10 +308,20 @@ AC_ARG_ENABLE([debug],
>>  if test "x$enable_debug" = xyes; then
>>      DEFINES="$DEFINES -DDEBUG"
>>      if test "x$GCC" = xyes; then
>> -        CFLAGS="$CFLAGS -g -O0"
>> +        if ! echo "$CFLAGS" | grep -q -e '-g'; then
>> +            CFLAGS="$CFLAGS -g"
>> +        fi
>> +        if ! echo "$CFLAGS" | grep -q -e '-O'; then
>> +            CFLAGS="$CFLAGS -O0"
>> +        fi
>>      fi
>>      if test "x$GXX" = xyes; then
>> -        CXXFLAGS="$CXXFLAGS -g -O0"
>> +        if ! echo "$CXXFLAGS" | grep -q -e '-g'; then
>> +            CXXFLAGS="$CXXFLAGS -g"
>> +        fi
>> +        if ! echo "$CXXFLAGS" | grep -q -e '-O'; then
>> +            CXXFLAGS="$CXXFLAGS -O0"
>> +        fi
>>      fi
>>  fi
>>
>> --
>> 1.8.1.4
> 
> This looks like strictly an improvement, so my feedback shouldn't hold
> this up, but maybe it's time to fight about whether --enable-debug
> should add -O0 at all. :)
> 
> Reviewed-by: Matt Turner <mattst88 at gmail.com>
> 
> Autotools defaults are -g -O2. Some people want debug builds to use
> -g, others -ggdb*. Some people want -O2 (optimize, but with assertions
> enabled), others -O0, others -Og. It'd be nice to not have
> --enable-debug turn on one combination of these.

I thought about that when I wrote this patch, but I decided against it.
 Principle of least surprise:  --enable-debug should enable debugging.
Ages ago, Mesa's build system only added -g in dri-debug builds (yay for
the static Makefiles).  If you forgot to change it (or wrap the build
with custom scripts), you would often be disappointed when trying to gdb
Mesa bugs.  New developers, that may not yet have custom scripts, will
have this same issue.

I think we should enable experienced developers to do what they want,
and make things easier for new developers.

That said, if the previaling opinion is to just remove it, I'm okay with
that too...



More information about the mesa-dev mailing list