1 @c Copyright (C) 1988, 89, 92, 93, 94, 1995 Free Software Foundation, Inc.
2 @c This is part of the GCC manual.
3 @c For copying conditions, see the file gcc.texi.
6 @chapter GNU CC Command Options
7 @cindex GNU CC command options
8 @cindex command options
9 @cindex options, GNU CC command
11 When you invoke GNU CC, it normally does preprocessing, compilation,
12 assembly and linking. The ``overall options'' allow you to stop this
13 process at an intermediate stage. For example, the @samp{-c} option
14 says not to run the linker. Then the output consists of object files
15 output by the assembler.
17 Other options are passed on to one stage of processing. Some options
18 control the preprocessor and others the compiler itself. Yet other
19 options control the assembler and linker; most of these are not
20 documented here, since you rarely need to use any of them.
22 @cindex C compilation options
23 Most of the command line options that you can use with GNU CC are useful
24 for C programs; when an option is only useful with another language
25 (usually C++), the explanation says so explicitly. If the description
26 for a particular option does not mention a source language, you can use
27 that option with all supported languages.
29 @cindex C++ compilation options
30 @xref{Invoking G++,,Compiling C++ Programs}, for a summary of special
31 options for compiling C++ programs.
33 @cindex grouping options
34 @cindex options, grouping
35 The @code{gcc} program accepts options and file names as operands. Many
36 options have multiletter names; therefore multiple single-letter options
37 may @emph{not} be grouped: @samp{-dr} is very different from @w{@samp{-d
40 @cindex order of options
41 @cindex options, order
42 You can mix options and other arguments. For the most part, the order
43 you use doesn't matter. Order does matter when you use several options
44 of the same kind; for example, if you specify @samp{-L} more than once,
45 the directories are searched in the order specified.
47 Many options have long names starting with @samp{-f} or with
48 @samp{-W}---for example, @samp{-fforce-mem},
49 @samp{-fstrength-reduce}, @samp{-Wformat} and so on. Most of
50 these have both positive and negative forms; the negative form of
51 @samp{-ffoo} would be @samp{-fno-foo}. This manual documents
52 only one of these two forms, whichever one is not the default.
55 * Option Summary:: Brief list of all options, without explanations.
56 * Overall Options:: Controlling the kind of output:
57 an executable, object files, assembler files,
58 or preprocessed source.
59 * Invoking G++:: Compiling C++ programs.
60 * C Dialect Options:: Controlling the variant of C language compiled.
61 * C++ Dialect Options:: Variations on C++.
62 * Warning Options:: How picky should the compiler be?
63 * Debugging Options:: Symbol tables, measurements, and debugging dumps.
64 * Optimize Options:: How much optimization?
65 * Preprocessor Options:: Controlling header files and macro definitions.
66 Also, getting dependency information for Make.
67 * Assembler Options:: Passing options to the assembler.
68 * Link Options:: Specifying libraries and so on.
69 * Directory Options:: Where to find header files and libraries.
70 Where to find the compiler executable files.
71 * Target Options:: Running a cross-compiler, or an old version of GNU CC.
72 * Submodel Options:: Specifying minor hardware or convention variations,
73 such as 68010 vs 68020.
74 * Code Gen Options:: Specifying conventions for function calls, data layout
76 * Environment Variables:: Env vars that affect GNU CC.
77 * Running Protoize:: Automatically adding or removing function prototypes.
81 @section Option Summary
83 Here is a summary of all the options, grouped by type. Explanations are
84 in the following sections.
88 @xref{Overall Options,,Options Controlling the Kind of Output}.
90 -c -S -E -o @var{file} -pipe -v -x @var{language}
93 @item C Language Options
94 @xref{C Dialect Options,,Options Controlling C Dialect}.
96 -ansi -fallow-single-precision -fcond-mismatch -fno-asm
97 -fno-builtin -fsigned-bitfields -fsigned-char
98 -funsigned-bitfields -funsigned-char -fwritable-strings
99 -traditional -traditional-cpp -trigraphs
102 @item C++ Language Options
103 @xref{C++ Dialect Options,,Options Controlling C++ Dialect}.
105 -fall-virtual -fdollars-in-identifiers -felide-constructors
106 -fenum-int-equiv -fexternal-templates -ffor-scope -fno-for-scope
107 -fhandle-signatures -fmemoize-lookups -fno-default-inline -fno-gnu-keywords
108 -fnonnull-objects -foperator-names -fstrict-prototype
109 -fthis-is-variable -nostdinc++ -traditional +e@var{n}
112 @item Warning Options
113 @xref{Warning Options,,Options to Request or Suppress Warnings}.
115 -fsyntax-only -pedantic -pedantic-errors
116 -w -W -Wall -Waggregate-return -Wbad-function-cast
117 -Wcast-align -Wcast-qual -Wchar-subscript -Wcomment
118 -Wconversion -Wenum-clash -Werror -Wformat
119 -Wid-clash-@var{len} -Wimplicit -Wimport -Winline
120 -Wlarger-than-@var{len} -Wmissing-declarations
121 -Wmissing-prototypes -Wnested-externs
122 -Wno-import -Woverloaded-virtual -Wparentheses
123 -Wpointer-arith -Wredundant-decls -Wreorder -Wreturn-type -Wshadow
124 -Wstrict-prototypes -Wswitch -Wsynth -Wtemplate-debugging
125 -Wtraditional -Wtrigraphs -Wuninitialized -Wunused
129 @item Debugging Options
130 @xref{Debugging Options,,Options for Debugging Your Program or GCC}.
132 -a -d@var{letters} -fpretend-float
133 -g -g@var{level} -gcoff -gdwarf -gdwarf+
134 -ggdb -gstabs -gstabs+ -gxcoff -gxcoff+
135 -p -pg -print-file-name=@var{library} -print-libgcc-file-name
136 -print-prog-name=@var{program} -print-search-dirs -save-temps
139 @item Optimization Options
140 @xref{Optimize Options,,Options that Control Optimization}.
142 -fcaller-saves -fcse-follow-jumps -fcse-skip-blocks
143 -fdelayed-branch -fexpensive-optimizations
144 -ffast-math -ffloat-store -fforce-addr -fforce-mem
145 -finline-functions -fkeep-inline-functions
146 -fno-default-inline -fno-defer-pop -fno-function-cse
147 -fno-inline -fno-peephole -fomit-frame-pointer
148 -frerun-cse-after-loop -fschedule-insns
149 -fschedule-insns2 -fstrength-reduce -fthread-jumps
150 -funroll-all-loops -funroll-loops
154 @item Preprocessor Options
155 @xref{Preprocessor Options,,Options Controlling the Preprocessor}.
157 -A@var{question}(@var{answer}) -C -dD -dM -dN
158 -D@var{macro}@r{[}=@var{defn}@r{]} -E -H
160 -include @var{file} -imacros @var{file}
161 -iprefix @var{file} -iwithprefix @var{dir}
162 -iwithprefixbefore @var{dir} -isystem @var{dir}
163 -M -MD -MM -MMD -MG -nostdinc -P -trigraphs
164 -undef -U@var{macro} -Wp,@var{option}
167 @item Assembler Option
168 @xref{Assembler Options,,Passing Options to the Assembler}.
174 @xref{Link Options,,Options for Linking}.
176 @var{object-file-name} -l@var{library}
177 -nostartfiles -nodefaultlibs -nostdlib
178 -s -static -shared -symbolic
179 -Wl,@var{option} -Xlinker @var{option}
183 @item Directory Options
184 @xref{Directory Options,,Options for Directory Search}.
186 -B@var{prefix} -I@var{dir} -I- -L@var{dir}
190 @c I wrote this xref this way to avoid overfull hbox. -- rms
191 @xref{Target Options}.
193 -b @var{machine} -V @var{version}
196 @item Machine Dependent Options
197 @xref{Submodel Options,,Hardware Models and Configurations}.
199 @emph{M680x0 Options}
200 -m68000 -m68020 -m68020-40 -m68030 -m68040 -m68881
201 -mbitfield -mc68000 -mc68020 -mfpa -mnobitfield
202 -mrtd -mshort -msoft-float
208 -mapp-regs -mcypress -mepilogue -mflat -mfpu -mhard-float
209 -mhard-quad-float -mno-app-regs -mno-flat -mno-fpu
210 -mno-epilogue -mno-unaligned-doubles
211 -msoft-float -msoft-quad-float
212 -msparclite -msupersparc -munaligned-doubles -mv8
214 SPARC V9 compilers support the following options
215 in addition to the above:
218 -mint32 -mint64 -mlong32 -mlong64
219 -mno-stack-bias -mstack-bias
221 @emph{Convex Options}
222 -mc1 -mc2 -mc32 -mc34 -mc38
223 -margcount -mnoargcount
225 -mvolatile-cache -mvolatile-nocache
227 @emph{AMD29K Options}
228 -m29000 -m29050 -mbw -mnbw -mdw -mndw
229 -mlarge -mnormal -msmall
230 -mkernel-registers -mno-reuse-arg-regs
231 -mno-stack-check -mno-storem-bug
232 -mreuse-arg-regs -msoft-float -mstack-check
233 -mstorem-bug -muser-registers
236 -mapcs -m2 -m3 -m6 -mbsd -mxopen -mno-symrename
239 -m88000 -m88100 -m88110 -mbig-pic
240 -mcheck-zero-division -mhandle-large-shift
241 -midentify-revision -mno-check-zero-division
242 -mno-ocs-debug-info -mno-ocs-frame-position
243 -mno-optimize-arg-area -mno-serialize-volatile
244 -mno-underscores -mocs-debug-info
245 -mocs-frame-position -moptimize-arg-area
246 -mserialize-volatile -mshort-data-@var{num} -msvr3
247 -msvr4 -mtrap-large-shift -muse-div-instruction
248 -mversion-03.00 -mwarn-passed-structs
250 @emph{RS/6000 and PowerPC Options}
252 -mpower -mno-power -mpower2 -mno-power2
253 -mpowerpc -mno-powerpc
254 -mpowerpc-gpopt -mno-powerpc-gpopt
255 -mpowerpc-gfxopt -mno-powerpc-gfxopt
256 -mnew-mnemonics -mno-new-mnemonics
257 -mfull-toc -mminimal-toc -mno-fop-in-toc -mno-sum-in-toc
258 -msoft-float -mhard-float -mmultiple -mno-multiple
259 -mstring -mno-string -mbit-align -mno-bit-align
260 -mstrict-align -mno-strict-align -mrelocatable -mno-relocatable
261 -mtoc -mno-toc -mtraceback -mno-traceback
262 -mlittle -mlittle-endian -mbig -mbig-endian
263 -mcall-aix -mcall-sysv -mprototype
266 -mcall-lib-mul -mfp-arg-in-fpregs -mfp-arg-in-gregs
267 -mfull-fp-blocks -mhc-struct-return -min-line-mul
268 -mminimum-fp-blocks -mnohc-struct-return
271 -mabicalls -mcpu=@var{cpu type} -membedded-data
272 -membedded-pic -mfp32 -mfp64 -mgas -mgp32 -mgp64
273 -mgpopt -mhalf-pic -mhard-float -mint64 -mips1
274 -mips2 -mips3 -mlong64 -mlong-calls -mmemcpy
275 -mmips-as -mmips-tfile -mno-abicalls
276 -mno-embedded-data -mno-embedded-pic
277 -mno-gpopt -mno-long-calls
278 -mno-memcpy -mno-mips-tfile -mno-rnames -mno-stats
279 -mrnames -msoft-float
280 -m4650 -msingle-float -mmad
281 -mstats -EL -EB -G @var{num} -nocpp
284 -m386 -m486 -mno-fancy-math-387
285 -mno-fp-ret-in-387 -mno-ieee-fp -mno-wide-multiply
286 -mprofiler-epilogue -mrtd -msoft-float
287 -msvr3-shlib -malign-double
288 -mreg-alloc=@var{list} -mregparm=@var{num}
289 -malign-jumps=@var{num} -malign-loops=@var{num}
290 -malign-functions=@var{num}
293 -mdisable-fpregs -mdisable-indexing -mfast-indirect-calls
294 -mgas -mjump-in-delay -mlong-millicode-calls -mno-disable-fpregs
295 -mno-disable-indexing -mno-fast-indirect-calls -mno-gas
296 -mno-jump-in-delay -mno-millicode-long-calls
297 -mno-portable-runtime -mno-soft-float -msoft-float
298 -mpa-risc-1-0 -mpa-risc-1-1 -mportable-runtime -mschedule=@var{list}
300 @emph{Intel 960 Options}
301 -m@var{cpu type} -masm-compat -mclean-linkage
302 -mcode-align -mcomplex-addr -mleaf-procedures
303 -mic-compat -mic2.0-compat -mic3.0-compat
304 -mintel-asm -mno-clean-linkage -mno-code-align
305 -mno-complex-addr -mno-leaf-procedures
306 -mno-old-align -mno-strict-align -mno-tail-call
307 -mnumerics -mold-align -msoft-float -mstrict-align
310 @emph{DEC Alpha Options}
311 -mfp-regs -mno-fp-regs -mno-soft-float
314 @emph{Clipper Options}
317 @emph{H8/300 Options}
320 @emph{System V Options}
321 -Qy -Qn -YP,@var{paths} -Ym,@var{dir}
324 @item Code Generation Options
325 @xref{Code Gen Options,,Options for Code Generation Conventions}.
327 -fcall-saved-@var{reg} -fcall-used-@var{reg}
328 -ffixed-@var{reg} -finhibit-size-directive
329 -fno-common -fno-ident -fno-gnu-linker
330 -fpcc-struct-return -fpic -fPIC
331 -freg-struct-return -fshared-data -fshort-enums
332 -fshort-double -fvolatile -fvolatile-global
333 -fverbose-asm -fpack-struct +e0 +e1
338 * Overall Options:: Controlling the kind of output:
339 an executable, object files, assembler files,
340 or preprocessed source.
341 * C Dialect Options:: Controlling the variant of C language compiled.
342 * C++ Dialect Options:: Variations on C++.
343 * Warning Options:: How picky should the compiler be?
344 * Debugging Options:: Symbol tables, measurements, and debugging dumps.
345 * Optimize Options:: How much optimization?
346 * Preprocessor Options:: Controlling header files and macro definitions.
347 Also, getting dependency information for Make.
348 * Assembler Options:: Passing options to the assembler.
349 * Link Options:: Specifying libraries and so on.
350 * Directory Options:: Where to find header files and libraries.
351 Where to find the compiler executable files.
352 * Target Options:: Running a cross-compiler, or an old version of GNU CC.
355 @node Overall Options
356 @section Options Controlling the Kind of Output
358 Compilation can involve up to four stages: preprocessing, compilation
359 proper, assembly and linking, always in that order. The first three
360 stages apply to an individual source file, and end by producing an
361 object file; linking combines all the object files (those newly
362 compiled, and those specified as input) into an executable file.
364 @cindex file name suffix
365 For any given input file, the file name suffix determines what kind of
370 C source code which must be preprocessed.
373 C source code which should not be preprocessed.
376 C++ source code which should not be preprocessed.
379 Objective-C source code. Note that you must link with the library
380 @file{libobjc.a} to make an Objective-C program work.
383 C header file (not to be compiled or linked).
386 @itemx @var{file}.cxx
387 @itemx @var{file}.cpp
389 C++ source code which must be preprocessed. Note that in @samp{.cxx},
390 the last two letters must both be literally @samp{x}. Likewise,
391 @samp{.C} refers to a literal capital C.
397 Assembler code which must be preprocessed.
400 An object file to be fed straight into linking.
401 Any file name with no recognized suffix is treated this way.
404 You can specify the input language explicitly with the @samp{-x} option:
407 @item -x @var{language}
408 Specify explicitly the @var{language} for the following input files
409 (rather than letting the compiler choose a default based on the file
410 name suffix). This option applies to all following input files until
411 the next @samp{-x} option. Possible values for @var{language} are:
414 c-header cpp-output c++-cpp-output
415 assembler assembler-with-cpp
419 Turn off any specification of a language, so that subsequent files are
420 handled according to their file name suffixes (as they are if @samp{-x}
421 has not been used at all).
424 If you only want some of the stages of compilation, you can use
425 @samp{-x} (or filename suffixes) to tell @code{gcc} where to start, and
426 one of the options @samp{-c}, @samp{-S}, or @samp{-E} to say where
427 @code{gcc} is to stop. Note that some combinations (for example,
428 @samp{-x cpp-output -E} instruct @code{gcc} to do nothing at all.
432 Compile or assemble the source files, but do not link. The linking
433 stage simply is not done. The ultimate output is in the form of an
434 object file for each source file.
436 By default, the object file name for a source file is made by replacing
437 the suffix @samp{.c}, @samp{.i}, @samp{.s}, etc., with @samp{.o}.
439 Unrecognized input files, not requiring compilation or assembly, are
443 Stop after the stage of compilation proper; do not assemble. The output
444 is in the form of an assembler code file for each non-assembler input
447 By default, the assembler file name for a source file is made by
448 replacing the suffix @samp{.c}, @samp{.i}, etc., with @samp{.s}.
450 Input files that don't require compilation are ignored.
453 Stop after the preprocessing stage; do not run the compiler proper. The
454 output is in the form of preprocessed source code, which is sent to the
457 Input files which don't require preprocessing are ignored.
459 @cindex output file option
461 Place output in file @var{file}. This applies regardless to whatever
462 sort of output is being produced, whether it be an executable file,
463 an object file, an assembler file or preprocessed C code.
465 Since only one output file can be specified, it does not make sense to
466 use @samp{-o} when compiling more than one input file, unless you are
467 producing an executable file as output.
469 If @samp{-o} is not specified, the default is to put an executable file
470 in @file{a.out}, the object file for @file{@var{source}.@var{suffix}} in
471 @file{@var{source}.o}, its assembler file in @file{@var{source}.s}, and
472 all preprocessed C source on standard output.@refill
475 Print (on standard error output) the commands executed to run the stages
476 of compilation. Also print the version number of the compiler driver
477 program and of the preprocessor and the compiler proper.
480 Use pipes rather than temporary files for communication between the
481 various stages of compilation. This fails to work on some systems where
482 the assembler is unable to read from a pipe; but the GNU assembler has
487 @section Compiling C++ Programs
489 @cindex suffixes for C++ source
490 @cindex C++ source file suffixes
491 C++ source files conventionally use one of the suffixes @samp{.C},
492 @samp{.cc}, @samp{cpp}, or @samp{.cxx}; preprocessed C++ files use the
493 suffix @samp{.ii}. GNU CC recognizes files with these names and
494 compiles them as C++ programs even if you call the compiler the same way
495 as for compiling C programs (usually with the name @code{gcc}).
499 However, C++ programs often require class libraries as well as a
500 compiler that understands the C++ language---and under some
501 circumstances, you might want to compile programs from standard input,
502 or otherwise without a suffix that flags them as C++ programs.
503 @code{g++} is a program that calls GNU CC with the default language
504 set to C++, and automatically specifies linking against the GNU class
506 @cindex @code{g++ 1.@var{xx}}
507 @cindex @code{g++}, separate compiler
508 @cindex @code{g++} older version
509 @footnote{Prior to release 2 of the compiler,
510 there was a separate @code{g++} compiler. That version was based on GNU
511 CC, but not integrated with it. Versions of @code{g++} with a
512 @samp{1.@var{xx}} version number---for example, @code{g++} version 1.37
513 or 1.42---are much less reliable than the versions integrated with GCC
514 2. Moreover, combining G++ @samp{1.@var{xx}} with a version 2 GCC will
515 simply not work.} On many systems, the script @code{g++} is also
516 installed with the name @code{c++}.
518 @cindex invoking @code{g++}
519 When you compile C++ programs, you may specify many of the same
520 command-line options that you use for compiling programs in any
521 language; or command-line options meaningful for C and related
522 languages; or options that are meaningful only for C++ programs.
523 @xref{C Dialect Options,,Options Controlling C Dialect}, for
524 explanations of options for languages related to C.
525 @xref{C++ Dialect Options,,Options Controlling C++ Dialect}, for
526 explanations of options that are meaningful only for C++ programs.
528 @node C Dialect Options
529 @section Options Controlling C Dialect
530 @cindex dialect options
531 @cindex language dialect options
532 @cindex options, dialect
534 The following options control the dialect of C (or languages derived
535 from C, such as C++ and Objective C) that the compiler accepts:
540 Support all ANSI standard C programs.
542 This turns off certain features of GNU C that are incompatible with ANSI
543 C, such as the @code{asm}, @code{inline} and @code{typeof} keywords, and
544 predefined macros such as @code{unix} and @code{vax} that identify the
545 type of system you are using. It also enables the undesirable and
546 rarely used ANSI trigraph feature, disallows @samp{$} as part of
547 identifiers, and disables recognition of C++ style @samp{//} comments.
549 The alternate keywords @code{__asm__}, @code{__extension__},
550 @code{__inline__} and @code{__typeof__} continue to work despite
551 @samp{-ansi}. You would not want to use them in an ANSI C program, of
552 course, but it is useful to put them in header files that might be included
553 in compilations done with @samp{-ansi}. Alternate predefined macros
554 such as @code{__unix__} and @code{__vax__} are also available, with or
555 without @samp{-ansi}.
557 The @samp{-ansi} option does not cause non-ANSI programs to be
558 rejected gratuitously. For that, @samp{-pedantic} is required in
559 addition to @samp{-ansi}. @xref{Warning Options}.
561 The macro @code{__STRICT_ANSI__} is predefined when the @samp{-ansi}
562 option is used. Some header files may notice this macro and refrain
563 from declaring certain functions or defining certain macros that the
564 ANSI standard doesn't call for; this is to avoid interfering with any
565 programs that might use these names for other things.
567 The functions @code{alloca}, @code{abort}, @code{exit}, and
568 @code{_exit} are not builtin functions when @samp{-ansi} is used.
571 Do not recognize @code{asm}, @code{inline} or @code{typeof} as a
572 keyword, so that code can use these words as identifiers. You can use
573 the keywords @code{__asm__}, @code{__inline__} and @code{__typeof__}
574 instead. @samp{-ansi} implies @samp{-fno-asm}.
576 In C++, this switch only affects the @code{typeof} keyword, since
577 @code{asm} and @code{inline} are standard keywords. You may want to
578 use the @samp{-fno-gnu-keywords} flag instead, as it also disables the
579 other, C++-specific, extension keywords such as @code{headof}.
582 @cindex builtin functions
598 Don't recognize builtin functions that do not begin with two leading
599 underscores. Currently, the functions affected include @code{abort},
600 @code{abs}, @code{alloca}, @code{cos}, @code{exit}, @code{fabs},
601 @code{ffs}, @code{labs}, @code{memcmp}, @code{memcpy}, @code{sin},
602 @code{sqrt}, @code{strcmp}, @code{strcpy}, and @code{strlen}.
604 GCC normally generates special code to handle certain builtin functions
605 more efficiently; for instance, calls to @code{alloca} may become single
606 instructions that adjust the stack directly, and calls to @code{memcpy}
607 may become inline copy loops. The resulting code is often both smaller
608 and faster, but since the function calls no longer appear as such, you
609 cannot set a breakpoint on those calls, nor can you change the behavior
610 of the functions by linking with a different library.
612 The @samp{-ansi} option prevents @code{alloca} and @code{ffs} from being
613 builtin functions, since these functions do not have an ANSI standard
617 Support ANSI C trigraphs. You don't want to know about this
618 brain-damage. The @samp{-ansi} option implies @samp{-trigraphs}.
620 @cindex traditional C language
621 @cindex C language, traditional
623 Attempt to support some aspects of traditional C compilers.
628 All @code{extern} declarations take effect globally even if they
629 are written inside of a function definition. This includes implicit
630 declarations of functions.
633 The newer keywords @code{typeof}, @code{inline}, @code{signed}, @code{const}
634 and @code{volatile} are not recognized. (You can still use the
635 alternative keywords such as @code{__typeof__}, @code{__inline__}, and
639 Comparisons between pointers and integers are always allowed.
642 Integer types @code{unsigned short} and @code{unsigned char} promote
643 to @code{unsigned int}.
646 Out-of-range floating point literals are not an error.
649 Certain constructs which ANSI regards as a single invalid preprocessing
650 number, such as @samp{0xe-0xd}, are treated as expressions instead.
653 String ``constants'' are not necessarily constant; they are stored in
654 writable space, and identical looking constants are allocated
655 separately. (This is the same as the effect of
656 @samp{-fwritable-strings}.)
658 @cindex @code{longjmp} and automatic variables
660 All automatic variables not declared @code{register} are preserved by
661 @code{longjmp}. Ordinarily, GNU C follows ANSI C: automatic variables
662 not declared @code{volatile} may be clobbered.
667 @cindex escape sequences, traditional
668 The character escape sequences @samp{\x} and @samp{\a} evaluate as the
669 literal characters @samp{x} and @samp{a} respectively. Without
670 @w{@samp{-traditional}}, @samp{\x} is a prefix for the hexadecimal
671 representation of a character, and @samp{\a} produces a bell.
674 In C++ programs, assignment to @code{this} is permitted with
675 @samp{-traditional}. (The option @samp{-fthis-is-variable} also has
679 You may wish to use @samp{-fno-builtin} as well as @samp{-traditional}
680 if your program uses names that are normally GNU C builtin functions for
681 other purposes of its own.
683 You cannot use @samp{-traditional} if you include any header files that
684 rely on ANSI C features. Some vendors are starting to ship systems with
685 ANSI C header files and you cannot use @samp{-traditional} on such
686 systems to compile files that include any system headers.
689 In the preprocessor, comments convert to nothing at all, rather than
690 to a space. This allows traditional token concatenation.
693 In preprocessing directive, the @samp{#} symbol must appear as the first
697 In the preprocessor, macro arguments are recognized within string
698 constants in a macro definition (and their values are stringified,
699 though without additional quote marks, when they appear in such a
700 context). The preprocessor always considers a string constant to end
704 @cindex detecting @w{@samp{-traditional}}
705 The predefined macro @code{__STDC__} is not defined when you use
706 @samp{-traditional}, but @code{__GNUC__} is (since the GNU extensions
707 which @code{__GNUC__} indicates are not affected by
708 @samp{-traditional}). If you need to write header files that work
709 differently depending on whether @samp{-traditional} is in use, by
710 testing both of these predefined macros you can distinguish four
711 situations: GNU C, traditional GNU C, other ANSI C compilers, and other
712 old C compilers. The predefined macro @code{__STDC_VERSION__} is also
713 not defined when you use @samp{-traditional}. @xref{Standard
714 Predefined,,Standard Predefined Macros,cpp.info,The C Preprocessor},
715 for more discussion of these and other predefined macros.
718 @cindex string constants vs newline
719 @cindex newline vs string constants
720 The preprocessor considers a string constant to end at a newline (unless
721 the newline is escaped with @samp{\}). (Without @w{@samp{-traditional}},
722 string constants can contain the newline character as typed.)
724 @item -traditional-cpp
725 Attempt to support some aspects of traditional C preprocessors.
726 This includes the last five items in the table immediately above,
727 but none of the other effects of @samp{-traditional}.
729 @item -fcond-mismatch
730 Allow conditional expressions with mismatched types in the second and
731 third arguments. The value of such an expression is void.
733 @item -funsigned-char
734 Let the type @code{char} be unsigned, like @code{unsigned char}.
736 Each kind of machine has a default for what @code{char} should
737 be. It is either like @code{unsigned char} by default or like
738 @code{signed char} by default.
740 Ideally, a portable program should always use @code{signed char} or
741 @code{unsigned char} when it depends on the signedness of an object.
742 But many programs have been written to use plain @code{char} and
743 expect it to be signed, or expect it to be unsigned, depending on the
744 machines they were written for. This option, and its inverse, let you
745 make such a program work with the opposite default.
747 The type @code{char} is always a distinct type from each of
748 @code{signed char} or @code{unsigned char}, even though its behavior
749 is always just like one of those two.
752 Let the type @code{char} be signed, like @code{signed char}.
754 Note that this is equivalent to @samp{-fno-unsigned-char}, which is
755 the negative form of @samp{-funsigned-char}. Likewise, the option
756 @samp{-fno-signed-char} is equivalent to @samp{-funsigned-char}.
758 @item -fsigned-bitfields
759 @itemx -funsigned-bitfields
760 @itemx -fno-signed-bitfields
761 @itemx -fno-unsigned-bitfields
762 These options control whether a bitfield is signed or unsigned, when the
763 declaration does not use either @code{signed} or @code{unsigned}. By
764 default, such a bitfield is signed, because this is consistent: the
765 basic integer types such as @code{int} are signed types.
767 However, when @samp{-traditional} is used, bitfields are all unsigned
770 @item -fwritable-strings
771 Store string constants in the writable data segment and don't uniquize
772 them. This is for compatibility with old programs which assume they can
773 write into string constants. The option @samp{-traditional} also has
776 Writing into string constants is a very bad idea; ``constants'' should
779 @item -fallow-single-precision
780 Do not promote single precision math operations to double precision,
781 even when compiling with @samp{-traditional}.
783 Traditional K&R C promotes all floating point operations to double
784 precision, regardless of the sizes of the operands. On the
785 architecture for which you are compiling, single precision may be faster
786 than double precision. If you must use @samp{-traditional}, but want
787 to use single precision operations when the operands are single
788 precision, use this option. This option has no effect when compiling
789 with ANSI or GNU C conventions (the default).
793 @node C++ Dialect Options
794 @section Options Controlling C++ Dialect
796 @cindex compiler options, C++
797 @cindex C++ options, command line
799 This section describes the command-line options that are only meaningful
800 for C++ programs; but you can also use most of the GNU compiler options
801 regardless of what language your program is in. For example, you
802 might compile a file @code{firstClass.C} like this:
805 g++ -g -felide-constructors -O -c firstClass.C
809 In this example, only @samp{-felide-constructors} is an option meant
810 only for C++ programs; you can use the other options with any
811 language supported by GNU CC.
813 Here is a list of options that are @emph{only} for compiling C++ programs:
816 @item -fno-access-control
817 Turn off all access checking. This switch is mainly useful for working
818 around bugs in the access control code.
821 Treat all possible member functions as virtual, implicitly.
822 All member functions (except for constructor functions and @code{new} or
823 @code{delete} member operators) are treated as virtual functions of the
824 class where they appear.
826 This does not mean that all calls to these member functions will be made
827 through the internal table of virtual functions. Under some
828 circumstances, the compiler can determine that a call to a given virtual
829 function can be made directly; in these cases the calls are direct in
833 Check that the pointer returned by @code{operator new} is non-null
834 before attempting to modify the storage allocated. The current Working
835 Paper requires that @code{operator new} never return a null pointer, so
836 this check is normally unnecessary.
838 @item -fconserve-space
839 Put uninitialized or runtime-initialized global variables into the
840 common segment, as C does. This saves space in the executable at the
841 cost of not diagnosing duplicate definitions. If you compile with this
842 flag and your program mysteriously crashes after @code{main()} has
843 completed, you may have an object that is being destroyed twice because
844 two definitions were merged.
846 @item -fdollars-in-identifiers
847 Accept @samp{$} in identifiers. You can also explicitly prohibit use of
848 @samp{$} with the option @samp{-fno-dollars-in-identifiers}. (GNU C++
849 allows @samp{$} by default on some target systems but not others.)
850 Traditional C allowed the character @samp{$} to form part of
851 identifiers. However, ANSI C and C++ forbid @samp{$} in identifiers.
853 @item -fenum-int-equiv
854 Anachronistically permit implicit conversion of @code{int} to
855 enumeration types. Current C++ allows conversion of @code{enum} to
856 @code{int}, but not the other way around.
858 @item -fexternal-templates
859 Cause template instantiations to obey @samp{#pragma interface} and
860 @samp{implementation}; template instances are emitted or not according
861 to the location of the template definition. @xref{Template
862 Instantiation}, for more information.
864 @item -falt-external-templates
865 Similar to -fexternal-templates, but template instances are emitted or
866 not according to the place where they are first instantiated.
867 @xref{Template Instantiation}, for more information.
871 If -ffor-scope is specified, the scope of variables declared in
872 a @i{for-init-statement} is limited to the @samp{for} loop itself,
873 as specified by the draft C++ standard.
874 If -fno-for-scope is specified, the scope of variables declared in
875 a @i{for-init-statement} extends to the end of the enclosing scope,
876 as was the case in old versions of gcc, and other (traditional)
877 implementations of C++.
879 The default if neither flag is given to follow the standard,
880 but to allow and give a warning for old-style code that would
881 otherwise be invalid, or have different behavior.
883 @item -fno-gnu-keywords
884 Do not recognize @code{classof}, @code{headof}, @code{signature},
885 @code{sigof} or @code{typeof} as a keyword, so that code can use these
886 words as identifiers. You can use the keywords @code{__classof__},
887 @code{__headof__}, @code{__signature__}, @code{__sigof__}, and
888 @code{__typeof__} instead. @samp{-ansi} implies
889 @samp{-fno-gnu-keywords}.
891 @item -fno-implicit-templates
892 Never emit code for templates which are instantiated implicitly (i.e. by
893 use); only emit code for explicit instantiations. @xref{Template
894 Instantiation}, for more information.
896 @item -fhandle-signatures
897 Recognize the @code{signature} and @code{sigof} keywords for specifying
898 abstract types. The default (@samp{-fno-handle-signatures}) is not to
899 recognize them. @xref{C++ Signatures, Type Abstraction using
903 Support virtual function calls for objects that exceed the size
904 representable by a @samp{short int}. Users should not use this flag by
905 default; if you need to use it, the compiler will tell you so. If you
906 compile any of your code with this flag, you must compile @emph{all} of
907 your code with this flag (including libg++, if you use it).
909 This flag is not useful when compiling with -fvtable-thunks.
911 @item -fno-implement-inlines
912 To save space, do not emit out-of-line copies of inline functions
913 controlled by @samp{#pragma implementation}. This will cause linker
914 errors if these functions are not inlined everywhere they are called.
916 @item -fmemoize-lookups
917 @itemx -fsave-memoized
918 Use heuristics to compile faster. These heuristics are not enabled by
919 default, since they are only effective for certain input files. Other
920 input files compile more slowly.
922 The first time the compiler must build a call to a member function (or
923 reference to a data member), it must (1) determine whether the class
924 implements member functions of that name; (2) resolve which member
925 function to call (which involves figuring out what sorts of type
926 conversions need to be made); and (3) check the visibility of the member
927 function to the caller. All of this adds up to slower compilation.
928 Normally, the second time a call is made to that member function (or
929 reference to that data member), it must go through the same lengthy
930 process again. This means that code like this:
933 cout << "This " << p << " has " << n << " legs.\n";
937 makes six passes through all three steps. By using a software cache, a
938 ``hit'' significantly reduces this cost. Unfortunately, using the cache
939 introduces another layer of mechanisms which must be implemented, and so
940 incurs its own overhead. @samp{-fmemoize-lookups} enables the software
943 Because access privileges (visibility) to members and member functions
944 may differ from one function context to the next, G++ may need to flush
945 the cache. With the @samp{-fmemoize-lookups} flag, the cache is flushed
946 after every function that is compiled. The @samp{-fsave-memoized} flag
947 enables the same software cache, but when the compiler determines that
948 the context of the last function compiled would yield the same access
949 privileges of the next function to compile, it preserves the cache.
950 This is most helpful when defining many member functions for the same
951 class: with the exception of member functions which are friends of other
952 classes, each member function has exactly the same access privileges as
953 every other, and the cache need not be flushed.
955 The code that implements these flags has rotted; you should probably
958 @item -fstrict-prototype
959 Within an @samp{extern "C"} linkage specification, treat a function
960 declaration with no arguments, such as @samp{int foo ();}, as declaring
961 the function to take no arguments. Normally, such a declaration means
962 that the function @code{foo} can take any combination of arguments, as
963 in C. @samp{-pedantic} implies @samp{-fstrict-prototype} unless
964 overridden with @samp{-fno-strict-prototype}.
966 This flag no longer affects declarations with C++ linkage.
968 @item -fno-nonnull-objects
969 Don't assume that a reference is initialized to refer to a valid object.
970 Although the current C++ Working Paper prohibits null references, some
971 old code may rely on them, and you can use @samp{-fno-nonnull-objects}
974 At the moment, the compiler only does this checking for conversions to
975 virtual base classes.
977 @item -foperator-names
978 Recognize the operator name keywords @code{and}, @code{bitand},
979 @code{bitor}, @code{compl}, @code{not}, @code{or} and @code{xor} as
980 synonyms for the symbols they refer to. @samp{-ansi} implies
981 @samp{-foperator-names}.
983 @item -fthis-is-variable
984 Permit assignment to @code{this}. The incorporation of user-defined
985 free store management into C++ has made assignment to @samp{this} an
986 anachronism. Therefore, by default it is invalid to assign to
987 @code{this} within a class member function; that is, GNU C++ treats
988 @samp{this} in a member function of class @code{X} as a non-lvalue of
989 type @samp{X *}. However, for backwards compatibility, you can make it
990 valid with @samp{-fthis-is-variable}.
992 @item -fvtable-thunks
993 Use @samp{thunks} to implement the virtual function dispatch table
994 (@samp{vtable}). The traditional (cfront-style) approach to
995 implementing vtables was to store a pointer to the function and two
996 offsets for adjusting the @samp{this} pointer at the call site. Newer
997 implementations store a single pointer to a @samp{thunk} function which
998 does any necessary adjustment and then calls the target function.
1000 This option also enables a heuristic for controlling emission of
1001 vtables; if a class has any non-inline virtual functions, the vtable
1002 will be emitted in the translation unit containing the first one of
1006 Do not search for header files in the standard directories specific to
1007 C++, but do still search the other standard directories. (This option
1008 is used when building libg++.)
1011 For C++ programs (in addition to the effects that apply to both C and
1012 C++), this has the same effect as @samp{-fthis-is-variable}.
1013 @xref{C Dialect Options,, Options Controlling C Dialect}.
1016 In addition, these optimization, warning, and code generation options
1017 have meanings only for C++ programs:
1020 @item -fno-default-inline
1021 Do not assume @samp{inline} for functions defined inside a class scope.
1022 @xref{Optimize Options,,Options That Control Optimization}.
1025 @itemx -Woverloaded-virtual
1026 @itemx -Wtemplate-debugging
1027 Warnings that apply only to C++ programs. @xref{Warning
1028 Options,,Options to Request or Suppress Warnings}.
1031 Control how virtual function definitions are used, in a fashion
1032 compatible with @code{cfront} 1.x. @xref{Code Gen Options,,Options for
1033 Code Generation Conventions}.
1036 @node Warning Options
1037 @section Options to Request or Suppress Warnings
1038 @cindex options to control warnings
1039 @cindex warning messages
1040 @cindex messages, warning
1041 @cindex suppressing warnings
1043 Warnings are diagnostic messages that report constructions which
1044 are not inherently erroneous but which are risky or suggest there
1045 may have been an error.
1047 You can request many specific warnings with options beginning @samp{-W},
1048 for example @samp{-Wimplicit} to request warnings on implicit
1049 declarations. Each of these specific warning options also has a
1050 negative form beginning @samp{-Wno-} to turn off warnings;
1051 for example, @samp{-Wno-implicit}. This manual lists only one of the
1052 two forms, whichever is not the default.
1054 These options control the amount and kinds of warnings produced by GNU
1058 @cindex syntax checking
1060 Check the code for syntax errors, but don't do anything beyond that.
1063 Issue all the warnings demanded by strict ANSI standard C; reject
1064 all programs that use forbidden extensions.
1066 Valid ANSI standard C programs should compile properly with or without
1067 this option (though a rare few will require @samp{-ansi}). However,
1068 without this option, certain GNU extensions and traditional C features
1069 are supported as well. With this option, they are rejected.
1071 @samp{-pedantic} does not cause warning messages for use of the
1072 alternate keywords whose names begin and end with @samp{__}. Pedantic
1073 warnings are also disabled in the expression that follows
1074 @code{__extension__}. However, only system header files should use
1075 these escape routes; application programs should avoid them.
1076 @xref{Alternate Keywords}.
1078 This option is not intended to be @i{useful}; it exists only to satisfy
1079 pedants who would otherwise claim that GNU CC fails to support the ANSI
1082 Some users try to use @samp{-pedantic} to check programs for strict ANSI
1083 C conformance. They soon find that it does not do quite what they want:
1084 it finds some non-ANSI practices, but not all---only those for which
1085 ANSI C @emph{requires} a diagnostic.
1087 A feature to report any failure to conform to ANSI C might be useful in
1088 some instances, but would require considerable additional work and would
1089 be quite different from @samp{-pedantic}. We recommend, rather, that
1090 users take advantage of the extensions of GNU C and disregard the
1091 limitations of other compilers. Aside from certain supercomputers and
1092 obsolete small machines, there is less and less reason ever to use any
1093 other C compiler other than for bootstrapping GNU CC.
1095 @item -pedantic-errors
1096 Like @samp{-pedantic}, except that errors are produced rather than
1100 Inhibit all warning messages.
1103 Inhibit warning messages about the use of @samp{#import}.
1105 @item -Wchar-subscripts
1106 Warn if an array subscript has type @code{char}. This is a common cause
1107 of error, as programmers often forget that this type is signed on some
1111 Warn whenever a comment-start sequence @samp{/*} appears in a comment.
1114 Check calls to @code{printf} and @code{scanf}, etc., to make sure that
1115 the arguments supplied have types appropriate to the format string
1119 Warn whenever a function or parameter is implicitly declared.
1122 Warn if parentheses are omitted in certain contexts, such
1123 as when there is an assignment in a context where a truth value
1124 is expected, or when operators are nested whose precedence people
1125 often get confused about.
1128 Warn whenever a function is defined with a return-type that defaults
1129 to @code{int}. Also warn about any @code{return} statement with no
1130 return-value in a function whose return-type is not @code{void}.
1133 Warn whenever a @code{switch} statement has an index of enumeral type
1134 and lacks a @code{case} for one or more of the named codes of that
1135 enumeration. (The presence of a @code{default} label prevents this
1136 warning.) @code{case} labels outside the enumeration range also
1137 provoke warnings when this option is used.
1140 Warn if any trigraphs are encountered (assuming they are enabled).
1143 Warn whenever a variable is unused aside from its declaration,
1144 whenever a function is declared static but never defined, whenever a
1145 label is declared but not used, and whenever a statement computes a
1146 result that is explicitly not used.
1148 To suppress this warning for an expression, simply cast it to void. For
1149 unused variables and parameters, use the @samp{unused} attribute
1150 (@pxref{Variable Attributes}).
1152 @item -Wuninitialized
1153 An automatic variable is used without first being initialized.
1155 These warnings are possible only in optimizing compilation,
1156 because they require data flow information that is computed only
1157 when optimizing. If you don't specify @samp{-O}, you simply won't
1160 These warnings occur only for variables that are candidates for
1161 register allocation. Therefore, they do not occur for a variable that
1162 is declared @code{volatile}, or whose address is taken, or whose size
1163 is other than 1, 2, 4 or 8 bytes. Also, they do not occur for
1164 structures, unions or arrays, even when they are in registers.
1166 Note that there may be no warning about a variable that is used only
1167 to compute a value that itself is never used, because such
1168 computations may be deleted by data flow analysis before the warnings
1171 These warnings are made optional because GNU CC is not smart
1172 enough to see all the reasons why the code might be correct
1173 despite appearing to have an error. Here is one example of how
1192 If the value of @code{y} is always 1, 2 or 3, then @code{x} is
1193 always initialized, but GNU CC doesn't know this. Here is
1194 another common case:
1199 if (change_y) save_y = y, y = new_y;
1201 if (change_y) y = save_y;
1206 This has no bug because @code{save_y} is used only if it is set.
1208 Some spurious warnings can be avoided if you declare all the functions
1209 you use that never return as @code{noreturn}. @xref{Function
1213 @cindex enumeration clash warnings
1214 @cindex warning for enumeration conversions
1215 Warn about conversion between different enumeration types.
1218 @item -Wreorder (C++ only)
1219 @cindex reordering, warning
1220 @cindex warning for reordering of member initializers
1221 Warn when the order of member initializers given in the code does not
1222 match the order in which they must be executed. For instance:
1228 A(): j (0), i (1) @{ @}
1232 Here the compiler will warn that the member initializers for @samp{i}
1233 and @samp{j} will be rearranged to match the declaration order of the
1236 @item -Wtemplate-debugging
1237 @cindex template debugging
1238 When using templates in a C++ program, warn if debugging is not yet
1239 fully available (C++ only).
1242 All of the above @samp{-W} options combined. These are all the
1243 options which pertain to usage that we recommend avoiding and that we
1244 believe is easy to avoid, even in conjunction with macros.
1247 The remaining @samp{-W@dots{}} options are not implied by @samp{-Wall}
1248 because they warn about constructions that we consider reasonable to
1249 use, on occasion, in clean programs.
1253 Print extra warning messages for these events:
1256 @cindex @code{longjmp} warnings
1258 A nonvolatile automatic variable might be changed by a call to
1259 @code{longjmp}. These warnings as well are possible only in
1260 optimizing compilation.
1262 The compiler sees only the calls to @code{setjmp}. It cannot know
1263 where @code{longjmp} will be called; in fact, a signal handler could
1264 call it at any point in the code. As a result, you may get a warning
1265 even when there is in fact no problem because @code{longjmp} cannot
1266 in fact be called at the place which would cause a problem.
1269 A function can return either with or without a value. (Falling
1270 off the end of the function body is considered returning without
1271 a value.) For example, this function would evoke such a
1285 An expression-statement or the left-hand side of a comma expression
1286 contains no side effects.
1287 To suppress the warning, cast the unused expression to void.
1288 For example, an expression such as @samp{x[i,j]} will cause a warning,
1289 but @samp{x[(void)i,j]} will not.
1292 An unsigned value is compared against zero with @samp{<} or @samp{<=}.
1295 A comparison like @samp{x<=y<=z} appears; this is equivalent to
1296 @samp{(x<=y ? 1 : 0) <= z}, which is a different interpretation from
1297 that of ordinary mathematical notation.
1300 Storage-class specifiers like @code{static} are not the first things in
1301 a declaration. According to the C Standard, this usage is obsolescent.
1304 If @samp{-Wall} or @samp{-Wunused} is also specified, warn about unused
1308 An aggregate has a partly bracketed initializer.
1309 For example, the following code would evoke such a warning,
1310 because braces are missing around the initializer for @code{x.h}:
1313 struct s @{ int f, g; @};
1314 struct t @{ struct s h; int i; @};
1315 struct t x = @{ 1, 2, 3 @};
1320 Warn about certain constructs that behave differently in traditional and
1325 Macro arguments occurring within string constants in the macro body.
1326 These would substitute the argument in traditional C, but are part of
1327 the constant in ANSI C.
1330 A function declared external in one block and then used after the end of
1334 A @code{switch} statement has an operand of type @code{long}.
1338 Warn whenever a local variable shadows another local variable.
1340 @item -Wid-clash-@var{len}
1341 Warn whenever two distinct identifiers match in the first @var{len}
1342 characters. This may help you prepare a program that will compile
1343 with certain obsolete, brain-damaged compilers.
1345 @item -Wlarger-than-@var{len}
1346 Warn whenever an object of larger than @var{len} bytes is defined.
1348 @item -Wpointer-arith
1349 Warn about anything that depends on the ``size of'' a function type or
1350 of @code{void}. GNU C assigns these types a size of 1, for
1351 convenience in calculations with @code{void *} pointers and pointers
1354 @item -Wbad-function-cast
1355 Warn whenever a function call is cast to a non-matching type.
1356 For example, warn if @code{int malloc()} is cast to @code{anything *}.
1359 Warn whenever a pointer is cast so as to remove a type qualifier from
1360 the target type. For example, warn if a @code{const char *} is cast
1361 to an ordinary @code{char *}.
1364 Warn whenever a pointer is cast such that the required alignment of the
1365 target is increased. For example, warn if a @code{char *} is cast to
1366 an @code{int *} on machines where integers can only be accessed at
1367 two- or four-byte boundaries.
1369 @item -Wwrite-strings
1370 Give string constants the type @code{const char[@var{length}]} so that
1371 copying the address of one into a non-@code{const} @code{char *}
1372 pointer will get a warning. These warnings will help you find at
1373 compile time code that can try to write into a string constant, but
1374 only if you have been very careful about using @code{const} in
1375 declarations and prototypes. Otherwise, it will just be a nuisance;
1376 this is why we did not make @samp{-Wall} request these warnings.
1379 Warn if a prototype causes a type conversion that is different from what
1380 would happen to the same argument in the absence of a prototype. This
1381 includes conversions of fixed point to floating and vice versa, and
1382 conversions changing the width or signedness of a fixed point argument
1383 except when the same as the default promotion.
1385 Also, warn if a negative integer constant expression is implicitly
1386 converted to an unsigned type. For example, warn about the assignment
1387 @code{x = -1} if @code{x} is unsigned. But do not warn about explicit
1388 casts like @code{(unsigned) -1}.
1390 @item -Waggregate-return
1391 Warn if any functions that return structures or unions are defined or
1392 called. (In languages where you can return an array, this also elicits
1395 @item -Wstrict-prototypes
1396 Warn if a function is declared or defined without specifying the
1397 argument types. (An old-style function definition is permitted without
1398 a warning if preceded by a declaration which specifies the argument
1401 @item -Wmissing-prototypes
1402 Warn if a global function is defined without a previous prototype
1403 declaration. This warning is issued even if the definition itself
1404 provides a prototype. The aim is to detect global functions that fail
1405 to be declared in header files.
1407 @item -Wmissing-declarations
1408 Warn if a global function is defined without a previous declaration.
1409 Do so even if the definition itself provides a prototype.
1410 Use this option to detect global functions that are not declared in
1413 @item -Wredundant-decls
1414 Warn if anything is declared more than once in the same scope, even in
1415 cases where multiple declaration is valid and changes nothing.
1417 @item -Wnested-externs
1418 Warn if an @code{extern} declaration is encountered within an function.
1421 Warn if a function can not be inlined, and either it was declared as inline,
1422 or else the @samp{-finline-functions} option was given.
1424 @item -Woverloaded-virtual
1425 @cindex overloaded virtual fn, warning
1426 @cindex warning for overloaded virtual fn
1427 Warn when a derived class function declaration may be an error in
1428 defining a virtual function (C++ only). In a derived class, the
1429 definitions of virtual functions must match the type signature of a
1430 virtual function declared in the base class. With this option, the
1431 compiler warns when you define a function with the same name as a
1432 virtual function, but with a type signature that does not match any
1433 declarations from the base class.
1435 @item -Wsynth (C++ only)
1436 @cindex warning for synthesized methods
1437 @cindex synthesized methods, warning
1438 Warn when g++'s synthesis behavior does not match that of cfront. For
1444 A& operator = (int);
1454 In this example, g++ will synthesize a default @samp{A& operator =
1455 (const A&);}, while cfront will use the user-defined @samp{operator =}.
1458 Make all warnings into errors.
1461 @node Debugging Options
1462 @section Options for Debugging Your Program or GNU CC
1463 @cindex options, debugging
1464 @cindex debugging information options
1466 GNU CC has various special options that are used for debugging
1467 either your program or GCC:
1471 Produce debugging information in the operating system's native format
1472 (stabs, COFF, XCOFF, or DWARF). GDB can work with this debugging
1475 On most systems that use stabs format, @samp{-g} enables use of extra
1476 debugging information that only GDB can use; this extra information
1477 makes debugging work better in GDB but will probably make other debuggers
1479 refuse to read the program. If you want to control for certain whether
1480 to generate the extra information, use @samp{-gstabs+}, @samp{-gstabs},
1481 @samp{-gxcoff+}, @samp{-gxcoff}, @samp{-gdwarf+}, or @samp{-gdwarf}
1484 Unlike most other C compilers, GNU CC allows you to use @samp{-g} with
1485 @samp{-O}. The shortcuts taken by optimized code may occasionally
1486 produce surprising results: some variables you declared may not exist
1487 at all; flow of control may briefly move where you did not expect it;
1488 some statements may not be executed because they compute constant
1489 results or their values were already at hand; some statements may
1490 execute in different places because they were moved out of loops.
1492 Nevertheless it proves possible to debug optimized output. This makes
1493 it reasonable to use the optimizer for programs that might have bugs.
1495 The following options are useful when GNU CC is generated with the
1496 capability for more than one debugging format.
1499 Produce debugging information in the native format (if that is supported),
1500 including GDB extensions if at all possible.
1503 Produce debugging information in stabs format (if that is supported),
1504 without GDB extensions. This is the format used by DBX on most BSD
1505 systems. On MIPS, Alpha and System V Release 4 systems this option
1506 produces stabs debugging output which is not understood by DBX or SDB.
1507 On System V Release 4 systems this option requires the GNU assembler.
1510 Produce debugging information in stabs format (if that is supported),
1511 using GNU extensions understood only by the GNU debugger (GDB). The
1512 use of these extensions is likely to make other debuggers crash or
1513 refuse to read the program.
1516 Produce debugging information in COFF format (if that is supported).
1517 This is the format used by SDB on most System V systems prior to
1521 Produce debugging information in XCOFF format (if that is supported).
1522 This is the format used by the DBX debugger on IBM RS/6000 systems.
1525 Produce debugging information in XCOFF format (if that is supported),
1526 using GNU extensions understood only by the GNU debugger (GDB). The
1527 use of these extensions is likely to make other debuggers crash or
1528 refuse to read the program, and may cause assemblers other than the GNU
1529 assembler (GAS) to fail with an error.
1532 Produce debugging information in DWARF format (if that is supported).
1533 This is the format used by SDB on most System V Release 4 systems.
1536 Produce debugging information in DWARF format (if that is supported),
1537 using GNU extensions understood only by the GNU debugger (GDB). The
1538 use of these extensions is likely to make other debuggers crash or
1539 refuse to read the program.
1542 @itemx -ggdb@var{level}
1543 @itemx -gstabs@var{level}
1544 @itemx -gcoff@var{level}
1545 @itemx -gxcoff@var{level}
1546 @itemx -gdwarf@var{level}
1547 Request debugging information and also use @var{level} to specify how
1548 much information. The default level is 2.
1550 Level 1 produces minimal information, enough for making backtraces in
1551 parts of the program that you don't plan to debug. This includes
1552 descriptions of functions and external variables, but no information
1553 about local variables and no line numbers.
1555 Level 3 includes extra information, such as all the macro definitions
1556 present in the program. Some debuggers support macro expansion when
1561 Generate extra code to write profile information suitable for the
1562 analysis program @code{prof}. You must use this option when compiling
1563 the source files you want data about, and you must also use it when
1566 @cindex @code{gprof}
1568 Generate extra code to write profile information suitable for the
1569 analysis program @code{gprof}. You must use this option when compiling
1570 the source files you want data about, and you must also use it when
1575 Generate extra code to write profile information for basic blocks, which will
1576 record the number of times each basic block is executed, the basic block start
1577 address, and the function name containing the basic block. If @samp{-g} is
1578 used, the line number and filename of the start of the basic block will also be
1579 recorded. If not overridden by the machine description, the default action is
1580 to append to the text file @file{bb.out}.
1582 This data could be analyzed by a program like @code{tcov}. Note,
1583 however, that the format of the data is not what @code{tcov} expects.
1584 Eventually GNU @code{gprof} should be extended to process this data.
1586 @item -d@var{letters}
1587 Says to make debugging dumps during compilation at times specified by
1588 @var{letters}. This is used for debugging the compiler. The file names
1589 for most of the dumps are made by appending a word to the source file
1590 name (e.g. @file{foo.c.rtl} or @file{foo.c.jump}). Here are the
1591 possible letters for use in @var{letters}, and their meanings:
1595 Dump all macro definitions, at the end of preprocessing, and write no
1598 Dump all macro names, at the end of preprocessing.
1600 Dump all macro definitions, at the end of preprocessing, in addition to
1603 Dump debugging information during parsing, to standard error.
1605 Dump after RTL generation, to @file{@var{file}.rtl}.
1607 Just generate RTL for a function instead of compiling it. Usually used
1610 Dump after first jump optimization, to @file{@var{file}.jump}.
1612 Dump after CSE (including the jump optimization that sometimes
1613 follows CSE), to @file{@var{file}.cse}.
1615 Dump after loop optimization, to @file{@var{file}.loop}.
1617 Dump after the second CSE pass (including the jump optimization that
1618 sometimes follows CSE), to @file{@var{file}.cse2}.
1620 Dump after flow analysis, to @file{@var{file}.flow}.
1622 Dump after instruction combination, to the file
1623 @file{@var{file}.combine}.
1625 Dump after the first instruction scheduling pass, to
1626 @file{@var{file}.sched}.
1628 Dump after local register allocation, to
1629 @file{@var{file}.lreg}.
1631 Dump after global register allocation, to
1632 @file{@var{file}.greg}.
1634 Dump after the second instruction scheduling pass, to
1635 @file{@var{file}.sched2}.
1637 Dump after last jump optimization, to @file{@var{file}.jump2}.
1639 Dump after delayed branch scheduling, to @file{@var{file}.dbr}.
1641 Dump after conversion from registers to stack, to @file{@var{file}.stack}.
1643 Produce all the dumps listed above.
1645 Print statistics on memory usage, at the end of the run, to
1648 Annotate the assembler output with a comment indicating which
1649 pattern and alternative was used.
1652 @item -fpretend-float
1653 When running a cross-compiler, pretend that the target machine uses the
1654 same floating point format as the host machine. This causes incorrect
1655 output of the actual floating constants, but the actual instruction
1656 sequence will probably be the same as GNU CC would make when running on
1660 Store the usual ``temporary'' intermediate files permanently; place them
1661 in the current directory and name them based on the source file. Thus,
1662 compiling @file{foo.c} with @samp{-c -save-temps} would produce files
1663 @file{foo.i} and @file{foo.s}, as well as @file{foo.o}.
1665 @item -print-file-name=@var{library}
1666 Print the full absolute name of the library file @var{library} that
1667 would be used when linking---and don't do anything else. With this
1668 option, GNU CC does not compile or link anything; it just prints the
1671 @item -print-prog-name=@var{program}
1672 Like @samp{-print-file-name}, but searches for a program such as @samp{cpp}.
1674 @item -print-libgcc-file-name
1675 Same as @samp{-print-file-name=libgcc.a}.
1677 This is useful when you use @samp{-nostdlib} or @samp{-nodefaultlibs}
1678 but you do want to link with @file{libgcc.a}. You can do
1681 gcc -nostdlib @var{files}@dots{} `gcc -print-libgcc-file-name`
1684 @item -print-search-dirs
1685 Print the name of the configured installation directory and a list of
1686 program and library directories gcc will search---and don't do anything else.
1688 This is useful when gcc prints the error message
1689 @samp{installation problem, cannot exec cpp: No such file or directory}.
1690 To resolve this you either need to put @file{cpp} and the other compiler
1691 components where gcc expects to find them, or you can set the environment
1692 variable @code{GCC_EXEC_PREFIX} to the directory where you installed them.
1693 Don't forget the trailing '/'.
1694 @xref{Environment Variables}.
1697 @node Optimize Options
1698 @section Options That Control Optimization
1699 @cindex optimize options
1700 @cindex options, optimization
1702 These options control various sorts of optimizations:
1707 Optimize. Optimizing compilation takes somewhat more time, and a lot
1708 more memory for a large function.
1710 Without @samp{-O}, the compiler's goal is to reduce the cost of
1711 compilation and to make debugging produce the expected results.
1712 Statements are independent: if you stop the program with a breakpoint
1713 between statements, you can then assign a new value to any variable or
1714 change the program counter to any other statement in the function and
1715 get exactly the results you would expect from the source code.
1717 Without @samp{-O}, the compiler only allocates variables declared
1718 @code{register} in registers. The resulting compiled code is a little
1719 worse than produced by PCC without @samp{-O}.
1721 With @samp{-O}, the compiler tries to reduce code size and execution
1724 When you specify @samp{-O}, the compiler turns on @samp{-fthread-jumps}
1725 and @samp{-fdefer-pop} on all machines. The compiler turns on
1726 @samp{-fdelayed-branch} on machines that have delay slots, and
1727 @samp{-fomit-frame-pointer} on machines that can support debugging even
1728 without a frame pointer. On some machines the compiler also turns
1729 on other flags.@refill
1732 Optimize even more. GNU CC performs nearly all supported optimizations
1733 that do not involve a space-speed tradeoff. The compiler does not
1734 perform loop unrolling or function inlining when you specify @samp{-O2}.
1735 As compared to @samp{-O}, this option increases both compilation time
1736 and the performance of the generated code.
1738 @samp{-O2} turns on all optional optimizations except for loop unrolling
1739 and function inlining. It also turns on the @samp{-fforce-mem} option
1740 on all machines and frame pointer elimination on machines where doing so
1741 does not interfere with debugging.
1744 Optimize yet more. @samp{-O3} turns on all optimizations specified by
1745 @samp{-O2} and also turns on the @samp{inline-functions} option.
1750 If you use multiple @samp{-O} options, with or without level numbers,
1751 the last such option is the one that is effective.
1754 Options of the form @samp{-f@var{flag}} specify machine-independent
1755 flags. Most flags have both positive and negative forms; the negative
1756 form of @samp{-ffoo} would be @samp{-fno-foo}. In the table below,
1757 only one of the forms is listed---the one which is not the default.
1758 You can figure out the other form by either removing @samp{no-} or
1763 Do not store floating point variables in registers, and inhibit other
1764 options that might change whether a floating point value is taken from a
1767 This option prevents undesirable excess precision on machines such as
1768 the 68000 where the floating registers (of the 68881) keep more
1769 precision than a @code{double} is supposed to have. For most programs,
1770 the excess precision does only good, but a few programs rely on the
1771 precise definition of IEEE floating point. Use @samp{-ffloat-store} for
1774 @item -fno-default-inline
1775 Do not make member functions inline by default merely because they are
1776 defined inside the class scope (C++ only). Otherwise, when you specify
1777 @w{@samp{-O}}, member functions defined inside class scope are compiled
1778 inline by default; i.e., you don't need to add @samp{inline} in front of
1779 the member function name.
1781 @item -fno-defer-pop
1782 Always pop the arguments to each function call as soon as that function
1783 returns. For machines which must pop arguments after a function call,
1784 the compiler normally lets arguments accumulate on the stack for several
1785 function calls and pops them all at once.
1788 Force memory operands to be copied into registers before doing
1789 arithmetic on them. This produces better code by making all memory
1790 references potential common subexpressions. When they are not common
1791 subexpressions, instruction combination should eliminate the separate
1792 register-load. The @samp{-O2} option turns on this option.
1795 Force memory address constants to be copied into registers before
1796 doing arithmetic on them. This may produce better code just as
1797 @samp{-fforce-mem} may.
1799 @item -fomit-frame-pointer
1800 Don't keep the frame pointer in a register for functions that
1801 don't need one. This avoids the instructions to save, set up and
1802 restore frame pointers; it also makes an extra register available
1803 in many functions. @strong{It also makes debugging impossible on
1807 On some machines, such as the Vax, this flag has no effect, because
1808 the standard calling sequence automatically handles the frame pointer
1809 and nothing is saved by pretending it doesn't exist. The
1810 machine-description macro @code{FRAME_POINTER_REQUIRED} controls
1811 whether a target machine supports this flag. @xref{Registers}.@refill
1814 On some machines, such as the Vax, this flag has no effect, because
1815 the standard calling sequence automatically handles the frame pointer
1816 and nothing is saved by pretending it doesn't exist. The
1817 machine-description macro @code{FRAME_POINTER_REQUIRED} controls
1818 whether a target machine supports this flag. @xref{Registers,,Register
1819 Usage, gcc.info, Using and Porting GCC}.@refill
1823 Don't pay attention to the @code{inline} keyword. Normally this option
1824 is used to keep the compiler from expanding any functions inline.
1825 Note that if you are not optimizing, no functions can be expanded inline.
1827 @item -finline-functions
1828 Integrate all simple functions into their callers. The compiler
1829 heuristically decides which functions are simple enough to be worth
1830 integrating in this way.
1832 If all calls to a given function are integrated, and the function is
1833 declared @code{static}, then the function is normally not output as
1834 assembler code in its own right.
1836 @item -fkeep-inline-functions
1837 Even if all calls to a given function are integrated, and the function
1838 is declared @code{static}, nevertheless output a separate run-time
1839 callable version of the function.
1841 @item -fno-function-cse
1842 Do not put function addresses in registers; make each instruction that
1843 calls a constant function contain the function's address explicitly.
1845 This option results in less efficient code, but some strange hacks
1846 that alter the assembler output may be confused by the optimizations
1847 performed when this option is not used.
1850 This option allows GCC to violate some ANSI or IEEE rules and/or
1851 specifications in the interest of optimizing code for speed. For
1852 example, it allows the compiler to assume arguments to the @code{sqrt}
1853 function are non-negative numbers and that no floating-point values
1856 This option should never be turned on by any @samp{-O} option since
1857 it can result in incorrect output for programs which depend on
1858 an exact implementation of IEEE or ANSI rules/specifications for
1862 @c following causes underfulls.. they don't look great, but we deal.
1864 The following options control specific optimizations. The @samp{-O2}
1865 option turns on all of these optimizations except @samp{-funroll-loops}
1866 and @samp{-funroll-all-loops}. On most machines, the @samp{-O} option
1867 turns on the @samp{-fthread-jumps} and @samp{-fdelayed-branch} options,
1868 but specific machines may handle it differently.
1870 You can use the following flags in the rare cases when ``fine-tuning''
1871 of optimizations to be performed is desired.
1874 @item -fstrength-reduce
1875 Perform the optimizations of loop strength reduction and
1876 elimination of iteration variables.
1878 @item -fthread-jumps
1879 Perform optimizations where we check to see if a jump branches to a
1880 location where another comparison subsumed by the first is found. If
1881 so, the first branch is redirected to either the destination of the
1882 second branch or a point immediately following it, depending on whether
1883 the condition is known to be true or false.
1885 @item -fcse-follow-jumps
1886 In common subexpression elimination, scan through jump instructions
1887 when the target of the jump is not reached by any other path. For
1888 example, when CSE encounters an @code{if} statement with an
1889 @code{else} clause, CSE will follow the jump when the condition
1892 @item -fcse-skip-blocks
1893 This is similar to @samp{-fcse-follow-jumps}, but causes CSE to
1894 follow jumps which conditionally skip over blocks. When CSE
1895 encounters a simple @code{if} statement with no else clause,
1896 @samp{-fcse-skip-blocks} causes CSE to follow the jump around the
1897 body of the @code{if}.
1899 @item -frerun-cse-after-loop
1900 Re-run common subexpression elimination after loop optimizations has been
1903 @item -fexpensive-optimizations
1904 Perform a number of minor optimizations that are relatively expensive.
1906 @item -fdelayed-branch
1907 If supported for the target machine, attempt to reorder instructions
1908 to exploit instruction slots available after delayed branch
1911 @item -fschedule-insns
1912 If supported for the target machine, attempt to reorder instructions to
1913 eliminate execution stalls due to required data being unavailable. This
1914 helps machines that have slow floating point or memory load instructions
1915 by allowing other instructions to be issued until the result of the load
1916 or floating point instruction is required.
1918 @item -fschedule-insns2
1919 Similar to @samp{-fschedule-insns}, but requests an additional pass of
1920 instruction scheduling after register allocation has been done. This is
1921 especially useful on machines with a relatively small number of
1922 registers and where memory load instructions take more than one cycle.
1924 @item -fcaller-saves
1925 Enable values to be allocated in registers that will be clobbered by
1926 function calls, by emitting extra instructions to save and restore the
1927 registers around such calls. Such allocation is done only when it
1928 seems to result in better code than would otherwise be produced.
1930 This option is enabled by default on certain machines, usually those
1931 which have no call-preserved registers to use instead.
1933 @item -funroll-loops
1934 Perform the optimization of loop unrolling. This is only done for loops
1935 whose number of iterations can be determined at compile time or run time.
1936 @samp{-funroll-loop} implies both @samp{-fstrength-reduce} and
1937 @samp{-frerun-cse-after-loop}.
1939 @item -funroll-all-loops
1940 Perform the optimization of loop unrolling. This is done for all loops
1941 and usually makes programs run more slowly. @samp{-funroll-all-loops}
1942 implies @samp{-fstrength-reduce} as well as @samp{-frerun-cse-after-loop}.
1945 Disable any machine-specific peephole optimizations.
1948 @node Preprocessor Options
1949 @section Options Controlling the Preprocessor
1950 @cindex preprocessor options
1951 @cindex options, preprocessor
1953 These options control the C preprocessor, which is run on each C source
1954 file before actual compilation.
1956 If you use the @samp{-E} option, nothing is done except preprocessing.
1957 Some of these options make sense only together with @samp{-E} because
1958 they cause the preprocessor output to be unsuitable for actual
1962 @item -include @var{file}
1963 Process @var{file} as input before processing the regular input file.
1964 In effect, the contents of @var{file} are compiled first. Any @samp{-D}
1965 and @samp{-U} options on the command line are always processed before
1966 @samp{-include @var{file}}, regardless of the order in which they are
1967 written. All the @samp{-include} and @samp{-imacros} options are
1968 processed in the order in which they are written.
1970 @item -imacros @var{file}
1971 Process @var{file} as input, discarding the resulting output, before
1972 processing the regular input file. Because the output generated from
1973 @var{file} is discarded, the only effect of @samp{-imacros @var{file}}
1974 is to make the macros defined in @var{file} available for use in the
1977 Any @samp{-D} and @samp{-U} options on the command line are always
1978 processed before @samp{-imacros @var{file}}, regardless of the order in
1979 which they are written. All the @samp{-include} and @samp{-imacros}
1980 options are processed in the order in which they are written.
1982 @item -idirafter @var{dir}
1983 @cindex second include path
1984 Add the directory @var{dir} to the second include path. The directories
1985 on the second include path are searched when a header file is not found
1986 in any of the directories in the main include path (the one that
1989 @item -iprefix @var{prefix}
1990 Specify @var{prefix} as the prefix for subsequent @samp{-iwithprefix}
1993 @item -iwithprefix @var{dir}
1994 Add a directory to the second include path. The directory's name is
1995 made by concatenating @var{prefix} and @var{dir}, where @var{prefix} was
1996 specified previously with @samp{-iprefix}. If you have not specified a
1997 prefix yet, the directory containing the installed passes of the
1998 compiler is used as the default.
2000 @item -iwithprefixbefore @var{dir}
2001 Add a directory to the main include path. The directory's name is made
2002 by concatenating @var{prefix} and @var{dir}, as in the case of
2003 @samp{-iwithprefix}.
2005 @item -isystem @var{dir}
2006 Add a directory to the beginning of the second include path, marking it
2007 as a system directory, so that it gets the same special treatment as
2008 is applied to the standard system directories.
2011 Do not search the standard system directories for header files. Only
2012 the directories you have specified with @samp{-I} options (and the
2013 current directory, if appropriate) are searched. @xref{Directory
2014 Options}, for information on @samp{-I}.
2016 By using both @samp{-nostdinc} and @samp{-I-}, you can limit the include-file
2017 search path to only those directories you specify explicitly.
2020 Do not predefine any nonstandard macros. (Including architecture flags).
2023 Run only the C preprocessor. Preprocess all the C source files
2024 specified and output the results to standard output or to the
2025 specified output file.
2028 Tell the preprocessor not to discard comments. Used with the
2032 Tell the preprocessor not to generate @samp{#line} directives.
2033 Used with the @samp{-E} option.
2036 @cindex dependencies, make
2038 Tell the preprocessor to output a rule suitable for @code{make}
2039 describing the dependencies of each object file. For each source file,
2040 the preprocessor outputs one @code{make}-rule whose target is the object
2041 file name for that source file and whose dependencies are all the
2042 @code{#include} header files it uses. This rule may be a single line or
2043 may be continued with @samp{\}-newline if it is long. The list of rules
2044 is printed on standard output instead of the preprocessed C program.
2046 @samp{-M} implies @samp{-E}.
2048 Another way to specify output of a @code{make} rule is by setting
2049 the environment variable @code{DEPENDENCIES_OUTPUT} (@pxref{Environment
2053 Like @samp{-M} but the output mentions only the user header files
2054 included with @samp{#include "@var{file}"}. System header files
2055 included with @samp{#include <@var{file}>} are omitted.
2058 Like @samp{-M} but the dependency information is written to a file made by
2059 replacing ".c" with ".d" at the end of the input file names.
2060 This is in addition to compiling the file as specified---@samp{-MD} does
2061 not inhibit ordinary compilation the way @samp{-M} does.
2063 In Mach, you can use the utility @code{md} to merge multiple dependency
2064 files into a single dependency file suitable for using with the @samp{make}
2068 Like @samp{-MD} except mention only user header files, not system
2072 Treat missing header files as generated files and assume they live in the
2073 same directory as the source file. If you specify @samp{-MG}, you
2074 must also specify either @samp{-M} or @samp{-MM}. @samp{-MG} is not
2075 supported with @samp{-MD} or @samp{-MMD}.
2078 Print the name of each header file used, in addition to other normal
2081 @item -A@var{question}(@var{answer})
2082 Assert the answer @var{answer} for @var{question}, in case it is tested
2083 with a preprocessing conditional such as @samp{#if
2084 #@var{question}(@var{answer})}. @samp{-A-} disables the standard
2085 assertions that normally describe the target machine.
2088 Define macro @var{macro} with the string @samp{1} as its definition.
2090 @item -D@var{macro}=@var{defn}
2091 Define macro @var{macro} as @var{defn}. All instances of @samp{-D} on
2092 the command line are processed before any @samp{-U} options.
2095 Undefine macro @var{macro}. @samp{-U} options are evaluated after all
2096 @samp{-D} options, but before any @samp{-include} and @samp{-imacros}
2100 Tell the preprocessor to output only a list of the macro definitions
2101 that are in effect at the end of preprocessing. Used with the @samp{-E}
2105 Tell the preprocessing to pass all macro definitions into the output, in
2106 their proper sequence in the rest of the output.
2109 Like @samp{-dD} except that the macro arguments and contents are omitted.
2110 Only @samp{#define @var{name}} is included in the output.
2113 Support ANSI C trigraphs. The @samp{-ansi} option also has this effect.
2115 @item -Wp,@var{option}
2116 Pass @var{option} as an option to the preprocessor. If @var{option}
2117 contains commas, it is split into multiple options at the commas.
2120 @node Assembler Options
2121 @section Passing Options to the Assembler
2123 @c prevent bad page break with this line
2124 You can pass options to the assembler.
2127 @item -Wa,@var{option}
2128 Pass @var{option} as an option to the assembler. If @var{option}
2129 contains commas, it is split into multiple options at the commas.
2133 @section Options for Linking
2134 @cindex link options
2135 @cindex options, linking
2137 These options come into play when the compiler links object files into
2138 an executable output file. They are meaningless if the compiler is
2139 not doing a link step.
2143 @item @var{object-file-name}
2144 A file name that does not end in a special recognized suffix is
2145 considered to name an object file or library. (Object files are
2146 distinguished from libraries by the linker according to the file
2147 contents.) If linking is done, these object files are used as input
2153 If any of these options is used, then the linker is not run, and
2154 object file names should not be used as arguments. @xref{Overall
2158 @item -l@var{library}
2159 Search the library named @var{library} when linking.
2161 It makes a difference where in the command you write this option; the
2162 linker searches processes libraries and object files in the order they
2163 are specified. Thus, @samp{foo.o -lz bar.o} searches library @samp{z}
2164 after file @file{foo.o} but before @file{bar.o}. If @file{bar.o} refers
2165 to functions in @samp{z}, those functions may not be loaded.
2167 The linker searches a standard list of directories for the library,
2168 which is actually a file named @file{lib@var{library}.a}. The linker
2169 then uses this file as if it had been specified precisely by name.
2171 The directories searched include several standard system directories
2172 plus any that you specify with @samp{-L}.
2174 Normally the files found this way are library files---archive files
2175 whose members are object files. The linker handles an archive file by
2176 scanning through it for members which define symbols that have so far
2177 been referenced but not defined. But if the file that is found is an
2178 ordinary object file, it is linked in the usual fashion. The only
2179 difference between using an @samp{-l} option and specifying a file name
2180 is that @samp{-l} surrounds @var{library} with @samp{lib} and @samp{.a}
2181 and searches several directories.
2184 You need this special case of the @samp{-l} option in order to
2185 link an Objective C program.
2188 Do not use the standard system startup files when linking.
2189 The standard system libraries are used normally, unless @code{-nostdlib}
2190 or @code{-nodefaultlibs} is used.
2192 @item -nodefaultlibs
2193 Do not use the standard system libraries when linking.
2194 Only the libraries you specify will be passed to the linker.
2195 The standard startup files are used normally, unless @code{-nostartfiles}
2199 Do not use the standard system startup files or libraries when linking.
2200 No startup files and only the libraries you specify will be passed to
2203 @cindex @code{-lgcc}, use with @code{-nostdlib}
2204 @cindex @code{-nostdlib} and unresolved references
2205 @cindex unresolved references and @code{-nostdlib}
2206 @cindex @code{-lgcc}, use with @code{-nodefaultlibs}
2207 @cindex @code{-nodefaultlibs} and unresolved references
2208 @cindex unresolved references and @code{-nodefaultlibs}
2209 One of the standard libraries bypassed by @samp{-nostdlib} and
2210 @samp{-nodefaultlibs} is @file{libgcc.a}, a library of internal subroutines
2211 that GNU CC uses to overcome shortcomings of particular machines, or special
2212 needs for some languages.
2214 (@xref{Interface,,Interfacing to GNU CC Output}, for more discussion of
2218 (@xref{Interface,,Interfacing to GNU CC Output,gcc.info,Porting GNU CC},
2219 for more discussion of @file{libgcc.a}.)
2221 In most cases, you need @file{libgcc.a} even when you want to avoid
2222 other standard libraries. In other words, when you specify @samp{-nostdlib}
2223 or @samp{-nodefaultlibs} you should usually specify @samp{-lgcc} as well.
2224 This ensures that you have no unresolved references to internal GNU CC
2225 library subroutines. (For example, @samp{__main}, used to ensure C++
2226 constructors will be called; @pxref{Collect2,,@code{collect2}}.)
2229 Remove all symbol table and relocation information from the executable.
2232 On systems that support dynamic linking, this prevents linking with the shared
2233 libraries. On other systems, this option has no effect.
2236 Produce a shared object which can then be linked with other objects to
2237 form an executable. Only a few systems support this option.
2240 Bind references to global symbols when building a shared object. Warn
2241 about any unresolved references (unless overridden by the link editor
2242 option @samp{-Xlinker -z -Xlinker defs}). Only a few systems support
2245 @item -Xlinker @var{option}
2246 Pass @var{option} as an option to the linker. You can use this to
2247 supply system-specific linker options which GNU CC does not know how to
2250 If you want to pass an option that takes an argument, you must use
2251 @samp{-Xlinker} twice, once for the option and once for the argument.
2252 For example, to pass @samp{-assert definitions}, you must write
2253 @samp{-Xlinker -assert -Xlinker definitions}. It does not work to write
2254 @samp{-Xlinker "-assert definitions"}, because this passes the entire
2255 string as a single argument, which is not what the linker expects.
2257 @item -Wl,@var{option}
2258 Pass @var{option} as an option to the linker. If @var{option} contains
2259 commas, it is split into multiple options at the commas.
2261 @item -u @var{symbol}
2262 Pretend the symbol @var{symbol} is undefined, to force linking of
2263 library modules to define it. You can use @samp{-u} multiple times with
2264 different symbols to force loading of additional library modules.
2267 @node Directory Options
2268 @section Options for Directory Search
2269 @cindex directory options
2270 @cindex options, directory search
2273 These options specify directories to search for header files, for
2274 libraries and for parts of the compiler:
2278 Add the directory @var{directory} to the head of the list of directories
2279 to be searched for header files. This can be used to override a system
2280 header file, substituting your own version, since these directories are
2281 searched before the system header file directories. If you use more
2282 than one @samp{-I} option, the directories are scanned in left-to-right
2283 order; the standard system directories come after.
2286 Any directories you specify with @samp{-I} options before the @samp{-I-}
2287 option are searched only for the case of @samp{#include "@var{file}"};
2288 they are not searched for @samp{#include <@var{file}>}.
2290 If additional directories are specified with @samp{-I} options after
2291 the @samp{-I-}, these directories are searched for all @samp{#include}
2292 directives. (Ordinarily @emph{all} @samp{-I} directories are used
2295 In addition, the @samp{-I-} option inhibits the use of the current
2296 directory (where the current input file came from) as the first search
2297 directory for @samp{#include "@var{file}"}. There is no way to
2298 override this effect of @samp{-I-}. With @samp{-I.} you can specify
2299 searching the directory which was current when the compiler was
2300 invoked. That is not exactly the same as what the preprocessor does
2301 by default, but it is often satisfactory.
2303 @samp{-I-} does not inhibit the use of the standard system directories
2304 for header files. Thus, @samp{-I-} and @samp{-nostdinc} are
2308 Add directory @var{dir} to the list of directories to be searched
2311 @item -B@var{prefix}
2312 This option specifies where to find the executables, libraries,
2313 include files, and data files of the compiler itself.
2315 The compiler driver program runs one or more of the subprograms
2316 @file{cpp}, @file{cc1}, @file{as} and @file{ld}. It tries
2317 @var{prefix} as a prefix for each program it tries to run, both with and
2318 without @samp{@var{machine}/@var{version}/} (@pxref{Target Options}).
2320 For each subprogram to be run, the compiler driver first tries the
2321 @samp{-B} prefix, if any. If that name is not found, or if @samp{-B}
2322 was not specified, the driver tries two standard prefixes, which are
2323 @file{/usr/lib/gcc/} and @file{/usr/local/lib/gcc-lib/}. If neither of
2324 those results in a file name that is found, the unmodified program
2325 name is searched for using the directories specified in your
2326 @samp{PATH} environment variable.
2328 @samp{-B} prefixes that effectively specify directory names also apply
2329 to libraries in the linker, because the compiler translates these
2330 options into @samp{-L} options for the linker. They also apply to
2331 includes files in the preprocessor, because the compiler translates these
2332 options into @samp{-isystem} options for the preprocessor. In this case,
2333 the compiler appends @samp{include} to the prefix.
2335 The run-time support file @file{libgcc.a} can also be searched for using
2336 the @samp{-B} prefix, if needed. If it is not found there, the two
2337 standard prefixes above are tried, and that is all. The file is left
2338 out of the link if it is not found by those means.
2340 Another way to specify a prefix much like the @samp{-B} prefix is to use
2341 the environment variable @code{GCC_EXEC_PREFIX}. @xref{Environment
2345 @node Target Options
2346 @section Specifying Target Machine and Compiler Version
2347 @cindex target options
2348 @cindex cross compiling
2349 @cindex specifying machine version
2350 @cindex specifying compiler version and target machine
2351 @cindex compiler version, specifying
2352 @cindex target machine, specifying
2354 By default, GNU CC compiles code for the same type of machine that you
2355 are using. However, it can also be installed as a cross-compiler, to
2356 compile for some other type of machine. In fact, several different
2357 configurations of GNU CC, for different target machines, can be
2358 installed side by side. Then you specify which one to use with the
2361 In addition, older and newer versions of GNU CC can be installed side
2362 by side. One of them (probably the newest) will be the default, but
2363 you may sometimes wish to use another.
2366 @item -b @var{machine}
2367 The argument @var{machine} specifies the target machine for compilation.
2368 This is useful when you have installed GNU CC as a cross-compiler.
2370 The value to use for @var{machine} is the same as was specified as the
2371 machine type when configuring GNU CC as a cross-compiler. For
2372 example, if a cross-compiler was configured with @samp{configure
2373 i386v}, meaning to compile for an 80386 running System V, then you
2374 would specify @samp{-b i386v} to run that cross compiler.
2376 When you do not specify @samp{-b}, it normally means to compile for
2377 the same type of machine that you are using.
2379 @item -V @var{version}
2380 The argument @var{version} specifies which version of GNU CC to run.
2381 This is useful when multiple versions are installed. For example,
2382 @var{version} might be @samp{2.0}, meaning to run GNU CC version 2.0.
2384 The default version, when you do not specify @samp{-V}, is the last
2385 version of GNU CC that you installed.
2388 The @samp{-b} and @samp{-V} options actually work by controlling part of
2389 the file name used for the executable files and libraries used for
2390 compilation. A given version of GNU CC, for a given target machine, is
2391 normally kept in the directory @file{/usr/local/lib/gcc-lib/@var{machine}/@var{version}}.@refill
2393 Thus, sites can customize the effect of @samp{-b} or @samp{-V} either by
2394 changing the names of these directories or adding alternate names (or
2395 symbolic links). If in directory @file{/usr/local/lib/gcc-lib/} the
2396 file @file{80386} is a link to the file @file{i386v}, then @samp{-b
2397 80386} becomes an alias for @samp{-b i386v}.
2399 In one respect, the @samp{-b} or @samp{-V} do not completely change
2400 to a different compiler: the top-level driver program @code{gcc}
2401 that you originally invoked continues to run and invoke the other
2402 executables (preprocessor, compiler per se, assembler and linker)
2403 that do the real work. However, since no real work is done in the
2404 driver program, it usually does not matter that the driver program
2405 in use is not the one for the specified target and version.
2407 The only way that the driver program depends on the target machine is
2408 in the parsing and handling of special machine-specific options.
2409 However, this is controlled by a file which is found, along with the
2410 other executables, in the directory for the specified version and
2411 target machine. As a result, a single installed driver program adapts
2412 to any specified target machine and compiler version.
2414 The driver program executable does control one significant thing,
2415 however: the default version and target machine. Therefore, you can
2416 install different instances of the driver program, compiled for
2417 different targets or versions, under different names.
2419 For example, if the driver for version 2.0 is installed as @code{ogcc}
2420 and that for version 2.1 is installed as @code{gcc}, then the command
2421 @code{gcc} will use version 2.1 by default, while @code{ogcc} will use
2422 2.0 by default. However, you can choose either version with either
2423 command with the @samp{-V} option.
2425 @node Submodel Options
2426 @section Hardware Models and Configurations
2427 @cindex submodel options
2428 @cindex specifying hardware config
2429 @cindex hardware models and configurations, specifying
2430 @cindex machine dependent options
2432 Earlier we discussed the standard option @samp{-b} which chooses among
2433 different installed compilers for completely different target
2434 machines, such as Vax vs. 68000 vs. 80386.
2436 In addition, each of these target machine types can have its own
2437 special options, starting with @samp{-m}, to choose among various
2438 hardware models or configurations---for example, 68010 vs 68020,
2439 floating coprocessor or none. A single installed version of the
2440 compiler can compile for any model or configuration, according to the
2443 Some configurations of the compiler also support additional special
2444 options, usually for compatibility with other compilers on the same
2448 These options are defined by the macro @code{TARGET_SWITCHES} in the
2449 machine description. The default for the options is also defined by
2450 that macro, which enables you to change the defaults.
2461 * RS/6000 and PowerPC Options::
2466 * Intel 960 Options::
2467 * DEC Alpha Options::
2470 * System V Options::
2473 @node M680x0 Options
2474 @subsection M680x0 Options
2475 @cindex M680x0 options
2477 These are the @samp{-m} options defined for the 68000 series. The default
2478 values for these options depends on which style of 68000 was selected when
2479 the compiler was configured; the defaults for the most common choices are
2485 Generate output for a 68000. This is the default
2486 when the compiler is configured for 68000-based systems.
2490 Generate output for a 68020. This is the default
2491 when the compiler is configured for 68020-based systems.
2494 Generate output containing 68881 instructions for floating point.
2495 This is the default for most 68020 systems unless @samp{-nfp} was
2496 specified when the compiler was configured.
2499 Generate output for a 68030. This is the default when the compiler is
2500 configured for 68030-based systems.
2503 Generate output for a 68040. This is the default when the compiler is
2504 configured for 68040-based systems.
2506 This option inhibits the use of 68881/68882 instructions that have to be
2507 emulated by software on the 68040. If your 68040 does not have code to
2508 emulate those instructions, use @samp{-m68040}.
2511 Generate output for a 68040, without using any of the new instructions.
2512 This results in code which can run relatively efficiently on either a
2513 68020/68881 or a 68030 or a 68040. The generated code does use the
2514 68881 instructions that are emulated on the 68040.
2517 Generate output containing Sun FPA instructions for floating point.
2520 Generate output containing library calls for floating point.
2521 @strong{Warning:} the requisite libraries are not available for all m68k
2522 targets. Normally the facilities of the machine's usual C compiler are
2523 used, but this can't be done directly in cross-compilation. You must
2524 make your own arrangements to provide suitable library functions for
2525 cross-compilation. The embedded targets @samp{m68k-*-aout} and
2526 @samp{m68k-*-coff} do provide software floating point support.
2529 Consider type @code{int} to be 16 bits wide, like @code{short int}.
2532 Do not use the bit-field instructions. The @samp{-m68000} option
2533 implies @w{@samp{-mnobitfield}}.
2536 Do use the bit-field instructions. The @samp{-m68020} option implies
2537 @samp{-mbitfield}. This is the default if you use a configuration
2538 designed for a 68020.
2541 Use a different function-calling convention, in which functions
2542 that take a fixed number of arguments return with the @code{rtd}
2543 instruction, which pops their arguments while returning. This
2544 saves one instruction in the caller since there is no need to pop
2545 the arguments there.
2547 This calling convention is incompatible with the one normally
2548 used on Unix, so you cannot use it if you need to call libraries
2549 compiled with the Unix compiler.
2551 Also, you must provide function prototypes for all functions that
2552 take variable numbers of arguments (including @code{printf});
2553 otherwise incorrect code will be generated for calls to those
2556 In addition, seriously incorrect code will result if you call a
2557 function with too many arguments. (Normally, extra arguments are
2558 harmlessly ignored.)
2560 The @code{rtd} instruction is supported by the 68010 and 68020
2561 processors, but not by the 68000.
2565 @subsection VAX Options
2568 These @samp{-m} options are defined for the Vax:
2572 Do not output certain jump instructions (@code{aobleq} and so on)
2573 that the Unix assembler for the Vax cannot handle across long
2577 Do output those jump instructions, on the assumption that you
2578 will assemble with the GNU assembler.
2581 Output code for g-format floating point numbers instead of d-format.
2585 @subsection SPARC Options
2586 @cindex SPARC options
2588 These @samp{-m} switches are supported on the SPARC:
2593 Specify @samp{-mapp-regs} to generate output using the global registers
2594 2 through 4, which the SPARC SVR4 ABI reserves for applications. This
2597 To be fully SVR4 ABI compliant at the cost of some performance loss,
2598 specify @samp{-mno-app-regs}. You should compile libraries and system
2599 software with this option.
2603 Generate output containing floating point instructions. This is the
2608 Generate output containing library calls for floating point.
2609 @strong{Warning:} the requisite libraries are not available for all SPARC
2610 targets. Normally the facilities of the machine's usual C compiler are
2611 used, but this cannot be done directly in cross-compilation. You must make
2612 your own arrangements to provide suitable library functions for
2613 cross-compilation. The embedded targets @samp{sparc-*-aout} and
2614 @samp{sparclite-*-*} do provide software floating point support.
2616 @samp{-msoft-float} changes the calling convention in the output file;
2617 therefore, it is only useful if you compile @emph{all} of a program with
2618 this option. In particular, you need to compile @file{libgcc.a}, the
2619 library that comes with GNU CC, with @samp{-msoft-float} in order for
2622 @item -mhard-quad-float
2623 Generate output containing quad-word (long double) floating point
2626 @item -msoft-quad-float
2627 Generate output containing library calls for quad-word (long double)
2628 floating point instructions. The functions called are those specified
2629 in the SPARC ABI. This is the default.
2631 As of this writing, there are no sparc implementations that have hardware
2632 support for the quad-word floating point instructions. They all invoke
2633 a trap handler for one of these instructions, and then the trap handler
2634 emulates the effect of the instruction. Because of the trap handler overhead,
2635 this is much slower than calling the ABI library routines. Thus the
2636 @samp{-msoft-quad-float} option is the default.
2640 With @samp{-mepilogue} (the default), the compiler always emits code for
2641 function exit at the end of each function. Any function exit in
2642 the middle of the function (such as a return statement in C) will
2643 generate a jump to the exit code at the end of the function.
2645 With @samp{-mno-epilogue}, the compiler tries to emit exit code inline
2646 at every function exit.
2650 With @samp{-mflat}, the compiler does not generate save/restore instructions
2651 and will use a "flat" or single register window calling convention.
2652 This model uses %i7 as the frame pointer and is compatible with the normal
2653 register window model. Code from either may be intermixed although
2654 debugger support is still incomplete. The local registers and the input
2655 registers (0-5) are still treated as "call saved" registers and will be
2656 saved on the stack as necessary.
2658 With @samp{-mno-flat} (the default), the compiler emits save/restore
2659 instructions (except for leaf functions) and is the normal mode of operation.
2661 @item -mno-unaligned-doubles
2662 @itemx -munaligned-doubles
2663 Assume that doubles have 8 byte alignment. This is the default.
2665 With @samp{-munaligned-doubles}, GNU CC assumes that doubles have 8 byte
2666 alignment only if they are contained in another type, or if they have an
2667 absolute address. Otherwise, it assumes they have 4 byte alignment.
2668 Specifying this option avoids some rare compatibility problems with code
2669 generated by other compilers. It is not the default because it results
2670 in a performance loss, especially for floating point code.
2674 These two options select variations on the SPARC architecture.
2676 By default (unless specifically configured for the Fujitsu SPARClite),
2677 GCC generates code for the v7 variant of the SPARC architecture.
2679 @samp{-mv8} will give you SPARC v8 code. The only difference from v7
2680 code is that the compiler emits the integer multiply and integer
2681 divide instructions which exist in SPARC v8 but not in SPARC v7.
2683 @samp{-msparclite} will give you SPARClite code. This adds the integer
2684 multiply, integer divide step and scan (@code{ffs}) instructions which
2685 exist in SPARClite but not in SPARC v7.
2689 These two options select the processor for which the code is optimised.
2691 With @samp{-mcypress} (the default), the compiler optimizes code for the
2692 Cypress CY7C602 chip, as used in the SparcStation/SparcServer 3xx series.
2693 This is also appropriate for the older SparcStation 1, 2, IPX etc.
2695 With @samp{-msupersparc} the compiler optimizes code for the SuperSparc cpu, as
2696 used in the SparcStation 10, 1000 and 2000 series. This flag also enables use
2697 of the full SPARC v8 instruction set.
2700 In a future version of GCC, these options will very likely be
2701 renamed to @samp{-mcpu=cypress} and @samp{-mcpu=supersparc}.
2703 These @samp{-m} switches are supported in addition to the above
2704 on SPARC V9 processors:
2708 Generate code for the Medium/Low code model: assume a 32 bit address space.
2709 Programs are statically linked, PIC is not supported. Pointers are still
2712 It is very likely that a future version of GCC will rename this option.
2715 Generate code for the Medium/Anywhere code model: assume a 32 bit text
2716 segment starting at offset 0, and a 32 bit data segment starting anywhere
2717 (determined at link time). Programs are statically linked, PIC is not
2718 supported. Pointers are still 64 bits.
2720 It is very likely that a future version of GCC will rename this option.
2723 Types long and int are 64 bits.
2726 Types long and int are 32 bits.
2730 Type long is 64 bits, and type int is 32 bits.
2733 @itemx -mno-stack-bias
2734 With @samp{-mstack-bias}, GNU CC assumes that the stack pointer, and
2735 frame pointer if present, are offset by -2047 which must be added back
2736 when making stack frame references.
2737 Otherwise, assume no such offset is present.
2740 @node Convex Options
2741 @subsection Convex Options
2742 @cindex Convex options
2744 These @samp{-m} options are defined for Convex:
2748 Generate output for C1. The code will run on any Convex machine.
2749 The preprocessor symbol @code{__convex__c1__} is defined.
2752 Generate output for C2. Uses instructions not available on C1.
2753 Scheduling and other optimizations are chosen for max performance on C2.
2754 The preprocessor symbol @code{__convex_c2__} is defined.
2757 Generate output for C32xx. Uses instructions not available on C1.
2758 Scheduling and other optimizations are chosen for max performance on C32.
2759 The preprocessor symbol @code{__convex_c32__} is defined.
2762 Generate output for C34xx. Uses instructions not available on C1.
2763 Scheduling and other optimizations are chosen for max performance on C34.
2764 The preprocessor symbol @code{__convex_c34__} is defined.
2767 Generate output for C38xx. Uses instructions not available on C1.
2768 Scheduling and other optimizations are chosen for max performance on C38.
2769 The preprocessor symbol @code{__convex_c38__} is defined.
2772 Generate code which puts an argument count in the word preceding each
2773 argument list. This is compatible with regular CC, and a few programs
2774 may need the argument count word. GDB and other source-level debuggers
2775 do not need it; this info is in the symbol table.
2778 Omit the argument count word. This is the default.
2780 @item -mvolatile-cache
2781 Allow volatile references to be cached. This is the default.
2783 @item -mvolatile-nocache
2784 Volatile references bypass the data cache, going all the way to memory.
2785 This is only needed for multi-processor code that does not use standard
2786 synchronization instructions. Making non-volatile references to volatile
2787 locations will not necessarily work.
2790 Type long is 32 bits, the same as type int. This is the default.
2793 Type long is 64 bits, the same as type long long. This option is useless,
2794 because no library support exists for it.
2797 @node AMD29K Options
2798 @subsection AMD29K Options
2799 @cindex AMD29K options
2801 These @samp{-m} options are defined for the AMD Am29000:
2806 @cindex DW bit (29k)
2807 Generate code that assumes the @code{DW} bit is set, i.e., that byte and
2808 halfword operations are directly supported by the hardware. This is the
2813 Generate code that assumes the @code{DW} bit is not set.
2817 @cindex byte writes (29k)
2818 Generate code that assumes the system supports byte and halfword write
2819 operations. This is the default.
2823 Generate code that assumes the systems does not support byte and
2824 halfword write operations. @samp{-mnbw} implies @samp{-mndw}.
2828 @cindex memory model (29k)
2829 Use a small memory model that assumes that all function addresses are
2830 either within a single 256 KB segment or at an absolute address of less
2831 than 256k. This allows the @code{call} instruction to be used instead
2832 of a @code{const}, @code{consth}, @code{calli} sequence.
2836 Use the normal memory model: Generate @code{call} instructions only when
2837 calling functions in the same file and @code{calli} instructions
2838 otherwise. This works if each file occupies less than 256 KB but allows
2839 the entire executable to be larger than 256 KB. This is the default.
2842 Always use @code{calli} instructions. Specify this option if you expect
2843 a single file to compile into more than 256 KB of code.
2847 @cindex processor selection (29k)
2848 Generate code for the Am29050.
2852 Generate code for the Am29000. This is the default.
2854 @item -mkernel-registers
2855 @kindex -mkernel-registers
2856 @cindex kernel and user registers (29k)
2857 Generate references to registers @code{gr64-gr95} instead of to
2858 registers @code{gr96-gr127}. This option can be used when compiling
2859 kernel code that wants a set of global registers disjoint from that used
2862 Note that when this option is used, register names in @samp{-f} flags
2863 must use the normal, user-mode, names.
2865 @item -muser-registers
2866 @kindex -muser-registers
2867 Use the normal set of global registers, @code{gr96-gr127}. This is the
2871 @itemx -mno-stack-check
2872 @kindex -mstack-check
2873 @cindex stack checks (29k)
2874 Insert (or do not insert) a call to @code{__msp_check} after each stack
2875 adjustment. This is often used for kernel code.
2878 @itemx -mno-storem-bug
2879 @kindex -mstorem-bug
2880 @cindex storem bug (29k)
2881 @samp{-mstorem-bug} handles 29k processors which cannot handle the
2882 separation of a mtsrim insn and a storem instruction (most 29000 chips
2883 to date, but not the 29050).
2885 @item -mno-reuse-arg-regs
2886 @itemx -mreuse-arg-regs
2887 @kindex -mreuse-arg-regs
2888 @samp{-mno-reuse-arg-regs} tells the compiler to only use incoming argument
2889 registers for copying out arguments. This helps detect calling a function
2890 with fewer arguments than it was declared with.
2893 @kindex -msoft-float
2894 Generate output containing library calls for floating point.
2895 @strong{Warning:} the requisite libraries are not part of GNU CC.
2896 Normally the facilities of the machine's usual C compiler are used, but
2897 this can't be done directly in cross-compilation. You must make your
2898 own arrangements to provide suitable library functions for
2903 @subsection ARM Options
2906 These @samp{-m} options are defined for Advanced RISC Machines (ARM)
2914 These options are identical. Generate code for the ARM2 and ARM3
2915 processors. This option is the default. You should also use this
2916 option to generate code for ARM6 processors that are running with a
2917 26-bit program counter.
2921 Generate code for the ARM6 processor when running with a 32-bit program
2926 Generate a stack frame that is compliant with the ARM Procedure Call
2927 Standard for all functions, even if this is not strictly necessary for
2928 correct execution of the code.
2932 This option only applies to RISC iX. Emulate the native BSD-mode
2933 compiler. This is the default if @samp{-ansi} is not specified.
2937 This option only applies to RISC iX. Emulate the native X/Open-mode
2940 @item -mno-symrename
2941 @kindex -mno-symrename
2942 This option only applies to RISC iX. Do not run the assembler
2943 post-processor, @samp{symrename}, after code has been assembled.
2944 Normally it is necessary to modify some of the standard symbols in
2945 preparation for linking with the RISC iX C library; this option
2946 suppresses this pass. The post-processor is never run when the
2947 compiler is built for cross-compilation.
2951 @subsection M88K Options
2952 @cindex M88k options
2954 These @samp{-m} options are defined for Motorola 88k architectures:
2959 Generate code that works well on both the m88100 and the
2964 Generate code that works best for the m88100, but that also
2969 Generate code that works best for the m88110, and may not run
2974 Obsolete option to be removed from the next revision.
2977 @item -midentify-revision
2978 @kindex -midentify-revision
2980 @cindex identifying source, compiler (88k)
2981 Include an @code{ident} directive in the assembler output recording the
2982 source file name, compiler name and version, timestamp, and compilation
2985 @item -mno-underscores
2986 @kindex -mno-underscores
2987 @cindex underscores, avoiding (88k)
2988 In assembler output, emit symbol names without adding an underscore
2989 character at the beginning of each name. The default is to use an
2990 underscore as prefix on each name.
2992 @item -mocs-debug-info
2993 @itemx -mno-ocs-debug-info
2994 @kindex -mocs-debug-info
2995 @kindex -mno-ocs-debug-info
2997 @cindex debugging, 88k OCS
2998 Include (or omit) additional debugging information (about registers used
2999 in each stack frame) as specified in the 88open Object Compatibility
3000 Standard, ``OCS''. This extra information allows debugging of code that
3001 has had the frame pointer eliminated. The default for DG/UX, SVr4, and
3002 Delta 88 SVr3.2 is to include this information; other 88k configurations
3003 omit this information by default.
3005 @item -mocs-frame-position
3006 @kindex -mocs-frame-position
3007 @cindex register positions in frame (88k)
3008 When emitting COFF debugging information for automatic variables and
3009 parameters stored on the stack, use the offset from the canonical frame
3010 address, which is the stack pointer (register 31) on entry to the
3011 function. The DG/UX, SVr4, Delta88 SVr3.2, and BCS configurations use
3012 @samp{-mocs-frame-position}; other 88k configurations have the default
3013 @samp{-mno-ocs-frame-position}.
3015 @item -mno-ocs-frame-position
3016 @kindex -mno-ocs-frame-position
3017 @cindex register positions in frame (88k)
3018 When emitting COFF debugging information for automatic variables and
3019 parameters stored on the stack, use the offset from the frame pointer
3020 register (register 30). When this option is in effect, the frame
3021 pointer is not eliminated when debugging information is selected by the
3024 @item -moptimize-arg-area
3025 @itemx -mno-optimize-arg-area
3026 @kindex -moptimize-arg-area
3027 @kindex -mno-optimize-arg-area
3028 @cindex arguments in frame (88k)
3029 Control how function arguments are stored in stack frames.
3030 @samp{-moptimize-arg-area} saves space by optimizing them, but this
3031 conflicts with the 88open specifications. The opposite alternative,
3032 @samp{-mno-optimize-arg-area}, agrees with 88open standards. By default
3033 GNU CC does not optimize the argument area.
3035 @item -mshort-data-@var{num}
3036 @kindex -mshort-data-@var{num}
3037 @cindex smaller data references (88k)
3038 @cindex r0-relative references (88k)
3039 Generate smaller data references by making them relative to @code{r0},
3040 which allows loading a value using a single instruction (rather than the
3041 usual two). You control which data references are affected by
3042 specifying @var{num} with this option. For example, if you specify
3043 @samp{-mshort-data-512}, then the data references affected are those
3044 involving displacements of less than 512 bytes.
3045 @samp{-mshort-data-@var{num}} is not effective for @var{num} greater
3048 @item -mserialize-volatile
3049 @kindex -mserialize-volatile
3050 @itemx -mno-serialize-volatile
3051 @kindex -mno-serialize-volatile
3052 @cindex sequential consistency on 88k
3053 Do, or don't, generate code to guarantee sequential consistency
3054 of volatile memory references. By default, consistency is
3057 The order of memory references made by the MC88110 processor does
3058 not always match the order of the instructions requesting those
3059 references. In particular, a load instruction may execute before
3060 a preceding store instruction. Such reordering violates
3061 sequential consistency of volatile memory references, when there
3062 are multiple processors. When consistency must be guaranteed,
3063 GNU C generates special instructions, as needed, to force
3064 execution in the proper order.
3066 The MC88100 processor does not reorder memory references and so
3067 always provides sequential consistency. However, by default, GNU
3068 C generates the special instructions to guarantee consistency
3069 even when you use @samp{-m88100}, so that the code may be run on an
3070 MC88110 processor. If you intend to run your code only on the
3071 MC88100 processor, you may use @samp{-mno-serialize-volatile}.
3073 The extra code generated to guarantee consistency may affect the
3074 performance of your application. If you know that you can safely
3075 forgo this guarantee, you may use @samp{-mno-serialize-volatile}.
3081 @cindex assembler syntax, 88k
3083 Turn on (@samp{-msvr4}) or off (@samp{-msvr3}) compiler extensions
3084 related to System V release 4 (SVr4). This controls the following:
3088 Which variant of the assembler syntax to emit.
3090 @samp{-msvr4} makes the C preprocessor recognize @samp{#pragma weak}
3091 that is used on System V release 4.
3093 @samp{-msvr4} makes GNU CC issue additional declaration directives used in
3097 @samp{-msvr4} is the default for the m88k-motorola-sysv4 and
3098 m88k-dg-dgux m88k configurations. @samp{-msvr3} is the default for all
3099 other m88k configurations.
3101 @item -mversion-03.00
3102 @kindex -mversion-03.00
3103 This option is obsolete, and is ignored.
3104 @c ??? which asm syntax better for GAS? option there too?
3106 @item -mno-check-zero-division
3107 @itemx -mcheck-zero-division
3108 @kindex -mno-check-zero-division
3109 @kindex -mcheck-zero-division
3110 @cindex zero division on 88k
3111 Do, or don't, generate code to guarantee that integer division by
3112 zero will be detected. By default, detection is guaranteed.
3114 Some models of the MC88100 processor fail to trap upon integer
3115 division by zero under certain conditions. By default, when
3116 compiling code that might be run on such a processor, GNU C
3117 generates code that explicitly checks for zero-valued divisors
3118 and traps with exception number 503 when one is detected. Use of
3119 mno-check-zero-division suppresses such checking for code
3120 generated to run on an MC88100 processor.
3122 GNU C assumes that the MC88110 processor correctly detects all
3123 instances of integer division by zero. When @samp{-m88110} is
3124 specified, both @samp{-mcheck-zero-division} and
3125 @samp{-mno-check-zero-division} are ignored, and no explicit checks for
3126 zero-valued divisors are generated.
3128 @item -muse-div-instruction
3129 @kindex -muse-div-instruction
3130 @cindex divide instruction, 88k
3131 Use the div instruction for signed integer division on the
3132 MC88100 processor. By default, the div instruction is not used.
3134 On the MC88100 processor the signed integer division instruction
3135 div) traps to the operating system on a negative operand. The
3136 operating system transparently completes the operation, but at a
3137 large cost in execution time. By default, when compiling code
3138 that might be run on an MC88100 processor, GNU C emulates signed
3139 integer division using the unsigned integer division instruction
3140 divu), thereby avoiding the large penalty of a trap to the
3141 operating system. Such emulation has its own, smaller, execution
3142 cost in both time and space. To the extent that your code's
3143 important signed integer division operations are performed on two
3144 nonnegative operands, it may be desirable to use the div
3145 instruction directly.
3147 On the MC88110 processor the div instruction (also known as the
3148 divs instruction) processes negative operands without trapping to
3149 the operating system. When @samp{-m88110} is specified,
3150 @samp{-muse-div-instruction} is ignored, and the div instruction is used
3151 for signed integer division.
3153 Note that the result of dividing INT_MIN by -1 is undefined. In
3154 particular, the behavior of such a division with and without
3155 @samp{-muse-div-instruction} may differ.
3157 @item -mtrap-large-shift
3158 @itemx -mhandle-large-shift
3159 @kindex -mtrap-large-shift
3160 @kindex -mhandle-large-shift
3161 @cindex bit shift overflow (88k)
3162 @cindex large bit shifts (88k)
3163 Include code to detect bit-shifts of more than 31 bits; respectively,
3164 trap such shifts or emit code to handle them properly. By default GNU CC
3165 makes no special provision for large bit shifts.
3167 @item -mwarn-passed-structs
3168 @kindex -mwarn-passed-structs
3169 @cindex structure passing (88k)
3170 Warn when a function passes a struct as an argument or result.
3171 Structure-passing conventions have changed during the evolution of the C
3172 language, and are often the source of portability problems. By default,
3173 GNU CC issues no such warning.
3176 @node RS/6000 and PowerPC Options
3177 @subsection IBM RS/6000 and PowerPC Options
3178 @cindex RS/6000 and PowerPC Options
3179 @cindex IBM RS/6000 and PowerPC Options
3181 These @samp{-m} options are defined for the IBM RS/6000 and PowerPC:
3189 @itemx -mpowerpc-gpopt
3190 @itemx -mno-powerpc-gpopt
3191 @itemx -mpowerpc-gfxopt
3192 @itemx -mno-powerpc-gfxopt
3196 @kindex -mpowerpc-gpopt
3197 @kindex -mpowerpc-gfxopt
3198 GNU CC supports two related instruction set architectures for the
3199 RS/6000 and PowerPC. The @dfn{POWER} instruction set are those
3200 instructions supported by the @samp{rios} chip set used in the original
3201 RS/6000 systems and the @dfn{PowerPC} instruction set is the
3202 architecture of the Motorola MPC6xx microprocessors. The PowerPC
3203 architecture defines 64-bit instructions, but they are not supported by
3204 any current processors.
3206 Neither architecture is a subset of the other. However there is a
3207 large common subset of instructions supported by both. An MQ
3208 register is included in processors supporting the POWER architecture.
3210 You use these options to specify which instructions are available on the
3211 processor you are using. The default value of these options is
3212 determined when configuring GNU CC. Specifying the
3213 @samp{-mcpu=@var{cpu_type}} overrides the specification of these
3214 options. We recommend you use that option rather than these.
3216 The @samp{-mpower} option allows GNU CC to generate instructions that
3217 are found only in the POWER architecture and to use the MQ register.
3218 Specifying @samp{-mpower2} implies @samp{-power} and also allows GNU CC
3219 to generate instructions that are present in the POWER2 architecture but
3220 not the original POWER architecture.
3222 The @samp{-mpowerpc} option allows GNU CC to generate instructions that
3223 are found only in the 32-bit subset of the PowerPC architecture.
3224 Specifying @samp{-mpowerpc-gpopt} implies @samp{-mpowerpc} and also allows
3225 GNU CC to use the optional PowerPC architecture instructions in the
3226 General Purpose group, including floating-point square root. Specifying
3227 @samp{-mpowerpc-gfxopt} implies @samp{-mpowerpc} and also allows GNU CC to
3228 use the optional PowerPC architecture instructions in the Graphics
3229 group, including floating-point select.
3231 If you specify both @samp{-mno-power} and @samp{-mno-powerpc}, GNU CC
3232 will use only the instructions in the common subset of both
3233 architectures plus some special AIX common-mode calls, and will not use
3234 the MQ register. Specifying both @samp{-mpower} and @samp{-mpowerpc}
3235 permits GNU CC to use any instruction from either architecture and to
3236 allow use of the MQ register; specify this for the Motorola MPC601.
3238 @item -mnew-mnemonics
3239 @itemx -mold-mnemonics
3240 @kindex -mnew-mnemonics
3241 @kindex -mold-mnemonics
3242 Select which mnemonics to use in the generated assembler code.
3243 @samp{-mnew-mnemonics} requests output that uses the assembler mnemonics
3244 defined for the PowerPC architecture, while @samp{-mold-mnemonics}
3245 requests the assembler mnemonics defined for the POWER architecture.
3246 Instructions defined in only one architecture have only one mnemonic;
3247 GNU CC uses that mnemonic irrespective of which of these options is
3250 PowerPC assemblers support both the old and new mnemonics, as will later
3251 POWER assemblers. Current POWER assemblers only support the old
3252 mnemonics. Specify @samp{-mnew-mnemonics} if you have an assembler that
3253 supports them, otherwise specify @samp{-mold-mnemonics}.
3255 The default value of these options depends on how GNU CC was configured.
3256 Specifying @samp{-mcpu=@var{cpu_type}} sometimes overrides the value of
3257 these option. Unless you are building a cross-compiler, you should
3258 normally not specify either @samp{-mnew-mnemonics} or
3259 @samp{-mold-mnemonics}, but should instead accept the default.
3261 @item -mcpu=@var{cpu_type}
3262 Set architecture type, register usage, choice of mnemonics, and instruction
3263 scheduling parameters for machine type @var{cpu_type}. By default,
3264 @var{cpu_type} is the target system defined when GNU CC was configured.
3265 Supported values for @var{cpu_type} are @samp{rios1}, @samp{rios2}, @samp{rsc},
3266 @samp{601}, @samp{603}, @samp{604}, @samp{power}, @samp{powerpc}, @samp{403},
3267 and @samp{common}. @samp{-mcpu=power} and @samp{-mcpu=powerpc} specify generic
3268 POWER and pure PowerPC (i.e., not MPC601) architecture machine types, with an
3269 appropriate, generic processor model assumed for scheduling purposes.@refill
3271 Specifying @samp{-mcpu=rios1}, @samp{-mcpu=rios2}, @samp{-mcpu=rsc}, or
3272 @samp{-mcpu=power} enables the @samp{-mpower} option and disables the
3273 @samp{-mpowerpc} option; @samp{-mcpu=601} enables both the @samp{-mpower} and
3274 @samp{-mpowerpc} options; @samp{-mcpu=603}, @samp{-mcpu=604}, @samp{-mcpu=403},
3275 and @samp{-mcpu=powerpc} enable the @samp{-mpowerpc} option and disable the
3276 @samp{-mpower} option; @samp{-mcpu=common} disables both the @samp{-mpower} and
3277 @samp{-mpowerpc} options.@refill
3279 To generate code that will operate on all members of the RS/6000 and
3280 PowerPC families, specify @samp{-mcpu=common}. In that case, GNU CC
3281 will use only the instructions in the common subset of both
3282 architectures plus some special AIX common-mode calls, and will not use
3283 the MQ register. GNU CC assumes a generic processor model for scheduling
3286 Specifying @samp{-mcpu=rios1}, @samp{-mcpu=rios2}, @samp{-mcpu=rsc}, or
3287 @samp{-mcpu=power} also disables the @samp{new-mnemonics} option.
3288 Specifying @samp{-mcpu=601}, @samp{-mcpu=603}, @samp{-mcpu=604},
3289 @samp{403}, or @samp{-mcpu=powerpc} also enables the @samp{new-mnemonics}
3293 @itemx -mno-fp-in-toc
3294 @itemx -mno-sum-in-toc
3295 @itemx -mminimal-toc
3296 Modify generation of the TOC (Table Of Contents), which is created for
3297 every executable file. The @samp{-mfull-toc} option is selected by
3298 default. In that case, GNU CC will allocate at least one TOC entry for
3299 each unique non-automatic variable reference in your program. GNU CC
3300 will also place floating-point constants in the TOC. However, only
3301 16,384 entries are available in the TOC.
3303 If you receive a linker error message that saying you have overflowed
3304 the available TOC space, you can reduce the amount of TOC space used
3305 with the @samp{-mno-fp-in-toc} and @samp{-mno-sum-in-toc} options.
3306 @samp{-mno-fp-in-toc} prevents GNU CC from putting floating-point
3307 constants in the TOC and @samp{-mno-sum-in-toc} forces GNU CC to
3308 generate code to calculate the sum of an address and a constant at
3309 run-time instead of putting that sum into the TOC. You may specify one
3310 or both of these options. Each causes GNU CC to produce very slightly
3311 slower and larger code at the expense of conserving TOC space.
3313 If you still run out of space in the TOC even when you specify both of
3314 these options, specify @samp{-mminimal-toc} instead. This option causes
3315 GNU CC to make only one TOC entry for every file. When you specify this
3316 option, GNU CC will produce code that is slower and larger but which
3317 uses extremely little TOC space. You may wish to use this option
3318 only on files that contain less frequently executed code. @refill
3322 Generate code that does not use (uses) the floating-point register set.
3323 Software floating point emulation is provided if you use the
3324 @samp{-msoft-float} option, and pass the option to GNU CC when linking.
3327 @itemx -mno-multiple
3328 Generate code that uses (does not use) the load multiple word
3329 instructions and the store multiple word instructions. These
3330 instructions are generated by default on POWER systems, and not
3331 generated on PowerPC systems. Do not use @samp{-mmultiple} on little
3332 endian PowerPC systems, since those instructions do not work when the
3333 processor is in little endian mode.
3337 Generate code that uses (does not use) the load string instructions and the
3338 store string word instructions to save multiple registers and do small block
3339 moves. These instructions are generated by default on POWER systems, anod not
3340 generated on PowerPC systems. Do not use @samp{-mstring} on little endian
3341 PowerPC systems, since those instructions do not work when the processor is in
3344 @item -mno-bit-align
3346 On System V.4 and embedded PowerPC systems do not (do) force structures
3347 and unions that contain bit fields to be aligned to the base type of the
3350 For example, by default a structure containing nothing but 8
3351 @code{unsigned} bitfields of length 1 would be aligned to a 4 byte
3352 boundary and have a size of 4 bytes. By using @samp{-mno-bit-align},
3353 the structure would be aligned to a 1 byte boundary and be one byte in
3356 @item -mno-strict-align
3357 @itemx -mstrict-align
3358 On System V.4 and embedded PowerPC systems do not (do) assume that
3359 unaligned memory references will be handled by the system.
3362 @itemx -mno-relocatable
3363 On embedded PowerPC systems generate code that allows (does not allow)
3364 the program to be relocated to a different address at runtime.
3368 On System V.4 and embedded PowerPC systems do not (do) assume that
3369 register 2 contains a pointer to a global area pointing to the addresses
3370 used in the program.
3372 @item -mno-traceback
3374 On embedded PowerPC systems do not (do) generate a traceback tag before
3375 the start of the function. This tag can be used by the debugger to
3376 identify where the start of a function is.
3379 @itemx -mlittle-endian
3380 On System V.4 and embedded PowerPC systems compile code for the
3381 processor in little endian mode. The @samp{-mlittle-endian} option is
3382 the same as @samp{-mlittle}.
3386 On System V.4 and embedded PowerPC systems compile code for the
3387 processor in big endian mode. The @samp{-mbig-endian} option is
3388 the same as @samp{-mbig}.
3391 On System V.4 and embedded PowerPC systems compile code using calling
3392 conventions that adheres to the March 1995 draft of the System V
3393 Application Binary Interface, PowerPC processor supplement. This is the
3394 default unless you configured GCC using @samp{powerpc-*-eabiaix}.
3397 On System V.4 and embedded PowerPC systems compile code using calling
3398 conventions that are similar to those used on AIX. This is the
3399 default if you configured GCC using @samp{powerpc-*-eabiaix}.
3402 @item -mno-prototype
3403 On System V.4 and embedded PowerPC systems assume that all calls to
3404 variable argument functions are properly prototyped. Otherwise, the
3405 compiler must insert an instruction before every non prototyped call to
3406 set or clear bit 6 of the condition code register (@var{CR}) to
3407 indicate whether floating point values were passed in the floating point
3408 registers in case the function takes a variable arguments. With
3409 @samp{-mprototype}, only calls to prototyped variable argument functions
3410 will set or clear the bit.
3413 @subsection IBM RT Options
3415 @cindex IBM RT options
3417 These @samp{-m} options are defined for the IBM RT PC:
3421 Use an in-line code sequence for integer multiplies. This is the
3424 @item -mcall-lib-mul
3425 Call @code{lmul$$} for integer multiples.
3427 @item -mfull-fp-blocks
3428 Generate full-size floating point data blocks, including the minimum
3429 amount of scratch space recommended by IBM. This is the default.
3431 @item -mminimum-fp-blocks
3432 Do not include extra scratch space in floating point data blocks. This
3433 results in smaller code, but slower execution, since scratch space must
3434 be allocated dynamically.
3436 @cindex @file{varargs.h} and RT PC
3437 @cindex @file{stdarg.h} and RT PC
3438 @item -mfp-arg-in-fpregs
3439 Use a calling sequence incompatible with the IBM calling convention in
3440 which floating point arguments are passed in floating point registers.
3441 Note that @code{varargs.h} and @code{stdargs.h} will not work with
3442 floating point operands if this option is specified.
3444 @item -mfp-arg-in-gregs
3445 Use the normal calling convention for floating point arguments. This is
3448 @item -mhc-struct-return
3449 Return structures of more than one word in memory, rather than in a
3450 register. This provides compatibility with the MetaWare HighC (hc)
3451 compiler. Use the option @samp{-fpcc-struct-return} for compatibility
3452 with the Portable C Compiler (pcc).
3454 @item -mnohc-struct-return
3455 Return some structures of more than one word in registers, when
3456 convenient. This is the default. For compatibility with the
3457 IBM-supplied compilers, use the option @samp{-fpcc-struct-return} or the
3458 option @samp{-mhc-struct-return}.
3462 @subsection MIPS Options
3463 @cindex MIPS options
3465 These @samp{-m} options are defined for the MIPS family of computers:
3468 @item -mcpu=@var{cpu type}
3469 Assume the defaults for the machine type @var{cpu type} when scheduling
3470 instructions. The choices for @var{cpu type} are @samp{r2000}, @samp{r3000},
3471 @samp{r4000}, @samp{r4400}, @samp{r4600}, and @samp{r6000}. While picking a
3472 specific @var{cpu type} will schedule things appropriately for that
3473 particular chip, the compiler will not generate any code that does not
3474 meet level 1 of the MIPS ISA (instruction set architecture) without
3475 the @samp{-mips2} or @samp{-mips3} switches being used.
3478 Issue instructions from level 1 of the MIPS ISA. This is the default.
3479 @samp{r3000} is the default @var{cpu type} at this ISA level.
3482 Issue instructions from level 2 of the MIPS ISA (branch likely, square
3483 root instructions). @samp{r6000} is the default @var{cpu type} at this
3487 Issue instructions from level 3 of the MIPS ISA (64 bit instructions).
3488 @samp{r4000} is the default @var{cpu type} at this ISA level.
3489 This option does not change the sizes of any of the C data types.
3492 Assume that 32 32-bit floating point registers are available. This is
3496 Assume that 32 64-bit floating point registers are available. This is
3497 the default when the @samp{-mips3} option is used.
3500 Assume that 32 32-bit general purpose registers are available. This is
3504 Assume that 32 64-bit general purpose registers are available. This is
3505 the default when the @samp{-mips3} option is used.
3508 Types long, int, and pointer are 64 bits. This works only if @samp{-mips3}
3512 Types long and pointer are 64 bits, and type int is 32 bits.
3513 This works only if @samp{-mips3} is also specified.
3516 Generate code for the MIPS assembler, and invoke @file{mips-tfile} to
3517 add normal debug information. This is the default for all
3518 platforms except for the OSF/1 reference platform, using the OSF/rose
3519 object format. If the either of the @samp{-gstabs} or @samp{-gstabs+}
3520 switches are used, the @file{mips-tfile} program will encapsulate the
3521 stabs within MIPS ECOFF.
3524 Generate code for the GNU assembler. This is the default on the OSF/1
3525 reference platform, using the OSF/rose object format.
3529 The @samp{-mrnames} switch says to output code using the MIPS software
3530 names for the registers, instead of the hardware names (ie, @var{a0}
3531 instead of @var{$4}). The only known assembler that supports this option
3532 is the Algorithmics assembler.
3536 The @samp{-mgpopt} switch says to write all of the data declarations
3537 before the instructions in the text section, this allows the MIPS
3538 assembler to generate one word memory references instead of using two
3539 words for short global or static data items. This is on by default if
3540 optimization is selected.
3544 For each non-inline function processed, the @samp{-mstats} switch
3545 causes the compiler to emit one line to the standard error file to
3546 print statistics about the program (number of registers saved, stack
3551 The @samp{-mmemcpy} switch makes all block moves call the appropriate
3552 string function (@samp{memcpy} or @samp{bcopy}) instead of possibly
3553 generating inline code.
3556 @itemx -mno-mips-tfile
3557 The @samp{-mno-mips-tfile} switch causes the compiler not
3558 postprocess the object file with the @file{mips-tfile} program,
3559 after the MIPS assembler has generated it to add debug support. If
3560 @file{mips-tfile} is not run, then no local variables will be
3561 available to the debugger. In addition, @file{stage2} and
3562 @file{stage3} objects will have the temporary file names passed to the
3563 assembler embedded in the object file, which means the objects will
3564 not compare the same. The @samp{-mno-mips-tfile} switch should only
3565 be used when there are bugs in the @file{mips-tfile} program that
3566 prevents compilation.
3569 Generate output containing library calls for floating point.
3570 @strong{Warning:} the requisite libraries are not part of GNU CC.
3571 Normally the facilities of the machine's usual C compiler are used, but
3572 this can't be done directly in cross-compilation. You must make your
3573 own arrangements to provide suitable library functions for
3577 Generate output containing floating point instructions. This is the
3578 default if you use the unmodified sources.
3581 @itemx -mno-abicalls
3582 Emit (or do not emit) the pseudo operations @samp{.abicalls},
3583 @samp{.cpload}, and @samp{.cprestore} that some System V.4 ports use for
3584 position independent code.
3587 @itemx -mno-long-calls
3588 Do all calls with the @samp{JALR} instruction, which requires
3589 loading up a function's address into a register before the call.
3590 You need to use this switch, if you call outside of the current
3591 512 megabyte segment to functions that are not through pointers.
3594 @itemx -mno-half-pic
3595 Put pointers to extern references into the data section and load them
3596 up, rather than put the references in the text section.
3598 @item -membedded-pic
3599 @itemx -mno-embedded-pic
3600 Generate PIC code suitable for some embedded systems. All calls are made
3601 using PC relative address, and all data is addressed using the $gp register.
3602 This requires GNU as and GNU ld which do most of the work.
3604 @item -membedded-data
3605 @itemx -mno-embedded-data
3606 Allocate variables to the read-only data section first if possible, then
3607 next in the small data section if possible, otherwise in data. This gives
3608 slightly slower code than the default, but reduces the amount of RAM required
3609 when executing, and thus may be preferred for some embedded systems.
3611 @item -msingle-float
3612 @itemx -mdouble-float
3613 The @samp{-msingle-float} switch tells gcc to assume that the floating
3614 point coprocessor only supports single precision operations, as on the
3615 @samp{r4650} chip. The @samp{-mdouble-float} switch permits gcc to use
3616 double precision operations. This is the default.
3620 Permit use of the @samp{mad}, @samp{madu} and @samp{mul} instructions,
3621 as on the @samp{r4650} chip.
3624 Turns on @samp{-msingle-float}, @samp{-mmad}, and, at least for now,
3628 Compile code for the processor in little endian mode.
3629 The requisite libraries are assumed to exist.
3632 Compile code for the processor in big endian mode.
3633 The requisite libraries are assumed to exist.
3636 @cindex smaller data references (MIPS)
3637 @cindex gp-relative references (MIPS)
3638 Put global and static items less than or equal to @var{num} bytes into
3639 the small data or bss sections instead of the normal data or bss
3640 section. This allows the assembler to emit one word memory reference
3641 instructions based on the global pointer (@var{gp} or @var{$28}),
3642 instead of the normal two words used. By default, @var{num} is 8 when
3643 the MIPS assembler is used, and 0 when the GNU assembler is used. The
3644 @samp{-G @var{num}} switch is also passed to the assembler and linker.
3645 All modules should be compiled with the same @samp{-G @var{num}}
3649 Tell the MIPS assembler to not run it's preprocessor over user
3650 assembler files (with a @samp{.s} suffix) when assembling them.
3654 These options are defined by the macro
3655 @code{TARGET_SWITCHES} in the machine description. The default for the
3656 options is also defined by that macro, which enables you to change the
3661 @subsection Intel 386 Options
3662 @cindex i386 Options
3663 @cindex Intel 386 Options
3665 These @samp{-m} options are defined for the i386 family of computers:
3670 Control whether or not code is optimized for a 486 instead of an
3671 386. Code generated for an 486 will run on a 386 and vice versa.
3675 Control whether or not the compiler uses IEEE floating point
3676 comparisons. These handle correctly the case where the result of a
3677 comparison is unordered.
3680 Generate output containing library calls for floating point.
3681 @strong{Warning:} the requisite libraries are not part of GNU CC.
3682 Normally the facilities of the machine's usual C compiler are used, but
3683 this can't be done directly in cross-compilation. You must make your
3684 own arrangements to provide suitable library functions for
3687 On machines where a function returns floating point results in the 80387
3688 register stack, some floating point opcodes may be emitted even if
3689 @samp{-msoft-float} is used.
3691 @item -mno-fp-ret-in-387
3692 Do not use the FPU registers for return values of functions.
3694 The usual calling convention has functions return values of types
3695 @code{float} and @code{double} in an FPU register, even if there
3696 is no FPU. The idea is that the operating system should emulate
3699 The option @samp{-mno-fp-ret-in-387} causes such values to be returned
3700 in ordinary CPU registers instead.
3702 @item -mno-fancy-math-387
3703 Some 387 emulators do not support the @code{sin}, @code{cos} and
3704 @code{sqrt} instructions for the 387. Specify this option to avoid
3705 generating those instructions. This option is the default on FreeBSD.
3706 As of revision 2.6.1, these instructions are not generated unless you
3707 also use the @samp{-ffast-math} switch.
3709 @item -malign-double
3710 @itemx -mno-align-double
3711 Control whether GNU CC aligns @code{double}, @code{long double}, and
3712 @code{long long} variables on a two word boundary or a one word
3713 boundary. Aligning @code{double} variables on a two word boundary will
3714 produce code that runs somewhat faster on a @samp{Pentium} at the
3715 expense of more memory.
3717 @strong{Warning:} if you use the @samp{-malign-double} switch,
3718 structures containing the above types will be aligned differently than
3719 the published application binary interface specifications for the 386.
3722 @itemx -mno-svr3-shlib
3723 Control whether GNU CC places uninitialized locals into @code{bss} or
3724 @code{data}. @samp{-msvr3-shlib} places these locals into @code{bss}.
3725 These options are meaningful only on System V Release 3.
3727 @item -mno-wide-multiply
3728 @itemx -mwide-multiply
3729 Control whether GNU CC uses the @code{mul} and @code{imul} that produce
3730 64 bit results in @code{eax:edx} from 32 bit operands to do @code{long
3731 long} multiplies and 32-bit division by constants.
3733 @item -mprofiler-epilogue
3734 @itemx -mno-profiler-epilogue
3735 Generate extra code to write profile information for function exits.
3736 This option has no effect except in combination with @samp{-g} or
3740 Use a different function-calling convention, in which functions that
3741 take a fixed number of arguments return with the @code{ret} @var{num}
3742 instruction, which pops their arguments while returning. This saves one
3743 instruction in the caller since there is no need to pop the arguments
3746 You can specify that an individual function is called with this calling
3747 sequence with the function attribute @samp{stdcall}. You can also
3748 override the @samp{-mrtd} option by using the function attribute
3749 @samp{cdecl}. @xref{Function Attributes}
3751 @strong{Warning:} this calling convention is incompatible with the one
3752 normally used on Unix, so you cannot use it if you need to call
3753 libraries compiled with the Unix compiler.
3755 Also, you must provide function prototypes for all functions that
3756 take variable numbers of arguments (including @code{printf});
3757 otherwise incorrect code will be generated for calls to those
3760 In addition, seriously incorrect code will result if you call a
3761 function with too many arguments. (Normally, extra arguments are
3762 harmlessly ignored.)
3764 @item -mreg-alloc=@var{regs}
3765 Control the default allocation order of integer registers. The
3766 string @var{regs} is a series of letters specifying a register. The
3767 supported letters are: @code{a} allocate EAX; @code{b} allocate EBX;
3768 @code{c} allocate ECX; @code{d} allocate EDX; @code{S} allocate ESI;
3769 @code{D} allocate EDI; @code{B} allocate EBP.
3771 @item -mregparm=@var{num}
3772 Control how many registers are used to pass integer arguments. By
3773 default, no registers are used to pass arguments, and at most 3
3774 registers can be used. You can control this behavior for a specific
3775 function by using the function attribute @samp{regparm}. @xref{Function Attributes}
3777 @strong{Warning:} if you use this switch, and
3778 @var{num} is nonzero, then you must build all modules with the same
3779 value, including any libraries. This includes the system libraries and
3782 @item -malign-loops=@var{num}
3783 Align loops to a 2 raised to a @var{num} byte boundary. If
3784 @samp{-malign-loops} is not specified, the default is 2.
3786 @item -malign-jumps=@var{num}
3787 Align instructions that are only jumped to to a 2 raised to a @var{num}
3788 byte boundary. If @samp{-malign-jumps} is not specified, the default is
3789 2 if optimizing for a 386, and 4 if optimizing for a 486.
3791 @item -malign-functions=@var{num}
3792 Align the start of functions to a 2 raised to @var{num} byte boundary.
3793 If @samp{-malign-jumps} is not specified, the default is 2 if optimizing
3794 for a 386, and 4 if optimizing for a 486.
3798 @subsection HPPA Options
3799 @cindex HPPA Options
3801 These @samp{-m} options are defined for the HPPA family of computers:
3805 Generate code for a PA 1.0 processor.
3808 Generate code for a PA 1.1 processor.
3810 @item -mjump-in-delay
3811 Fill delay slots of function calls with unconditional jump instructions
3812 by modifying the return pointer for the function call to be the target
3813 of the conditional jump.
3815 @item -mmillicode-long-calls
3816 Generate code which assumes millicode routines can not be reached
3817 by the standard millicode call sequence, linker-generated long-calls,
3818 or linker-modified millicode calls. In practice this should only be
3819 needed for dynamicly linked executables with extremely large SHLIB_INFO
3822 @item -mdisable-fpregs
3823 Prevent floating point registers from being used in any manner. This is
3824 necessary for compiling kernels which perform lazy context switching of
3825 floating point registers. If you use this option and attempt to perform
3826 floating point operations, the compiler will abort.
3828 @item -mdisable-indexing
3829 Prevent the compiler from using indexing address modes. This avoids some
3830 rather obscure problems when compiling MIG generated code under MACH.
3832 @item -mfast-indirect-calls
3833 Generate code which performs faster indirect calls. Such code is suitable
3834 for kernels and for static linking. The fast indirect call code will fail
3835 miserably if it's part of a dynamically linked executable and in the presense
3836 of nested functions.
3838 @item -mportable-runtime
3839 Use the portable calling conventions proposed by HP for ELF systems.
3842 Enable the use of assembler directives only GAS understands.
3844 @item -mschedule=@var{cpu type}
3845 Schedule code according to the constraints for the machine type
3846 @var{cpu type}. The choices for @var{cpu type} are @samp{700} for
3847 7@var{n}0 machines, @samp{7100} for 7@var{n}5 machines, and @samp{7100}
3848 for 7@var{n}2 machines. @samp{700} is the default for @var{cpu type}.
3850 Note the @samp{7100LC} scheduling information is incomplete and using
3851 @samp{7100LC} often leads to bad schedules. For now it's probably best
3852 to use @samp{7100} instead of @samp{7100LC} for the 7@var{n}2 machines.
3855 Generate output containing library calls for floating point.
3856 @strong{Warning:} the requisite libraries are not available for all HPPA
3857 targets. Normally the facilities of the machine's usual C compiler are
3858 used, but this cannot be done directly in cross-compilation. You must make
3859 your own arrangements to provide suitable library functions for
3860 cross-compilation. The embedded target @samp{hppa1.1-*-pro}
3861 does provide software floating point support.
3863 @samp{-msoft-float} changes the calling convention in the output file;
3864 therefore, it is only useful if you compile @emph{all} of a program with
3865 this option. In particular, you need to compile @file{libgcc.a}, the
3866 library that comes with GNU CC, with @samp{-msoft-float} in order for
3870 @node Intel 960 Options
3871 @subsection Intel 960 Options
3873 These @samp{-m} options are defined for the Intel 960 implementations:
3876 @item -m@var{cpu type}
3877 Assume the defaults for the machine type @var{cpu type} for some of
3878 the other options, including instruction scheduling, floating point
3879 support, and addressing modes. The choices for @var{cpu type} are
3880 @samp{ka}, @samp{kb}, @samp{mc}, @samp{ca}, @samp{cf},
3881 @samp{sa}, and @samp{sb}.
3887 The @samp{-mnumerics} option indicates that the processor does support
3888 floating-point instructions. The @samp{-msoft-float} option indicates
3889 that floating-point support should not be assumed.
3891 @item -mleaf-procedures
3892 @itemx -mno-leaf-procedures
3893 Do (or do not) attempt to alter leaf procedures to be callable with the
3894 @code{bal} instruction as well as @code{call}. This will result in more
3895 efficient code for explicit calls when the @code{bal} instruction can be
3896 substituted by the assembler or linker, but less efficient code in other
3897 cases, such as calls via function pointers, or using a linker that doesn't
3898 support this optimization.
3901 @itemx -mno-tail-call
3902 Do (or do not) make additional attempts (beyond those of the
3903 machine-independent portions of the compiler) to optimize tail-recursive
3904 calls into branches. You may not want to do this because the detection of
3905 cases where this is not valid is not totally complete. The default is
3906 @samp{-mno-tail-call}.
3908 @item -mcomplex-addr
3909 @itemx -mno-complex-addr
3910 Assume (or do not assume) that the use of a complex addressing mode is a
3911 win on this implementation of the i960. Complex addressing modes may not
3912 be worthwhile on the K-series, but they definitely are on the C-series.
3913 The default is currently @samp{-mcomplex-addr} for all processors except
3917 @itemx -mno-code-align
3918 Align code to 8-byte boundaries for faster fetching (or don't bother).
3919 Currently turned on by default for C-series implementations only.
3922 @item -mclean-linkage
3923 @itemx -mno-clean-linkage
3924 These options are not fully implemented.
3928 @itemx -mic2.0-compat
3929 @itemx -mic3.0-compat
3930 Enable compatibility with iC960 v2.0 or v3.0.
3934 Enable compatibility with the iC960 assembler.
3936 @item -mstrict-align
3937 @itemx -mno-strict-align
3938 Do not permit (do permit) unaligned accesses.
3941 Enable structure-alignment compatibility with Intel's gcc release version
3942 1.3 (based on gcc 1.37). Currently this is buggy in that @samp{#pragma
3943 align 1} is always assumed as well, and cannot be turned off.
3946 @node DEC Alpha Options
3947 @subsection DEC Alpha Options
3949 These @samp{-m} options are defined for the DEC Alpha implementations:
3952 @item -mno-soft-float
3954 Use (do not use) the hardware floating-point instructions for
3955 floating-point operations. When @code{-msoft-float} is specified,
3956 functions in @file{libgcc1.c} will be used to perform floating-point
3957 operations. Unless they are replaced by routines that emulate the
3958 floating-point operations, or compiled in such a way as to call such
3959 emulations routines, these routines will issue floating-point
3960 operations. If you are compiling for an Alpha without floating-point
3961 operations, you must ensure that the library is built so as not to call
3964 Note that Alpha implementations without floating-point operations are
3965 required to have floating-point registers.
3969 Generate code that uses (does not use) the floating-point register set.
3970 @code{-mno-fp-regs} implies @code{-msoft-float}. If the floating-point
3971 register set is not used, floating point operands are passed in integer
3972 registers as if they were integers and floating-point results are passed
3973 in $0 instead of $f0. This is a non-standard calling sequence, so any
3974 function with a floating-point argument or return value called by code
3975 compiled with @code{-mno-fp-regs} must also be compiled with that
3978 A typical use of this option is building a kernel that does not use,
3979 and hence need not save and restore, any floating-point registers.
3982 @node Clipper Options
3983 @subsection Clipper Options
3985 These @samp{-m} options are defined for the Clipper implementations:
3989 Produce code for a C300 Clipper processor. This is the default.
3992 Produce code for a C400 Clipper processor i.e. use floating point
3996 @node H8/300 Options
3997 @subsection H8/300 Options
3999 These @samp{-m} options are defined for the H8/300 implementations:
4003 Shorten some address references at link time, when possible; uses the
4004 linker option @samp{-relax}. @xref{H8/300,, @code{ld} and the H8/300,
4005 ld.info, Using ld}, for a fuller description.
4008 Generate code for the H8/300H.
4011 @node System V Options
4012 @subsection Options for System V
4014 These additional options are available on System V Release 4 for
4015 compatibility with other compilers on those systems:
4019 This should say *what the option does* and only then say
4020 "For compatibility only..."
4022 On SVr4 systems, @code{gcc} accepts the option @samp{-G} (and passes
4023 it to the system linker), for compatibility with other compilers.
4024 However, we suggest you use @samp{-symbolic} or @samp{-shared} as
4025 appropriate, instead of supplying linker options on the @code{gcc}
4030 Identify the versions of each tool used by the compiler, in a
4031 @code{.ident} assembler directive in the output.
4034 Refrain from adding @code{.ident} directives to the output file (this is
4037 @item -YP,@var{dirs}
4038 Search the directories @var{dirs}, and no others, for libraries
4039 specified with @samp{-l}.
4042 Look in the directory @var{dir} to find the M4 preprocessor.
4043 The assembler uses this option.
4044 @c This is supposed to go with a -Yd for predefined M4 macro files, but
4045 @c the generic assembler that comes with Solaris takes just -Ym.
4048 @node Code Gen Options
4049 @section Options for Code Generation Conventions
4050 @cindex code generation conventions
4051 @cindex options, code generation
4052 @cindex run-time options
4054 These machine-independent options control the interface conventions
4055 used in code generation.
4057 Most of them have both positive and negative forms; the negative form
4058 of @samp{-ffoo} would be @samp{-fno-foo}. In the table below, only
4059 one of the forms is listed---the one which is not the default. You
4060 can figure out the other form by either removing @samp{no-} or adding
4064 @item -fpcc-struct-return
4065 Return ``short'' @code{struct} and @code{union} values in memory like
4066 longer ones, rather than in registers. This convention is less
4067 efficient, but it has the advantage of allowing intercallability between
4068 GNU CC-compiled files and files compiled with other compilers.
4070 The precise convention for returning structures in memory depends
4071 on the target configuration macros.
4073 Short structures and unions are those whose size and alignment match
4074 that of some integer type.
4076 @item -freg-struct-return
4077 Use the convention that @code{struct} and @code{union} values are
4078 returned in registers when possible. This is more efficient for small
4079 structures than @samp{-fpcc-struct-return}.
4081 If you specify neither @samp{-fpcc-struct-return} nor its contrary
4082 @samp{-freg-struct-return}, GNU CC defaults to whichever convention is
4083 standard for the target. If there is no standard convention, GNU CC
4084 defaults to @samp{-fpcc-struct-return}, except on targets where GNU CC
4085 is the principal compiler. In those cases, we can choose the standard,
4086 and we chose the more efficient register return alternative.
4089 Allocate to an @code{enum} type only as many bytes as it needs for the
4090 declared range of possible values. Specifically, the @code{enum} type
4091 will be equivalent to the smallest integer type which has enough room.
4093 @item -fshort-double
4094 Use the same size for @code{double} as for @code{float}.
4097 Requests that the data and non-@code{const} variables of this
4098 compilation be shared data rather than private data. The distinction
4099 makes sense only on certain operating systems, where shared data is
4100 shared between processes running the same program, while private data
4101 exists in one copy per process.
4104 Allocate even uninitialized global variables in the bss section of the
4105 object file, rather than generating them as common blocks. This has the
4106 effect that if the same variable is declared (without @code{extern}) in
4107 two different compilations, you will get an error when you link them.
4108 The only reason this might be useful is if you wish to verify that the
4109 program will work on other systems which always work this way.
4112 Ignore the @samp{#ident} directive.
4114 @item -fno-gnu-linker
4115 Do not output global initializations (such as C++ constructors and
4116 destructors) in the form used by the GNU linker (on systems where the GNU
4117 linker is the standard method of handling them). Use this option when
4118 you want to use a non-GNU linker, which also requires using the
4119 @code{collect2} program to make sure the system linker includes
4120 constructors and destructors. (@code{collect2} is included in the GNU CC
4121 distribution.) For systems which @emph{must} use @code{collect2}, the
4122 compiler driver @code{gcc} is configured to do this automatically.
4124 @item -finhibit-size-directive
4125 Don't output a @code{.size} assembler directive, or anything else that
4126 would cause trouble if the function is split in the middle, and the
4127 two halves are placed at locations far apart in memory. This option is
4128 used when compiling @file{crtstuff.c}; you should not need to use it
4132 Put extra commentary information in the generated assembly code to
4133 make it more readable. This option is generally only of use to those
4134 who actually need to read the generated assembly code (perhaps while
4135 debugging the compiler itself).
4138 Consider all memory references through pointers to be volatile.
4140 @item -fvolatile-global
4141 Consider all memory references to extern and global data items to
4145 @cindex global offset table
4147 Generate position-independent code (PIC) suitable for use in a shared
4148 library, if supported for the target machine. Such code accesses all
4149 constant addresses through a global offset table (GOT). If the GOT size
4150 for the linked executable exceeds a machine-specific maximum size, you
4151 get an error message from the linker indicating that @samp{-fpic} does
4152 not work; in that case, recompile with @samp{-fPIC} instead. (These
4153 maximums are 16k on the m88k, 8k on the Sparc, and 32k on the m68k and
4154 RS/6000. The 386 has no such limit.)
4156 Position-independent code requires special support, and therefore works
4157 only on certain machines. For the 386, GNU CC supports PIC for System V
4158 but not for the Sun 386i. Code generated for the IBM RS/6000 is always
4159 position-independent.
4161 The GNU assembler does not fully support PIC. Currently, you must use
4162 some other assembler in order for PIC to work. We would welcome
4163 volunteers to upgrade GAS to handle this; the first part of the job is
4164 to figure out what the assembler must do differently.
4167 If supported for the target machine, emit position-independent code,
4168 suitable for dynamic linking and avoiding any limit on the size of the
4169 global offset table. This option makes a difference on the m68k, m88k
4172 Position-independent code requires special support, and therefore works
4173 only on certain machines.
4175 @item -ffixed-@var{reg}
4176 Treat the register named @var{reg} as a fixed register; generated code
4177 should never refer to it (except perhaps as a stack pointer, frame
4178 pointer or in some other fixed role).
4180 @var{reg} must be the name of a register. The register names accepted
4181 are machine-specific and are defined in the @code{REGISTER_NAMES}
4182 macro in the machine description macro file.
4184 This flag does not have a negative form, because it specifies a
4187 @item -fcall-used-@var{reg}
4188 Treat the register named @var{reg} as an allocatable register that is
4189 clobbered by function calls. It may be allocated for temporaries or
4190 variables that do not live across a call. Functions compiled this way
4191 will not save and restore the register @var{reg}.
4193 Use of this flag for a register that has a fixed pervasive role in the
4194 machine's execution model, such as the stack pointer or frame pointer,
4195 will produce disastrous results.
4197 This flag does not have a negative form, because it specifies a
4200 @item -fcall-saved-@var{reg}
4201 Treat the register named @var{reg} as an allocatable register saved by
4202 functions. It may be allocated even for temporaries or variables that
4203 live across a call. Functions compiled this way will save and restore
4204 the register @var{reg} if they use it.
4206 Use of this flag for a register that has a fixed pervasive role in the
4207 machine's execution model, such as the stack pointer or frame pointer,
4208 will produce disastrous results.
4210 A different sort of disaster will result from the use of this flag for
4211 a register in which function values may be returned.
4213 This flag does not have a negative form, because it specifies a
4217 Pack all structure members together without holes. Usually you would
4218 not want to use this option, since it makes the code suboptimal, and
4219 the offsets of structure members won't agree with system libraries.
4223 Control whether virtual function definitions in classes are used to
4224 generate code, or only to define interfaces for their callers. (C++
4227 These options are provided for compatibility with @code{cfront} 1.x
4228 usage; the recommended alternative GNU C++ usage is in flux. @xref{C++
4229 Interface,,Declarations and Definitions in One Header}.
4231 With @samp{+e0}, virtual function definitions in classes are declared
4232 @code{extern}; the declaration is used only as an interface
4233 specification, not to generate code for the virtual functions (in this
4236 With @samp{+e1}, G++ actually generates the code implementing virtual
4237 functions defined in the code, and makes them publicly visible.
4240 @node Environment Variables
4241 @section Environment Variables Affecting GNU CC
4242 @cindex environment variables
4244 This section describes several environment variables that affect how GNU
4245 CC operates. They work by specifying directories or prefixes to use
4246 when searching for various kinds of files.
4249 Note that you can also specify places to search using options such as
4250 @samp{-B}, @samp{-I} and @samp{-L} (@pxref{Directory Options}). These
4251 take precedence over places specified using environment variables, which
4252 in turn take precedence over those specified by the configuration of GNU
4256 Note that you can also specify places to search using options such as
4257 @samp{-B}, @samp{-I} and @samp{-L} (@pxref{Directory Options}). These
4258 take precedence over places specified using environment variables, which
4259 in turn take precedence over those specified by the configuration of GNU
4266 If @code{TMPDIR} is set, it specifies the directory to use for temporary
4267 files. GNU CC uses temporary files to hold the output of one stage of
4268 compilation which is to be used as input to the next stage: for example,
4269 the output of the preprocessor, which is the input to the compiler
4272 @item GCC_EXEC_PREFIX
4273 @findex GCC_EXEC_PREFIX
4274 If @code{GCC_EXEC_PREFIX} is set, it specifies a prefix to use in the
4275 names of the subprograms executed by the compiler. No slash is added
4276 when this prefix is combined with the name of a subprogram, but you can
4277 specify a prefix that ends with a slash if you wish.
4279 If GNU CC cannot find the subprogram using the specified prefix, it
4280 tries looking in the usual places for the subprogram.
4282 The default value of @code{GCC_EXEC_PREFIX} is
4283 @file{@var{prefix}/lib/gcc-lib/} where @var{prefix} is the value
4284 of @code{prefix} when you ran the @file{configure} script.
4286 Other prefixes specified with @samp{-B} take precedence over this prefix.
4288 This prefix is also used for finding files such as @file{crt0.o} that are
4291 In addition, the prefix is used in an unusual way in finding the
4292 directories to search for header files. For each of the standard
4293 directories whose name normally begins with @samp{/usr/local/lib/gcc-lib}
4294 (more precisely, with the value of @code{GCC_INCLUDE_DIR}), GNU CC tries
4295 replacing that beginning with the specified prefix to produce an
4296 alternate directory name. Thus, with @samp{-Bfoo/}, GNU CC will search
4297 @file{foo/bar} where it would normally search @file{/usr/local/lib/bar}.
4298 These alternate directories are searched first; the standard directories
4302 @findex COMPILER_PATH
4303 The value of @code{COMPILER_PATH} is a colon-separated list of
4304 directories, much like @code{PATH}. GNU CC tries the directories thus
4305 specified when searching for subprograms, if it can't find the
4306 subprograms using @code{GCC_EXEC_PREFIX}.
4309 @findex LIBRARY_PATH
4310 The value of @code{LIBRARY_PATH} is a colon-separated list of
4311 directories, much like @code{PATH}. When configured as a native compiler,
4312 GNU CC tries the directories thus specified when searching for special
4313 linker files, if it can't find them using @code{GCC_EXEC_PREFIX}. Linking
4314 using GNU CC also uses these directories when searching for ordinary
4315 libraries for the @samp{-l} option (but directories specified with
4316 @samp{-L} come first).
4318 @item C_INCLUDE_PATH
4319 @itemx CPLUS_INCLUDE_PATH
4320 @itemx OBJC_INCLUDE_PATH
4321 @findex C_INCLUDE_PATH
4322 @findex CPLUS_INCLUDE_PATH
4323 @findex OBJC_INCLUDE_PATH
4324 @c @itemx OBJCPLUS_INCLUDE_PATH
4325 These environment variables pertain to particular languages. Each
4326 variable's value is a colon-separated list of directories, much like
4327 @code{PATH}. When GNU CC searches for header files, it tries the
4328 directories listed in the variable for the language you are using, after
4329 the directories specified with @samp{-I} but before the standard header
4332 @item DEPENDENCIES_OUTPUT
4333 @findex DEPENDENCIES_OUTPUT
4334 @cindex dependencies for make as output
4335 If this variable is set, its value specifies how to output dependencies
4336 for Make based on the header files processed by the compiler. This
4337 output looks much like the output from the @samp{-M} option
4338 (@pxref{Preprocessor Options}), but it goes to a separate file, and is
4339 in addition to the usual results of compilation.
4341 The value of @code{DEPENDENCIES_OUTPUT} can be just a file name, in
4342 which case the Make rules are written to that file, guessing the target
4343 name from the source file name. Or the value can have the form
4344 @samp{@var{file} @var{target}}, in which case the rules are written to
4345 file @var{file} using @var{target} as the target name.
4348 @node Running Protoize
4349 @section Running Protoize
4351 The program @code{protoize} is an optional part of GNU C. You can use
4352 it to add prototypes to a program, thus converting the program to ANSI
4353 C in one respect. The companion program @code{unprotoize} does the
4354 reverse: it removes argument types from any prototypes that are found.
4356 When you run these programs, you must specify a set of source files as
4357 command line arguments. The conversion programs start out by compiling
4358 these files to see what functions they define. The information gathered
4359 about a file @var{foo} is saved in a file named @file{@var{foo}.X}.
4361 After scanning comes actual conversion. The specified files are all
4362 eligible to be converted; any files they include (whether sources or
4363 just headers) are eligible as well.
4365 But not all the eligible files are converted. By default,
4366 @code{protoize} and @code{unprotoize} convert only source and header
4367 files in the current directory. You can specify additional directories
4368 whose files should be converted with the @samp{-d @var{directory}}
4369 option. You can also specify particular files to exclude with the
4370 @samp{-x @var{file}} option. A file is converted if it is eligible, its
4371 directory name matches one of the specified directory names, and its
4372 name within the directory has not been excluded.
4374 Basic conversion with @code{protoize} consists of rewriting most
4375 function definitions and function declarations to specify the types of
4376 the arguments. The only ones not rewritten are those for varargs
4379 @code{protoize} optionally inserts prototype declarations at the
4380 beginning of the source file, to make them available for any calls that
4381 precede the function's definition. Or it can insert prototype
4382 declarations with block scope in the blocks where undeclared functions
4385 Basic conversion with @code{unprotoize} consists of rewriting most
4386 function declarations to remove any argument types, and rewriting
4387 function definitions to the old-style pre-ANSI form.
4389 Both conversion programs print a warning for any function declaration or
4390 definition that they can't convert. You can suppress these warnings
4393 The output from @code{protoize} or @code{unprotoize} replaces the
4394 original source file. The original file is renamed to a name ending
4395 with @samp{.save}. If the @samp{.save} file already exists, then
4396 the source file is simply discarded.
4398 @code{protoize} and @code{unprotoize} both depend on GNU CC itself to
4399 scan the program and collect information about the functions it uses.
4400 So neither of these programs will work until GNU CC is installed.
4402 Here is a table of the options you can use with @code{protoize} and
4403 @code{unprotoize}. Each option works with both programs unless
4407 @item -B @var{directory}
4408 Look for the file @file{SYSCALLS.c.X} in @var{directory}, instead of the
4409 usual directory (normally @file{/usr/local/lib}). This file contains
4410 prototype information about standard system functions. This option
4411 applies only to @code{protoize}.
4413 @item -c @var{compilation-options}
4414 Use @var{compilation-options} as the options when running @code{gcc} to
4415 produce the @samp{.X} files. The special option @samp{-aux-info} is
4416 always passed in addition, to tell @code{gcc} to write a @samp{.X} file.
4418 Note that the compilation options must be given as a single argument to
4419 @code{protoize} or @code{unprotoize}. If you want to specify several
4420 @code{gcc} options, you must quote the entire set of compilation options
4421 to make them a single word in the shell.
4423 There are certain @code{gcc} arguments that you cannot use, because they
4424 would produce the wrong kind of output. These include @samp{-g},
4425 @samp{-O}, @samp{-c}, @samp{-S}, and @samp{-o} If you include these in
4426 the @var{compilation-options}, they are ignored.
4429 Rename files to end in @samp{.C} instead of @samp{.c}.
4430 This is convenient if you are converting a C program to C++.
4431 This option applies only to @code{protoize}.
4434 Add explicit global declarations. This means inserting explicit
4435 declarations at the beginning of each source file for each function
4436 that is called in the file and was not declared. These declarations
4437 precede the first function definition that contains a call to an
4438 undeclared function. This option applies only to @code{protoize}.
4440 @item -i @var{string}
4441 Indent old-style parameter declarations with the string @var{string}.
4442 This option applies only to @code{protoize}.
4444 @code{unprotoize} converts prototyped function definitions to old-style
4445 function definitions, where the arguments are declared between the
4446 argument list and the initial @samp{@{}. By default, @code{unprotoize}
4447 uses five spaces as the indentation. If you want to indent with just
4448 one space instead, use @samp{-i " "}.
4451 Keep the @samp{.X} files. Normally, they are deleted after conversion
4455 Add explicit local declarations. @code{protoize} with @samp{-l} inserts
4456 a prototype declaration for each function in each block which calls the
4457 function without any declaration. This option applies only to
4461 Make no real changes. This mode just prints information about the conversions
4462 that would have been done without @samp{-n}.
4465 Make no @samp{.save} files. The original files are simply deleted.
4466 Use this option with caution.
4468 @item -p @var{program}
4469 Use the program @var{program} as the compiler. Normally, the name
4473 Work quietly. Most warnings are suppressed.
4476 Print the version number, just like @samp{-v} for @code{gcc}.
4479 If you need special compiler options to compile one of your program's
4480 source files, then you should generate that file's @samp{.X} file
4481 specially, by running @code{gcc} on that source file with the
4482 appropriate options and the option @samp{-aux-info}. Then run
4483 @code{protoize} on the entire set of files. @code{protoize} will use
4484 the existing @samp{.X} file because it is newer than the source file.
4488 gcc -Dfoo=bar file1.c -aux-info
4493 You need to include the special files along with the rest in the
4494 @code{protoize} command, even though their @samp{.X} files already
4495 exist, because otherwise they won't get converted.
4497 @xref{Protoize Caveats}, for more information on how to use
4498 @code{protoize} successfully.