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.

classification
Title: --with-pydebug builds now include -O2 by default
Type: behavior Stage:
Components: Build Versions: Python 3.2, Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: mark.dickinson Nosy List: Arfrever, lemburg, mark.dickinson, pitrou, vstinner
Priority: normal Keywords: patch

Created on 2010-05-05 14:03 by mark.dickinson, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
no_debug_optimization.patch mark.dickinson, 2010-05-05 14:03
Messages (6)
msg105035 - (view) Author: Mark Dickinson (mark.dickinson) * (Python committer) Date: 2010-05-05 14:03
When doing a debug build of Python with gcc, without any previous setting of CFLAGS, the '-O2' flag is now automatically included.

This behaviour started in r79218.

It would be nice to restore the original behaviour, if possible, since the optimization causes difficulties when debugging.  One solution would be to add '-O0' to OPT for debug builds (on gcc), as in the attached patch.  You then get compiler flags including:

"-g -O2 -g -O0"

which is somewhat ugly, but the -O0 overrides the -O2 (I think).  Does this seem like a reasonable solution?
msg105037 - (view) Author: Mark Dickinson (mark.dickinson) * (Python committer) Date: 2010-05-05 14:08
Just double checked the gcc manual.  From:

http://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html

"""If you use multiple -O options, with or without level numbers, the last such option is the one that is effective."""
msg105038 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2010-05-05 14:10
> It would be nice to restore the original behaviour, if possible, since
> the optimization causes difficulties when debugging.  One solution
> would be to add '-O0' to OPT for debug builds (on gcc), as in the
> attached patch.  You then get compiler flags including:
> 
> "-g -O2 -g -O0"
> 
> which is somewhat ugly, but the -O0 overrides the -O2 (I think).  Does
> this seem like a reasonable solution?

Probably good enough.
msg105049 - (view) Author: Marc-Andre Lemburg (lemburg) * (Python committer) Date: 2010-05-05 15:27
Antoine Pitrou wrote:
> 
> Antoine Pitrou <pitrou@free.fr> added the comment:
> 
>> It would be nice to restore the original behaviour, if possible, since
>> the optimization causes difficulties when debugging.  One solution
>> would be to add '-O0' to OPT for debug builds (on gcc), as in the
>> attached patch.  You then get compiler flags including:
>>
>> "-g -O2 -g -O0"
>>
>> which is somewhat ugly, but the -O0 overrides the -O2 (I think).  Does
>> this seem like a reasonable solution?
> 
> Probably good enough.

+1

OPT can also be overridden by the user, to e.g. actually get an
optimized debug build in order to debug compiler optimization
problems.
msg105103 - (view) Author: Mark Dickinson (mark.dickinson) * (Python committer) Date: 2010-05-05 22:33
Applied in r80832 (trunk), r80834 (py3k).  Thanks, all.
msg105114 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2010-05-06 00:31
Thanks!
History
Date User Action Args
2022-04-11 14:57:00adminsetgithub: 52871
2010-05-06 00:31:46vstinnersetmessages: + msg105114
2010-05-05 22:33:53mark.dickinsonsetstatus: open -> closed
assignee: mark.dickinson
resolution: fixed
messages: + msg105103
2010-05-05 15:27:23lemburgsetmessages: + msg105049
2010-05-05 15:21:55Arfreversetnosy: + Arfrever
2010-05-05 14:10:58pitrousetmessages: + msg105038
2010-05-05 14:08:30mark.dickinsonsetmessages: + msg105037
2010-05-05 14:03:48mark.dickinsoncreate