autoconf
[Top][All Lists]
Advanced

[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: Tue, 07 Feb 2006 12:13:22 -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:
When you override CFLAGS on the configure command line, you give
configure the opportunity to add more flags to the CFLAGS variable that
are then passed on to make. On the other hand, when you modify CFLAGS on
the make command line, you are overriding all settings provided to the
Makefile by the configure script when the Makefile was built. For
example, I have a (generated) Makefile that contains the following
definition for CFLAGS:
CFLAGS = -g -O2 -DLINUX -Wall -Werror -O3
The -g -O2 comes from the AC_PROG_CC macro in my configure.ac file. The
-DLINUX comes from some hand-written script in that same configure.ac
that determines my platform (based on host_os), while thet -Wall -Werror
comes from some more script that determines which compiler I'm using.
Finally, the -O3 is determined by yet another piece of script that
determines based on --enable features specified how optimal I want the
code to be.
If you say "make CFLAGS=-g", you've just lost the definition for LINUX
and the warning options defined in the configure script. Before you all
flame me on this, let me say that I'm already aware that I should be
passing the -D option in the CPPFLAGS, but I would argue that CFLAGS is
the only viable place to pass the -W options, and that these options
should probably be set by a configure script that can figure out which
compiler you're using. I would also like to point out that this is a
simple example - I know of projects that also much more carefully craft
optimization flags - they pass a dozen or more -f flags based on
compiler and platform characteristics.

This is a common problem, and the common solution is to push each bit of potential settings into its own macro, which is then referenced from the Makefile's CFLAGS macro. Thus for command line overrides you only override one of the other macros, not CFLAGS itself.

E.g. in OpenLDAP the Makefile.in uses:
address@hidden@

to get the AC_PROG_CC flags. The actual CFLAGS is
CFLAGS=$(AC_CFLAGS) $(DEFS)

with DEFS referencing a variety of other macros for whatever other flags are needed.

Then
        make AC_CFLAGS=-g
is sufficient to override the "-g -O2" that autoconf puts in there by default.

I reserve setting CFLAGS on the make command line for when I absolutely
need to specify the entire set of CFLAGS in a build - for instance, when
I'm experimenting with something new.

Right; I pretty much never override CFLAGS itself, too much hassle to get all of the other definitions.

--
  -- 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/




reply via email to

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