GNU project C and C++ compiler
-g  Produce debugging information in the operating system's native format (stabs, COFF, XCOFF, or DWARF).
    GDB can work with this debugging information.

    On most systems that use stabs format, -g enables use of extra debugging information that only GDB
    can use; this extra information makes debugging work better in GDB but will probably make other
    debuggers crash or refuse to read the program.  If you want to control for certain whether to
    generate the extra information, use -gstabs+, -gstabs, -gxcoff+, -gxcoff, or -gvms (see below).

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

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

    The following options are useful when GCC is generated with the capability for more than one
    debugging format.
-fPIC
    If supported for the target machine, emit position-independent code, suitable for dynamic linking and
    avoiding any limit on the size of the global offset table.  This option makes a difference on the
    m68k and the SPARC.

    Position-independent code requires special support, and therefore works only on certain machines.
-Wall
    All of the above -W options combined.  This enables all the warnings about constructions that some
    users consider questionable, and that are easy to avoid (or modify to prevent the warning), even in
    conjunction with macros.  This also enables some language-specific warnings described in C++ Dialect
    Options and Objective-C Dialect Options.

The following -W... options are not implied by -Wall.  Some of them warn about constructions that users
generally do not consider questionable, but which occasionally you might wish to check for; others warn
about constructions that are necessary or hard to avoid in some cases, and there is no simple way to
modify the code to suppress the warning.
    -Werror
        Make all warnings into errors.

Options for Debugging Your Program or GCC
    GCC has various special options that are used for debugging either your program or GCC:
-Wextra
    (This option used to be called -W.  The older name is still supported, but the newer name is more
    descriptive.)  Print extra warning messages for these events:
-pedantic
    Issue all the warnings demanded by strict ISO C and ISO C++; reject all programs that use forbidden
    extensions, and some other programs that do not follow ISO C and ISO C++.  For ISO C, follows the
    version of the ISO C standard specified by any -std option used.
-shared
    Produce a shared object which can then be linked with other objects to form an executable.  Not all
    systems support this option.  For predictable results, you must also specify the same set of options
    that were used to generate code (-fpic, -fPIC, or model suboptions) when you specify this option.[1]
-o file
    Place output in file file.  This applies regardless to whatever sort of output is being produced,
    whether it be an executable file, an object file, an assembler file or preprocessed C code.

    If you specify -o when compiling more than one input file, or you are producing an executable file as
    output, all the source files on the command line will be compiled at once.

    If -o is not specified, the default is to put an executable file in a.out, the object file for
    source.suffix in source.o, its assembler file in source.s, and all preprocessed C source on standard
    output.
source manpages: h8300-hitachi-coff-g++