This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author vstinner
Recipients vstinner
Date 2010-03-23.12:14:04
SpamBayes Score 2.6914104e-09
Marked as misclassified No
Message-id <1269346447.99.0.323336928566.issue8211@psf.upfronthosting.co.za>
In-reply-to
Content
configure.in uses AC_PROG_CC, extract of the autoconf manual:
(http://www.delorie.com/gnu/docs/autoconf/autoconf_64.html)
 
 If using the GNU C compiler, set shell variable GCC to `yes'. If output variable CFLAGS was not already set, set it to `-g -O2' for the GNU C compiler (`-O2' on systems where GCC does not accept `-g'), or `-g' for other compilers.

Python does already set the optimization level in its OPT variable: for gcc, it uses -O3 by default, and not -O option (in this case, gcc disables all optimisations, it's like -O0) if --with-pydebug is used.

Because of AC_PROG_CC, Python is compiled with -O2 even if --with-pydebug is used, which is bad because it's harder to debug an optimized program: most variable are unavailable (gcc prints "<optimized out>").

Another problem is that AC_PROG_CC eats user CFLAGS. It's not possible to specify: ./configure CFLAGS="myflags".

On the autoconf mailing list, I saw a simple "trick": 

   Save CFLAGS before you call AC_PROG_CC, and restore it after, 
   if you don't want "-g -O2".

Attached patch implements that. Results:
 * ./configure: CFLAGS=$(BASECFLAGS) $(OPT) $(EXTRA_CFLAGS)
 * ./configure --with-pdebug CFLAGS="-O0": CFLAGS=$(BASECFLAGS) -O0 $(OPT) $(EXTRA_CFLAGS)

It works :-)
History
Date User Action Args
2010-03-23 12:14:08vstinnersetrecipients: + vstinner
2010-03-23 12:14:07vstinnersetmessageid: <1269346447.99.0.323336928566.issue8211@psf.upfronthosting.co.za>
2010-03-23 12:14:06vstinnerlinkissue8211 messages
2010-03-23 12:14:05vstinnercreate