GNU project C and C++ compiler
-g  Produce debugging information in the operating system's native format (stabs, COFF, XCOFF, or DWARF
    2).  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).

    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, PowerPC and SPARC.

    Position-independent code requires special support, and therefore works only on certain machines.

    When this flag is set, the macros "__pic__" and "__PIC__" are defined to 2.
-Wall
    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 and Objective-C++
    Dialect Options.

    -Wall turns on the following warning flags:

    -Waddress -Warray-bounds (only with -O2) -Wc++0x-compat -Wchar-subscripts -Wenum-compare (in C/Objc;
    this is on by default in C++) -Wimplicit-int (C and Objective-C only) -Wimplicit-function-declaration
    (C and Objective-C only) -Wcomment -Wformat -Wmain (only for C/ObjC and unless -ffreestanding)
    -Wmissing-braces -Wnonnull -Wparentheses -Wpointer-sign -Wreorder -Wreturn-type -Wsequence-point
    -Wsign-compare (only in C++) -Wstrict-aliasing -Wstrict-overflow=1 -Wswitch -Wtrigraphs
    -Wuninitialized -Wunknown-pragmas -Wunused-function -Wunused-label -Wunused-value -Wunused-variable
    -Wvolatile-register-var

    Note that some warning flags 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. Some of them are enabled by -Wextra but many
    of them must be enabled individually.
-Werror
    Make all warnings into errors.
-Wextra
    This enables some extra warning flags that are not enabled by -Wall. (This option used to be called
    -W.  The older name is still supported, but the newer name is more descriptive.)
-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 -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, a precompiled header file in
    source.suffix.gch, and all preprocessed C source on standard output.
source manpages: gcc