autoconf
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: debug builds with NO optimizations


From: John Calcote
Subject: Re: debug builds with NO optimizations
Date: Tue, 07 Feb 2006 09:57:34 -0700

Brian,
 
Thanks for the reply. I get this. I realize that you MAY set CFLAGS on
the command line if you wish - and you should - IF you have special
flags to set on the command line for a specific configuration or build.
My complaint was that the AC_PROG_CC macro just assumes you want -O2
(again - IF nothing else is already set).
 
I don't want it to assume you want any sort of user configuration -
including optimization. Other things this macro does include setting any
flags necessary to enable ansi C processing, and enabling symbol
generation. These I like. I just don't like the -O2 optimization flag. I
think it's inappropriate. I believe a better solution would be to have
the autoconf guys add a standard macro that allows you to choose an
optimization level. This way you could set the appropriate optimization
level based on your projects needs. 
 
BTW, the way I currently "work around" this issue is to go ahead and
add -O0 if "--enable-debug" is specified, or -O3 if it's not (on GCC
only, of course). GCC docs specify that the last -O option wins, so I
just live with the fact that -O2 is specified first, and then the actual
optimization level that I want. 
 
Of course, my configuration file is set to allow the user to override
all of these options if they use CFLAGS on the command line of either
configure, or make.
 
John

>>> Brian Dessent <address@hidden> 2/6/2006 5:25:04 pm >>>
John Calcote wrote:

> Generally, when I build with the DEBUG macro defined, it's because I
want to step through a portion of my code with the debugger. However,
I've noticed that using AC_PROG_CC sets CFLAGS to "-g -O2" on GCC - and
tries to use similar options on other compilers.

"-g -O2" is simply a default if CFLAGS is not already set.  It is by
no
means set in stone, and in fact any package that insists on a
particular
setting of CFLAGS is broken since this is meant to be a user-supplied
variable.  You are expected to set CFLAGS when configuring if you want
something else.  For example if you have a package and you want to
build
it both optimized without debug information as well as a debug build:

$ mkdir build-release && cd build-release
$ CFLAGS="-g0 -O2" ../configure --prefix=/opt/foobar && make
$ cd ..
$ mkdir build-debug && cd build-debug
$ CFLAGS="-g -O0" ../configure --prefix=/opt/foobar && make

Brian


reply via email to

[Prev in Thread] Current Thread [Next in Thread]