[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: debug builds with NO optimizations
From: |
Howard Chu |
Subject: |
Re: debug builds with NO optimizations |
Date: |
Mon, 06 Feb 2006 15:43:48 -0800 |
User-agent: |
Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9a1) Gecko/20060115 SeaMonkey/1.5a Mnenhy/0.7.3.0 |
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.
I really like the use of this macro because it also attempts to put the compiler into standard C mode - which has no standard mechnism, so it really belongs in the macro. I also completely subscribe to the "symbols on all builds" philosophy, so I too would recommend enabling -g-like functionality on all possible compilers for all possible build configurations. What I _don't_ agree with is automatically tacking in a -O2 * who thought that would be a good idea?
What we really need is a macro that enables optimization levels (such as -Ox), or completely disables them. Then we can use our various debug flags to enable/disable them conditionally, as maintainer/programmer configuration dictates.
My question: Anyone know of a good idiom for managing optimization flags - including disabling the obligatory -O2 placed in CFLAGS by AC_PROG_CC?
I run into this all the time but never bothered to sit down and think of
a permanent solution. I always wind up editing the relevant Makefiles
and changing
CFLAGS=-g -O2 ...
to
OPT=-g -O2
CFLAGS=$(OPT) ...
and running with "make OPT=-g" when I want a pure debug build.
--
-- Howard Chu
Chief Architect, Symas Corp. http://www.symas.com
Director, Highland Sun http://highlandsun.com/hyc
OpenLDAP Core Team http://www.openldap.org/project/