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?
> 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.
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.