Intel® Fortran Compiler 16.0 User and Reference Guide

Debugging and Optimizations

This topic describes the relationship between various command-line options that control debugging and optimizing.

Whenever you enable debugging with the -g option (Linux* OS and OS X*) or /debug:full option (Windows* OS) , you disable optimizations. You can override this behavior by explicitly specifying compiler options for optimizations on the command line.

The following summarizes commonly used options for debugging and for optimization.

-O0 (Linux* OS and OS X*)

/Od (Windows* OS)

Disables optimizations so you can debug your program before any optimization is attempted. This is the default behavior when debugging.

Note

On Linux* OS and OS X*, -fno-omit-frame-pointer is set if either option -O0 or -g is specified.

For more information, see the following topics:

  • -O0 (Linux* OS and OS X*) compiler option
  • /Od (Windows* OS) compiler option

O1, O2, or O3 (Linux* OS and OS X*)

O (Windows* OS)

Specifies the code optimization level for applications. If you use any of these options, it is recommended that you use -debug extended when debugging.

For more information, see the following topics:

  • -O1, -O2, -O3 (Linux* OS and OS X*) compiler options

  • /O (Windows* OS) compiler option

-g (Linux* OS and OS X*)

/debug:full (Windows* OS)

Generates symbolic debugging information and line numbers in the object code for use by the source-level debuggers. Turns off O2 and makes -O0 (Linux* OS and OS X*) or /Od (Windows* OS) the default. The exception to this is if options O1, O2, or O3 are explicitly specified in the command line.

For more information, see the following topics:

  • -g (Linux* OS and OS X*)
  • /debug:full (Windows* OS) compiler option

-debug extended (Linux* OS and OS X*)

Specifies settings that enhance debugging.

For more information, see the following topic:

  • -debug extended (Linux* OS and OS X*)

-fp (Linux* OS and OS X*)

/Oy (Windows* OS)

(IA-32 architecture only)

Disables the ebp register in optimizations and sets the ebp register to be used as the frame pointer.

For more information, see the following compiler option topics:

  • -fp (Linux* OS and OS X*)
  • /Oy (Windows* OS)

Traceback

Causes the compiler to generate extra information in the object file, which allows a symbolic stack traceback.

For more information, see the following topic:

  • Traceback compiler option

Combining Optimization and Debugging

The compiler lets you generate code to support symbolic debugging when O1, O2, or O3 optimization options are specified on the command line along with -g (Linux* OS and OS X*) or /debug:full (Windows* OS); this produces symbolic debug information in the object file.

Note

Note that if you specify an O1, O2, or O3 option with the -g (Linux* OS and OS X*) or /debug:full (Windows* OS) option, some of the debugging information returned may be inaccurate as a side-effect of optimization.

To counter this on Linux* OS and OS X*, you should also specify the -debug extended option.

It is best to make your optimization and/or debugging choices explicit:

Note

When no optimization level is specified, the -g or /debug:full option slows program execution; this is because this option turns on -O0 or /Od, which causes the slowdown. However, if both O2 and -g (Linux* OS and OS X*) or /debug:full (Windows* OS) are specified, for example, the code should not experience much of a slowdown.

Refer to the table below for the summary of the effects of using the -g or /debug:full option with the optimization options.

These options

Produce these results

-g (Linux* OS and OS X*)

/debug:full (Windows* OS)

Debugging information produced, -O0 (Linux* OS and OS X*) or /Od (Windows* OS) enabled (meaning optimizations are disabled).

For Linux* OS and OS X*, -fp is also enabled for compilations targeted for IA-32 architecture.

-g -O1 (Linux* OS and OS X*)

/debug:full /O1 (Windows* OS)

Debugging information produced, O1 optimizations enabled.

-g -O2 (Linux* OS and OS X*)

/debug:full /O2 (Windows* OS)

Debugging information produced, O2 optimizations enabled.

-g -O2 (Linux* OS and OS X*)

/debug:full /O2 /Oy- (Windows* OS)

Debugging information produced, O2 optimizations enabled. For Windows* OS using IA-32 architecture, /Oy disabled.

-g -O3 -fp (Linux* OS and OS X*)

/debug:full /O3 (Windows* OS)

Debugging information produced, O3 optimizations enabled. For Linux* OS, -fp enabled for compilations targeted for IA-32 architecture.

Note

Even the use of option debug extended with optimized programs may not allow you to examine all variables or to set breaks at all lines, due to code movement or removal during the optimization process.