This section describes command-line options that are primarily of interest to GCC developers, including options to support compiler testing and investigation of compiler bugs and compile-time performance problems. This includes options that produce debug dumps at various points in the compilation; that print statistics such as memory use and execution time; and that print information about GCC's configuration, such as where it searches for libraries. You should rarely need to use any of these options for ordinary compilation and linking tasks.
-d
letters-fdump-rtl-
pass-fdump-rtl-
pass=
filename
-E
is used for preprocessing. Debug dumps can be enabled with a -fdump-rtl
switch or some -d
option letters. Here are the possible letters for use in pass and letters, and their meanings:
-fdump-rtl-alignments
-fdump-rtl-asmcons
-fdump-rtl-auto_inc_dec
-fdump-rtl-barriers
-fdump-rtl-bbpart
-fdump-rtl-bbro
-fdump-rtl-btl1
-fdump-rtl-btl2
-fdump-rtl-btl1
and -fdump-rtl-btl2
enable dumping after the two branch target load optimization passes. -fdump-rtl-bypass
-fdump-rtl-combine
-fdump-rtl-compgotos
-fdump-rtl-ce1
-fdump-rtl-ce2
-fdump-rtl-ce3
-fdump-rtl-ce1
, -fdump-rtl-ce2
, and -fdump-rtl-ce3
enable dumping after the three if conversion passes. -fdump-rtl-cprop_hardreg
-fdump-rtl-csa
-fdump-rtl-cse1
-fdump-rtl-cse2
-fdump-rtl-cse1
and -fdump-rtl-cse2
enable dumping after the two common subexpression elimination passes. -fdump-rtl-dce
-fdump-rtl-dbr
-fdump-rtl-dce1
-fdump-rtl-dce2
-fdump-rtl-dce1
and -fdump-rtl-dce2
enable dumping after the two dead store elimination passes. -fdump-rtl-eh
-fdump-rtl-eh_ranges
-fdump-rtl-expand
-fdump-rtl-fwprop1
-fdump-rtl-fwprop2
-fdump-rtl-fwprop1
and -fdump-rtl-fwprop2
enable dumping after the two forward propagation passes. -fdump-rtl-gcse1
-fdump-rtl-gcse2
-fdump-rtl-gcse1
and -fdump-rtl-gcse2
enable dumping after global common subexpression elimination. -fdump-rtl-init-regs
-fdump-rtl-initvals
-fdump-rtl-into_cfglayout
-fdump-rtl-ira
-fdump-rtl-jump
-fdump-rtl-loop2
-fdump-rtl-loop2
enables dumping after the rtl loop optimization passes. -fdump-rtl-mach
-fdump-rtl-mode_sw
-fdump-rtl-rnreg
-fdump-rtl-outof_cfglayout
-fdump-rtl-peephole2
-fdump-rtl-postreload
-fdump-rtl-pro_and_epilogue
-fdump-rtl-sched1
-fdump-rtl-sched2
-fdump-rtl-sched1
and -fdump-rtl-sched2
enable dumping after the basic block scheduling passes. -fdump-rtl-ree
-fdump-rtl-seqabstr
-fdump-rtl-shorten
-fdump-rtl-sibling
-fdump-rtl-split1
-fdump-rtl-split2
-fdump-rtl-split3
-fdump-rtl-split4
-fdump-rtl-split5
-fdump-rtl-sms
-fdump-rtl-stack
-fdump-rtl-subreg1
-fdump-rtl-subreg2
-fdump-rtl-subreg1
and -fdump-rtl-subreg2
enable dumping after the two subreg expansion passes. -fdump-rtl-unshare
-fdump-rtl-vartrack
-fdump-rtl-vregs
-fdump-rtl-web
-fdump-rtl-regclass
-fdump-rtl-subregs_of_mode_init
-fdump-rtl-subregs_of_mode_finish
-fdump-rtl-dfinit
-fdump-rtl-dfinish
-da
-fdump-rtl-all
-dA
-dD
-dH
-dp
-dP
-dp
annotation. -dx
-fdump-rtl-expand
. -fdump-noaddr
-freport-bug
-fdump-unnumbered
-g
. -fdump-unnumbered-links
-d
option above), suppress instruction numbers for the links to the previous and next instructions in a sequence. -fdump-translation-unit
(C++ only)-fdump-translation-unit-
options (C++ only)
.tu
to the source file name, and the file is created in the same directory as the output file. If the ‘-options’ form is used, options controls the details of the dump as described for the -fdump-tree
options. -fdump-class-hierarchy
(C++ only)-fdump-class-hierarchy-
options (C++ only)
.class
to the source file name, and the file is created in the same directory as the output file. If the ‘-options’ form is used, options controls the details of the dump as described for the -fdump-tree
options. -fdump-ipa-
switch
all
’cgraph
’inline
’-fdump-passes
-fdump-statistics-
option
.statistics
’ to the source file name, and the file is created in the same directory as the output file. If the ‘-option’ form is used, ‘-stats
’ causes counters to be summed over the whole compilation unit while ‘-details
’ dumps every event as the passes generate them. The default with no option is to sum counters for each function compiled. -fdump-tree-
switch-fdump-tree-
switch-
options-fdump-tree-
switch-
options=
filename
-
’ separated options which control the details of the dump. Not all options are applicable to all dumps; those that are not meaningful are ignored. The following options are available address
’asmname
’DECL_ASSEMBLER_NAME
has been set for a given decl, use that in the dump instead of DECL_NAME
. Its primary use is ease of use working backward from mangled names in the assembly file. slim
’When dumping pretty-printed trees, this option inhibits dumping the bodies of control structures.
When dumping RTL, print the RTL in slim (condensed) form instead of the default LISP-like representation.
raw
’details
’stats
’blocks
’graph
’This option currently only works for RTL dumps, and the RTL is always dumped in slim form.
vops
’lineno
’uid
’DECL_UID
) for each variable. verbose
’eh
’scev
’optimized
’missed
’note
’stdout
and stderr
are treated specially and are considered already open standard streams. For example, gcc -O2 -ftree-vectorize -fdump-tree-vect-blocks=foo.dump -fdump-tree-pre=stderr file.c
outputs vectorizer dump into foo.dump
, while the PRE dump is output on to stderr
. If two conflicting dump filenames are given for the same pass, then the latter option overrides the earlier one.
split-paths
’.split-paths
to the source file name. all
’raw
, slim
, verbose
and lineno
. optall
’optimized
, missed
, and note
. The following tree dumps are possible:
original
’optimized
’gimple
’.gimple
to the source file name. cfg
’.cfg
to the source file name. ch
’.ch
to the source file name. ssa
’.ssa
to the source file name. alias
’.alias
to the source file name. ccp
’.ccp
to the source file name. storeccp
’.storeccp
to the source file name. pre
’.pre
to the source file name. fre
’.fre
to the source file name. copyprop
’.copyprop
to the source file name. store_copyprop
’.store_copyprop
to the source file name. dce
’.dce
to the source file name. sra
’.sra
to the source file name. sink
’.sink
to the source file name. dom
’.dom
to the source file name. dse
’.dse
to the source file name. phiopt
’.phiopt
to the source file name. backprop
’.backprop
to the source file name. forwprop
’.forwprop
to the source file name. nrv
’.nrv
to the source file name. vect
’.vect
to the source file name. slp
’.slp
to the source file name. vrp
’.vrp
to the source file name. oaccdevlow
’.oaccdevlow
to the source file name. all
’-fopt-info
-fopt-info-
options-fopt-info-
options=
filename
-
’ separated option keywords to select the dump details and optimizations. The options can be divided into two groups: options describing the verbosity of the dump, and options describing which optimizations should be included. The options from both the groups can be freely mixed as they are non-overlapping. However, in case of any conflicts, the later options override the earlier options on the command line.
The following options control the dump verbosity:
optimized
’missed
’note
’all
’optimized
’, ‘missed
’, and ‘note
’. One or more of the following option keywords can be used to describe a group of optimizations:
ipa
’loop
’inline
’vec
’optall
’If options is omitted, it defaults to ‘optimized-optall
’, which means to dump all info about successful optimizations from all the passes.
If the filename is provided, then the dumps from all the applicable optimizations are concatenated into the filename. Otherwise the dump is output onto stderr
. Though multiple -fopt-info
options are accepted, only one of them can include a filename. If other filenames are provided then all but the first such option are ignored.
Note that the output filename is overwritten in case of multiple translation units. If a combined output from multiple translation units is desired, stderr
should be used instead.
In the following example, the optimization info is output to stderr
:
gcc -O3 -fopt-info
This example:
gcc -O3 -fopt-info-missed=missed.all
outputs missed optimization report from all the passes into missed.all
, and this one:
gcc -O2 -ftree-vectorize -fopt-info-vec-missed
prints information about missed optimization opportunities from vectorization passes on stderr
. Note that -fopt-info-vec-missed
is equivalent to -fopt-info-missed-vec
.
As another example,
gcc -O3 -fopt-info-inline-optimized-missed=inline.txt
outputs information about missed optimizations as well as optimized locations from all the inlining passes into inline.txt
.
Finally, consider:
gcc -fopt-info-vec-missed=vec.miss -fopt-info-loop-optimized=loop.opt
Here the two output filenames vec.miss
and loop.opt
are in conflict since only one output file is allowed. In this case, only the first option takes effect and the subsequent options are ignored. Thus only vec.miss
is produced which contains dumps from the vectorizer about missed opportunities.
-fsched-verbose=
n
For n greater than zero, -fsched-verbose
outputs the same information as -fdump-rtl-sched1
and -fdump-rtl-sched2
. For n greater than one, it also output basic block probabilities, detailed ready list information and unit/insn info. For n greater than two, it includes RTL at abort point, control-flow and regions info. And for n over four, -fsched-verbose
also includes dependence info.
-fenable-
kind-
pass-fdisable-
kind-
pass=
range-list
-fdisable-ipa-
pass
-fdisable-rtl-
pass-fdisable-rtl-
pass=
range-list
-fdump-passes
. -fdisable-tree-
pass-fdisable-tree-
pass=
range-list
-fdisable-rtl
for the description of option arguments. -fenable-ipa-
pass
-fenable-rtl-
pass-fenable-rtl-
pass=
range-list
-fdisable-rtl
for option argument description and examples. -fenable-tree-
pass-fenable-tree-
pass=
range-list
-fdisable-rtl
for the description of option arguments. Here are some examples showing uses of these options.
# disable ccp1 for all functions -fdisable-tree-ccp1 # disable complete unroll for function whose cgraph node uid is 1 -fenable-tree-cunroll=1 # disable gcse2 for functions at the following ranges [1,1], # [300,400], and [400,1000] # disable gcse2 for functions foo and foo2 -fdisable-rtl-gcse2=foo,foo2 # disable early inlining -fdisable-tree-einline # disable ipa inlining -fdisable-ipa-inline # enable tree full unroll -fenable-tree-unroll
-fchecking
-frandom-seed=
string
-frandom-seed
option to produce reproducibly identical object files. The string can either be a number (decimal, octal or hex) or an arbitrary string (in which case it's converted to a number by computing CRC32).
The string should be different for every file you compile.
-save-temps
-save-temps=cwd
foo.c
with -c -save-temps
produces files foo.i
and foo.s
, as well as foo.o
. This creates a preprocessed foo.i
output file even though the compiler now normally uses an integrated preprocessor. When used in combination with the -x
command-line option, -save-temps
is sensible enough to avoid over writing an input source file with the same extension as an intermediate file. The corresponding intermediate file may be obtained by renaming the source file before using -save-temps
.
If you invoke GCC in parallel, compiling several different source files that share a common base name in different subdirectories or the same source file compiled for multiple output destinations, it is likely that the different parallel compilers will interfere with each other, and overwrite the temporary files. For instance:
gcc -save-temps -o outdir1/foo.o indir1/foo.c& gcc -save-temps -o outdir2/foo.o indir2/foo.c&
may result in foo.i
and foo.o
being written to simultaneously by both compilers.
-save-temps=obj
-o
option is used, the temporary files are based on the object file. If the -o
option is not used, the -save-temps=obj
switch behaves like -save-temps
. For example:
gcc -save-temps=obj -c foo.c gcc -save-temps=obj -c bar.c -o dir/xbar.o gcc -save-temps=obj foobar.c -o dir2/yfoobar
creates foo.i
, foo.s
, dir/xbar.i
, dir/xbar.s
, dir2/yfoobar.i
, dir2/yfoobar.s
, and dir2/yfoobar.o
.
-time
[=
file]
Without the specification of an output file, the output looks like this:
# cc1 0.12 0.01 # as 0.00 0.01
The first number on each line is the “user time”, that is time spent executing the program itself. The second number is “system time”, time spent executing operating system routines on behalf of the program. Both numbers are in seconds.
With the specification of an output file, the output is appended to the named file, and it looks like this:
0.12 0.01 cc1 options 0.00 0.01 as options
The “user time” and the “system time” are moved before the program name, and the options passed to the program are displayed, so that one can later tell what file was being compiled, and with which options.
-fdump-final-insns
[=
file]
.
), the name of the dump file is determined by appending .gkd
to the compilation output file name. -fcompare-debug
[=
opts]
-fcompare-debug-second
to the arguments passed to the second compilation. Dump the final internal representation in both compilations, and print an error if they differ. If the equal sign is omitted, the default -gtoggle
is used.
The environment variable GCC_COMPARE_DEBUG
, if defined, non-empty and nonzero, implicitly enables -fcompare-debug
. If GCC_COMPARE_DEBUG
is defined to a string starting with a dash, then it is used for opts, otherwise the default -gtoggle
is used.
-fcompare-debug=
, with the equal sign but without opts, is equivalent to -fno-compare-debug
, which disables the dumping of the final representation and the second compilation, preventing even GCC_COMPARE_DEBUG
from taking effect.
To verify full coverage during -fcompare-debug
testing, set GCC_COMPARE_DEBUG
to say -fcompare-debug-not-overridden
, which GCC rejects as an invalid option in any actual compilation (rather than preprocessing, assembly or linking). To get just a warning, setting GCC_COMPARE_DEBUG
to ‘-w%n-fcompare-debug not overridden
’ will do.
-fcompare-debug-second
-fcompare-debug
, along with options to silence warnings, and omitting other options that would cause side-effect compiler outputs to files or to the standard output. Dump files and preserved temporary files are renamed so as to contain the .gk
additional extension during the second compilation, to avoid overwriting those generated by the first. When this option is passed to the compiler driver, it causes the first compilation to be skipped, which makes it useful for little other than debugging the compiler proper.
-gtoggle
-fcompare-debug
. -fvar-tracking-assignments-toggle
-fvar-tracking-assignments
, in the same way that -gtoggle
toggles -g
. -Q
-ftime-report
-fira-verbose=
n
-flto-report
-flto
). Disabled by default.
-flto-report-wpa
-flto-report
, but only print for the WPA phase of Link Time Optimization. -fmem-report
-fmem-report-wpa
-fpre-ipa-mem-report
-fpost-ipa-mem-report
-fprofile-report
-fstack-usage
.su
to the auxname. auxname is generated from the name of the output file, if explicitly specified and it is not an executable, otherwise it is the basename of the source file. An entry is made up of three fields: static
, dynamic
, bounded
. The qualifier static
means that the function manipulates the stack statically: a fixed number of bytes are allocated for the frame on function entry and released on function exit; no stack adjustments are otherwise made in the function. The second field is this fixed number of bytes.
The qualifier dynamic
means that the function manipulates the stack dynamically: in addition to the static allocation described above, stack adjustments are made in the body of the function, for example to push/pop arguments around function calls. If the qualifier bounded
is also present, the amount of these adjustments is bounded at compile time and the second field is an upper bound of the total amount of stack used by the function. If it is not present, the amount of these adjustments is not bounded at compile time and the second field only represents the bounded part.
-fstats
-fdbg-cnt-list
-fdbg-cnt=
counter-value-list
UINT_MAX
; thus dbg_cnt
returns true always unless the upper bound is set by this option. For example, with -fdbg-cnt=dce:10,tail_call:0
, dbg_cnt(dce)
returns true only for first 10 invocations. -print-file-name=
library
-print-multi-directory
GCC_EXEC_PREFIX
. -print-multi-lib
;
’, and each switch starts with an ‘@
’ instead of the ‘-
’, without spaces between multiple switches. This is supposed to ease shell processing. -print-multi-os-directory
lib
subdirectory. If OS libraries are present in the lib
subdirectory and no multilibs are used, this is usually just .
, if OS libraries are present in libsuffix sibling directories this prints e.g. ../lib64
, ../lib
or ../lib32
, or if OS libraries are present in lib/subdir subdirectories it prints e.g. amd64
, sparcv9
or ev6
. -print-multiarch
lib
subdirectory. -print-prog-name=
program
-print-file-name
, but searches for a program such as cpp
. -print-libgcc-file-name
-print-file-name=libgcc.a
. This is useful when you use -nostdlib
or -nodefaultlibs
but you do want to link with libgcc.a
. You can do:
gcc -nostdlib files... `gcc -print-libgcc-file-name`
-print-search-dirs
gcc
searches—and don't do anything else. This is useful when gcc
prints the error message ‘installation problem, cannot exec cpp0: No such file or directory
’. To resolve this you either need to put cpp0
and the other compiler components where gcc
expects to find them, or you can set the environment variable GCC_EXEC_PREFIX
to the directory where you installed them. Don't forget the trailing ‘/
’. See Environment Variables.
-print-sysroot
--sysroot
option, possibly with an extra suffix that depends on compilation options. If no target sysroot is specified, the option prints nothing. -print-sysroot-headers-suffix
-dumpmachine
i686-pc-linux-gnu
’)—and don't do anything else. -dumpversion
3.0
)—and don't do anything else. -dumpspecs
© Free Software Foundation
Licensed under the GNU Free Documentation License, Version 1.3.
https://gcc.gnu.org/onlinedocs/gcc-6.3.0/gcc/Developer-Options.html