manpagez: man pages & more
info gcc
Home | html | info | man
[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

3.2 Options Controlling the Kind of Output

Compilation can involve up to four stages: preprocessing, compilation proper, assembly and linking, always in that order. GCC is capable of preprocessing and compiling several files either into several assembler input files, or into one assembler input file; then each assembler input file produces an object file, and linking combines all the object files (those newly compiled, and those specified as input) into an executable file.

For any given input file, the file name suffix determines what kind of compilation is done:

@gcctabopt file.c

C source code that must be preprocessed.

@gcctabopt file.i

C source code that should not be preprocessed.

@gcctabopt file.ii

C++ source code that should not be preprocessed.

@gcctabopt file.m

Objective-C source code. Note that you must link with the ‘libobjc’ library to make an Objective-C program work.

@gcctabopt file.mi

Objective-C source code that should not be preprocessed.

@gcctabopt file.mm
@gcctabopt file.M

Objective-C++ source code. Note that you must link with the ‘libobjc’ library to make an Objective-C++ program work. Note that ‘.M’ refers to a literal capital M.

@gcctabopt file.mii

Objective-C++ source code that should not be preprocessed.

@gcctabopt file.h

C, C++, Objective-C or Objective-C++ header file to be turned into a precompiled header (default), or C, C++ header file to be turned into an Ada spec (via the ‘-fdump-ada-spec’ switch).

@gcctabopt file.cc
@gcctabopt file.cp
@gcctabopt file.cxx
@gcctabopt file.cpp
@gcctabopt file.CPP
@gcctabopt file.c++
@gcctabopt file.C

C++ source code that must be preprocessed. Note that in ‘.cxx’, the last two letters must both be literally ‘x’. Likewise, ‘.C’ refers to a literal capital C.

@gcctabopt file.mm
@gcctabopt file.M

Objective-C++ source code that must be preprocessed.

@gcctabopt file.mii

Objective-C++ source code that should not be preprocessed.

@gcctabopt file.hh
@gcctabopt file.H
@gcctabopt file.hp
@gcctabopt file.hxx
@gcctabopt file.hpp
@gcctabopt file.HPP
@gcctabopt file.h++
@gcctabopt file.tcc

C++ header file to be turned into a precompiled header or Ada spec.

@gcctabopt file.f
@gcctabopt file.for
@gcctabopt file.ftn

Fixed form Fortran source code that should not be preprocessed.

@gcctabopt file.F
@gcctabopt file.FOR
@gcctabopt file.fpp
@gcctabopt file.FPP
@gcctabopt file.FTN

Fixed form Fortran source code that must be preprocessed (with the traditional preprocessor).

@gcctabopt file.f90
@gcctabopt file.f95
@gcctabopt file.f03
@gcctabopt file.f08

Free form Fortran source code that should not be preprocessed.

@gcctabopt file.F90
@gcctabopt file.F95
@gcctabopt file.F03
@gcctabopt file.F08

Free form Fortran source code that must be preprocessed (with the traditional preprocessor).

@gcctabopt file.go

Go source code.

@gcctabopt file.ads

Ada source code file that contains a library unit declaration (a declaration of a package, subprogram, or generic, or a generic instantiation), or a library unit renaming declaration (a package, generic, or subprogram renaming declaration). Such files are also called specs.

@gcctabopt file.adb

Ada source code file containing a library unit body (a subprogram or package body). Such files are also called bodies.

@gcctabopt file.s

Assembler code.

@gcctabopt file.S
@gcctabopt file.sx

Assembler code that must be preprocessed.

@gcctabopt other

An object file to be fed straight into linking. Any file name with no recognized suffix is treated this way.

You can specify the input language explicitly with the ‘-x’ option:

@gcctabopt -x language

Specify explicitly the language for the following input files (rather than letting the compiler choose a default based on the file name suffix). This option applies to all following input files until the next ‘-x’ option. Possible values for language are:

c  c-header  cpp-output
c++  c++-header  c++-cpp-output
objective-c  objective-c-header  objective-c-cpp-output
objective-c++ objective-c++-header objective-c++-cpp-output
assembler  assembler-with-cpp
ada
f77  f77-cpp-input f95  f95-cpp-input
go
java
@gcctabopt -x none

Turn off any specification of a language, so that subsequent files are handled according to their file name suffixes (as they are if ‘-x’ has not been used at all).

@gcctabopt -pass-exit-codes

Normally the gcc program will exit with the code of 1 if any phase of the compiler returns a non-success return code. If you specify ‘-pass-exit-codes’, the gcc program will instead return with numerically highest error produced by any phase that returned an error indication. The C, C++, and Fortran frontends return 4, if an internal compiler error is encountered.

If you only want some of the stages of compilation, you can use ‘-x’ (or filename suffixes) to tell gcc where to start, and one of the options ‘-c’, ‘-S’, or ‘-E’ to say where gcc is to stop. Note that some combinations (for example, ‘-x cpp-output -E’) instruct gcc to do nothing at all.

@gcctabopt -c

Compile or assemble the source files, but do not link. The linking stage simply is not done. The ultimate output is in the form of an object file for each source file.

By default, the object file name for a source file is made by replacing the suffix ‘.c’, ‘.i’, ‘.s’, etc., with ‘.o’.

Unrecognized input files, not requiring compilation or assembly, are ignored.

@gcctabopt -S

Stop after the stage of compilation proper; do not assemble. The output is in the form of an assembler code file for each non-assembler input file specified.

By default, the assembler file name for a source file is made by replacing the suffix ‘.c’, ‘.i’, etc., with ‘.s’.

Input files that don’t require compilation are ignored.

@gcctabopt -E

Stop after the preprocessing stage; do not run the compiler proper. The output is in the form of preprocessed source code, which is sent to the standard output.

Input files that don’t require preprocessing are ignored.

@gcctabopt -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.

@gcctabopt -v

Print (on standard error output) the commands executed to run the stages of compilation. Also print the version number of the compiler driver program and of the preprocessor and the compiler proper.

@gcctabopt -###

Like ‘-v’ except the commands are not executed and arguments are quoted unless they contain only alphanumeric characters or ./-_. This is useful for shell scripts to capture the driver-generated command lines.

@gcctabopt -pipe

Use pipes rather than temporary files for communication between the various stages of compilation. This fails to work on some systems where the assembler is unable to read from a pipe; but the GNU assembler has no trouble.

@gcctabopt –help

Print (on the standard output) a description of the command-line options understood by gcc. If the ‘-v’ option is also specified then ‘--help’ will also be passed on to the various processes invoked by gcc, so that they can display the command-line options they accept. If the ‘-Wextra’ option has also been specified (prior to the ‘--help’ option), then command-line options that have no documentation associated with them will also be displayed.

@gcctabopt –target-help

Print (on the standard output) a description of target-specific command-line options for each tool. For some targets extra target-specific information may also be printed.

@gcctabopt –help={class|[^]qualifier}[,…]

Print (on the standard output) a description of the command-line options understood by the compiler that fit into all specified classes and qualifiers. These are the supported classes:

optimizers

This will display all of the optimization options supported by the compiler.

warnings

This will display all of the options controlling warning messages produced by the compiler.

target

This will display target-specific options. Unlike the ‘--target-help’ option however, target-specific options of the linker and assembler will not be displayed. This is because those tools do not currently support the extended ‘--help=’ syntax.

params

This will display the values recognized by the ‘--param’ option.

language

This will display the options supported for language, where language is the name of one of the languages supported in this version of GCC.

common

This will display the options that are common to all languages.

These are the supported qualifiers:

undocumented

Display only those options that are undocumented.

joined

Display options taking an argument that appears after an equal sign in the same continuous piece of text, such as: ‘--help=target’.

separate

Display options taking an argument that appears as a separate word following the original option, such as: ‘-o output-file’.

Thus for example to display all the undocumented target-specific switches supported by the compiler the following can be used:

--help=target,undocumented

The sense of a qualifier can be inverted by prefixing it with the ‘^’ character, so for example to display all binary warning options (i.e., ones that are either on or off and that do not take an argument) that have a description, use:

--help=warnings,^joined,^undocumented

The argument to ‘--help=’ should not consist solely of inverted qualifiers.

Combining several classes is possible, although this usually restricts the output by so much that there is nothing to display. One case where it does work however is when one of the classes is target. So for example to display all the target-specific optimization options the following can be used:

--help=target,optimizers

The ‘--help=’ option can be repeated on the command line. Each successive use will display its requested class of options, skipping those that have already been displayed.

If the ‘-Q’ option appears on the command line before the ‘--help=’ option, then the descriptive text displayed by ‘--help=’ is changed. Instead of describing the displayed options, an indication is given as to whether the option is enabled, disabled or set to a specific value (assuming that the compiler knows this at the point where the ‘--help=’ option is used).

Here is a truncated example from the ARM port of gcc:

  % gcc -Q -mabi=2 --help=target -c
  The following options are target specific:
  -mabi=                                2
  -mabort-on-noreturn                   [disabled]
  -mapcs                                [disabled]

The output is sensitive to the effects of previous command-line options, so for example it is possible to find out which optimizations are enabled at ‘-O2’ by using:

-Q -O2 --help=optimizers

Alternatively you can discover which binary optimizations are enabled by ‘-O3’ by using:

gcc -c -Q -O3 --help=optimizers > /tmp/O3-opts
gcc -c -Q -O2 --help=optimizers > /tmp/O2-opts
diff /tmp/O2-opts /tmp/O3-opts | grep enabled
@gcctabopt -no-canonical-prefixes

Do not expand any symbolic links, resolve references to ‘/../’ or ‘/./’, or make the path absolute when generating a relative prefix.

@gcctabopt –version

Display the version number and copyrights of the invoked GCC.

@gcctabopt -wrapper

Invoke all subcommands under a wrapper program. The name of the wrapper program and its parameters are passed as a comma separated list.

gcc -c t.c -wrapper gdb,--args

This will invoke all subprograms of gcc under ‘gdb --args’, thus the invocation of cc1 will be ‘gdb --args cc1 …’.

@gcctabopt -fplugin=name.so

Load the plugin code in file name.so, assumed to be a shared object to be dlopen’d by the compiler. The base name of the shared object file is used to identify the plugin for the purposes of argument parsing (See ‘-fplugin-arg-name-key=value’ below). Each plugin should define the callback functions specified in the Plugins API.

@gcctabopt -fplugin-arg-name-key=value

Define an argument called key with a value of value for the plugin called name.

@gcctabopt -fdump-ada-spec[-slim]

For C and C++ source and include files, generate corresponding Ada specs. See Generating Ada Bindings for C and C++ headers in GNAT User’s Guide, which provides detailed documentation on this feature.

@gcctabopt -fdump-go-spec=file

For input files in any language, generate corresponding Go declarations in file. This generates Go const, type, var, and func declarations which may be a useful way to start writing a Go interface to code written in some other language.


[ << ] [ < ] [ Up ] [ > ] [ >> ]         [Top] [Contents] [Index] [ ? ]

This document was generated on June 14, 2014 using texi2html 5.0.

© manpagez.com 2000-2025
Individual documents may contain additional copyright information.