This is the mail archive of the
automake@gnu.org
mailing list for the automake project.
Re: Disabling optimization
- From: Braden McDaniel <braden at endoframe dot com>
- To: Jonathan <voigtjr at gmail dot com>
- Cc: automake at gnu dot org
- Date: Wed, 17 Nov 2004 20:01:45 -0500
- Subject: Re: Disabling optimization
- References: <1c1ef760411171548675fa77b@mail.gmail.com>
On Wed, 2004-11-17 at 18:48 -0500, Jonathan wrote:
> My autoconf/automake project is optimizing by default with "-g -O2".
> Unfortunately, we have verified that this is causing a run-time error
> by overriding CXXFLAGS in Makefile.am with just "-g". With the "-O2"
> flag removed, everything works great.
>
> I have been trying to find out where this "-O2" is coming from so I
> can disable it at the configure.ac level, but my attempts have been
> fruitless.
"-g -O2" is what AC_PROG_CC/AC_PROG_CXX sets CFLAGS/CXXFLAGS to if it
isn't already set to something.
> How do I disable the "-O2" flag in the most portable way possible?
I would do something like this (in configure.ac):
if test -n "${CXXFLAGS}"; then
user_set_cxxflags=yes
fi
AC_PROG_CXX
if test X$user_set_cxxflags != Xyes; then
CXXFLAGS="-g"
fi
Really you should probably be a little more clever and also check to see
if the compiler in use is the one you have a problem with. But this
approach allows someone who really *wants* to use -O2 (to experiment,
perhaps) to do so.
--
Braden McDaniel e-mail: <braden@endoframe.com>
<http://endoframe.com> Jabber: <braden@jabber.org>