Microchip Technology SW006023-1N Data Sheet

Page of 238
MPLAB
®
 XC32 C/C++ Compiler User’s Guide
DS51686E-page 72
 2012 Microchip Technology Inc.
3.9.6
Options for Debugging
The following options are used for debugging.
3.9.7
Options for Controlling Optimization
The following options control compiler optimizations.
TABLE 3-10:
DEBUGGING OPTIONS
Option
Definition
-g
Produce debugging information.
The compiler supports the use of -g with -O making it possible to 
debug optimized code. The shortcuts taken by optimized code may 
occasionally produce surprising results:
• Some declared variables may not exist at all
• Flow of control may briefly move unexpectedly
• 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. 
-Q
Makes the compiler print out each function name as it is compiled, and 
print some statistics about each pass when it finishes.
-save-temps
-save-temps=cwd
Don’t delete intermediate files. Place them in the current directory and 
name them based on the source file. Thus, compiling foo.c with -c 
-save-temps
 would produce the following files:
foo.i
(preprocessed file)
foo.s
(assembly language file)
foo.o
(object file)
-save-temps=obj
Similar to -save-temps=cwd, but if the -o option is specified, the 
temporary files are based on the object file. If the -o option is not 
specified, the -save-temps=obj switch behaves like –save-temps.
For example:
 xc32-gcc -save-temps=obj -c foo.c
 xc32-gcc -save-temps=obj -c bar.c -o dir/xbar.o
 xc32-gcc -save-temps=obj foobar.c -o dir2/yfoobar
would create
 foo.i, foo.s, dir/xbar.i, dir/xbar.s, 
dir2/yfoobar.i
, dir2/yfoobar.s, and dir2/yfoobar.o.
TABLE 3-11:
GENERAL OPTIMIZATION OPTIONS
Option
Definition
-O0
Do not optimize. (This is the default.)
Without -O, the compiler’s goal is to reduce the cost of compilation and to make 
debugging produce the expected results. Statements are independent: if you stop 
the program with a breakpoint between statements, you can then assign a new 
value to any variable or change the program counter to any other statement in 
the function and get exactly the results you would expect from the source code.
The compiler only allocates variables declared register in registers.
-O
-O1
Optimization level 1. Optimizing compilation takes somewhat longer, and a lot 
more host memory for a large function. 
With -O, the compiler tries to reduce code size and execution time.
When -O is specified, the compiler turns on -fthread-jumps and
-fdefer-pop
. The compiler turns on
 
-fomit-frame-pointer
.