| <html lang="en"> |
| <head> |
| <title>Debugging Options - Using the GNU Compiler Collection (GCC)</title> |
| <meta http-equiv="Content-Type" content="text/html"> |
| <meta name="description" content="Using the GNU Compiler Collection (GCC)"> |
| <meta name="generator" content="makeinfo 4.13"> |
| <link title="Top" rel="start" href="index.html#Top"> |
| <link rel="up" href="Invoking-GCC.html#Invoking-GCC" title="Invoking GCC"> |
| <link rel="prev" href="Warning-Options.html#Warning-Options" title="Warning Options"> |
| <link rel="next" href="Optimize-Options.html#Optimize-Options" title="Optimize Options"> |
| <link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage"> |
| <!-- |
| Copyright (C) 1988-2013 Free Software Foundation, Inc. |
| |
| Permission is granted to copy, distribute and/or modify this document |
| under the terms of the GNU Free Documentation License, Version 1.3 or |
| any later version published by the Free Software Foundation; with the |
| Invariant Sections being ``Funding Free Software'', the Front-Cover |
| Texts being (a) (see below), and with the Back-Cover Texts being (b) |
| (see below). A copy of the license is included in the section entitled |
| ``GNU Free Documentation License''. |
| |
| (a) The FSF's Front-Cover Text is: |
| |
| A GNU Manual |
| |
| (b) The FSF's Back-Cover Text is: |
| |
| You have freedom to copy and modify this GNU Manual, like GNU |
| software. Copies published by the Free Software Foundation raise |
| funds for GNU development.--> |
| <meta http-equiv="Content-Style-Type" content="text/css"> |
| <style type="text/css"><!-- |
| pre.display { font-family:inherit } |
| pre.format { font-family:inherit } |
| pre.smalldisplay { font-family:inherit; font-size:smaller } |
| pre.smallformat { font-family:inherit; font-size:smaller } |
| pre.smallexample { font-size:smaller } |
| pre.smalllisp { font-size:smaller } |
| span.sc { font-variant:small-caps } |
| span.roman { font-family:serif; font-weight:normal; } |
| span.sansserif { font-family:sans-serif; font-weight:normal; } |
| --></style> |
| </head> |
| <body> |
| <div class="node"> |
| <a name="Debugging-Options"></a> |
| <p> |
| Next: <a rel="next" accesskey="n" href="Optimize-Options.html#Optimize-Options">Optimize Options</a>, |
| Previous: <a rel="previous" accesskey="p" href="Warning-Options.html#Warning-Options">Warning Options</a>, |
| Up: <a rel="up" accesskey="u" href="Invoking-GCC.html#Invoking-GCC">Invoking GCC</a> |
| <hr> |
| </div> |
| |
| <h3 class="section">3.9 Options for Debugging Your Program or GCC</h3> |
| |
| <p><a name="index-options_002c-debugging-538"></a><a name="index-debugging-information-options-539"></a> |
| GCC has various special options that are used for debugging |
| either your program or GCC: |
| |
| <dl> |
| <dt><code>-g</code><dd><a name="index-g-540"></a>Produce debugging information in the operating system's native format |
| (stabs, COFF, XCOFF, or DWARF 2). GDB can work with this debugging |
| information. |
| |
| <p>On most systems that use stabs format, <samp><span class="option">-g</span></samp> enables use of extra |
| debugging information that only GDB can use; this extra information |
| makes debugging work better in GDB but probably makes other debuggers |
| crash or |
| refuse to read the program. If you want to control for certain whether |
| to generate the extra information, use <samp><span class="option">-gstabs+</span></samp>, <samp><span class="option">-gstabs</span></samp>, |
| <samp><span class="option">-gxcoff+</span></samp>, <samp><span class="option">-gxcoff</span></samp>, or <samp><span class="option">-gvms</span></samp> (see below). |
| |
| <p>GCC allows you to use <samp><span class="option">-g</span></samp> with |
| <samp><span class="option">-O</span></samp>. 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 are already at hand; some statements may |
| execute in different places because they have been moved out of loops. |
| |
| <p>Nevertheless it proves possible to debug optimized output. This makes |
| it reasonable to use the optimizer for programs that might have bugs. |
| |
| <p>The following options are useful when GCC is generated with the |
| capability for more than one debugging format. |
| |
| <br><dt><code>-gsplit-dwarf</code><dd><a name="index-gsplit_002ddwarf-541"></a>Separate as much dwarf debugging information as possible into a |
| separate output file with the extension .dwo. This option allows |
| the build system to avoid linking files with debug information. To |
| be useful, this option requires a debugger capable of reading .dwo |
| files. |
| |
| <br><dt><code>-ggdb</code><dd><a name="index-ggdb-542"></a>Produce debugging information for use by GDB. This means to use the |
| most expressive format available (DWARF 2, stabs, or the native format |
| if neither of those are supported), including GDB extensions if at all |
| possible. |
| |
| <br><dt><code>-gpubnames</code><dd><a name="index-gpubnames-543"></a>Generate dwarf .debug_pubnames and .debug_pubtypes sections. |
| |
| <br><dt><code>-gstabs</code><dd><a name="index-gstabs-544"></a>Produce debugging information in stabs format (if that is supported), |
| without GDB extensions. This is the format used by DBX on most BSD |
| systems. On MIPS, Alpha and System V Release 4 systems this option |
| produces stabs debugging output that is not understood by DBX or SDB. |
| On System V Release 4 systems this option requires the GNU assembler. |
| |
| <br><dt><code>-feliminate-unused-debug-symbols</code><dd><a name="index-feliminate_002dunused_002ddebug_002dsymbols-545"></a>Produce debugging information in stabs format (if that is supported), |
| for only symbols that are actually used. |
| |
| <br><dt><code>-femit-class-debug-always</code><dd>Instead of emitting debugging information for a C++ class in only one |
| object file, emit it in all object files using the class. This option |
| should be used only with debuggers that are unable to handle the way GCC |
| normally emits debugging information for classes because using this |
| option increases the size of debugging information by as much as a |
| factor of two. |
| |
| <br><dt><code>-fdebug-types-section</code><dd><a name="index-fdebug_002dtypes_002dsection-546"></a><a name="index-fno_002ddebug_002dtypes_002dsection-547"></a>When using DWARF Version 4 or higher, type DIEs can be put into |
| their own <code>.debug_types</code> section instead of making them part of the |
| <code>.debug_info</code> section. It is more efficient to put them in a separate |
| comdat sections since the linker can then remove duplicates. |
| But not all DWARF consumers support <code>.debug_types</code> sections yet |
| and on some objects <code>.debug_types</code> produces larger instead of smaller |
| debugging information. |
| |
| <br><dt><code>-gstabs+</code><dd><a name="index-gstabs_002b-548"></a>Produce debugging information in stabs format (if that is supported), |
| using GNU extensions understood only by the GNU debugger (GDB). The |
| use of these extensions is likely to make other debuggers crash or |
| refuse to read the program. |
| |
| <br><dt><code>-gcoff</code><dd><a name="index-gcoff-549"></a>Produce debugging information in COFF format (if that is supported). |
| This is the format used by SDB on most System V systems prior to |
| System V Release 4. |
| |
| <br><dt><code>-gxcoff</code><dd><a name="index-gxcoff-550"></a>Produce debugging information in XCOFF format (if that is supported). |
| This is the format used by the DBX debugger on IBM RS/6000 systems. |
| |
| <br><dt><code>-gxcoff+</code><dd><a name="index-gxcoff_002b-551"></a>Produce debugging information in XCOFF format (if that is supported), |
| using GNU extensions understood only by the GNU debugger (GDB). The |
| use of these extensions is likely to make other debuggers crash or |
| refuse to read the program, and may cause assemblers other than the GNU |
| assembler (GAS) to fail with an error. |
| |
| <br><dt><code>-gdwarf-</code><var>version</var><dd><a name="index-gdwarf_002d_0040var_007bversion_007d-552"></a>Produce debugging information in DWARF format (if that is supported). |
| The value of <var>version</var> may be either 2, 3 or 4; the default version |
| for most targets is 4. |
| |
| <p>Note that with DWARF Version 2, some ports require and always |
| use some non-conflicting DWARF 3 extensions in the unwind tables. |
| |
| <p>Version 4 may require GDB 7.0 and <samp><span class="option">-fvar-tracking-assignments</span></samp> |
| for maximum benefit. |
| |
| <br><dt><code>-grecord-gcc-switches</code><dd><a name="index-grecord_002dgcc_002dswitches-553"></a>This switch causes the command-line options used to invoke the |
| compiler that may affect code generation to be appended to the |
| DW_AT_producer attribute in DWARF debugging information. The options |
| are concatenated with spaces separating them from each other and from |
| the compiler version. See also <samp><span class="option">-frecord-gcc-switches</span></samp> for another |
| way of storing compiler options into the object file. This is the default. |
| |
| <br><dt><code>-gno-record-gcc-switches</code><dd><a name="index-gno_002drecord_002dgcc_002dswitches-554"></a>Disallow appending command-line options to the DW_AT_producer attribute |
| in DWARF debugging information. |
| |
| <br><dt><code>-gstrict-dwarf</code><dd><a name="index-gstrict_002ddwarf-555"></a>Disallow using extensions of later DWARF standard version than selected |
| with <samp><span class="option">-gdwarf-</span><var>version</var></samp>. On most targets using non-conflicting |
| DWARF extensions from later standard versions is allowed. |
| |
| <br><dt><code>-gno-strict-dwarf</code><dd><a name="index-gno_002dstrict_002ddwarf-556"></a>Allow using extensions of later DWARF standard version than selected with |
| <samp><span class="option">-gdwarf-</span><var>version</var></samp>. |
| |
| <br><dt><code>-gvms</code><dd><a name="index-gvms-557"></a>Produce debugging information in Alpha/VMS debug format (if that is |
| supported). This is the format used by DEBUG on Alpha/VMS systems. |
| |
| <br><dt><code>-g</code><var>level</var><dt><code>-ggdb</code><var>level</var><dt><code>-gstabs</code><var>level</var><dt><code>-gcoff</code><var>level</var><dt><code>-gxcoff</code><var>level</var><dt><code>-gvms</code><var>level</var><dd>Request debugging information and also use <var>level</var> to specify how |
| much information. The default level is 2. |
| |
| <p>Level 0 produces no debug information at all. Thus, <samp><span class="option">-g0</span></samp> negates |
| <samp><span class="option">-g</span></samp>. |
| |
| <p>Level 1 produces minimal information, enough for making backtraces in |
| parts of the program that you don't plan to debug. This includes |
| descriptions of functions and external variables, but no information |
| about local variables and no line numbers. |
| |
| <p>Level 3 includes extra information, such as all the macro definitions |
| present in the program. Some debuggers support macro expansion when |
| you use <samp><span class="option">-g3</span></samp>. |
| |
| <p><samp><span class="option">-gdwarf-2</span></samp> does not accept a concatenated debug level, because |
| GCC used to support an option <samp><span class="option">-gdwarf</span></samp> that meant to generate |
| debug information in version 1 of the DWARF format (which is very |
| different from version 2), and it would have been too confusing. That |
| debug format is long obsolete, but the option cannot be changed now. |
| Instead use an additional <samp><span class="option">-g</span><var>level</var></samp> option to change the |
| debug level for DWARF. |
| |
| <br><dt><code>-gtoggle</code><dd><a name="index-gtoggle-558"></a>Turn off generation of debug info, if leaving out this option |
| generates it, or turn it on at level 2 otherwise. The position of this |
| argument in the command line does not matter; it takes effect after all |
| other options are processed, and it does so only once, no matter how |
| many times it is given. This is mainly intended to be used with |
| <samp><span class="option">-fcompare-debug</span></samp>. |
| |
| <br><dt><code>-fsanitize=address</code><dd>Enable AddressSanitizer, a fast memory error detector. |
| Memory access instructions will be instrumented to detect |
| out-of-bounds and use-after-free bugs. |
| See <a href="http://code.google.com/p/address-sanitizer/">http://code.google.com/p/address-sanitizer/</a> for more details. |
| |
| <br><dt><code>-fsanitize=thread</code><dd>Enable ThreadSanitizer, a fast data race detector. |
| Memory access instructions will be instrumented to detect |
| data race bugs. |
| See <a href="http://code.google.com/p/data-race-test/wiki/ThreadSanitizer">http://code.google.com/p/data-race-test/wiki/ThreadSanitizer</a> for more details. |
| |
| <br><dt><code>-fdump-final-insns</code><span class="roman">[</span><code>=</code><var>file</var><span class="roman">]</span><dd><a name="index-fdump_002dfinal_002dinsns-559"></a>Dump the final internal representation (RTL) to <var>file</var>. If the |
| optional argument is omitted (or if <var>file</var> is <code>.</code>), the name |
| of the dump file is determined by appending <code>.gkd</code> to the |
| compilation output file name. |
| |
| <br><dt><code>-fcompare-debug</code><span class="roman">[</span><code>=</code><var>opts</var><span class="roman">]</span><dd><a name="index-fcompare_002ddebug-560"></a><a name="index-fno_002dcompare_002ddebug-561"></a>If no error occurs during compilation, run the compiler a second time, |
| adding <var>opts</var> and <samp><span class="option">-fcompare-debug-second</span></samp> to the arguments |
| passed to the second compilation. Dump the final internal |
| representation in both compilations, and print an error if they differ. |
| |
| <p>If the equal sign is omitted, the default <samp><span class="option">-gtoggle</span></samp> is used. |
| |
| <p>The environment variable <samp><span class="env">GCC_COMPARE_DEBUG</span></samp>, if defined, non-empty |
| and nonzero, implicitly enables <samp><span class="option">-fcompare-debug</span></samp>. If |
| <samp><span class="env">GCC_COMPARE_DEBUG</span></samp> is defined to a string starting with a dash, |
| then it is used for <var>opts</var>, otherwise the default <samp><span class="option">-gtoggle</span></samp> |
| is used. |
| |
| <p><samp><span class="option">-fcompare-debug=</span></samp>, with the equal sign but without <var>opts</var>, |
| is equivalent to <samp><span class="option">-fno-compare-debug</span></samp>, which disables the dumping |
| of the final representation and the second compilation, preventing even |
| <samp><span class="env">GCC_COMPARE_DEBUG</span></samp> from taking effect. |
| |
| <p>To verify full coverage during <samp><span class="option">-fcompare-debug</span></samp> testing, set |
| <samp><span class="env">GCC_COMPARE_DEBUG</span></samp> to say ‘<samp><span class="samp">-fcompare-debug-not-overridden</span></samp>’, |
| which GCC rejects as an invalid option in any actual compilation |
| (rather than preprocessing, assembly or linking). To get just a |
| warning, setting <samp><span class="env">GCC_COMPARE_DEBUG</span></samp> to ‘<samp><span class="samp">-w%n-fcompare-debug |
| not overridden</span></samp>’ will do. |
| |
| <br><dt><code>-fcompare-debug-second</code><dd><a name="index-fcompare_002ddebug_002dsecond-562"></a>This option is implicitly passed to the compiler for the second |
| compilation requested by <samp><span class="option">-fcompare-debug</span></samp>, 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 |
| <code>.gk</code> additional extension during the second compilation, to avoid |
| overwriting those generated by the first. |
| |
| <p>When this option is passed to the compiler driver, it causes the |
| <em>first</em> compilation to be skipped, which makes it useful for little |
| other than debugging the compiler proper. |
| |
| <br><dt><code>-feliminate-dwarf2-dups</code><dd><a name="index-feliminate_002ddwarf2_002ddups-563"></a>Compress DWARF 2 debugging information by eliminating duplicated |
| information about each symbol. This option only makes sense when |
| generating DWARF 2 debugging information with <samp><span class="option">-gdwarf-2</span></samp>. |
| |
| <br><dt><code>-femit-struct-debug-baseonly</code><dd>Emit debug information for struct-like types |
| only when the base name of the compilation source file |
| matches the base name of file in which the struct is defined. |
| |
| <p>This option substantially reduces the size of debugging information, |
| but at significant potential loss in type information to the debugger. |
| See <samp><span class="option">-femit-struct-debug-reduced</span></samp> for a less aggressive option. |
| See <samp><span class="option">-femit-struct-debug-detailed</span></samp> for more detailed control. |
| |
| <p>This option works only with DWARF 2. |
| |
| <br><dt><code>-femit-struct-debug-reduced</code><dd>Emit debug information for struct-like types |
| only when the base name of the compilation source file |
| matches the base name of file in which the type is defined, |
| unless the struct is a template or defined in a system header. |
| |
| <p>This option significantly reduces the size of debugging information, |
| with some potential loss in type information to the debugger. |
| See <samp><span class="option">-femit-struct-debug-baseonly</span></samp> for a more aggressive option. |
| See <samp><span class="option">-femit-struct-debug-detailed</span></samp> for more detailed control. |
| |
| <p>This option works only with DWARF 2. |
| |
| <br><dt><code>-femit-struct-debug-detailed</code><span class="roman">[</span><code>=</code><var>spec-list</var><span class="roman">]</span><dd>Specify the struct-like types |
| for which the compiler generates debug information. |
| The intent is to reduce duplicate struct debug information |
| between different object files within the same program. |
| |
| <p>This option is a detailed version of |
| <samp><span class="option">-femit-struct-debug-reduced</span></samp> and <samp><span class="option">-femit-struct-debug-baseonly</span></samp>, |
| which serves for most needs. |
| |
| <p>A specification has the syntax<br> |
| [‘<samp><span class="samp">dir:</span></samp>’|‘<samp><span class="samp">ind:</span></samp>’][‘<samp><span class="samp">ord:</span></samp>’|‘<samp><span class="samp">gen:</span></samp>’](‘<samp><span class="samp">any</span></samp>’|‘<samp><span class="samp">sys</span></samp>’|‘<samp><span class="samp">base</span></samp>’|‘<samp><span class="samp">none</span></samp>’) |
| |
| <p>The optional first word limits the specification to |
| structs that are used directly (‘<samp><span class="samp">dir:</span></samp>’) or used indirectly (‘<samp><span class="samp">ind:</span></samp>’). |
| A struct type is used directly when it is the type of a variable, member. |
| Indirect uses arise through pointers to structs. |
| That is, when use of an incomplete struct is valid, the use is indirect. |
| An example is |
| ‘<samp><span class="samp">struct one direct; struct two * indirect;</span></samp>’. |
| |
| <p>The optional second word limits the specification to |
| ordinary structs (‘<samp><span class="samp">ord:</span></samp>’) or generic structs (‘<samp><span class="samp">gen:</span></samp>’). |
| Generic structs are a bit complicated to explain. |
| For C++, these are non-explicit specializations of template classes, |
| or non-template classes within the above. |
| Other programming languages have generics, |
| but <samp><span class="option">-femit-struct-debug-detailed</span></samp> does not yet implement them. |
| |
| <p>The third word specifies the source files for those |
| structs for which the compiler should emit debug information. |
| The values ‘<samp><span class="samp">none</span></samp>’ and ‘<samp><span class="samp">any</span></samp>’ have the normal meaning. |
| The value ‘<samp><span class="samp">base</span></samp>’ means that |
| the base of name of the file in which the type declaration appears |
| must match the base of the name of the main compilation file. |
| In practice, this means that when compiling <samp><span class="file">foo.c</span></samp>, debug information |
| is generated for types declared in that file and <samp><span class="file">foo.h</span></samp>, |
| but not other header files. |
| The value ‘<samp><span class="samp">sys</span></samp>’ means those types satisfying ‘<samp><span class="samp">base</span></samp>’ |
| or declared in system or compiler headers. |
| |
| <p>You may need to experiment to determine the best settings for your application. |
| |
| <p>The default is <samp><span class="option">-femit-struct-debug-detailed=all</span></samp>. |
| |
| <p>This option works only with DWARF 2. |
| |
| <br><dt><code>-fno-merge-debug-strings</code><dd><a name="index-fmerge_002ddebug_002dstrings-564"></a><a name="index-fno_002dmerge_002ddebug_002dstrings-565"></a>Direct the linker to not merge together strings in the debugging |
| information that are identical in different object files. Merging is |
| not supported by all assemblers or linkers. Merging decreases the size |
| of the debug information in the output file at the cost of increasing |
| link processing time. Merging is enabled by default. |
| |
| <br><dt><code>-fdebug-prefix-map=</code><var>old</var><code>=</code><var>new</var><dd><a name="index-fdebug_002dprefix_002dmap-566"></a>When compiling files in directory <samp><var>old</var></samp>, record debugging |
| information describing them as in <samp><var>new</var></samp> instead. |
| |
| <br><dt><code>-fno-dwarf2-cfi-asm</code><dd><a name="index-fdwarf2_002dcfi_002dasm-567"></a><a name="index-fno_002ddwarf2_002dcfi_002dasm-568"></a>Emit DWARF 2 unwind info as compiler generated <code>.eh_frame</code> section |
| instead of using GAS <code>.cfi_*</code> directives. |
| |
| <p><a name="index-g_t_0040command_007bprof_007d-569"></a><br><dt><code>-p</code><dd><a name="index-p-570"></a>Generate extra code to write profile information suitable for the |
| analysis program <samp><span class="command">prof</span></samp>. You must use this option when compiling |
| the source files you want data about, and you must also use it when |
| linking. |
| |
| <p><a name="index-g_t_0040command_007bgprof_007d-571"></a><br><dt><code>-pg</code><dd><a name="index-pg-572"></a>Generate extra code to write profile information suitable for the |
| analysis program <samp><span class="command">gprof</span></samp>. You must use this option when compiling |
| the source files you want data about, and you must also use it when |
| linking. |
| |
| <br><dt><code>-Q</code><dd><a name="index-Q-573"></a>Makes the compiler print out each function name as it is compiled, and |
| print some statistics about each pass when it finishes. |
| |
| <br><dt><code>-ftime-report</code><dd><a name="index-ftime_002dreport-574"></a>Makes the compiler print some statistics about the time consumed by each |
| pass when it finishes. |
| |
| <br><dt><code>-fmem-report</code><dd><a name="index-fmem_002dreport-575"></a>Makes the compiler print some statistics about permanent memory |
| allocation when it finishes. |
| |
| <br><dt><code>-fmem-report-wpa</code><dd><a name="index-fmem_002dreport_002dwpa-576"></a>Makes the compiler print some statistics about permanent memory |
| allocation for the WPA phase only. |
| |
| <br><dt><code>-fpre-ipa-mem-report</code><dd><a name="index-fpre_002dipa_002dmem_002dreport-577"></a><br><dt><code>-fpost-ipa-mem-report</code><dd><a name="index-fpost_002dipa_002dmem_002dreport-578"></a>Makes the compiler print some statistics about permanent memory |
| allocation before or after interprocedural optimization. |
| |
| <br><dt><code>-fprofile-report</code><dd><a name="index-fprofile_002dreport-579"></a>Makes the compiler print some statistics about consistency of the |
| (estimated) profile and effect of individual passes. |
| |
| <br><dt><code>-fstack-usage</code><dd><a name="index-fstack_002dusage-580"></a>Makes the compiler output stack usage information for the program, on a |
| per-function basis. The filename for the dump is made by appending |
| <samp><span class="file">.su</span></samp> to the <var>auxname</var>. <var>auxname</var> 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: |
| |
| <ul> |
| <li>The name of the function. |
| <li>A number of bytes. |
| <li>One or more qualifiers: <code>static</code>, <code>dynamic</code>, <code>bounded</code>. |
| </ul> |
| |
| <p>The qualifier <code>static</code> 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. |
| |
| <p>The qualifier <code>dynamic</code> 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 <code>bounded</code> 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. |
| |
| <br><dt><code>-fprofile-arcs</code><dd><a name="index-fprofile_002darcs-581"></a>Add code so that program flow <dfn>arcs</dfn> are instrumented. During |
| execution the program records how many times each branch and call is |
| executed and how many times it is taken or returns. When the compiled |
| program exits it saves this data to a file called |
| <samp><var>auxname</var><span class="file">.gcda</span></samp> for each source file. The data may be used for |
| profile-directed optimizations (<samp><span class="option">-fbranch-probabilities</span></samp>), or for |
| test coverage analysis (<samp><span class="option">-ftest-coverage</span></samp>). Each object file's |
| <var>auxname</var> is generated from the name of the output file, if |
| explicitly specified and it is not the final executable, otherwise it is |
| the basename of the source file. In both cases any suffix is removed |
| (e.g. <samp><span class="file">foo.gcda</span></samp> for input file <samp><span class="file">dir/foo.c</span></samp>, or |
| <samp><span class="file">dir/foo.gcda</span></samp> for output file specified as <samp><span class="option">-o dir/foo.o</span></samp>). |
| See <a href="Cross_002dprofiling.html#Cross_002dprofiling">Cross-profiling</a>. |
| |
| <p><a name="index-g_t_0040command_007bgcov_007d-582"></a><br><dt><code>--coverage</code><dd><a name="index-coverage-583"></a> |
| This option is used to compile and link code instrumented for coverage |
| analysis. The option is a synonym for <samp><span class="option">-fprofile-arcs</span></samp> |
| <samp><span class="option">-ftest-coverage</span></samp> (when compiling) and <samp><span class="option">-lgcov</span></samp> (when |
| linking). See the documentation for those options for more details. |
| |
| <ul> |
| <li>Compile the source files with <samp><span class="option">-fprofile-arcs</span></samp> plus optimization |
| and code generation options. For test coverage analysis, use the |
| additional <samp><span class="option">-ftest-coverage</span></samp> option. You do not need to profile |
| every source file in a program. |
| |
| <li>Link your object files with <samp><span class="option">-lgcov</span></samp> or <samp><span class="option">-fprofile-arcs</span></samp> |
| (the latter implies the former). |
| |
| <li>Run the program on a representative workload to generate the arc profile |
| information. This may be repeated any number of times. You can run |
| concurrent instances of your program, and provided that the file system |
| supports locking, the data files will be correctly updated. Also |
| <code>fork</code> calls are detected and correctly handled (double counting |
| will not happen). |
| |
| <li>For profile-directed optimizations, compile the source files again with |
| the same optimization and code generation options plus |
| <samp><span class="option">-fbranch-probabilities</span></samp> (see <a href="Optimize-Options.html#Optimize-Options">Options that Control Optimization</a>). |
| |
| <li>For test coverage analysis, use <samp><span class="command">gcov</span></samp> to produce human readable |
| information from the <samp><span class="file">.gcno</span></samp> and <samp><span class="file">.gcda</span></samp> files. Refer to the |
| <samp><span class="command">gcov</span></samp> documentation for further information. |
| |
| </ul> |
| |
| <p>With <samp><span class="option">-fprofile-arcs</span></samp>, for each function of your program GCC |
| creates a program flow graph, then finds a spanning tree for the graph. |
| Only arcs that are not on the spanning tree have to be instrumented: the |
| compiler adds code to count the number of times that these arcs are |
| executed. When an arc is the only exit or only entrance to a block, the |
| instrumentation code can be added to the block; otherwise, a new basic |
| block must be created to hold the instrumentation code. |
| |
| <br><dt><code>-ftest-coverage</code><dd><a name="index-ftest_002dcoverage-584"></a>Produce a notes file that the <samp><span class="command">gcov</span></samp> code-coverage utility |
| (see <a href="Gcov.html#Gcov"><samp><span class="command">gcov</span></samp>—a Test Coverage Program</a>) can use to |
| show program coverage. Each source file's note file is called |
| <samp><var>auxname</var><span class="file">.gcno</span></samp>. Refer to the <samp><span class="option">-fprofile-arcs</span></samp> option |
| above for a description of <var>auxname</var> and instructions on how to |
| generate test coverage data. Coverage data matches the source files |
| more closely if you do not optimize. |
| |
| <br><dt><code>-fdbg-cnt-list</code><dd><a name="index-fdbg_002dcnt_002dlist-585"></a>Print the name and the counter upper bound for all debug counters. |
| |
| <br><dt><code>-fdbg-cnt=</code><var>counter-value-list</var><dd><a name="index-fdbg_002dcnt-586"></a>Set the internal debug counter upper bound. <var>counter-value-list</var> |
| is a comma-separated list of <var>name</var>:<var>value</var> pairs |
| which sets the upper bound of each debug counter <var>name</var> to <var>value</var>. |
| All debug counters have the initial upper bound of <code>UINT_MAX</code>; |
| thus <code>dbg_cnt()</code> returns true always unless the upper bound |
| is set by this option. |
| For example, with <samp><span class="option">-fdbg-cnt=dce:10,tail_call:0</span></samp>, |
| <code>dbg_cnt(dce)</code> returns true only for first 10 invocations. |
| |
| <br><dt><code>-fenable-</code><var>kind</var><code>-</code><var>pass</var><dt><code>-fdisable-</code><var>kind</var><code>-</code><var>pass</var><code>=</code><var>range-list</var><dd><a name="index-fdisable_002d-587"></a><a name="index-fenable_002d-588"></a> |
| This is a set of options that are used to explicitly disable/enable |
| optimization passes. These options are intended for use for debugging GCC. |
| Compiler users should use regular options for enabling/disabling |
| passes instead. |
| |
| <dl> |
| <dt><code>-fdisable-ipa-</code><var>pass</var><dd>Disable IPA pass <var>pass</var>. <var>pass</var> is the pass name. If the same pass is |
| statically invoked in the compiler multiple times, the pass name should be |
| appended with a sequential number starting from 1. |
| |
| <br><dt><code>-fdisable-rtl-</code><var>pass</var><dt><code>-fdisable-rtl-</code><var>pass</var><code>=</code><var>range-list</var><dd>Disable RTL pass <var>pass</var>. <var>pass</var> is the pass name. If the same pass is |
| statically invoked in the compiler multiple times, the pass name should be |
| appended with a sequential number starting from 1. <var>range-list</var> is a |
| comma-separated list of function ranges or assembler names. Each range is a number |
| pair separated by a colon. The range is inclusive in both ends. If the range |
| is trivial, the number pair can be simplified as a single number. If the |
| function's call graph node's <var>uid</var> falls within one of the specified ranges, |
| the <var>pass</var> is disabled for that function. The <var>uid</var> is shown in the |
| function header of a dump file, and the pass names can be dumped by using |
| option <samp><span class="option">-fdump-passes</span></samp>. |
| |
| <br><dt><code>-fdisable-tree-</code><var>pass</var><dt><code>-fdisable-tree-</code><var>pass</var><code>=</code><var>range-list</var><dd>Disable tree pass <var>pass</var>. See <samp><span class="option">-fdisable-rtl</span></samp> for the description of |
| option arguments. |
| |
| <br><dt><code>-fenable-ipa-</code><var>pass</var><dd>Enable IPA pass <var>pass</var>. <var>pass</var> is the pass name. If the same pass is |
| statically invoked in the compiler multiple times, the pass name should be |
| appended with a sequential number starting from 1. |
| |
| <br><dt><code>-fenable-rtl-</code><var>pass</var><dt><code>-fenable-rtl-</code><var>pass</var><code>=</code><var>range-list</var><dd>Enable RTL pass <var>pass</var>. See <samp><span class="option">-fdisable-rtl</span></samp> for option argument |
| description and examples. |
| |
| <br><dt><code>-fenable-tree-</code><var>pass</var><dt><code>-fenable-tree-</code><var>pass</var><code>=</code><var>range-list</var><dd>Enable tree pass <var>pass</var>. See <samp><span class="option">-fdisable-rtl</span></samp> for the description |
| of option arguments. |
| |
| </dl> |
| |
| <p>Here are some examples showing uses of these options. |
| |
| <pre class="smallexample"> |
| # 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 |
| |
| </pre> |
| <br><dt><code>-d</code><var>letters</var><dt><code>-fdump-rtl-</code><var>pass</var><dt><code>-fdump-rtl-</code><var>pass</var><code>=</code><var>filename</var><dd><a name="index-d-589"></a>Says to make debugging dumps during compilation at times specified by |
| <var>letters</var>. This is used for debugging the RTL-based passes of the |
| compiler. The file names for most of the dumps are made by appending |
| a pass number and a word to the <var>dumpname</var>, and the files are |
| created in the directory of the output file. In case of |
| <samp><span class="option">=</span><var>filename</var></samp> option, the dump is output on the given file |
| instead of the pass numbered dump files. Note that the pass number is |
| computed statically as passes get registered into the pass manager. |
| Thus the numbering is not related to the dynamic order of execution of |
| passes. In particular, a pass installed by a plugin could have a |
| number over 200 even if it executed quite early. <var>dumpname</var> 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. These switches may have different effects when |
| <samp><span class="option">-E</span></samp> is used for preprocessing. |
| |
| <p>Debug dumps can be enabled with a <samp><span class="option">-fdump-rtl</span></samp> switch or some |
| <samp><span class="option">-d</span></samp> option <var>letters</var>. Here are the possible |
| letters for use in <var>pass</var> and <var>letters</var>, and their meanings: |
| |
| <dl> |
| <dt><code>-fdump-rtl-alignments</code><dd><a name="index-fdump_002drtl_002dalignments-590"></a>Dump after branch alignments have been computed. |
| |
| <br><dt><code>-fdump-rtl-asmcons</code><dd><a name="index-fdump_002drtl_002dasmcons-591"></a>Dump after fixing rtl statements that have unsatisfied in/out constraints. |
| |
| <br><dt><code>-fdump-rtl-auto_inc_dec</code><dd><a name="index-fdump_002drtl_002dauto_005finc_005fdec-592"></a>Dump after auto-inc-dec discovery. This pass is only run on |
| architectures that have auto inc or auto dec instructions. |
| |
| <br><dt><code>-fdump-rtl-barriers</code><dd><a name="index-fdump_002drtl_002dbarriers-593"></a>Dump after cleaning up the barrier instructions. |
| |
| <br><dt><code>-fdump-rtl-bbpart</code><dd><a name="index-fdump_002drtl_002dbbpart-594"></a>Dump after partitioning hot and cold basic blocks. |
| |
| <br><dt><code>-fdump-rtl-bbro</code><dd><a name="index-fdump_002drtl_002dbbro-595"></a>Dump after block reordering. |
| |
| <br><dt><code>-fdump-rtl-btl1</code><dt><code>-fdump-rtl-btl2</code><dd><a name="index-fdump_002drtl_002dbtl2-596"></a><a name="index-fdump_002drtl_002dbtl2-597"></a><samp><span class="option">-fdump-rtl-btl1</span></samp> and <samp><span class="option">-fdump-rtl-btl2</span></samp> enable dumping |
| after the two branch |
| target load optimization passes. |
| |
| <br><dt><code>-fdump-rtl-bypass</code><dd><a name="index-fdump_002drtl_002dbypass-598"></a>Dump after jump bypassing and control flow optimizations. |
| |
| <br><dt><code>-fdump-rtl-combine</code><dd><a name="index-fdump_002drtl_002dcombine-599"></a>Dump after the RTL instruction combination pass. |
| |
| <br><dt><code>-fdump-rtl-compgotos</code><dd><a name="index-fdump_002drtl_002dcompgotos-600"></a>Dump after duplicating the computed gotos. |
| |
| <br><dt><code>-fdump-rtl-ce1</code><dt><code>-fdump-rtl-ce2</code><dt><code>-fdump-rtl-ce3</code><dd><a name="index-fdump_002drtl_002dce1-601"></a><a name="index-fdump_002drtl_002dce2-602"></a><a name="index-fdump_002drtl_002dce3-603"></a><samp><span class="option">-fdump-rtl-ce1</span></samp>, <samp><span class="option">-fdump-rtl-ce2</span></samp>, and |
| <samp><span class="option">-fdump-rtl-ce3</span></samp> enable dumping after the three |
| if conversion passes. |
| |
| <br><dt><code>-fdump-rtl-cprop_hardreg</code><dd><a name="index-fdump_002drtl_002dcprop_005fhardreg-604"></a>Dump after hard register copy propagation. |
| |
| <br><dt><code>-fdump-rtl-csa</code><dd><a name="index-fdump_002drtl_002dcsa-605"></a>Dump after combining stack adjustments. |
| |
| <br><dt><code>-fdump-rtl-cse1</code><dt><code>-fdump-rtl-cse2</code><dd><a name="index-fdump_002drtl_002dcse1-606"></a><a name="index-fdump_002drtl_002dcse2-607"></a><samp><span class="option">-fdump-rtl-cse1</span></samp> and <samp><span class="option">-fdump-rtl-cse2</span></samp> enable dumping after |
| the two common subexpression elimination passes. |
| |
| <br><dt><code>-fdump-rtl-dce</code><dd><a name="index-fdump_002drtl_002ddce-608"></a>Dump after the standalone dead code elimination passes. |
| |
| <br><dt><code>-fdump-rtl-dbr</code><dd><a name="index-fdump_002drtl_002ddbr-609"></a>Dump after delayed branch scheduling. |
| |
| <br><dt><code>-fdump-rtl-dce1</code><dt><code>-fdump-rtl-dce2</code><dd><a name="index-fdump_002drtl_002ddce1-610"></a><a name="index-fdump_002drtl_002ddce2-611"></a><samp><span class="option">-fdump-rtl-dce1</span></samp> and <samp><span class="option">-fdump-rtl-dce2</span></samp> enable dumping after |
| the two dead store elimination passes. |
| |
| <br><dt><code>-fdump-rtl-eh</code><dd><a name="index-fdump_002drtl_002deh-612"></a>Dump after finalization of EH handling code. |
| |
| <br><dt><code>-fdump-rtl-eh_ranges</code><dd><a name="index-fdump_002drtl_002deh_005franges-613"></a>Dump after conversion of EH handling range regions. |
| |
| <br><dt><code>-fdump-rtl-expand</code><dd><a name="index-fdump_002drtl_002dexpand-614"></a>Dump after RTL generation. |
| |
| <br><dt><code>-fdump-rtl-fwprop1</code><dt><code>-fdump-rtl-fwprop2</code><dd><a name="index-fdump_002drtl_002dfwprop1-615"></a><a name="index-fdump_002drtl_002dfwprop2-616"></a><samp><span class="option">-fdump-rtl-fwprop1</span></samp> and <samp><span class="option">-fdump-rtl-fwprop2</span></samp> enable |
| dumping after the two forward propagation passes. |
| |
| <br><dt><code>-fdump-rtl-gcse1</code><dt><code>-fdump-rtl-gcse2</code><dd><a name="index-fdump_002drtl_002dgcse1-617"></a><a name="index-fdump_002drtl_002dgcse2-618"></a><samp><span class="option">-fdump-rtl-gcse1</span></samp> and <samp><span class="option">-fdump-rtl-gcse2</span></samp> enable dumping |
| after global common subexpression elimination. |
| |
| <br><dt><code>-fdump-rtl-init-regs</code><dd><a name="index-fdump_002drtl_002dinit_002dregs-619"></a>Dump after the initialization of the registers. |
| |
| <br><dt><code>-fdump-rtl-initvals</code><dd><a name="index-fdump_002drtl_002dinitvals-620"></a>Dump after the computation of the initial value sets. |
| |
| <br><dt><code>-fdump-rtl-into_cfglayout</code><dd><a name="index-fdump_002drtl_002dinto_005fcfglayout-621"></a>Dump after converting to cfglayout mode. |
| |
| <br><dt><code>-fdump-rtl-ira</code><dd><a name="index-fdump_002drtl_002dira-622"></a>Dump after iterated register allocation. |
| |
| <br><dt><code>-fdump-rtl-jump</code><dd><a name="index-fdump_002drtl_002djump-623"></a>Dump after the second jump optimization. |
| |
| <br><dt><code>-fdump-rtl-loop2</code><dd><a name="index-fdump_002drtl_002dloop2-624"></a><samp><span class="option">-fdump-rtl-loop2</span></samp> enables dumping after the rtl |
| loop optimization passes. |
| |
| <br><dt><code>-fdump-rtl-mach</code><dd><a name="index-fdump_002drtl_002dmach-625"></a>Dump after performing the machine dependent reorganization pass, if that |
| pass exists. |
| |
| <br><dt><code>-fdump-rtl-mode_sw</code><dd><a name="index-fdump_002drtl_002dmode_005fsw-626"></a>Dump after removing redundant mode switches. |
| |
| <br><dt><code>-fdump-rtl-rnreg</code><dd><a name="index-fdump_002drtl_002drnreg-627"></a>Dump after register renumbering. |
| |
| <br><dt><code>-fdump-rtl-outof_cfglayout</code><dd><a name="index-fdump_002drtl_002doutof_005fcfglayout-628"></a>Dump after converting from cfglayout mode. |
| |
| <br><dt><code>-fdump-rtl-peephole2</code><dd><a name="index-fdump_002drtl_002dpeephole2-629"></a>Dump after the peephole pass. |
| |
| <br><dt><code>-fdump-rtl-postreload</code><dd><a name="index-fdump_002drtl_002dpostreload-630"></a>Dump after post-reload optimizations. |
| |
| <br><dt><code>-fdump-rtl-pro_and_epilogue</code><dd><a name="index-fdump_002drtl_002dpro_005fand_005fepilogue-631"></a>Dump after generating the function prologues and epilogues. |
| |
| <br><dt><code>-fdump-rtl-regmove</code><dd><a name="index-fdump_002drtl_002dregmove-632"></a>Dump after the register move pass. |
| |
| <br><dt><code>-fdump-rtl-sched1</code><dt><code>-fdump-rtl-sched2</code><dd><a name="index-fdump_002drtl_002dsched1-633"></a><a name="index-fdump_002drtl_002dsched2-634"></a><samp><span class="option">-fdump-rtl-sched1</span></samp> and <samp><span class="option">-fdump-rtl-sched2</span></samp> enable dumping |
| after the basic block scheduling passes. |
| |
| <br><dt><code>-fdump-rtl-see</code><dd><a name="index-fdump_002drtl_002dsee-635"></a>Dump after sign extension elimination. |
| |
| <br><dt><code>-fdump-rtl-seqabstr</code><dd><a name="index-fdump_002drtl_002dseqabstr-636"></a>Dump after common sequence discovery. |
| |
| <br><dt><code>-fdump-rtl-shorten</code><dd><a name="index-fdump_002drtl_002dshorten-637"></a>Dump after shortening branches. |
| |
| <br><dt><code>-fdump-rtl-sibling</code><dd><a name="index-fdump_002drtl_002dsibling-638"></a>Dump after sibling call optimizations. |
| |
| <br><dt><code>-fdump-rtl-split1</code><dt><code>-fdump-rtl-split2</code><dt><code>-fdump-rtl-split3</code><dt><code>-fdump-rtl-split4</code><dt><code>-fdump-rtl-split5</code><dd><a name="index-fdump_002drtl_002dsplit1-639"></a><a name="index-fdump_002drtl_002dsplit2-640"></a><a name="index-fdump_002drtl_002dsplit3-641"></a><a name="index-fdump_002drtl_002dsplit4-642"></a><a name="index-fdump_002drtl_002dsplit5-643"></a><samp><span class="option">-fdump-rtl-split1</span></samp>, <samp><span class="option">-fdump-rtl-split2</span></samp>, |
| <samp><span class="option">-fdump-rtl-split3</span></samp>, <samp><span class="option">-fdump-rtl-split4</span></samp> and |
| <samp><span class="option">-fdump-rtl-split5</span></samp> enable dumping after five rounds of |
| instruction splitting. |
| |
| <br><dt><code>-fdump-rtl-sms</code><dd><a name="index-fdump_002drtl_002dsms-644"></a>Dump after modulo scheduling. This pass is only run on some |
| architectures. |
| |
| <br><dt><code>-fdump-rtl-stack</code><dd><a name="index-fdump_002drtl_002dstack-645"></a>Dump after conversion from GCC's “flat register file” registers to the |
| x87's stack-like registers. This pass is only run on x86 variants. |
| |
| <br><dt><code>-fdump-rtl-subreg1</code><dt><code>-fdump-rtl-subreg2</code><dd><a name="index-fdump_002drtl_002dsubreg1-646"></a><a name="index-fdump_002drtl_002dsubreg2-647"></a><samp><span class="option">-fdump-rtl-subreg1</span></samp> and <samp><span class="option">-fdump-rtl-subreg2</span></samp> enable dumping after |
| the two subreg expansion passes. |
| |
| <br><dt><code>-fdump-rtl-unshare</code><dd><a name="index-fdump_002drtl_002dunshare-648"></a>Dump after all rtl has been unshared. |
| |
| <br><dt><code>-fdump-rtl-vartrack</code><dd><a name="index-fdump_002drtl_002dvartrack-649"></a>Dump after variable tracking. |
| |
| <br><dt><code>-fdump-rtl-vregs</code><dd><a name="index-fdump_002drtl_002dvregs-650"></a>Dump after converting virtual registers to hard registers. |
| |
| <br><dt><code>-fdump-rtl-web</code><dd><a name="index-fdump_002drtl_002dweb-651"></a>Dump after live range splitting. |
| |
| <br><dt><code>-fdump-rtl-regclass</code><dt><code>-fdump-rtl-subregs_of_mode_init</code><dt><code>-fdump-rtl-subregs_of_mode_finish</code><dt><code>-fdump-rtl-dfinit</code><dt><code>-fdump-rtl-dfinish</code><dd><a name="index-fdump_002drtl_002dregclass-652"></a><a name="index-fdump_002drtl_002dsubregs_005fof_005fmode_005finit-653"></a><a name="index-fdump_002drtl_002dsubregs_005fof_005fmode_005ffinish-654"></a><a name="index-fdump_002drtl_002ddfinit-655"></a><a name="index-fdump_002drtl_002ddfinish-656"></a>These dumps are defined but always produce empty files. |
| |
| <br><dt><code>-da</code><dt><code>-fdump-rtl-all</code><dd><a name="index-da-657"></a><a name="index-fdump_002drtl_002dall-658"></a>Produce all the dumps listed above. |
| |
| <br><dt><code>-dA</code><dd><a name="index-dA-659"></a>Annotate the assembler output with miscellaneous debugging information. |
| |
| <br><dt><code>-dD</code><dd><a name="index-dD-660"></a>Dump all macro definitions, at the end of preprocessing, in addition to |
| normal output. |
| |
| <br><dt><code>-dH</code><dd><a name="index-dH-661"></a>Produce a core dump whenever an error occurs. |
| |
| <br><dt><code>-dp</code><dd><a name="index-dp-662"></a>Annotate the assembler output with a comment indicating which |
| pattern and alternative is used. The length of each instruction is |
| also printed. |
| |
| <br><dt><code>-dP</code><dd><a name="index-dP-663"></a>Dump the RTL in the assembler output as a comment before each instruction. |
| Also turns on <samp><span class="option">-dp</span></samp> annotation. |
| |
| <br><dt><code>-dx</code><dd><a name="index-dx-664"></a>Just generate RTL for a function instead of compiling it. Usually used |
| with <samp><span class="option">-fdump-rtl-expand</span></samp>. |
| </dl> |
| |
| <br><dt><code>-fdump-noaddr</code><dd><a name="index-fdump_002dnoaddr-665"></a>When doing debugging dumps, suppress address output. This makes it more |
| feasible to use diff on debugging dumps for compiler invocations with |
| different compiler binaries and/or different |
| text / bss / data / heap / stack / dso start locations. |
| |
| <br><dt><code>-fdump-unnumbered</code><dd><a name="index-fdump_002dunnumbered-666"></a>When doing debugging dumps, suppress instruction numbers and address output. |
| This makes it more feasible to use diff on debugging dumps for compiler |
| invocations with different options, in particular with and without |
| <samp><span class="option">-g</span></samp>. |
| |
| <br><dt><code>-fdump-unnumbered-links</code><dd><a name="index-fdump_002dunnumbered_002dlinks-667"></a>When doing debugging dumps (see <samp><span class="option">-d</span></samp> option above), suppress |
| instruction numbers for the links to the previous and next instructions |
| in a sequence. |
| |
| <br><dt><code>-fdump-translation-unit </code><span class="roman">(C++ only)</span><dt><code>-fdump-translation-unit-</code><var>options</var> <span class="roman">(C++ only)</span><dd><a name="index-fdump_002dtranslation_002dunit-668"></a>Dump a representation of the tree structure for the entire translation |
| unit to a file. The file name is made by appending <samp><span class="file">.tu</span></samp> to the |
| source file name, and the file is created in the same directory as the |
| output file. If the ‘<samp><span class="samp">-</span><var>options</var></samp>’ form is used, <var>options</var> |
| controls the details of the dump as described for the |
| <samp><span class="option">-fdump-tree</span></samp> options. |
| |
| <br><dt><code>-fdump-class-hierarchy </code><span class="roman">(C++ only)</span><dt><code>-fdump-class-hierarchy-</code><var>options</var> <span class="roman">(C++ only)</span><dd><a name="index-fdump_002dclass_002dhierarchy-669"></a>Dump a representation of each class's hierarchy and virtual function |
| table layout to a file. The file name is made by appending |
| <samp><span class="file">.class</span></samp> to the source file name, and the file is created in the |
| same directory as the output file. If the ‘<samp><span class="samp">-</span><var>options</var></samp>’ form |
| is used, <var>options</var> controls the details of the dump as described |
| for the <samp><span class="option">-fdump-tree</span></samp> options. |
| |
| <br><dt><code>-fdump-ipa-</code><var>switch</var><dd><a name="index-fdump_002dipa-670"></a>Control the dumping at various stages of inter-procedural analysis |
| language tree to a file. The file name is generated by appending a |
| switch specific suffix to the source file name, and the file is created |
| in the same directory as the output file. The following dumps are |
| possible: |
| |
| <dl> |
| <dt>‘<samp><span class="samp">all</span></samp>’<dd>Enables all inter-procedural analysis dumps. |
| |
| <br><dt>‘<samp><span class="samp">cgraph</span></samp>’<dd>Dumps information about call-graph optimization, unused function removal, |
| and inlining decisions. |
| |
| <br><dt>‘<samp><span class="samp">inline</span></samp>’<dd>Dump after function inlining. |
| |
| </dl> |
| |
| <br><dt><code>-fdump-passes</code><dd><a name="index-fdump_002dpasses-671"></a>Dump the list of optimization passes that are turned on and off by |
| the current command-line options. |
| |
| <br><dt><code>-fdump-statistics-</code><var>option</var><dd><a name="index-fdump_002dstatistics-672"></a>Enable and control dumping of pass statistics in a separate file. The |
| file name is generated by appending a suffix ending in |
| ‘<samp><span class="samp">.statistics</span></samp>’ to the source file name, and the file is created in |
| the same directory as the output file. If the ‘<samp><span class="samp">-</span><var>option</var></samp>’ |
| form is used, ‘<samp><span class="samp">-stats</span></samp>’ causes counters to be summed over the |
| whole compilation unit while ‘<samp><span class="samp">-details</span></samp>’ dumps every event as |
| the passes generate them. The default with no option is to sum |
| counters for each function compiled. |
| |
| <br><dt><code>-fdump-tree-</code><var>switch</var><dt><code>-fdump-tree-</code><var>switch</var><code>-</code><var>options</var><dt><code>-fdump-tree-</code><var>switch</var><code>-</code><var>options</var><code>=</code><var>filename</var><dd><a name="index-fdump_002dtree-673"></a>Control the dumping at various stages of processing the intermediate |
| language tree to a file. The file name is generated by appending a |
| switch-specific suffix to the source file name, and the file is |
| created in the same directory as the output file. In case of |
| <samp><span class="option">=</span><var>filename</var></samp> option, the dump is output on the given file |
| instead of the auto named dump files. If the ‘<samp><span class="samp">-</span><var>options</var></samp>’ |
| form is used, <var>options</var> is a list of ‘<samp><span class="samp">-</span></samp>’ 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 |
| |
| <dl> |
| <dt>‘<samp><span class="samp">address</span></samp>’<dd>Print the address of each node. Usually this is not meaningful as it |
| changes according to the environment and source file. Its primary use |
| is for tying up a dump file with a debug environment. |
| <br><dt>‘<samp><span class="samp">asmname</span></samp>’<dd>If <code>DECL_ASSEMBLER_NAME</code> has been set for a given decl, use that |
| in the dump instead of <code>DECL_NAME</code>. Its primary use is ease of |
| use working backward from mangled names in the assembly file. |
| <br><dt>‘<samp><span class="samp">slim</span></samp>’<dd>When dumping front-end intermediate representations, inhibit dumping |
| of members of a scope or body of a function merely because that scope |
| has been reached. Only dump such items when they are directly reachable |
| by some other path. |
| |
| <p>When dumping pretty-printed trees, this option inhibits dumping the |
| bodies of control structures. |
| |
| <p>When dumping RTL, print the RTL in slim (condensed) form instead of |
| the default LISP-like representation. |
| <br><dt>‘<samp><span class="samp">raw</span></samp>’<dd>Print a raw representation of the tree. By default, trees are |
| pretty-printed into a C-like representation. |
| <br><dt>‘<samp><span class="samp">details</span></samp>’<dd>Enable more detailed dumps (not honored by every dump option). Also |
| include information from the optimization passes. |
| <br><dt>‘<samp><span class="samp">stats</span></samp>’<dd>Enable dumping various statistics about the pass (not honored by every dump |
| option). |
| <br><dt>‘<samp><span class="samp">blocks</span></samp>’<dd>Enable showing basic block boundaries (disabled in raw dumps). |
| <br><dt>‘<samp><span class="samp">graph</span></samp>’<dd>For each of the other indicated dump files (<samp><span class="option">-fdump-rtl-</span><var>pass</var></samp>), |
| dump a representation of the control flow graph suitable for viewing with |
| GraphViz to <samp><var>file</var><span class="file">.</span><var>passid</var><span class="file">.</span><var>pass</var><span class="file">.dot</span></samp>. Each function in |
| the file is pretty-printed as a subgraph, so that GraphViz can render them |
| all in a single plot. |
| |
| <p>This option currently only works for RTL dumps, and the RTL is always |
| dumped in slim form. |
| <br><dt>‘<samp><span class="samp">vops</span></samp>’<dd>Enable showing virtual operands for every statement. |
| <br><dt>‘<samp><span class="samp">lineno</span></samp>’<dd>Enable showing line numbers for statements. |
| <br><dt>‘<samp><span class="samp">uid</span></samp>’<dd>Enable showing the unique ID (<code>DECL_UID</code>) for each variable. |
| <br><dt>‘<samp><span class="samp">verbose</span></samp>’<dd>Enable showing the tree dump for each statement. |
| <br><dt>‘<samp><span class="samp">eh</span></samp>’<dd>Enable showing the EH region number holding each statement. |
| <br><dt>‘<samp><span class="samp">scev</span></samp>’<dd>Enable showing scalar evolution analysis details. |
| <br><dt>‘<samp><span class="samp">optimized</span></samp>’<dd>Enable showing optimization information (only available in certain |
| passes). |
| <br><dt>‘<samp><span class="samp">missed</span></samp>’<dd>Enable showing missed optimization information (only available in certain |
| passes). |
| <br><dt>‘<samp><span class="samp">notes</span></samp>’<dd>Enable other detailed optimization information (only available in |
| certain passes). |
| <br><dt>‘<samp><span class="samp">=</span><var>filename</var></samp>’<dd>Instead of an auto named dump file, output into the given file |
| name. The file names <samp><span class="file">stdout</span></samp> and <samp><span class="file">stderr</span></samp> are treated |
| specially and are considered already open standard streams. For |
| example, |
| |
| <pre class="smallexample"> gcc -O2 -ftree-vectorize -fdump-tree-vect-blocks=foo.dump |
| -fdump-tree-pre=stderr file.c |
| </pre> |
| <p>outputs vectorizer dump into <samp><span class="file">foo.dump</span></samp>, while the PRE dump is |
| output on to <samp><span class="file">stderr</span></samp>. If two conflicting dump filenames are |
| given for the same pass, then the latter option overrides the earlier |
| one. |
| |
| <br><dt>‘<samp><span class="samp">all</span></samp>’<dd>Turn on all options, except <samp><span class="option">raw</span></samp>, <samp><span class="option">slim</span></samp>, <samp><span class="option">verbose</span></samp> |
| and <samp><span class="option">lineno</span></samp>. |
| |
| <br><dt>‘<samp><span class="samp">optall</span></samp>’<dd>Turn on all optimization options, i.e., <samp><span class="option">optimized</span></samp>, |
| <samp><span class="option">missed</span></samp>, and <samp><span class="option">note</span></samp>. |
| </dl> |
| |
| <p>The following tree dumps are possible: |
| <dl> |
| <dt>‘<samp><span class="samp">original</span></samp>’<dd><a name="index-fdump_002dtree_002doriginal-674"></a>Dump before any tree based optimization, to <samp><var>file</var><span class="file">.original</span></samp>. |
| |
| <br><dt>‘<samp><span class="samp">optimized</span></samp>’<dd><a name="index-fdump_002dtree_002doptimized-675"></a>Dump after all tree based optimization, to <samp><var>file</var><span class="file">.optimized</span></samp>. |
| |
| <br><dt>‘<samp><span class="samp">gimple</span></samp>’<dd><a name="index-fdump_002dtree_002dgimple-676"></a>Dump each function before and after the gimplification pass to a file. The |
| file name is made by appending <samp><span class="file">.gimple</span></samp> to the source file name. |
| |
| <br><dt>‘<samp><span class="samp">cfg</span></samp>’<dd><a name="index-fdump_002dtree_002dcfg-677"></a>Dump the control flow graph of each function to a file. The file name is |
| made by appending <samp><span class="file">.cfg</span></samp> to the source file name. |
| |
| <br><dt>‘<samp><span class="samp">ch</span></samp>’<dd><a name="index-fdump_002dtree_002dch-678"></a>Dump each function after copying loop headers. The file name is made by |
| appending <samp><span class="file">.ch</span></samp> to the source file name. |
| |
| <br><dt>‘<samp><span class="samp">ssa</span></samp>’<dd><a name="index-fdump_002dtree_002dssa-679"></a>Dump SSA related information to a file. The file name is made by appending |
| <samp><span class="file">.ssa</span></samp> to the source file name. |
| |
| <br><dt>‘<samp><span class="samp">alias</span></samp>’<dd><a name="index-fdump_002dtree_002dalias-680"></a>Dump aliasing information for each function. The file name is made by |
| appending <samp><span class="file">.alias</span></samp> to the source file name. |
| |
| <br><dt>‘<samp><span class="samp">ccp</span></samp>’<dd><a name="index-fdump_002dtree_002dccp-681"></a>Dump each function after CCP. The file name is made by appending |
| <samp><span class="file">.ccp</span></samp> to the source file name. |
| |
| <br><dt>‘<samp><span class="samp">storeccp</span></samp>’<dd><a name="index-fdump_002dtree_002dstoreccp-682"></a>Dump each function after STORE-CCP. The file name is made by appending |
| <samp><span class="file">.storeccp</span></samp> to the source file name. |
| |
| <br><dt>‘<samp><span class="samp">pre</span></samp>’<dd><a name="index-fdump_002dtree_002dpre-683"></a>Dump trees after partial redundancy elimination. The file name is made |
| by appending <samp><span class="file">.pre</span></samp> to the source file name. |
| |
| <br><dt>‘<samp><span class="samp">fre</span></samp>’<dd><a name="index-fdump_002dtree_002dfre-684"></a>Dump trees after full redundancy elimination. The file name is made |
| by appending <samp><span class="file">.fre</span></samp> to the source file name. |
| |
| <br><dt>‘<samp><span class="samp">copyprop</span></samp>’<dd><a name="index-fdump_002dtree_002dcopyprop-685"></a>Dump trees after copy propagation. The file name is made |
| by appending <samp><span class="file">.copyprop</span></samp> to the source file name. |
| |
| <br><dt>‘<samp><span class="samp">store_copyprop</span></samp>’<dd><a name="index-fdump_002dtree_002dstore_005fcopyprop-686"></a>Dump trees after store copy-propagation. The file name is made |
| by appending <samp><span class="file">.store_copyprop</span></samp> to the source file name. |
| |
| <br><dt>‘<samp><span class="samp">dce</span></samp>’<dd><a name="index-fdump_002dtree_002ddce-687"></a>Dump each function after dead code elimination. The file name is made by |
| appending <samp><span class="file">.dce</span></samp> to the source file name. |
| |
| <br><dt>‘<samp><span class="samp">mudflap</span></samp>’<dd><a name="index-fdump_002dtree_002dmudflap-688"></a>Dump each function after adding mudflap instrumentation. The file name is |
| made by appending <samp><span class="file">.mudflap</span></samp> to the source file name. |
| |
| <br><dt>‘<samp><span class="samp">sra</span></samp>’<dd><a name="index-fdump_002dtree_002dsra-689"></a>Dump each function after performing scalar replacement of aggregates. The |
| file name is made by appending <samp><span class="file">.sra</span></samp> to the source file name. |
| |
| <br><dt>‘<samp><span class="samp">sink</span></samp>’<dd><a name="index-fdump_002dtree_002dsink-690"></a>Dump each function after performing code sinking. The file name is made |
| by appending <samp><span class="file">.sink</span></samp> to the source file name. |
| |
| <br><dt>‘<samp><span class="samp">dom</span></samp>’<dd><a name="index-fdump_002dtree_002ddom-691"></a>Dump each function after applying dominator tree optimizations. The file |
| name is made by appending <samp><span class="file">.dom</span></samp> to the source file name. |
| |
| <br><dt>‘<samp><span class="samp">dse</span></samp>’<dd><a name="index-fdump_002dtree_002ddse-692"></a>Dump each function after applying dead store elimination. The file |
| name is made by appending <samp><span class="file">.dse</span></samp> to the source file name. |
| |
| <br><dt>‘<samp><span class="samp">phiopt</span></samp>’<dd><a name="index-fdump_002dtree_002dphiopt-693"></a>Dump each function after optimizing PHI nodes into straightline code. The file |
| name is made by appending <samp><span class="file">.phiopt</span></samp> to the source file name. |
| |
| <br><dt>‘<samp><span class="samp">forwprop</span></samp>’<dd><a name="index-fdump_002dtree_002dforwprop-694"></a>Dump each function after forward propagating single use variables. The file |
| name is made by appending <samp><span class="file">.forwprop</span></samp> to the source file name. |
| |
| <br><dt>‘<samp><span class="samp">copyrename</span></samp>’<dd><a name="index-fdump_002dtree_002dcopyrename-695"></a>Dump each function after applying the copy rename optimization. The file |
| name is made by appending <samp><span class="file">.copyrename</span></samp> to the source file name. |
| |
| <br><dt>‘<samp><span class="samp">nrv</span></samp>’<dd><a name="index-fdump_002dtree_002dnrv-696"></a>Dump each function after applying the named return value optimization on |
| generic trees. The file name is made by appending <samp><span class="file">.nrv</span></samp> to the source |
| file name. |
| |
| <br><dt>‘<samp><span class="samp">vect</span></samp>’<dd><a name="index-fdump_002dtree_002dvect-697"></a>Dump each function after applying vectorization of loops. The file name is |
| made by appending <samp><span class="file">.vect</span></samp> to the source file name. |
| |
| <br><dt>‘<samp><span class="samp">slp</span></samp>’<dd><a name="index-fdump_002dtree_002dslp-698"></a>Dump each function after applying vectorization of basic blocks. The file name |
| is made by appending <samp><span class="file">.slp</span></samp> to the source file name. |
| |
| <br><dt>‘<samp><span class="samp">vrp</span></samp>’<dd><a name="index-fdump_002dtree_002dvrp-699"></a>Dump each function after Value Range Propagation (VRP). The file name |
| is made by appending <samp><span class="file">.vrp</span></samp> to the source file name. |
| |
| <br><dt>‘<samp><span class="samp">all</span></samp>’<dd><a name="index-fdump_002dtree_002dall-700"></a>Enable all the available tree dumps with the flags provided in this option. |
| </dl> |
| |
| <br><dt><code>-fopt-info</code><dt><code>-fopt-info-</code><var>options</var><dt><code>-fopt-info-</code><var>options</var><code>=</code><var>filename</var><dd><a name="index-fopt_002dinfo-701"></a>Controls optimization dumps from various optimization passes. If the |
| ‘<samp><span class="samp">-</span><var>options</var></samp>’ form is used, <var>options</var> is a list of |
| ‘<samp><span class="samp">-</span></samp>’ separated options to select the dump details and |
| optimizations. If <var>options</var> is not specified, it defaults to |
| <samp><span class="option">all</span></samp> for details and <samp><span class="option">optall</span></samp> for optimization |
| groups. If the <var>filename</var> is not specified, it defaults to |
| <samp><span class="file">stderr</span></samp>. Note that the output <var>filename</var> will be overwritten |
| in case of multiple translation units. If a combined output from |
| multiple translation units is desired, <samp><span class="file">stderr</span></samp> should be used |
| instead. |
| |
| <p>The options can be divided into two groups, 1) options describing the |
| verbosity of the dump, and 2) 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 latter options override the earlier options on the command |
| line. Though multiple -fopt-info options are accepted, only one of |
| them can have <samp><span class="option">=filename</span></samp>. If other filenames are provided then |
| all but the first one are ignored. |
| |
| <p>The dump verbosity has the following options |
| |
| <dl> |
| <dt>‘<samp><span class="samp">optimized</span></samp>’<dd>Print information when an optimization is successfully applied. It is |
| up to a pass to decide which information is relevant. For example, the |
| vectorizer passes print the source location of loops which got |
| successfully vectorized. |
| <br><dt>‘<samp><span class="samp">missed</span></samp>’<dd>Print information about missed optimizations. Individual passes |
| control which information to include in the output. For example, |
| |
| <pre class="smallexample"> gcc -O2 -ftree-vectorize -fopt-info-vec-missed |
| </pre> |
| <p>will print information about missed optimization opportunities from |
| vectorization passes on stderr. |
| <br><dt>‘<samp><span class="samp">note</span></samp>’<dd>Print verbose information about optimizations, such as certain |
| transformations, more detailed messages about decisions etc. |
| <br><dt>‘<samp><span class="samp">all</span></samp>’<dd>Print detailed optimization information. This includes |
| <var>optimized</var>, <var>missed</var>, and <var>note</var>. |
| </dl> |
| |
| <p>The second set of options describes a group of optimizations and may |
| include one or more of the following. |
| |
| <dl> |
| <dt>‘<samp><span class="samp">ipa</span></samp>’<dd>Enable dumps from all interprocedural optimizations. |
| <br><dt>‘<samp><span class="samp">loop</span></samp>’<dd>Enable dumps from all loop optimizations. |
| <br><dt>‘<samp><span class="samp">inline</span></samp>’<dd>Enable dumps from all inlining optimizations. |
| <br><dt>‘<samp><span class="samp">vec</span></samp>’<dd>Enable dumps from all vectorization optimizations. |
| </dl> |
| |
| <p>For example, |
| <pre class="smallexample"> gcc -O3 -fopt-info-missed=missed.all |
| </pre> |
| <p>outputs missed optimization report from all the passes into |
| <samp><span class="file">missed.all</span></samp>. |
| |
| <p>As another example, |
| <pre class="smallexample"> gcc -O3 -fopt-info-inline-optimized-missed=inline.txt |
| </pre> |
| <p>will output information about missed optimizations as well as |
| optimized locations from all the inlining passes into |
| <samp><span class="file">inline.txt</span></samp>. |
| |
| <p>If the <var>filename</var> is provided, then the dumps from all the |
| applicable optimizations are concatenated into the <samp><span class="file">filename</span></samp>. |
| Otherwise the dump is output onto <samp><span class="file">stderr</span></samp>. If <var>options</var> is |
| omitted, it defaults to <samp><span class="option">all-optall</span></samp>, which means dump all |
| available optimization info from all the passes. In the following |
| example, all optimization info is output on to <samp><span class="file">stderr</span></samp>. |
| |
| <pre class="smallexample"> gcc -O3 -fopt-info |
| </pre> |
| <p>Note that <samp><span class="option">-fopt-info-vec-missed</span></samp> behaves the same as |
| <samp><span class="option">-fopt-info-missed-vec</span></samp>. |
| |
| <p>As another example, consider |
| |
| <pre class="smallexample"> gcc -fopt-info-vec-missed=vec.miss -fopt-info-loop-optimized=loop.opt |
| </pre> |
| <p>Here the two output filenames <samp><span class="file">vec.miss</span></samp> and <samp><span class="file">loop.opt</span></samp> 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 the <samp><span class="file">vec.miss</span></samp> is produced which cotaints |
| dumps from the vectorizer about missed opportunities. |
| |
| <br><dt><code>-ftree-vectorizer-verbose=</code><var>n</var><dd><a name="index-ftree_002dvectorizer_002dverbose-702"></a>This option is deprecated and is implemented in terms of |
| <samp><span class="option">-fopt-info</span></samp>. Please use <samp><span class="option">-fopt-info-</span><var>kind</var></samp> form |
| instead, where <var>kind</var> is one of the valid opt-info options. It |
| prints additional optimization information. For <var>n</var>=0 no |
| diagnostic information is reported. If <var>n</var>=1 the vectorizer |
| reports each loop that got vectorized, and the total number of loops |
| that got vectorized. If <var>n</var>=2 the vectorizer reports locations |
| which could not be vectorized and the reasons for those. For any |
| higher verbosity levels all the analysis and transformation |
| information from the vectorizer is reported. |
| |
| <p>Note that the information output by <samp><span class="option">-ftree-vectorizer-verbose</span></samp> |
| option is sent to <samp><span class="file">stderr</span></samp>. If the equivalent form |
| <samp><span class="option">-fopt-info-</span><var>options</var><span class="option">=</span><var>filename</var></samp> is used then the |
| output is sent into <var>filename</var> instead. |
| |
| <br><dt><code>-frandom-seed=</code><var>string</var><dd><a name="index-frandom_002dseed-703"></a>This option provides a seed that GCC uses in place of |
| random numbers in generating certain symbol names |
| that have to be different in every compiled file. It is also used to |
| place unique stamps in coverage data files and the object files that |
| produce them. You can use the <samp><span class="option">-frandom-seed</span></samp> option to produce |
| reproducibly identical object files. |
| |
| <p>The <var>string</var> should be different for every file you compile. |
| |
| <br><dt><code>-fsched-verbose=</code><var>n</var><dd><a name="index-fsched_002dverbose-704"></a>On targets that use instruction scheduling, this option controls the |
| amount of debugging output the scheduler prints. This information is |
| written to standard error, unless <samp><span class="option">-fdump-rtl-sched1</span></samp> or |
| <samp><span class="option">-fdump-rtl-sched2</span></samp> is specified, in which case it is output |
| to the usual dump listing file, <samp><span class="file">.sched1</span></samp> or <samp><span class="file">.sched2</span></samp> |
| respectively. However for <var>n</var> greater than nine, the output is |
| always printed to standard error. |
| |
| <p>For <var>n</var> greater than zero, <samp><span class="option">-fsched-verbose</span></samp> outputs the |
| same information as <samp><span class="option">-fdump-rtl-sched1</span></samp> and <samp><span class="option">-fdump-rtl-sched2</span></samp>. |
| For <var>n</var> greater than one, it also output basic block probabilities, |
| detailed ready list information and unit/insn info. For <var>n</var> greater |
| than two, it includes RTL at abort point, control-flow and regions info. |
| And for <var>n</var> over four, <samp><span class="option">-fsched-verbose</span></samp> also includes |
| dependence info. |
| |
| <br><dt><code>-save-temps</code><dt><code>-save-temps=cwd</code><dd><a name="index-save_002dtemps-705"></a>Store the usual “temporary” intermediate files permanently; place them |
| in the current directory and name them based on the source file. Thus, |
| compiling <samp><span class="file">foo.c</span></samp> with <samp><span class="option">-c -save-temps</span></samp> produces files |
| <samp><span class="file">foo.i</span></samp> and <samp><span class="file">foo.s</span></samp>, as well as <samp><span class="file">foo.o</span></samp>. This creates a |
| preprocessed <samp><span class="file">foo.i</span></samp> output file even though the compiler now |
| normally uses an integrated preprocessor. |
| |
| <p>When used in combination with the <samp><span class="option">-x</span></samp> command-line option, |
| <samp><span class="option">-save-temps</span></samp> 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 <samp><span class="option">-save-temps</span></samp>. |
| |
| <p>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: |
| |
| <pre class="smallexample"> gcc -save-temps -o outdir1/foo.o indir1/foo.c& |
| gcc -save-temps -o outdir2/foo.o indir2/foo.c& |
| </pre> |
| <p>may result in <samp><span class="file">foo.i</span></samp> and <samp><span class="file">foo.o</span></samp> being written to |
| simultaneously by both compilers. |
| |
| <br><dt><code>-save-temps=obj</code><dd><a name="index-save_002dtemps_003dobj-706"></a>Store the usual “temporary” intermediate files permanently. If the |
| <samp><span class="option">-o</span></samp> option is used, the temporary files are based on the |
| object file. If the <samp><span class="option">-o</span></samp> option is not used, the |
| <samp><span class="option">-save-temps=obj</span></samp> switch behaves like <samp><span class="option">-save-temps</span></samp>. |
| |
| <p>For example: |
| |
| <pre class="smallexample"> 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 |
| </pre> |
| <p class="noindent">creates <samp><span class="file">foo.i</span></samp>, <samp><span class="file">foo.s</span></samp>, <samp><span class="file">dir/xbar.i</span></samp>, |
| <samp><span class="file">dir/xbar.s</span></samp>, <samp><span class="file">dir2/yfoobar.i</span></samp>, <samp><span class="file">dir2/yfoobar.s</span></samp>, and |
| <samp><span class="file">dir2/yfoobar.o</span></samp>. |
| |
| <br><dt><code>-time</code><span class="roman">[</span><code>=</code><var>file</var><span class="roman">]</span><dd><a name="index-time-707"></a>Report the CPU time taken by each subprocess in the compilation |
| sequence. For C source files, this is the compiler proper and assembler |
| (plus the linker if linking is done). |
| |
| <p>Without the specification of an output file, the output looks like this: |
| |
| <pre class="smallexample"> # cc1 0.12 0.01 |
| # as 0.00 0.01 |
| </pre> |
| <p>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. |
| |
| <p>With the specification of an output file, the output is appended to the |
| named file, and it looks like this: |
| |
| <pre class="smallexample"> 0.12 0.01 cc1 <var>options</var> |
| 0.00 0.01 as <var>options</var> |
| </pre> |
| <p>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. |
| |
| <br><dt><code>-fvar-tracking</code><dd><a name="index-fvar_002dtracking-708"></a>Run variable tracking pass. It computes where variables are stored at each |
| position in code. Better debugging information is then generated |
| (if the debugging information format supports this information). |
| |
| <p>It is enabled by default when compiling with optimization (<samp><span class="option">-Os</span></samp>, |
| <samp><span class="option">-O</span></samp>, <samp><span class="option">-O2</span></samp>, <small class="dots">...</small>), debugging information (<samp><span class="option">-g</span></samp>) and |
| the debug info format supports it. |
| |
| <br><dt><code>-fvar-tracking-assignments</code><dd><a name="index-fvar_002dtracking_002dassignments-709"></a><a name="index-fno_002dvar_002dtracking_002dassignments-710"></a>Annotate assignments to user variables early in the compilation and |
| attempt to carry the annotations over throughout the compilation all the |
| way to the end, in an attempt to improve debug information while |
| optimizing. Use of <samp><span class="option">-gdwarf-4</span></samp> is recommended along with it. |
| |
| <p>It can be enabled even if var-tracking is disabled, in which case |
| annotations are created and maintained, but discarded at the end. |
| |
| <br><dt><code>-fvar-tracking-assignments-toggle</code><dd><a name="index-fvar_002dtracking_002dassignments_002dtoggle-711"></a><a name="index-fno_002dvar_002dtracking_002dassignments_002dtoggle-712"></a>Toggle <samp><span class="option">-fvar-tracking-assignments</span></samp>, in the same way that |
| <samp><span class="option">-gtoggle</span></samp> toggles <samp><span class="option">-g</span></samp>. |
| |
| <br><dt><code>-print-file-name=</code><var>library</var><dd><a name="index-print_002dfile_002dname-713"></a>Print the full absolute name of the library file <var>library</var> that |
| would be used when linking—and don't do anything else. With this |
| option, GCC does not compile or link anything; it just prints the |
| file name. |
| |
| <br><dt><code>-print-multi-directory</code><dd><a name="index-print_002dmulti_002ddirectory-714"></a>Print the directory name corresponding to the multilib selected by any |
| other switches present in the command line. This directory is supposed |
| to exist in <samp><span class="env">GCC_EXEC_PREFIX</span></samp>. |
| |
| <br><dt><code>-print-multi-lib</code><dd><a name="index-print_002dmulti_002dlib-715"></a>Print the mapping from multilib directory names to compiler switches |
| that enable them. The directory name is separated from the switches by |
| ‘<samp><span class="samp">;</span></samp>’, and each switch starts with an ‘<samp><span class="samp">@</span></samp>’ instead of the |
| ‘<samp><span class="samp">-</span></samp>’, without spaces between multiple switches. This is supposed to |
| ease shell processing. |
| |
| <br><dt><code>-print-multi-os-directory</code><dd><a name="index-print_002dmulti_002dos_002ddirectory-716"></a>Print the path to OS libraries for the selected |
| multilib, relative to some <samp><span class="file">lib</span></samp> subdirectory. If OS libraries are |
| present in the <samp><span class="file">lib</span></samp> subdirectory and no multilibs are used, this is |
| usually just <samp><span class="file">.</span></samp>, if OS libraries are present in <samp><span class="file">lib</span><var>suffix</var></samp> |
| sibling directories this prints e.g. <samp><span class="file">../lib64</span></samp>, <samp><span class="file">../lib</span></samp> or |
| <samp><span class="file">../lib32</span></samp>, or if OS libraries are present in <samp><span class="file">lib/</span><var>subdir</var></samp> |
| subdirectories it prints e.g. <samp><span class="file">amd64</span></samp>, <samp><span class="file">sparcv9</span></samp> or <samp><span class="file">ev6</span></samp>. |
| |
| <br><dt><code>-print-multiarch</code><dd><a name="index-print_002dmultiarch-717"></a>Print the path to OS libraries for the selected multiarch, |
| relative to some <samp><span class="file">lib</span></samp> subdirectory. |
| |
| <br><dt><code>-print-prog-name=</code><var>program</var><dd><a name="index-print_002dprog_002dname-718"></a>Like <samp><span class="option">-print-file-name</span></samp>, but searches for a program such as ‘<samp><span class="samp">cpp</span></samp>’. |
| |
| <br><dt><code>-print-libgcc-file-name</code><dd><a name="index-print_002dlibgcc_002dfile_002dname-719"></a>Same as <samp><span class="option">-print-file-name=libgcc.a</span></samp>. |
| |
| <p>This is useful when you use <samp><span class="option">-nostdlib</span></samp> or <samp><span class="option">-nodefaultlibs</span></samp> |
| but you do want to link with <samp><span class="file">libgcc.a</span></samp>. You can do: |
| |
| <pre class="smallexample"> gcc -nostdlib <var>files</var>... `gcc -print-libgcc-file-name` |
| </pre> |
| <br><dt><code>-print-search-dirs</code><dd><a name="index-print_002dsearch_002ddirs-720"></a>Print the name of the configured installation directory and a list of |
| program and library directories <samp><span class="command">gcc</span></samp> searches—and don't do anything else. |
| |
| <p>This is useful when <samp><span class="command">gcc</span></samp> prints the error message |
| ‘<samp><span class="samp">installation problem, cannot exec cpp0: No such file or directory</span></samp>’. |
| To resolve this you either need to put <samp><span class="file">cpp0</span></samp> and the other compiler |
| components where <samp><span class="command">gcc</span></samp> expects to find them, or you can set the environment |
| variable <samp><span class="env">GCC_EXEC_PREFIX</span></samp> to the directory where you installed them. |
| Don't forget the trailing ‘<samp><span class="samp">/</span></samp>’. |
| See <a href="Environment-Variables.html#Environment-Variables">Environment Variables</a>. |
| |
| <br><dt><code>-print-sysroot</code><dd><a name="index-print_002dsysroot-721"></a>Print the target sysroot directory that is used during |
| compilation. This is the target sysroot specified either at configure |
| time or using the <samp><span class="option">--sysroot</span></samp> option, possibly with an extra |
| suffix that depends on compilation options. If no target sysroot is |
| specified, the option prints nothing. |
| |
| <br><dt><code>-print-sysroot-headers-suffix</code><dd><a name="index-print_002dsysroot_002dheaders_002dsuffix-722"></a>Print the suffix added to the target sysroot when searching for |
| headers, or give an error if the compiler is not configured with such |
| a suffix—and don't do anything else. |
| |
| <br><dt><code>-dumpmachine</code><dd><a name="index-dumpmachine-723"></a>Print the compiler's target machine (for example, |
| ‘<samp><span class="samp">i686-pc-linux-gnu</span></samp>’)—and don't do anything else. |
| |
| <br><dt><code>-dumpversion</code><dd><a name="index-dumpversion-724"></a>Print the compiler version (for example, ‘<samp><span class="samp">3.0</span></samp>’)—and don't do |
| anything else. |
| |
| <br><dt><code>-dumpspecs</code><dd><a name="index-dumpspecs-725"></a>Print the compiler's built-in specs—and don't do anything else. (This |
| is used when GCC itself is being built.) See <a href="Spec-Files.html#Spec-Files">Spec Files</a>. |
| |
| <br><dt><code>-fno-eliminate-unused-debug-types</code><dd><a name="index-feliminate_002dunused_002ddebug_002dtypes-726"></a><a name="index-fno_002deliminate_002dunused_002ddebug_002dtypes-727"></a>Normally, when producing DWARF 2 output, GCC avoids producing debug symbol |
| output for types that are nowhere used in the source file being compiled. |
| Sometimes it is useful to have GCC emit debugging |
| information for all types declared in a compilation |
| unit, regardless of whether or not they are actually used |
| in that compilation unit, for example |
| if, in the debugger, you want to cast a value to a type that is |
| not actually used in your program (but is declared). More often, |
| however, this results in a significant amount of wasted space. |
| </dl> |
| |
| </body></html> |
| |