Opened 15 years ago

Closed 15 years ago

#477 closed discussion (wontfix)

compiler do optimize in --enable-debug mode

Reported by: Peter Owned by: Jari Häkkinen
Priority: trivial Milestone:
Component: build Version: trunk
Keywords: Cc:

Description

If --enable-debug is given to ./configure we will set AM_CXXFLAGS = -O, which is equivalent with -O1.

Is this really the intention? I though we wanted no optimizations in --enable-debug mode. No optimization is performed if we pass -O0 (which is default so it could be omitted).

http://www.redhat.com/docs/manuals/enterprise/RHEL-3-Manual/gcc/optimize-options.html

Change History (2)

comment:1 Changed 15 years ago by Jari Häkkinen

Usually one sees -g -O at the same time, at least with gnu compilers. I suppose it is safe with GCC. From man gcc and man g++:

GCC allows you to use -g with -O. The shortcuts taken by optimized code may occasionally
produce surprising results: some variables you declared may not exist at all; flow of control
may briefly move where you did not expect it; some statements may not be executed because they
compute constant results or their values were already at hand; some statements may execute in
different places because they were moved out of loops.

Nevertheless it proves possible to debug optimized output. This makes it reasonable to use
the optimizer for programs that might have bugs.

I think we should leave it as it is.

comment:2 Changed 15 years ago by Peter

Milestone: yat 0.5
Resolution: wontfix
Status: newclosed

OK. Only reason not to optimize would be speed (when developing compilation is performed more than once), but I don't know how much we are talking about. OTOH, I guess the compiler need to optimize to find, for example, variables not used and warn about it.

Note: See TracTickets for help on using tickets.