gcc(1) gcc 5.4R3.00 gcc(1)
NAME
gcc - GNU C language compiler
SYNOPSIS
gcc [ option ] ... file ...
DESCRIPTION
The GNU C compiler uses a command syntax much like the Unix C
compiler. The gcc program accepts options and file names as
operands. Multiple single-letter options may not be grouped: `-dr'
is very different from `-d -r'. When you invoke gcc, it normally
does preprocessing, compilation, assembly and linking. File names
that end in .c are taken as C source to be preprocessed and compiled;
compiler output files plus any input files with names ending in .s
are assembled; then the resulting object files, plus any other input
files, are linked together to produce an executable. Command options
allow you to stop this process at an intermediate stage. For
example, the -c option says not to run the link editor. Then the
output consists of object files output by the assembler. Other
command options are passed on to one stage. Some options control the
preprocessor and others the compiler itself.
Many options have long names starting with -f or with -W: for
example, -fforce-mem, -fstrength-reduce, -Wformat and so on. Most of
these have both positive and negative forms; the negative form of
-ffoo would be -fno-foo. Only one of these two forms is documented
here, whichever one is not the default.
OPTIONS
Here are the options to control the overall compilation process,
including those that say whether to link, whether to assemble, and so
on.
-V version
The argument version specifies which version of GNU C to run.
This is useful when multiple versions are installed. For
example, version might be 2, meaning to run GNU C version 2.
-c Compile or assemble the source files, but do not link. Produce
object files with names made by replacing .c or .s with .o at the
end of the input file names. Do nothing at all for object files
specified as input.
-S Compile into assembler code but do not assemble. The assembler
output file name is made by replacing .c with .s at the end of
the input file name. Do nothing at all for assembler source
files or object files specified as input.
-E Run only the C preprocessor. Preprocess all the C source files
specified and output the results to standard output.
-o file
Place output in file file. This applies to any output being
produced, whether it be an executable file, an object file, an
Licensed material--property of copyright holder(s) 1
gcc(1) gcc 5.4R3.00 gcc(1)
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.c in source.o, an assembler file in source.s, and
preprocessed C on standard output.
-v Compiler driver program prints the commands it executes as it
runs the preprocessor, compiler proper, assembler and link
editor. Some of these are directed to print their own version
numbers.
-pipe
Run preprocessor, compiler, and assembler in parallel, connected
via pipelines. You should not use this option if your system
does not have enough physical memory to support all four
processes simultaneously.
Options Controlling Language
These options determine the dialect of C that the compiler accepts:
-ansi
Support all ANSI standard C programs. This turns off certain
features of GNU C that are incompatible with ANSI C, such as the
asm, inline and typeof keywords, and predefined macros such as
unix that identify the type of system you are using. It also
enables the rarely-used ANSI trigraph feature.
The alternate keywords asm, inline and typeof
continue to work despite -ansi. You would not want to use them
in an ANSI C program, of course, but it useful to put them in
header files that might be included in compilations done with
-ansi. Alternate predefined macros such as unix are also
available, with or without -ansi.
The -ansi option does not cause non-ANSI programs to be rejected
gratuitously. For that, -pedantic is required in addition to
-ansi. The macro STRICTANSI is predefined when the -ansi
option is used. Some header files may notice this macro and
refrain from declaring certain functions or defining certain
macros that the ANSI standard doesn't call for; this is to avoid
interfering with any programs that might use these names for
other things.
-fno-asm
Do not recognize asm, inline or typeof as a keyword. These words
may then be used as identifiers. You can use asm, inline
and typeof instead. -ansi implies -fno-asm.
-fno-builtin
Don't recognize built-in functions that do not begin with two
leading underscores. Currently, the functions affected include
alloca, abort, exit, exit, abs, fabs, labs, memcpy, memcmp,
strcmp, strcpy, strlen, and sqrt.
Licensed material--property of copyright holder(s) 2
gcc(1) gcc 5.4R3.00 gcc(1)
The -ansi option prevents alloca and exit from being builtin
functions.
-trigraphs
Support ANSI C trigraphs. The -ansi option also has this effect.
-traditional
Attempt to support some aspects of traditional C compilers.
Specifically:
* All extern declarations take effect globally even if they are
written inside a function definition. This includes implicit
declarations of functions.
* The keywords typeof, inline, signed, const and volatile are
not recognized. (You can still use the alternative keywords
such as typeof, inline, and so on.)
* Comparisons between pointers and integers are always allowed.
* Integer types unsigned short and unsigned char promote to
unsigned int.
* Out-of-range floating point literals are not an error.
* String ``constants'' are not necessarily constant; they are
stored in writable space, and identical looking constants are
allocated separately. (This is the same as the effect of
-fwritable-strings.)
* All automatic variables not declared register are preserved by
longjmp. Ordinarily, GNU C follows ANSI C: automatic
variables not declared volatile may be clobbered.
* In the preprocessor, comments convert to nothing at all,
rather than to a space. This allows traditional token
concatenation.
* In the preprocessor, macro arguments are recognized within
string constants in a macro definition (and their values are
stringified, though without additional quote marks, when they
appear in such a context). The preprocessor also considers a
string constant to end at a newline.
* The predefined macro STDC is not defined when you use
-traditional, but GNUC is (since the GNU extensions which
GNUC indicates are not affected by -traditional). If you
need to write header files that work differently depending on
whether -traditional is in use, by testing both of these
predefined macros you can distinguish four situations: GNU C,
traditional GNU C, other ANSI C compilers, and other old C
compilers.
You may wish to use -fno-builtin as well as -traditional if your
Licensed material--property of copyright holder(s) 3
gcc(1) gcc 5.4R3.00 gcc(1)
program uses names that are normally GNU C builtin functions for
other purposes of its own.
-traditional-cpp
Attempt to support some aspects of traditional C preprocessors.
This includes the last three items in the list immediately above,
but none of the other effects of -traditional.
-fcond-mismatch
Allow conditional expressions with mismatched types in the second
and third arguments. The value of such an expression is void.
-funsigned-char
Let the type char be unsigned, like unsigned char. The type char
is always a distinct type from either signed char or unsigned
char, even though its behavior is always just like one of those
two.
-fsigned-char
Let the type char be signed, like signed char.
Note that this is equivalent to -fno-unsigned-char, which is the
negative form of -funsigned-char. Likewise, -fno-signed-char is
equivalent to -funsigned-char.
-fwritable-strings
Store string constants in the writable data segment and represent
identical strings distinctly (don't share storage). This is for
compatibility with old programs which assume they can write into
string constants. -traditional also has this effect.
Options to Request or Suppress Warnings
-fsyntax-only
Check the code for syntax errors, but don't output code. To
suppress all output, you may want to add -S -o /dev/null.
-w Inhibit all warning messages.
-Wno-import
Inhibit warning messages about the use of #import.
-pedantic
Issue all the warnings demanded by strict ANSI standard C; reject
all programs that use forbidden extensions. Valid ANSI standard
C programs should compile properly with or without this option
(though a rare few will require -ansi). However, without this
option, certain GNU extensions and traditional C features are
supported as well. With this option, they are rejected.
-pedantic does not cause warning messages for use of the
alternate keywords whose names begin and end with . Pedantic
warnings are also disabled in the expression that follows
extension. However, only system header files should use
Licensed material--property of copyright holder(s) 4
gcc(1) gcc 5.4R3.00 gcc(1)
these escape routes; application programs should avoid them.
-pedantic-errors
Like -pedantic, except that errors are produced rather than
warnings.
-Werror
Treat warnings as errors.
-W Print extra warning messages for these events:
* A nonvolatile automatic variable might be changed by a call to
longjmp. These warnings as well are possible only in
optimizing compilation. The compiler sees only the calls to
setjmp. It cannot know where longjmp will be called; in fact,
a signal handler could call it at any point in the code. As a
result, you may get a warning even when there is in fact no
problem because longjmp cannot in fact be called at the place
which would cause a problem.
* A function can return either with or without a value.
(Falling off the end of the function body is considered
returning without a value.) Spurious warnings can occur
because GNU C does not realize that certain functions
(including abort and longjmp) will never return.
* An expression-statement contains no side effects.
* An unsigned value is compared against zero with > or <=.
* A comparison like x<=y<=z appears; this is equivalent to (x<=y
? 1 : 0) <= z, which is a different interpretation from that
of ordinary mathematical notation. (V2 only)
* Storage-class specifiers like static are not the first things
in a declaration. According to the C Standard, this usage is
obsolescent. (V2 only)
* An aggregate has a partly bracketed initializer (V2 only).
For example, the following code would evoke such a warning,
because braces are missing around the initializer for x.h:
struct s { int f, g; };
struct t { struct s h; int i; };
struct t x = { 1, 2, 3 };
-Wimplicit
Warn whenever a function is implicitly declared.
-Wreturn-type
Warn whenever a function is defined with a return-type that
defaults to int. Also warn about any return statement with no
return-value in a function whose return-type is not void.
Licensed material--property of copyright holder(s) 5
gcc(1) gcc 5.4R3.00 gcc(1)
-Wunused
Warn whenever a local variable is unused aside from its
declaration, whenever a function is declared static but never
defined, and whenever a statement computes a result that is
explicitly not used.
-Wswitch
Warn whenever a switch statement has an index of enumeral type
and lacks a case for one or more of the named codes of that
enumeration. (The presence of a default label prevents this
warning.) `case' labels outside the enumeration range also
provoke warnings when this option is used.
-Wcomment
Warn whenever a comment-start sequence `/*' appears in a comment.
-Wtrigraphs
Warn if any trigraphs are encountered (assuming they are
enabled).
-Waggregate-return
Warn if any functions that return structures or unions are
defined or called.
-Wformat
Check calls to printf and scanf, etc., to make sure that the
arguments supplied have types appropriate to the format string
specified.
-Wchar-subscripts
Warn if an array subscript has type char. This is a common cause
of error, as programmers often forget that this type is signed on
some machines.
-Wuninitialized
An automatic variable is used without first being initialized.
These warnings are possible only in optimizing compilation,
because they require data flow information that is computed only
when optimizing. If you don't specify -O, you simply won't get
these warnings.
These warnings occur only for variables that are candidates for
register allocation. Therefore, they do not occur for a variable
that is declared volatile, or whose address is taken, or whose
size is other than 1, 2, 4 or 8 bytes. Also, they do not occur
for structures, unions or arrays, even when they are in
registers.
Note that there may be no warning about a variable that is used
only to compute a value that itself is never used, because such
computations may be deleted by data flow analysis before the
warnings are printed. These warnings are made optional because
GNU C is not smart enough to see all the reasons why the code
might be correct despite appearing to have an error.
Licensed material--property of copyright holder(s) 6
gcc(1) gcc 5.4R3.00 gcc(1)
-Wparentheses
Warn if parentheses are omitted in certain contexts.
-Wall
All of the above -W options combined.
The remaining -W... options are not implied by -Wall because they
warn about constructions that we consider reasonable to use, on
occasion, in clean programs.
-Wtraditional
Warn about certain constructs that behave differently in
traditional and ANSI C.
* Macro arguments occurring within string constants in the macro
body. These would substitute the argument in traditional C,
but are part of the constant in ANSI C.
* A function declared external in one block and then used after
the end of the block.
* A switch statement has an operand of type long.
-Wshadow
Warn whenever a local variable shadows another local variable.
-Wid-clash-len
Warn whenever two distinct identifiers match in the first len
characters.
-Wpointer-arith
Warn about anything that depends on the ``size of'' a function
type or of void. GNU C assigns these types a size of 1, for
convenience in calculations with void * pointers and pointers to
functions.
-Wcast-qual
Warn whenever a pointer is cast so as to remove a type qualifier
from the target type. For example, warn if a const char * is
cast to an ordinary char *.
-Wcast-align
Warn whenever a pointer is cast such that the required alignment
of the target is increased. For example, warn if a char * is
cast to an int * on machines where integers can only be accessed
at two- or four-byte boundaries.
-Wwrite-strings
Give string constants the type const char[length] so that copying
the address of one into a non-const char * pointer will get a
warning. These warnings will help you find at compile time code
that can try to write into a string constant, but only if you
have been very careful about using const in declarations and
prototypes. Otherwise, it will just be a nuisance; this is why
Licensed material--property of copyright holder(s) 7
gcc(1) gcc 5.4R3.00 gcc(1)
-Wall does not request these warnings.
-Wconversion
Warn if a prototype causes a type conversion that is different
from what would happen to the same argument in the absence of a
prototype. This includes conversions of fixed point to floating
and vice versa, and conversions changing the width or signedness
of a fixed point argument except when the same as the default
promotion.
-Waggregate-return
Warn if any functions that return structures or unions are
defined or called.
-Wstrict-prototypes
Warn if a function is declared or defined without specifying the
argument types. (An old-style function definition is permitted
without a warning if preceded by a declaration which specifies
the argument types.)
-Wmissing-prototypes
Warn if a global function is defined without a previous prototype
declaration. This warning is issued even if the definition
itself provides a prototype. The aim is to detect global
functions that fail to be declared in header files.
-Wredundant-decls
Warn if anything is declared more than once in the same scope,
even in cases where multiple declaration is valid and changes
nothing.
-Wnested-externs
Warn if an extern declaration is encountered within a function.
-Winline
Warn if a function cannot be inlined, and either it was declared
as inline, or else the -finline-functions option was given.
-mwarn-passed-structs
Emit a warning message if a structure is passed to a function, or
declared as a function argument. This warns about the places
where gcc will not interoperate with compilers that do not pass
structures according to the 88open Object Compatibility Standard.
Options for Debugging Your Program
-g Produce debugging information for mxdb, dbx, or sdb.
Unlike most other C compilers, GNU C 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
Licensed material--property of copyright holder(s) 8
gcc(1) gcc 5.4R3.00 gcc(1)
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.
In the ELF environment, debugging information is in legend(5) format
for all supported debuggers. An optional LEGENDS environment
variable can contain special generation options such as -external to
reduce link-time by storing most debugging information in a separate
file. See legend(5) for details.
In a COFF environment, GNU C generates debugging information in
legend format for use by mxdb when the LEGENDS environment variable
is present; the information is in standard COFF format by default.
These four options control legend generation.
-mstandard
Causes the assembler to retain standard debugging information.
-mlegend
In the ELF environment, causes the assembler to invoke dtl(1),
the DWARF-to-legend translator. In a COFF environment, causes
the assembler to invoke ctl(1), the COFF-to-legend translator.
-mexternal-legend
Causes the assembler to pass the -external option to dtl(1) or
ctl(1).
-mkeep-coff
Causes the assembler to pass the -keep-std option to dtl(1) or
ctl(1).
-glevel
Request debugging information and also use level to specify how
much information. The default level is 2. 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. Level 3 includes extra
information, such as all the macro definitions present in the
program. Some debuggers support macro expansion when you use
-g3.
-mocs-debug-info
Put out additional debug information to comply with the 88open
Object Compatibility Standard text description information. This
is the default.
-mno-ocs-debug-info
Do not put out any additional debugging information.
-mocs-frame-position
When emitting debugging information for automatic variables and
parameters stored on the stack, use the offset from the canonical
Licensed material--property of copyright holder(s) 9
gcc(1) gcc 5.4R3.00 gcc(1)
frame address (CFA), which is the stack pointer (register 31)
when the function is entered. The CFA is specified by the 88open
Object Compatibility Standard. This is the default behavior of
GNU C.
-mno-ocs-frame-position
When emitting debugging information for automatic variables and
parameters stored on the stack, use the offset from the frame
pointer register (register 30). When this option is in effect,
the frame pointer is not eliminated when debugging information is
selected by the -g switch.
-p Generate extra code to write profile information suitable for the
analysis program prof.
-save-temps
Store the usual ``temporary'' intermediate files permanently;
place them in the current directory and name them based on the
source file. Thus, compiling file.c with -c -save-temps would
produce files file.i and file.s, as well as file.o.
Options Controlling Optimization
-O Optimize. Optimizing compilation takes somewhat more time, and a
lot more memory for a large function.
Without -O, the compiler's goal is to reduce the cost of
compilation and to make debugging produce the expected results.
Statements are independent: if you stop the program with a
breakpoint between statements, you can then assign a new value to
any variable or change the program counter to any other statement
in the function and get exactly the results you would expect from
the source code. Without -O, only variables declared register
are allocated in registers.
With -O, the compiler tries to reduce code size and execution
time. Some of the -f options described below turn specific kinds
of optimization on or off.
-O2 Highly optimize. All supported optimizations that do not involve
a space-speed tradeoff are performed. As compared to -O, this
option will increase both compilation time and the performance of
the generated code. All -fflag options that control optimization
are turned on when -O2 is specified.
Options of the form -fflag specify machine-independent flags. Most
flags have both positive and negative forms, as in -ffoo and -fno-
foo. Only one of the forms is listed here: the one which is not the
default.
-ffloat-store
Do not store floating-point variables in registers.
Licensed material--property of copyright holder(s) 10
gcc(1) gcc 5.4R3.00 gcc(1)
-fno-defer-pop
Always pop the arguments to each function call as soon as that
function returns. Normally the compiler (when optimizing) lets
arguments accumulate on the stack for several function calls and
pops them all at once.
-fforce-mem
Force memory operands to be copied into registers before doing
arithmetic on them. This may produce better code by making all
memory references potential common subexpressions. When they are
not common subexpressions, instruction combination should
eliminate the separate register-load.
-fforce-addr
Force memory address constants to be copied into registers before
doing arithmetic on them. This may produce better code just as
-fforce-mem may.
-fomit-frame-pointer
Don't keep the frame pointer in a register for functions that
don't need one. This eliminates the instructions that save, set
up and restore frame pointers; it also makes an extra register
available in many functions. If you specify -O and do not
specify -fno-omit-frame-pointer, this is enabled automatically.
-finline
Pay attention the inline keyword. Normally the negation of this
option -fno-inline is used to keep the compiler from expanding
any functions inline. However, the opposite effect may be
desirable when compiling with -g, since -g normally turns off all
inline function expansion.
-finline-functions
Integrate all simple functions into their callers. The compiler
heuristically decides which functions are simple enough to be
worth integrating in this way. If all calls to a given function
are integrated, and the function is declared static, then the
function is normally not output as assembler code in its own
right.
-fcaller-saves
Enable values to be allocated in registers that will be clobbered
by function calls, by emitting extra instructions to save and
restore the registers around such calls.
-fkeep-inline-functions
Even if all calls to a given function are integrated, and the
function is declared static, nevertheless output a separate run-
time callable version of the function.
-fno-function-cse
Do not put function addresses in registers; make each instruction
that calls a constant function contain the function's address
explicitly. This option results in less efficient code, but some
Licensed material--property of copyright holder(s) 11
gcc(1) gcc 5.4R3.00 gcc(1)
strange hacks that alter the assembler output may be confused by
the optimizations performed when this option is not used.
The following options control specific optimizations. The -O2 option
turns on all of these optimization except -funroll-loops and
-funroll-all-loops. The -O option turns on -fthread-jumps,
-fdelayed-branch, and -fomit-frame-pointer. You can use the
following flags in the rare cases when ``fine-tuning'' of
optimizations to be performed is desired.
-fstrength-reduce
Perform the optimizations of loop strength reduction and
elimination of iteration variables.
-fthread-jumps
Perform optimizations where we check to see if a jump branches to
a location where another comparison subsumed by the first is
found. If so, the first branch is redirected to either the
destination of the second branch or a point immediately following
it, depending on whether the condition is known to be true or
false.
-funroll-loops
Perform the optimization of loop unrolling. This is only done
for loops whose number of iterations can be determined at compile
time or run time.
-funroll-all-loops
Perform the optimization of loop unrolling. This is done for all
loops. This usually makes programs run more slowly.
-fcse-follow-jumps
In common subexpression elimination, scan through jump
instructions in certain cases. This is not as powerful as
completely global CSE, but not as slow either.
-frerun-cse-after-loop
Re-run common subexpression elimination after loop optimizations
has been performed.
-fcse-skip-blocks
Have cse follow branches around blocks.
-fexpensive-optimizations
Perform a number of minor optimizations that are relatively
expensive.
-fdelayed-branch
Reorder instructions to take advantage of the delay slot
following branch and subroutine call instructions.
-fschedule-insns
Attempt to reorder instructions to eliminate execution stalls due
to required data being unavailable.
Licensed material--property of copyright holder(s) 12
gcc(1) gcc 5.4R3.00 gcc(1)
-fschedule-insns2
Similar to -fschedule-insns, but requests an additional pass of
instruction scheduling after register allocation has been done.
-funroll-loops
Perform the optimization of loop unrolling. This is only done
for loops whose number of iterations can be determined at compile
time or run time. -funroll-loop implies -fstrength-reduce and
-frerun-cse-after-loop.
-funroll-all-loops
Perform the optimization of loop unrolling. This is done for all
loops and usually makes programs run more slowly. -funroll-all-
loops implies -fstrength-reduce and -frerun-cse-after-loop.
-fno-peephole
Disable any machine-specific peephole optimizations.
Options Controlling the Preprocessor
These options control the C preprocessor, which is run on each C
source file before actual compilation. If you use the -E option,
nothing is done except C preprocessing. Some of these options make
sense only together with -E because they request preprocessor output
that is not suitable for actual compilation.
-nostdinc
Do not search the standard system directories for header files.
Only the directories you have specified with -I options (and the
current directory, if appropriate) are searched. Between
-nostdinc and -I-, you can eliminate all directories from the
search path except those you specify.
-E Run only the C preprocessor. Preprocess all the C source files
specified and output the results to standard output.
-C Tell the preprocessor not to discard comments. Used with the -E
option.
-P Tell the preprocessor not to generate #line commands. Used with
the -E option.
-M Tell the preprocessor to output a rule suitable for make
describing the dependencies of each object file. For each source
file, the preprocessor outputs one make-rule whose target is the
object file name for that source file and whose dependencies are
all the files #included in it. This rule may be a single line or
may be continued with `\'-newline if it is long. -M implies -E.
You can also specify output of a make rule by setting the
environment variable DEPENDENCIESOUTPUT.
-MM Like -M, but the output mentions only the user-header files
included with `#include "file".' System header files included
Licensed material--property of copyright holder(s) 13
gcc(1) gcc 5.4R3.00 gcc(1)
with `#include <file>' are omitted. -MM implies -E.
-MD Like -M but the dependency information is written to files with
names made by replacing .c with .d at the end of the input file
names. This is in addition to compiling the file as specified:
-MD does not inhibit ordinary compilation the way -M does.
-MMD
Like -MD but mention only user header files, not system header
files.
-H Print the name of each header file to the standard error file, in
addition to the normal processing.
-Dmacro
Define macro macro with the string `1' as its definition.
-Dmacro=defn
Define macro macro as defn.
-Umacro
Undefine macro macro.
-trigraphs
Support ANSI C trigraphs. The -ansi option also has this effect.
Options for Linking
-llibrary
Search a standard list of directories for a library named
library, which is actually a file named liblibrary.a. The link
editor uses this file as if it had been specified precisely by
name. The directories searched include several standard system
directories plus any that you specify with -L. Normally the
files found this way are library files--archive files whose
members are object files. The link editor handles an archive
file by scanning through it for members which define symbols that
have so far been referenced but not defined. But if the file
that is found is an ordinary object file, it is linked in the
usual fashion. The only difference between an -l option and
specifying a file name is that -l searches several directories.
-nostdlib
Don't use the standard system libraries and startup files when
linking. Only the files you specify will be passed to the link
editor.
-static
Produce a static object, that is an object which contains no
shared objects. This option causes -dn to be added to the link
line; see ld(1).
-shared
Produce a shared object. This option causes -G to be added to
Licensed material--property of copyright holder(s) 14
gcc(1) gcc 5.4R3.00 gcc(1)
the link line, to produce a shared object which can then be
linked with other objects to form an executable.
-symbolic
Bind references to global symbols when building a shared object.
Warn about any unresolved references (unless overridden by the
link editor option -z defs: see ld(1)). This option causes
-Bsymbolic -G to be added to the link line.
-Xlinker option
Pass option as an option to the linker. You can use this to
supply system-specific linker options which GNU CC does not know
how to recognize.
If you want to pass an option that takes an argument, you must
use -Xlinker twice, once for the option and once for the
argument. For example, to pass -assert definitions, you must
write -Xlinker -assert -Xlinker definitions. It does not work to
write -Xlinker "-assert definitions", because this passes the
entire string as a single argument, which is not what the linker
expects.
GNU C also passes the options -e, -h, -n, -r, -s, -t, -u, -x, and -z
to the link editor; see ld(1) for these options.
Options for Directory Search
-Idir
Search directory dir for include files.
-I- Any directories specified with -I options before the -I- option
are searched only for the case of `#include "file"'; they are not
searched for `#include <file>'. If additional directories are
specified with -I options after the -I-, these directories are
searched for all #include directives. (Ordinarily all -I
directories are used this way.) In addition, the -I- option
inhibits the use of the current directory as the first search
directory for `#include "file"'. (The current directory is the
directory of the current input file. It is tried first because
it is presumed to be the location of the files that the current
input file refers to.) Therefore, the current directory is
searched only if it is requested explicitly with `-I.'.
Specifying both `-I-' and `-I.' allows you to control precisely
which directories are searched before the current one and which
are searched after.
-Ldir
Add directory dir to the list of directories to be searched for
-l.
-Bprefix
The compiler driver program tries prefix as a prefix for each
program it tries to run. These programs are cpp, cc1, as and ld.
For each subprogram to be run, the compiler driver first tries
Licensed material--property of copyright holder(s) 15
gcc(1) gcc 5.4R3.00 gcc(1)
the -B prefix, if any. If that name is not found, or if -B was
not specified, the driver tries the standard prefix, which is
/usr/lib/gcc/gcc-. If this does not result in a file name that
is found, the unmodified program name is searched for, using the
directories specified in your PATH environment variable.
The run-time support file gnulib is also searched for, using the
-B prefix, if needed. If it is not found there, the standard
prefix above is tried, and that is all. The file is left out of
the link if it is not found by those means.
You can get a similar result from the environment variable
GCCEXECPREFIX. If it is defined, its value is used as a prefix
in the same way. If both the -B option and the GCCEXECPREFIX
variable are present, the -B option is used first and the
environment variable value second.
Options for Code Generation Conventions
-m88000
Generate code that runs well on all members of the 88000 family.
-m88100
Generate code that is optimized for MC88100, but also runs on
MC88110.
-m88110
Generate code that is optimized for MC88110, and may not run on
MC88100.
-fpic
Generate position-independent code, suitable for use in a shared
object.
-fPIC
-mbig-pic
Produce position-independent code that will work correctly if the
global offset table of a shared object exceeds 16k. (Modules
should be recompiled with this option when the link editor
reports the error ``Relocation overflows at address...'' when
producing a shared object.)
-mshort-data-size
Specify the maximum size of a datum to be referenced with short
addressing. Short addressing will be used to reference a static
datum if its size is less than or equal to size bytes. For
example, specifying -mshort-data-512 requests short addressing
for data no larger than 512 bytes in size.
Short addressing generates more compact references to small
static data by pooling these data and referencing them relative
to one or more static base registers. Because the number of base
registers and the range for register-based addressing are
limited, linking can fail if there is too much short data. The
Licensed material--property of copyright holder(s) 16
gcc(1) gcc 5.4R3.00 gcc(1)
only recourse is recompilation with a smaller value for size.
For this reason, use of -mshort-data-size is discouraged for
software to be distributed in object form, such as libraries.
The default value for size is zero. That is, short addressing is
disabled by default.
-fshort-enums
Allocate to an enum type only as many bytes as it needs for the
declared range of possible values. Specifically, the enum type
will be equivalent to the smallest integer type which has enough
room.
-fshort-double
Use the same size for double as for float.
-fno-common
Allocate even initialized global variables in the bss section of
the object file, rather than generating them as common blocks.
This has the effect that if the same variable is declared
(without extern) in two different compilations, you will get an
error when you link them. The only reason this might be useful
is if you wish to verify that the program will work on other
systems which always work this way.
-fvolatile
Consider all memory references through pointers to be volatile.
-mserialize-volatile
-mno-serialize-volatile
Do, or don't, generate code to guarantee sequential consistency
of volatile memory references. By default, consistency is
guaranteed.
The order of memory references made by the MC88110 processor does
not always match the order of the instructions requesting those
references. In particular, a load instruction may execute before
a preceding store instruction. Such reordering violates
sequential consistency of volatile memory references, when there
are multiple processors. When consistency must be guaranteed,
GNU C generates special instructions, as needed, to force
execution in the proper order.
The MC88100 processor does not reorder memory references and so
always provides sequential consistency. However, by default, GNU
C generates the special instructions to guarantee consistency
even when you use -m88100, so that the code may be run on an
MC88110 processor. If you intend to run your code only on the
MC88100 processor, you may use -mno-serialize-volatile.
The extra code generated to guarantee consistency may affect the
performance of your application. If you know that you can safely
forgo this guarantee, you may use -mno-serialize-volatile.
Licensed material--property of copyright holder(s) 17
gcc(1) gcc 5.4R3.00 gcc(1)
-ffixed-reg
Treat the register named reg as a fixed register; generated code
should never refer to it (except perhaps as a stack pointer,
frame pointer or in some other fixed role). reg is one of
r0-r31. Use of this flag for a register that has a fixed
pervasive role in the machine's execution model, such as the
stack pointer or frame pointer, will produce disastrous results.
This flag does not have a negative form, because it specifies a
three-way choice.
-fcall-used-reg
Treat the register named reg as an allocatable register that is
clobbered by function calls. It may be allocated for temporaries
or variables that do not live across a call. Functions compiled
this way will not save and restore the register reg. Use of this
flag for a register that has a fixed pervasive role in the
machine's execution model, such as the stack pointer or frame
pointer, will produce disastrous results. This flag does not
have a negative form, because it specifies a three-way choice.
-fcall-saved-reg
Treat the register named reg as an allocatable register saved by
functions. It may be allocated even for temporaries or variables
that live across a call. Functions compiled this way will save
and restore the register reg if they use it. Use of this flag
for a register that has a fixed pervasive role in the machine's
execution model, such as the stack pointer or frame pointer, will
produce disastrous results. A different sort of disaster will
result from the use of this flag for a register in which function
values may be returned. This flag does not have a negative form,
because it specifies a three-way choice.
-mno-underscores
Do not emit a leading underscore before all external names. This
switch is useful for embedded systems and does not allow
interoperation with the standard library.
-mtrap-large-shift
Emit a tbnd instruction before each shift by a non-constant
amount, to trap if the shift count is less than zero or greater
than 31. The 88000 produces unusual results in such cases, and
the trap will halt the program at the point an out of range shift
is done, rather than producing unexpected results. The ANSI
standard for C specifies that shifts outside of the range of 0 to
number_bits - 1 is undefined. It is an error to specify both
-mtrap-large-shift and -mhandle-large-shift.
-mhandle-large-shift
Emit a four instruction sequence for each shift by a non-constant
amount, if the shift count is less than zero or greater than 31.
Logical shifts and arithmetic shifts left produce a 0 result if
the shift count is out of bounds. Arithmetic shifts right
produce a copy of the sign bit if the shift count is out of
bounds. The ANSI standard for C specifies that shifts outside of
Licensed material--property of copyright holder(s) 18
gcc(1) gcc 5.4R3.00 gcc(1)
the range of 0 to number_bits - 1 is undefined. It is an error
to specify both -mtrap-large-shift and -mhandle-large-shift.
-mno-check-zero-division
Do not emit code to check if an integer division by zero occurs
and issue trap number 503 if it occurs.
-muse-div-instruction
Do not emit code to check both the divisor and dividend when
doing signed integer division to see if either is negative, and
adjust the signs so the divide is done using non-negative
numbers. You would use this switch when you are confident that
most or all signed divisions are done with positive numbers.
If this fixup is not done, the 88100 will trap to the kernel if
either number is negative. The operating system will calculate
the correct answer for all negative operands, except for the most
negative number (-214783648) divided by negative 1, whose signed
result cannot be represented in 32 bits.
-midentify-revision
Emit an assembly ident directive which gives the filename, date,
time, and compiler revision, for use with the what command.
Environment Variables Affecting GNU C
Several environment variables affect the operation of GNU C. They
work by specifying directories or prefixes to use when searching for
various kinds of files. Note that you can also specify places to
search using options such as -B, -I and -L. These take precedence
over places specified using environment variables, which in turn take
precedence over those specified by the configuration of GNU C.
TMPDIR
If TMPDIR is set, it specifies the directory to use for temporary
files. GNU C uses temporary files to hold the output of one
stage of compilation which is to be used as input to the next
stage: for example, the output of the preprocessor, which is the
input to the compiler proper.
GCCEXECPREFIX
If GCCEXECPREFIX is set, it specifies a prefix to use in the
names of the subprograms executed by the compiler. No slash is
added when this prefix is combined with the name of a subprogram,
but you can specify a prefix that ends with a slash if you wish.
If GNU C cannot find the subprogram using the specified prefix,
it tries looking in the usual places for the subprogram.
Other prefixes specified with -B take precedence over this
prefix.
This prefix is also used for finding files such as crt0.o that
are used for linking.
Licensed material--property of copyright holder(s) 19
gcc(1) gcc 5.4R3.00 gcc(1)
In addition, the prefix is used in an unusual way in finding the
directories to search for header files. For each of the standard
directories whose name normally begins with /usr/local/lib/gcc
(more precisely, with the value of GCCINCLUDEDIR), GNU C tries
replacing that beginning with the specified prefix to produce an
alternate directory name. Thus, with -Bfoo/, GNU C will search
foo/bar where it would normally search /usr/local/lib/bar. These
alternate directories are searched first; the standard
directories come next.
COMPILERPATH
The value of COMPILERPATH is a colon-separated list of
directories, much like PATH. GNU C tries the directories thus
specified when searching for subprograms, if it can't find the
subprograms using GCCEXECPREFIX.
LIBRARYPATH
The value of LIBRARYPATH is a colon-separated list of
directories, much like PATH. GNU C tries the directories thus
specified when searching for special linker files, if it can't
find them using GCCEXECPREFIX. Linking using GNU C also uses
these directories when searching for ordinary libraries for the
-l option (but directories specified with -L come first).
CINCLUDEPATH
The variable's value is a colon-separated list of directories,
much like PATH. When GNU C searches for header files, it tries
the directories listed in the variable, after the directories
specified with -I but before the standard header file
directories.
DEPENDENCIESOUTPUT
If this variable is set, its value specifies how to output
dependencies for Make based on the header files processed by the
compiler. This output looks much like the output from the -M
option, but it goes to a separate file, and is in addition to the
usual results of compilation.
The value of DEPENDENCIESOUTPUT can be just a file name, in
which case the Make rules are written to that file, guessing the
target name from the source file name. Or the value can have the
form file target, in which case the rules are written to file
file using target as the target name.
There are several macros you can define to control your source and
target environments when developing applications. These macros
control header files, function declarations, binary formats, and
other aspects of the source and target environments. The macros are
helpful when you are porting applications to or from non-DG/UX
systems such as BSD or AT&T systems. The macros can also make
development of POSIX- or BCS-conformant applications easier. For
developing BCS-conformant applications, the SDE utility is also
helpful. See Porting Applications to the DG/UX (Trademark) System
and the sde-target(1), sdetab(4), and sde(5) manual pages.
Licensed material--property of copyright holder(s) 20
gcc(1) gcc 5.4R3.00 gcc(1)
FILES
file.c input file
file.o object file
a.out loaded output
TMPDIR/cc* temporary files. TMPDIR is usually /usr/tmp
but can be redefined by setting the
environment variable TMPDIR.
/usr/lib/gcc/gcc-cpp preprocessor
/usr/lib/gcc/gcc-cc1 compiler
/usr/lib/gcc/gcc-gnulib library needed by gcc
/lib/crt0.o runtime startup routine
/lib/libc.a standard library, see intro(3)
/usr/include standard directory for #include files
SEE ALSO
as(1), cc(1), ctl(1), dtl(1), ld(1), sde-target(1), sdetab(4),
sde(5), legend(5).
COPYING
Copyright (c) 1988 Free Software Foundation, Inc.
Permission is granted to make and distribute verbatim copies of the
gcc(1) manual page provided the copyright notice and this permission
notice are preserved on all copies.
Permission is granted to copy and distribute modified versions of the
gcc(1) manual page under the conditions for verbatim copying,
provided that the entire resulting derived work is distributed under
the terms of a permission notice identical to this one.
Permission is granted to copy and distribute translations of the
gcc(1) manual page into another language, under the above conditions
for modified versions, except that this permission notice may be
included in translations approved by the Free Software Foundation
instead of in the original English.
Licensed material--property of copyright holder(s) 21