]>
Commit | Line | Data |
---|---|---|
d0a5eb32 RK |
1 | @c Copyright (C) 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, |
2 | @c 2000, 2001 Free Software Foundation, Inc. | |
74291a4b MM |
3 | @c This is part of the GCC manual. |
4 | @c For copying conditions, see the file gcc.texi. | |
5 | ||
9d86bffc JM |
6 | @ignore |
7 | @c man begin COPYRIGHT | |
8 | Copyright @copyright{} 1988, 1989, 1992, 1993, 1994, 1995, 1996, 1997, | |
21c7361e | 9 | 1998, 1999, 2000, 2001 Free Software Foundation, Inc. |
9d86bffc JM |
10 | |
11 | Permission is granted to make and distribute verbatim copies of this | |
12 | manual provided the copyright notice and this permission notice are | |
13 | preserved on all copies. | |
14 | ||
15 | Permission is granted to copy and distribute modified versions of this | |
16 | manual under the conditions for verbatim copying, provided also that the | |
17 | entire resulting derived work is distributed under the terms of a | |
18 | permission notice identical to this one. | |
19 | ||
20 | Permission is granted to copy and distribute translations of this manual | |
21 | into another language, under the above conditions for modified versions, | |
22 | except that this permission notice may be included in translations | |
23 | approved by the Free Software Foundation instead of in the original | |
24 | English. | |
25 | @c man end | |
26 | @c Set file name and title for the man page. | |
27 | @setfilename gcc | |
28 | @settitle GNU project C and C++ compiler | |
29 | @c man begin SYNOPSIS | |
630d3d5a JM |
30 | gcc [@option{-c}|@option{-S}|@option{-E}] [@option{-std=}@var{standard}] |
31 | [@option{-g}] [@option{-pg}] [@option{-O}@var{level}] | |
32 | [@option{-W}@var{warn}@dots{}] [@option{-pedantic}] | |
33 | [@option{-I}@var{dir}@dots{}] [@option{-L}@var{dir}@dots{}] | |
34 | [@option{-D}@var{macro}[=@var{defn}]@dots{}] [@option{-U}@var{macro}] | |
35 | [@option{-f}@var{option}@dots{}] [@option{-m}@var{machine-option}@dots{}] | |
36 | [@option{-o} @var{outfile}] @var{infile}@dots{} | |
9d86bffc JM |
37 | |
38 | Only the most useful options are listed here; see below for the | |
39 | remainder. @samp{g++} accepts mostly the same options as @samp{gcc}. | |
40 | @c man end | |
41 | @c man begin SEEALSO | |
42 | cpp(1), gcov(1), g77(1), as(1), ld(1), gdb(1), adb(1), dbx(1), sdb(1) | |
43 | and the Info entries for @file{gcc}, @file{cpp}, @file{g77}, @file{as}, | |
44 | @file{ld}, @file{binutils} and @file{gdb}. | |
45 | @c man end | |
2642624b JM |
46 | @c man begin BUGS |
47 | For instructions on reporting bugs, see | |
bedc7537 | 48 | @w{@uref{http://gcc.gnu.org/bugs.html}}. Use of the @command{gccbug} |
2642624b JM |
49 | script to report bugs is recommended. |
50 | @c man end | |
51 | @c man begin AUTHOR | |
52 | See the Info entry for @file{gcc}, or | |
161d7b59 | 53 | @w{@uref{http://gcc.gnu.org/thanks.html}}, for contributors to GCC@. |
2642624b | 54 | @c man end |
9d86bffc JM |
55 | @end ignore |
56 | ||
74291a4b | 57 | @node Invoking GCC |
0c2d1a2a JB |
58 | @chapter GCC Command Options |
59 | @cindex GCC command options | |
74291a4b | 60 | @cindex command options |
0c2d1a2a | 61 | @cindex options, GCC command |
74291a4b | 62 | |
9d86bffc JM |
63 | @c man begin DESCRIPTION |
64 | ||
0c2d1a2a | 65 | When you invoke GCC, it normally does preprocessing, compilation, |
74291a4b | 66 | assembly and linking. The ``overall options'' allow you to stop this |
630d3d5a | 67 | process at an intermediate stage. For example, the @option{-c} option |
74291a4b MM |
68 | says not to run the linker. Then the output consists of object files |
69 | output by the assembler. | |
70 | ||
71 | Other options are passed on to one stage of processing. Some options | |
72 | control the preprocessor and others the compiler itself. Yet other | |
73 | options control the assembler and linker; most of these are not | |
74 | documented here, since you rarely need to use any of them. | |
75 | ||
76 | @cindex C compilation options | |
0c2d1a2a | 77 | Most of the command line options that you can use with GCC are useful |
74291a4b MM |
78 | for C programs; when an option is only useful with another language |
79 | (usually C++), the explanation says so explicitly. If the description | |
80 | for a particular option does not mention a source language, you can use | |
81 | that option with all supported languages. | |
82 | ||
83 | @cindex C++ compilation options | |
84 | @xref{Invoking G++,,Compiling C++ Programs}, for a summary of special | |
85 | options for compiling C++ programs. | |
86 | ||
87 | @cindex grouping options | |
88 | @cindex options, grouping | |
bedc7537 | 89 | The @command{gcc} program accepts options and file names as operands. Many |
b192711e | 90 | options have multi-letter names; therefore multiple single-letter options |
630d3d5a | 91 | may @emph{not} be grouped: @option{-dr} is very different from @w{@samp{-d |
74291a4b MM |
92 | -r}}. |
93 | ||
94 | @cindex order of options | |
95 | @cindex options, order | |
96 | You can mix options and other arguments. For the most part, the order | |
97 | you use doesn't matter. Order does matter when you use several options | |
630d3d5a | 98 | of the same kind; for example, if you specify @option{-L} more than once, |
74291a4b MM |
99 | the directories are searched in the order specified. |
100 | ||
101 | Many options have long names starting with @samp{-f} or with | |
630d3d5a JM |
102 | @samp{-W}---for example, @option{-fforce-mem}, |
103 | @option{-fstrength-reduce}, @option{-Wformat} and so on. Most of | |
74291a4b | 104 | these have both positive and negative forms; the negative form of |
630d3d5a | 105 | @option{-ffoo} would be @option{-fno-foo}. This manual documents |
74291a4b MM |
106 | only one of these two forms, whichever one is not the default. |
107 | ||
9d86bffc JM |
108 | @c man end |
109 | ||
cd3bb277 JM |
110 | @xref{Option Index}, for an index to GCC's options. |
111 | ||
74291a4b MM |
112 | @menu |
113 | * Option Summary:: Brief list of all options, without explanations. | |
114 | * Overall Options:: Controlling the kind of output: | |
115 | an executable, object files, assembler files, | |
116 | or preprocessed source. | |
117 | * Invoking G++:: Compiling C++ programs. | |
118 | * C Dialect Options:: Controlling the variant of C language compiled. | |
119 | * C++ Dialect Options:: Variations on C++. | |
60de6385 | 120 | * Objective-C Dialect Options:: Variations on Objective-C. |
764dbbf2 | 121 | * Language Independent Options:: Controlling how diagnostics should be |
02f52e19 | 122 | formatted. |
74291a4b MM |
123 | * Warning Options:: How picky should the compiler be? |
124 | * Debugging Options:: Symbol tables, measurements, and debugging dumps. | |
125 | * Optimize Options:: How much optimization? | |
126 | * Preprocessor Options:: Controlling header files and macro definitions. | |
127 | Also, getting dependency information for Make. | |
128 | * Assembler Options:: Passing options to the assembler. | |
129 | * Link Options:: Specifying libraries and so on. | |
130 | * Directory Options:: Where to find header files and libraries. | |
131 | Where to find the compiler executable files. | |
a743d340 | 132 | * Spec Files:: How to pass switches to sub-processes. |
0c2d1a2a | 133 | * Target Options:: Running a cross-compiler, or an old version of GCC. |
74291a4b MM |
134 | * Submodel Options:: Specifying minor hardware or convention variations, |
135 | such as 68010 vs 68020. | |
136 | * Code Gen Options:: Specifying conventions for function calls, data layout | |
137 | and register usage. | |
0c2d1a2a | 138 | * Environment Variables:: Env vars that affect GCC. |
74291a4b MM |
139 | * Running Protoize:: Automatically adding or removing function prototypes. |
140 | @end menu | |
141 | ||
4bc1997b JM |
142 | @c man begin OPTIONS |
143 | ||
74291a4b MM |
144 | @node Option Summary |
145 | @section Option Summary | |
146 | ||
147 | Here is a summary of all the options, grouped by type. Explanations are | |
148 | in the following sections. | |
149 | ||
150 | @table @emph | |
151 | @item Overall Options | |
152 | @xref{Overall Options,,Options Controlling the Kind of Output}. | |
4bc1997b JM |
153 | @gccoptlist{ |
154 | -c -S -E -o @var{file} -pipe -pass-exit-codes -x @var{language} @gol | |
155 | -v --target-help --help} | |
74291a4b MM |
156 | |
157 | @item C Language Options | |
158 | @xref{C Dialect Options,,Options Controlling C Dialect}. | |
4bc1997b | 159 | @gccoptlist{ |
b1018de6 AO |
160 | -ansi -std=@var{standard} -aux-info @var{filename} @gol |
161 | -fno-asm -fno-builtin @gol | |
4bc1997b JM |
162 | -fhosted -ffreestanding @gol |
163 | -trigraphs -traditional -traditional-cpp @gol | |
164 | -fallow-single-precision -fcond-mismatch @gol | |
165 | -fsigned-bitfields -fsigned-char @gol | |
166 | -funsigned-bitfields -funsigned-char @gol | |
167 | -fwritable-strings -fshort-wchar} | |
74291a4b MM |
168 | |
169 | @item C++ Language Options | |
170 | @xref{C++ Dialect Options,,Options Controlling C++ Dialect}. | |
4bc1997b JM |
171 | @gccoptlist{ |
172 | -fno-access-control -fcheck-new -fconserve-space @gol | |
aa0cc562 JM |
173 | -fno-const-strings -fdollars-in-identifiers @gol |
174 | -fno-elide-constructors @gol | |
4bc1997b JM |
175 | -fno-enforce-eh-specs -fexternal-templates @gol |
176 | -falt-external-templates @gol | |
1dbb6023 | 177 | -ffor-scope -fno-for-scope -fno-gnu-keywords @gol |
90ecce3e | 178 | -fno-implicit-templates @gol |
4bc1997b JM |
179 | -fno-implicit-inline-templates @gol |
180 | -fno-implement-inlines -fms-extensions @gol | |
aa0cc562 | 181 | -fno-nonansi-builtins -fno-operator-names @gol |
4bc1997b | 182 | -fno-optional-diags -fpermissive @gol |
aa0cc562 | 183 | -frepo -fno-rtti -fstats -ftemplate-depth-@var{n} @gol |
90ecce3e | 184 | -fuse-cxa-atexit -fvtable-gc -fno-weak -nostdinc++ @gol |
4bc1997b JM |
185 | -fno-default-inline -Wctor-dtor-privacy @gol |
186 | -Wnon-virtual-dtor -Wreorder @gol | |
187 | -Weffc++ -Wno-deprecated @gol | |
188 | -Wno-non-template-friend -Wold-style-cast @gol | |
189 | -Woverloaded-virtual -Wno-pmf-conversions @gol | |
190 | -Wsign-promo -Wsynth} | |
74291a4b | 191 | |
60de6385 SS |
192 | @item Objective-C Language Options |
193 | @xref{Objective-C Dialect Options,,Options Controlling Objective-C Dialect}. | |
194 | @gccoptlist{ | |
630d3d5a | 195 | -fconstant-string-class=@var{class-name} @gol |
310668e8 | 196 | -fgnu-runtime -fnext-runtime -gen-decls @gol |
60de6385 SS |
197 | -Wno-protocol -Wselector} |
198 | ||
764dbbf2 GDR |
199 | @item Language Independent Options |
200 | @xref{Language Independent Options,,Options to Control Diagnostic Messages Formatting}. | |
4bc1997b JM |
201 | @gccoptlist{ |
202 | -fmessage-length=@var{n} @gol | |
203 | -fdiagnostics-show-location=@r{[}once@r{|}every-line@r{]}} | |
764dbbf2 | 204 | |
74291a4b MM |
205 | @item Warning Options |
206 | @xref{Warning Options,,Options to Request or Suppress Warnings}. | |
4bc1997b JM |
207 | @gccoptlist{ |
208 | -fsyntax-only -pedantic -pedantic-errors @gol | |
209 | -w -W -Wall -Waggregate-return @gol | |
210 | -Wcast-align -Wcast-qual -Wchar-subscripts -Wcomment @gol | |
feb48bde | 211 | -Wconversion -Wdisabled-optimization -Werror @gol |
4bc1997b | 212 | -Wfloat-equal -Wformat -Wformat=2 @gol |
feb48bde JM |
213 | -Wformat-nonliteral -Wformat-security @gol |
214 | -Wimplicit -Wimplicit-int @gol | |
4bc1997b JM |
215 | -Wimplicit-function-declaration @gol |
216 | -Werror-implicit-function-declaration @gol | |
217 | -Wimport -Winline @gol | |
218 | -Wlarger-than-@var{len} -Wlong-long @gol | |
1f0c3120 | 219 | -Wmain -Wmissing-braces -Wmissing-declarations @gol |
4bc1997b | 220 | -Wmissing-format-attribute -Wmissing-noreturn @gol |
feb48bde | 221 | -Wmultichar -Wno-format-extra-args -Wno-format-y2k @gol |
4bc1997b | 222 | -Wno-import -Wpacked -Wpadded @gol |
310668e8 | 223 | -Wparentheses -Wpointer-arith -Wredundant-decls @gol |
4bc1997b JM |
224 | -Wreturn-type -Wsequence-point -Wshadow @gol |
225 | -Wsign-compare -Wswitch -Wsystem-headers @gol | |
226 | -Wtrigraphs -Wundef -Wuninitialized @gol | |
227 | -Wunknown-pragmas -Wunreachable-code @gol | |
228 | -Wunused -Wunused-function -Wunused-label -Wunused-parameter @gol | |
229 | -Wunused-value -Wunused-variable -Wwrite-strings} | |
74291a4b | 230 | |
fe50c0eb | 231 | @item C-only Warning Options |
4bc1997b | 232 | @gccoptlist{ |
310668e8 JM |
233 | -Wbad-function-cast -Wmissing-prototypes -Wnested-externs @gol |
234 | -Wstrict-prototypes -Wtraditional} | |
fe50c0eb | 235 | |
74291a4b MM |
236 | @item Debugging Options |
237 | @xref{Debugging Options,,Options for Debugging Your Program or GCC}. | |
4bc1997b | 238 | @gccoptlist{ |
1f0c3120 | 239 | -a -ax -d@var{letters} -dumpspecs -dumpmachine -dumpversion @gol |
aee96fe9 JM |
240 | -fdump-unnumbered -fdump-translation-unit@r{[}-@var{n}@r{]} @gol |
241 | -fdump-class-hierarchy@r{[}-@var{n}@r{]} @gol | |
22367161 NS |
242 | -fdump-tree-original@r{[}-@var{n}@r{]} -fdump-tree-optimized@r{[}-@var{n}@r{]} @gol |
243 | -fdump-tree-inlined@r{[}-@var{n}@r{]} @gol | |
e76b4820 | 244 | -fmem-report -fpretend-float @gol |
1f0c3120 | 245 | -fprofile-arcs -ftest-coverage -ftime-report @gol |
4bc1997b JM |
246 | -g -g@var{level} -gcoff -gdwarf -gdwarf-1 -gdwarf-1+ -gdwarf-2 @gol |
247 | -ggdb -gstabs -gstabs+ -gxcoff -gxcoff+ @gol | |
248 | -p -pg -print-file-name=@var{library} -print-libgcc-file-name @gol | |
b1018de6 | 249 | -print-multi-directory -print-multi-lib @gol |
4bc1997b JM |
250 | -print-prog-name=@var{program} -print-search-dirs -Q @gol |
251 | -save-temps -time} | |
74291a4b MM |
252 | |
253 | @item Optimization Options | |
254 | @xref{Optimize Options,,Options that Control Optimization}. | |
4bc1997b JM |
255 | @gccoptlist{ |
256 | -falign-functions=@var{n} -falign-jumps=@var{n} @gol | |
257 | -falign-labels=@var{n} -falign-loops=@var{n} @gol | |
258 | -fbranch-probabilities -fcaller-saves @gol | |
62d285ff | 259 | -fcse-follow-jumps -fcse-skip-blocks -fdata-sections @gol |
4bc1997b JM |
260 | -fdelayed-branch -fdelete-null-pointer-checks @gol |
261 | -fexpensive-optimizations -ffast-math -ffloat-store @gol | |
feb48bde JM |
262 | -fforce-addr -fforce-mem -ffunction-sections @gol |
263 | -fgcse -fgcse-lm -fgcse-sm @gol | |
4bc1997b | 264 | -finline-functions -finline-limit=@var{n} -fkeep-inline-functions @gol |
201556f0 JJ |
265 | -fkeep-static-consts -fmerge-constants -fmerge-all-constants @gol |
266 | -fmove-all-movables -fno-default-inline -fno-defer-pop @gol | |
feb48bde | 267 | -fno-function-cse -fno-guess-branch-probability @gol |
6cfc0341 | 268 | -fno-inline -fno-math-errno -fno-peephole -fno-peephole2 @gol |
de6c5979 | 269 | -funsafe-math-optimizations -fno-trapping-math @gol |
4bc1997b JM |
270 | -fomit-frame-pointer -foptimize-register-move @gol |
271 | -foptimize-sibling-calls -freduce-all-givs @gol | |
272 | -fregmove -frename-registers @gol | |
273 | -frerun-cse-after-loop -frerun-loop-opt @gol | |
274 | -fschedule-insns -fschedule-insns2 @gol | |
0b47e4c1 | 275 | -fsingle-precision-constant -fssa -fssa-ccp -fssa-dce @gol |
4bc1997b JM |
276 | -fstrength-reduce -fstrict-aliasing -fthread-jumps -ftrapv @gol |
277 | -funroll-all-loops -funroll-loops @gol | |
3af64fd6 | 278 | --param @var{name}=@var{value} |
4bc1997b | 279 | -O -O0 -O1 -O2 -O3 -Os} |
74291a4b MM |
280 | |
281 | @item Preprocessor Options | |
282 | @xref{Preprocessor Options,,Options Controlling the Preprocessor}. | |
4bc1997b JM |
283 | @gccoptlist{ |
284 | -$ -A@var{question}=@var{answer} -A-@var{question}@r{[}=@var{answer}@r{]} @gol | |
285 | -C -dD -dI -dM -dN @gol | |
286 | -D@var{macro}@r{[}=@var{defn}@r{]} -E -H @gol | |
287 | -idirafter @var{dir} @gol | |
288 | -include @var{file} -imacros @var{file} @gol | |
289 | -iprefix @var{file} -iwithprefix @var{dir} @gol | |
bdd42dd9 | 290 | -iwithprefixbefore @var{dir} -isystem @var{dir} @gol |
4bc1997b | 291 | -M -MM -MF -MG -MP -MQ -MT -nostdinc -P -remap @gol |
aee96fe9 | 292 | -trigraphs -undef -U@var{macro} -Wp,@var{option}} |
74291a4b MM |
293 | |
294 | @item Assembler Option | |
295 | @xref{Assembler Options,,Passing Options to the Assembler}. | |
4bc1997b | 296 | @gccoptlist{ |
aee96fe9 | 297 | -Wa,@var{option}} |
74291a4b MM |
298 | |
299 | @item Linker Options | |
300 | @xref{Link Options,,Options for Linking}. | |
4bc1997b JM |
301 | @gccoptlist{ |
302 | @var{object-file-name} -l@var{library} @gol | |
303 | -nostartfiles -nodefaultlibs -nostdlib @gol | |
304 | -s -static -static-libgcc -shared -shared-libgcc -symbolic @gol | |
aee96fe9 | 305 | -Wl,@var{option} -Xlinker @var{option} @gol |
4bc1997b | 306 | -u @var{symbol}} |
74291a4b MM |
307 | |
308 | @item Directory Options | |
309 | @xref{Directory Options,,Options for Directory Search}. | |
4bc1997b JM |
310 | @gccoptlist{ |
311 | -B@var{prefix} -I@var{dir} -I- -L@var{dir} -specs=@var{file}} | |
74291a4b MM |
312 | |
313 | @item Target Options | |
314 | @c I wrote this xref this way to avoid overfull hbox. -- rms | |
315 | @xref{Target Options}. | |
4bc1997b JM |
316 | @gccoptlist{ |
317 | -b @var{machine} -V @var{version}} | |
74291a4b MM |
318 | |
319 | @item Machine Dependent Options | |
320 | @xref{Submodel Options,,Hardware Models and Configurations}. | |
74291a4b | 321 | @emph{M680x0 Options} |
4bc1997b JM |
322 | @gccoptlist{ |
323 | -m68000 -m68020 -m68020-40 -m68020-60 -m68030 -m68040 @gol | |
feb48bde | 324 | -m68060 -mcpu32 -m5200 -m68881 -mbitfield -mc68000 -mc68020 @gol |
310668e8 JM |
325 | -mfpa -mnobitfield -mrtd -mshort -msoft-float -mpcrel @gol |
326 | -malign-int -mstrict-align} | |
74291a4b | 327 | |
2856c3e3 | 328 | @emph{M68hc1x Options} |
4bc1997b JM |
329 | @gccoptlist{ |
330 | -m6811 -m6812 -m68hc11 -m68hc12 @gol | |
331 | -mauto-incdec -mshort -msoft-reg-count=@var{count}} | |
2856c3e3 | 332 | |
74291a4b | 333 | @emph{VAX Options} |
4bc1997b JM |
334 | @gccoptlist{ |
335 | -mg -mgnu -munix} | |
74291a4b MM |
336 | |
337 | @emph{SPARC Options} | |
4bc1997b | 338 | @gccoptlist{ |
630d3d5a JM |
339 | -mcpu=@var{cpu-type} @gol |
340 | -mtune=@var{cpu-type} @gol | |
341 | -mcmodel=@var{code-model} @gol | |
4bc1997b JM |
342 | -m32 -m64 @gol |
343 | -mapp-regs -mbroken-saverestore -mcypress @gol | |
feb48bde | 344 | -mepilogue -mfaster-structs -mflat @gol |
4bc1997b JM |
345 | -mfpu -mhard-float -mhard-quad-float @gol |
346 | -mimpure-text -mlive-g0 -mno-app-regs @gol | |
310668e8 JM |
347 | -mno-epilogue -mno-faster-structs -mno-flat -mno-fpu @gol |
348 | -mno-impure-text -mno-stack-bias -mno-unaligned-doubles @gol | |
4bc1997b JM |
349 | -msoft-float -msoft-quad-float -msparclite -mstack-bias @gol |
350 | -msupersparc -munaligned-doubles -mv8} | |
74291a4b MM |
351 | |
352 | @emph{Convex Options} | |
4bc1997b JM |
353 | @gccoptlist{ |
354 | -mc1 -mc2 -mc32 -mc34 -mc38 @gol | |
355 | -margcount -mnoargcount @gol | |
356 | -mlong32 -mlong64 @gol | |
357 | -mvolatile-cache -mvolatile-nocache} | |
74291a4b MM |
358 | |
359 | @emph{AMD29K Options} | |
4bc1997b JM |
360 | @gccoptlist{ |
361 | -m29000 -m29050 -mbw -mnbw -mdw -mndw @gol | |
362 | -mlarge -mnormal -msmall @gol | |
363 | -mkernel-registers -mno-reuse-arg-regs @gol | |
364 | -mno-stack-check -mno-storem-bug @gol | |
365 | -mreuse-arg-regs -msoft-float -mstack-check @gol | |
366 | -mstorem-bug -muser-registers} | |
74291a4b MM |
367 | |
368 | @emph{ARM Options} | |
4bc1997b | 369 | @gccoptlist{ |
310668e8 JM |
370 | -mapcs-frame -mno-apcs-frame @gol |
371 | -mapcs-26 -mapcs-32 @gol | |
372 | -mapcs-stack-check -mno-apcs-stack-check @gol | |
373 | -mapcs-float -mno-apcs-float @gol | |
374 | -mapcs-reentrant -mno-apcs-reentrant @gol | |
375 | -msched-prolog -mno-sched-prolog @gol | |
376 | -mlittle-endian -mbig-endian -mwords-little-endian @gol | |
377 | -malignment-traps -mno-alignment-traps @gol | |
378 | -msoft-float -mhard-float -mfpe @gol | |
379 | -mthumb-interwork -mno-thumb-interwork @gol | |
380 | -mcpu=@var{name} -march=@var{name} -mfpe=@var{name} @gol | |
247f8561 | 381 | -mstructure-size-boundary=@var{n} @gol |
310668e8 | 382 | -mbsd -mxopen -mno-symrename @gol |
4bc1997b | 383 | -mabort-on-noreturn @gol |
310668e8 JM |
384 | -mlong-calls -mno-long-calls @gol |
385 | -msingle-pic-base -mno-single-pic-base @gol | |
247f8561 PB |
386 | -mpic-register=@var{reg} @gol |
387 | -mnop-fun-dllimport @gol | |
388 | -mpoke-function-name @gol | |
310668e8 JM |
389 | -mthumb -marm @gol |
390 | -mtpcs-frame -mtpcs-leaf-frame @gol | |
391 | -mcaller-super-interworking -mcallee-super-interworking } | |
74291a4b | 392 | |
ecff22ab | 393 | @emph{MN10200 Options} |
4bc1997b JM |
394 | @gccoptlist{ |
395 | -mrelax} | |
ecff22ab | 396 | |
6d6d0fa0 | 397 | @emph{MN10300 Options} |
4bc1997b | 398 | @gccoptlist{ |
c474f76b AO |
399 | -mmult-bug -mno-mult-bug @gol |
400 | -mam33 -mno-am33 @gol | |
401 | -mno-crt0 -mrelax} | |
6d6d0fa0 | 402 | |
861bb6c1 | 403 | @emph{M32R/D Options} |
4bc1997b | 404 | @gccoptlist{ |
630d3d5a | 405 | -mcode-model=@var{model-type} -msdata=@var{sdata-type} @gol |
4bc1997b | 406 | -G @var{num}} |
861bb6c1 | 407 | |
74291a4b | 408 | @emph{M88K Options} |
4bc1997b JM |
409 | @gccoptlist{ |
410 | -m88000 -m88100 -m88110 -mbig-pic @gol | |
411 | -mcheck-zero-division -mhandle-large-shift @gol | |
412 | -midentify-revision -mno-check-zero-division @gol | |
413 | -mno-ocs-debug-info -mno-ocs-frame-position @gol | |
414 | -mno-optimize-arg-area -mno-serialize-volatile @gol | |
415 | -mno-underscores -mocs-debug-info @gol | |
416 | -mocs-frame-position -moptimize-arg-area @gol | |
417 | -mserialize-volatile -mshort-data-@var{num} -msvr3 @gol | |
418 | -msvr4 -mtrap-large-shift -muse-div-instruction @gol | |
419 | -mversion-03.00 -mwarn-passed-structs} | |
74291a4b MM |
420 | |
421 | @emph{RS/6000 and PowerPC Options} | |
4bc1997b | 422 | @gccoptlist{ |
630d3d5a JM |
423 | -mcpu=@var{cpu-type} @gol |
424 | -mtune=@var{cpu-type} @gol | |
4bc1997b JM |
425 | -mpower -mno-power -mpower2 -mno-power2 @gol |
426 | -mpowerpc -mpowerpc64 -mno-powerpc @gol | |
427 | -mpowerpc-gpopt -mno-powerpc-gpopt @gol | |
428 | -mpowerpc-gfxopt -mno-powerpc-gfxopt @gol | |
429 | -mnew-mnemonics -mold-mnemonics @gol | |
430 | -mfull-toc -mminimal-toc -mno-fop-in-toc -mno-sum-in-toc @gol | |
431 | -m64 -m32 -mxl-call -mno-xl-call -mthreads -mpe @gol | |
432 | -msoft-float -mhard-float -mmultiple -mno-multiple @gol | |
433 | -mstring -mno-string -mupdate -mno-update @gol | |
434 | -mfused-madd -mno-fused-madd -mbit-align -mno-bit-align @gol | |
435 | -mstrict-align -mno-strict-align -mrelocatable @gol | |
436 | -mno-relocatable -mrelocatable-lib -mno-relocatable-lib @gol | |
437 | -mtoc -mno-toc -mlittle -mlittle-endian -mbig -mbig-endian @gol | |
9c34dbbf ZW |
438 | -mcall-aix -mcall-sysv -mcall-netbsd @gol |
439 | -mprototype -mno-prototype @gol | |
4bc1997b JM |
440 | -msim -mmvme -mads -myellowknife -memb -msdata @gol |
441 | -msdata=@var{opt} -mvxworks -G @var{num}} | |
74291a4b MM |
442 | |
443 | @emph{RT Options} | |
4bc1997b JM |
444 | @gccoptlist{ |
445 | -mcall-lib-mul -mfp-arg-in-fpregs -mfp-arg-in-gregs @gol | |
446 | -mfull-fp-blocks -mhc-struct-return -min-line-mul @gol | |
447 | -mminimum-fp-blocks -mnohc-struct-return} | |
74291a4b MM |
448 | |
449 | @emph{MIPS Options} | |
4bc1997b | 450 | @gccoptlist{ |
7dac2f89 EC |
451 | -mabicalls -march=@var{cpu-type} -mtune=@var{cpu=type} @gol |
452 | -mcpu=@var{cpu-type} -membedded-data -muninit-const-in-rodata @gol | |
13fac94a GK |
453 | -membedded-pic -mfp32 -mfp64 -mfused-madd -mno-fused-madd @gol |
454 | -mgas -mgp32 -mgp64 @gol | |
4bc1997b | 455 | -mgpopt -mhalf-pic -mhard-float -mint64 -mips1 @gol |
feb48bde | 456 | -mips2 -mips3 -mips4 -mlong64 -mlong32 -mlong-calls -mmemcpy @gol |
4bc1997b | 457 | -mmips-as -mmips-tfile -mno-abicalls @gol |
feb48bde JM |
458 | -mno-embedded-data -mno-uninit-const-in-rodata @gol |
459 | -mno-embedded-pic -mno-gpopt -mno-long-calls @gol | |
4bc1997b JM |
460 | -mno-memcpy -mno-mips-tfile -mno-rnames -mno-stats @gol |
461 | -mrnames -msoft-float @gol | |
462 | -m4650 -msingle-float -mmad @gol | |
463 | -mstats -EL -EB -G @var{num} -nocpp @gol | |
feb48bde JM |
464 | -mabi=32 -mabi=n32 -mabi=64 -mabi=eabi @gol |
465 | -mfix7000 -mno-crt0} | |
74291a4b MM |
466 | |
467 | @emph{i386 Options} | |
4bc1997b | 468 | @gccoptlist{ |
630d3d5a | 469 | -mcpu=@var{cpu-type} -march=@var{cpu-type} @gol |
4bc1997b JM |
470 | -mintel-syntax -mieee-fp -mno-fancy-math-387 @gol |
471 | -mno-fp-ret-in-387 -msoft-float -msvr3-shlib @gol | |
472 | -mno-wide-multiply -mrtd -malign-double @gol | |
3e18fdf6 | 473 | -mpreferred-stack-boundary=@var{num} @gol |
feb48bde JM |
474 | -mthreads -mno-align-stringops -minline-all-stringops @gol |
475 | -mpush-args -maccumulate-outgoing-args -m128bit-long-double @gol | |
476 | -m96bit-long-double -mregparm=@var{num} -momit-leaf-frame-pointer} | |
74291a4b MM |
477 | |
478 | @emph{HPPA Options} | |
4bc1997b | 479 | @gccoptlist{ |
630d3d5a | 480 | -march=@var{architecture-type} @gol |
feb48bde JM |
481 | -mbig-switch -mdisable-fpregs -mdisable-indexing @gol |
482 | -mfast-indirect-calls -mgas -mjump-in-delay @gol | |
4bc1997b JM |
483 | -mlong-load-store -mno-big-switch -mno-disable-fpregs @gol |
484 | -mno-disable-indexing -mno-fast-indirect-calls -mno-gas @gol | |
feb48bde | 485 | -mno-jump-in-delay -mno-long-load-store @gol |
4bc1997b | 486 | -mno-portable-runtime -mno-soft-float @gol |
feb48bde JM |
487 | -mno-space-regs -msoft-float -mpa-risc-1-0 @gol |
488 | -mpa-risc-1-1 -mpa-risc-2-0 -mportable-runtime @gol | |
630d3d5a | 489 | -mschedule=@var{cpu-type} -mspace-regs} |
74291a4b MM |
490 | |
491 | @emph{Intel 960 Options} | |
4bc1997b | 492 | @gccoptlist{ |
630d3d5a | 493 | -m@var{cpu-type} -masm-compat -mclean-linkage @gol |
4bc1997b JM |
494 | -mcode-align -mcomplex-addr -mleaf-procedures @gol |
495 | -mic-compat -mic2.0-compat -mic3.0-compat @gol | |
496 | -mintel-asm -mno-clean-linkage -mno-code-align @gol | |
497 | -mno-complex-addr -mno-leaf-procedures @gol | |
498 | -mno-old-align -mno-strict-align -mno-tail-call @gol | |
499 | -mnumerics -mold-align -msoft-float -mstrict-align @gol | |
500 | -mtail-call} | |
74291a4b MM |
501 | |
502 | @emph{DEC Alpha Options} | |
4bc1997b | 503 | @gccoptlist{ |
310668e8 JM |
504 | -mfp-regs -mno-fp-regs -mno-soft-float -msoft-float @gol |
505 | -malpha-as -mgas @gol | |
4bc1997b JM |
506 | -mieee -mieee-with-inexact -mieee-conformant @gol |
507 | -mfp-trap-mode=@var{mode} -mfp-rounding-mode=@var{mode} @gol | |
508 | -mtrap-precision=@var{mode} -mbuild-constants @gol | |
630d3d5a | 509 | -mcpu=@var{cpu-type} @gol |
310668e8 | 510 | -mbwx -mno-bwx -mcix -mno-cix -mmax -mno-max @gol |
4bc1997b | 511 | -mmemory-latency=@var{time}} |
74291a4b MM |
512 | |
513 | @emph{Clipper Options} | |
4bc1997b JM |
514 | @gccoptlist{ |
515 | -mc300 -mc400} | |
74291a4b MM |
516 | |
517 | @emph{H8/300 Options} | |
4bc1997b | 518 | @gccoptlist{ |
310668e8 | 519 | -mrelax -mh -ms -mint32 -malign-300} |
74291a4b MM |
520 | |
521 | @emph{SH Options} | |
4bc1997b JM |
522 | @gccoptlist{ |
523 | -m1 -m2 -m3 -m3e @gol | |
524 | -m4-nofpu -m4-single-only -m4-single -m4 @gol | |
525 | -mb -ml -mdalign -mrelax @gol | |
526 | -mbigtable -mfmovd -mhitachi -mnomacsave @gol | |
c474f76b AO |
527 | -mieee -misize -mpadstruct -mspace @gol |
528 | -mprefergot -musermode} | |
74291a4b MM |
529 | |
530 | @emph{System V Options} | |
4bc1997b | 531 | @gccoptlist{ |
aee96fe9 | 532 | -Qy -Qn -YP,@var{paths} -Ym,@var{dir}} |
74291a4b | 533 | |
56b2d7a7 | 534 | @emph{ARC Options} |
4bc1997b JM |
535 | @gccoptlist{ |
536 | -EB -EL @gol | |
630d3d5a JM |
537 | -mmangle-cpu -mcpu=@var{cpu} -mtext=@var{text-section} @gol |
538 | -mdata=@var{data-section} -mrodata=@var{readonly-data-section}} | |
56b2d7a7 | 539 | |
282a61e6 | 540 | @emph{TMS320C3x/C4x Options} |
4bc1997b | 541 | @gccoptlist{ |
310668e8 JM |
542 | -mcpu=@var{cpu} -mbig -msmall -mregparm -mmemparm @gol |
543 | -mfast-fix -mmpyi -mbk -mti -mdp-isr-reload @gol | |
544 | -mrpts=@var{count} -mrptb -mdb -mloop-unsigned @gol | |
545 | -mparallel-insns -mparallel-mpy -mpreserve-float} | |
282a61e6 | 546 | |
f84271d9 | 547 | @emph{V850 Options} |
4bc1997b | 548 | @gccoptlist{ |
310668e8 JM |
549 | -mlong-calls -mno-long-calls -mep -mno-ep @gol |
550 | -mprolog-function -mno-prolog-function -mspace @gol | |
551 | -mtda=@var{n} -msda=@var{n} -mzda=@var{n} @gol | |
552 | -mv850 -mbig-switch} | |
83575957 ID |
553 | |
554 | @emph{NS32K Options} | |
4bc1997b | 555 | @gccoptlist{ |
310668e8 | 556 | -m32032 -m32332 -m32532 -m32081 -m32381 @gol |
feb48bde | 557 | -mmult-add -mnomult-add -msoft-float -mrtd -mnortd @gol |
310668e8 JM |
558 | -mregparam -mnoregparam -msb -mnosb @gol |
559 | -mbitfield -mnobitfield -mhimem -mnohimem} | |
789a3090 | 560 | |
052a4b28 | 561 | @emph{AVR Options} |
4bc1997b | 562 | @gccoptlist{ |
310668e8 JM |
563 | -mmcu=@var{mcu} -msize -minit-stack=@var{n} -mno-interrupts @gol |
564 | -mcall-prologues -mno-tablejump -mtiny-stack} | |
052a4b28 | 565 | |
789a3090 | 566 | @emph{MCore Options} |
4bc1997b | 567 | @gccoptlist{ |
feb48bde | 568 | -mhardlit -mno-hardlit -mdiv -mno-div -mrelax-immediates @gol |
310668e8 JM |
569 | -mno-relax-immediates -mwide-bitfields -mno-wide-bitfields @gol |
570 | -m4byte-functions -mno-4byte-functions -mcallgraph-data @gol | |
571 | -mno-callgraph-data -mslow-bytes -mno-slow-bytes -mno-lsim @gol | |
572 | -mlittle-endian -mbig-endian -m210 -m340 -mstack-increment} | |
f84271d9 | 573 | |
df6194d4 JW |
574 | @emph{IA-64 Options} |
575 | @gccoptlist{ | |
310668e8 JM |
576 | -mbig-endian -mlittle-endian -mgnu-as -mgnu-ld -mno-pic @gol |
577 | -mvolatile-asm-stop -mb-step -mregister-names -mno-sdata @gol | |
578 | -mconstant-gp -mauto-pic -minline-divide-min-latency @gol | |
579 | -minline-divide-max-throughput -mno-dwarf2-asm @gol | |
630d3d5a | 580 | -mfixed-range=@var{register-range}} |
df6194d4 | 581 | |
91abf72d HP |
582 | @emph{S/390 and zSeries Options} |
583 | @gccoptlist{ | |
584 | -mhard-float -msoft-float -mbackchain -mno-backchain @gol | |
585 | -msmall-exec -mno-small-exec -mmvcle -mno-mvcle @gol | |
586 | -m64 -m31 -mdebug -mno-debug} | |
587 | ||
74291a4b MM |
588 | @item Code Generation Options |
589 | @xref{Code Gen Options,,Options for Code Generation Conventions}. | |
4bc1997b JM |
590 | @gccoptlist{ |
591 | -fcall-saved-@var{reg} -fcall-used-@var{reg} @gol | |
6cfc0341 RH |
592 | -ffixed-@var{reg} -fexceptions @gol |
593 | -fnon-call-exceptions -funwind-tables @gol | |
4bc1997b JM |
594 | -finhibit-size-directive -finstrument-functions @gol |
595 | -fcheck-memory-usage -fprefix-function-name @gol | |
596 | -fno-common -fno-ident -fno-gnu-linker @gol | |
597 | -fpcc-struct-return -fpic -fPIC @gol | |
598 | -freg-struct-return -fshared-data -fshort-enums @gol | |
310668e8 JM |
599 | -fshort-double -fvolatile @gol |
600 | -fvolatile-global -fvolatile-static @gol | |
4bc1997b JM |
601 | -fverbose-asm -fpack-struct -fstack-check @gol |
602 | -fstack-limit-register=@var{reg} -fstack-limit-symbol=@var{sym} @gol | |
603 | -fargument-alias -fargument-noalias @gol | |
310668e8 | 604 | -fargument-noalias-global -fleading-underscore} |
74291a4b MM |
605 | @end table |
606 | ||
607 | @menu | |
608 | * Overall Options:: Controlling the kind of output: | |
609 | an executable, object files, assembler files, | |
610 | or preprocessed source. | |
611 | * C Dialect Options:: Controlling the variant of C language compiled. | |
612 | * C++ Dialect Options:: Variations on C++. | |
60de6385 | 613 | * Objective-C Dialect Options:: Variations on Objective-C. |
764dbbf2 | 614 | * Language Independent Options:: Controlling how diagnostics should be |
02f52e19 | 615 | formatted. |
74291a4b MM |
616 | * Warning Options:: How picky should the compiler be? |
617 | * Debugging Options:: Symbol tables, measurements, and debugging dumps. | |
618 | * Optimize Options:: How much optimization? | |
619 | * Preprocessor Options:: Controlling header files and macro definitions. | |
620 | Also, getting dependency information for Make. | |
621 | * Assembler Options:: Passing options to the assembler. | |
622 | * Link Options:: Specifying libraries and so on. | |
623 | * Directory Options:: Where to find header files and libraries. | |
624 | Where to find the compiler executable files. | |
a743d340 | 625 | * Spec Files:: How to pass switches to sub-processes. |
0c2d1a2a | 626 | * Target Options:: Running a cross-compiler, or an old version of GCC. |
74291a4b MM |
627 | @end menu |
628 | ||
629 | @node Overall Options | |
630 | @section Options Controlling the Kind of Output | |
631 | ||
632 | Compilation can involve up to four stages: preprocessing, compilation | |
633 | proper, assembly and linking, always in that order. The first three | |
634 | stages apply to an individual source file, and end by producing an | |
635 | object file; linking combines all the object files (those newly | |
636 | compiled, and those specified as input) into an executable file. | |
637 | ||
638 | @cindex file name suffix | |
639 | For any given input file, the file name suffix determines what kind of | |
640 | compilation is done: | |
641 | ||
2642624b | 642 | @table @gcctabopt |
74291a4b MM |
643 | @item @var{file}.c |
644 | C source code which must be preprocessed. | |
645 | ||
646 | @item @var{file}.i | |
647 | C source code which should not be preprocessed. | |
648 | ||
649 | @item @var{file}.ii | |
650 | C++ source code which should not be preprocessed. | |
651 | ||
652 | @item @var{file}.m | |
653 | Objective-C source code. Note that you must link with the library | |
654 | @file{libobjc.a} to make an Objective-C program work. | |
655 | ||
b9265ec1 JM |
656 | @item @var{file}.mi |
657 | Objective-C source code which should not be preprocessed. | |
658 | ||
74291a4b MM |
659 | @item @var{file}.h |
660 | C header file (not to be compiled or linked). | |
661 | ||
662 | @item @var{file}.cc | |
b9265ec1 | 663 | @itemx @var{file}.cp |
74291a4b MM |
664 | @itemx @var{file}.cxx |
665 | @itemx @var{file}.cpp | |
b9265ec1 | 666 | @itemx @var{file}.c++ |
74291a4b MM |
667 | @itemx @var{file}.C |
668 | C++ source code which must be preprocessed. Note that in @samp{.cxx}, | |
669 | the last two letters must both be literally @samp{x}. Likewise, | |
161d7b59 | 670 | @samp{.C} refers to a literal capital C@. |
74291a4b | 671 | |
b9265ec1 JM |
672 | @item @var{file}.f |
673 | @itemx @var{file}.for | |
674 | @itemx @var{file}.FOR | |
675 | Fortran source code which should not be preprocessed. | |
676 | ||
677 | @item @var{file}.F | |
678 | @itemx @var{file}.fpp | |
679 | @itemx @var{file}.FPP | |
680 | Fortran source code which must be preprocessed (with the traditional | |
681 | preprocessor). | |
682 | ||
683 | @item @var{file}.r | |
684 | Fortran source code which must be preprocessed with a RATFOR | |
161d7b59 | 685 | preprocessor (not included with GCC)@. |
b9265ec1 JM |
686 | |
687 | @xref{Overall Options,,Options Controlling the Kind of Output, g77, | |
688 | Using and Porting GNU Fortran}, for more details of the handling of | |
689 | Fortran input files. | |
690 | ||
691 | @c FIXME: Descriptions of Java file types. | |
692 | @c @var{file}.java | |
693 | @c @var{file}.class | |
694 | @c @var{file}.zip | |
695 | @c @var{file}.jar | |
696 | ||
697 | @c GCC also knows about some suffixes for languages not yet included: | |
698 | @c Ada: | |
699 | @c @var{file}.ads | |
700 | @c @var{file}.adb | |
701 | @c @var{file}.ada | |
702 | @c Pascal: | |
703 | @c @var{file}.p | |
704 | @c @var{file}.pas | |
705 | ||
706 | @item @var{file}.ch | |
707 | @itemx @var{file}.chi | |
708 | CHILL source code (preprocessed with the traditional preprocessor). | |
709 | ||
74291a4b MM |
710 | @item @var{file}.s |
711 | Assembler code. | |
712 | ||
713 | @item @var{file}.S | |
714 | Assembler code which must be preprocessed. | |
715 | ||
716 | @item @var{other} | |
717 | An object file to be fed straight into linking. | |
718 | Any file name with no recognized suffix is treated this way. | |
719 | @end table | |
720 | ||
cd3bb277 | 721 | @opindex x |
630d3d5a | 722 | You can specify the input language explicitly with the @option{-x} option: |
74291a4b | 723 | |
2642624b | 724 | @table @gcctabopt |
74291a4b MM |
725 | @item -x @var{language} |
726 | Specify explicitly the @var{language} for the following input files | |
727 | (rather than letting the compiler choose a default based on the file | |
728 | name suffix). This option applies to all following input files until | |
630d3d5a | 729 | the next @option{-x} option. Possible values for @var{language} are: |
74291a4b | 730 | @example |
b9265ec1 JM |
731 | c c-header cpp-output |
732 | c++ c++-cpp-output | |
733 | objective-c objc-cpp-output | |
74291a4b | 734 | assembler assembler-with-cpp |
b9265ec1 JM |
735 | f77 f77-cpp-input ratfor |
736 | java chill | |
74291a4b | 737 | @end example |
b9265ec1 | 738 | @c Also f77-version, for internal use only. |
74291a4b MM |
739 | |
740 | @item -x none | |
741 | Turn off any specification of a language, so that subsequent files are | |
630d3d5a | 742 | handled according to their file name suffixes (as they are if @option{-x} |
74291a4b | 743 | has not been used at all). |
14a774a9 RK |
744 | |
745 | @item -pass-exit-codes | |
cd3bb277 | 746 | @opindex pass-exit-codes |
bedc7537 | 747 | Normally the @command{gcc} program will exit with the code of 1 if any |
14a774a9 | 748 | phase of the compiler returns a non-success return code. If you specify |
630d3d5a | 749 | @option{-pass-exit-codes}, the @command{gcc} program will instead return with |
14a774a9 RK |
750 | numerically highest error produced by any phase that returned an error |
751 | indication. | |
74291a4b MM |
752 | @end table |
753 | ||
754 | If you only want some of the stages of compilation, you can use | |
630d3d5a JM |
755 | @option{-x} (or filename suffixes) to tell @command{gcc} where to start, and |
756 | one of the options @option{-c}, @option{-S}, or @option{-E} to say where | |
bedc7537 NC |
757 | @command{gcc} is to stop. Note that some combinations (for example, |
758 | @samp{-x cpp-output -E}) instruct @command{gcc} to do nothing at all. | |
74291a4b | 759 | |
2642624b | 760 | @table @gcctabopt |
74291a4b | 761 | @item -c |
cd3bb277 | 762 | @opindex c |
74291a4b MM |
763 | Compile or assemble the source files, but do not link. The linking |
764 | stage simply is not done. The ultimate output is in the form of an | |
765 | object file for each source file. | |
766 | ||
767 | By default, the object file name for a source file is made by replacing | |
768 | the suffix @samp{.c}, @samp{.i}, @samp{.s}, etc., with @samp{.o}. | |
769 | ||
770 | Unrecognized input files, not requiring compilation or assembly, are | |
771 | ignored. | |
772 | ||
773 | @item -S | |
cd3bb277 | 774 | @opindex S |
74291a4b MM |
775 | Stop after the stage of compilation proper; do not assemble. The output |
776 | is in the form of an assembler code file for each non-assembler input | |
777 | file specified. | |
778 | ||
779 | By default, the assembler file name for a source file is made by | |
780 | replacing the suffix @samp{.c}, @samp{.i}, etc., with @samp{.s}. | |
781 | ||
782 | Input files that don't require compilation are ignored. | |
783 | ||
784 | @item -E | |
cd3bb277 | 785 | @opindex E |
74291a4b MM |
786 | Stop after the preprocessing stage; do not run the compiler proper. The |
787 | output is in the form of preprocessed source code, which is sent to the | |
788 | standard output. | |
789 | ||
790 | Input files which don't require preprocessing are ignored. | |
791 | ||
792 | @cindex output file option | |
793 | @item -o @var{file} | |
cd3bb277 | 794 | @opindex o |
74291a4b MM |
795 | Place output in file @var{file}. This applies regardless to whatever |
796 | sort of output is being produced, whether it be an executable file, | |
797 | an object file, an assembler file or preprocessed C code. | |
798 | ||
799 | Since only one output file can be specified, it does not make sense to | |
630d3d5a | 800 | use @option{-o} when compiling more than one input file, unless you are |
74291a4b MM |
801 | producing an executable file as output. |
802 | ||
630d3d5a | 803 | If @option{-o} is not specified, the default is to put an executable file |
74291a4b MM |
804 | in @file{a.out}, the object file for @file{@var{source}.@var{suffix}} in |
805 | @file{@var{source}.o}, its assembler file in @file{@var{source}.s}, and | |
bd819a4a | 806 | all preprocessed C source on standard output. |
74291a4b MM |
807 | |
808 | @item -v | |
cd3bb277 | 809 | @opindex v |
74291a4b MM |
810 | Print (on standard error output) the commands executed to run the stages |
811 | of compilation. Also print the version number of the compiler driver | |
812 | program and of the preprocessor and the compiler proper. | |
813 | ||
814 | @item -pipe | |
cd3bb277 | 815 | @opindex pipe |
74291a4b MM |
816 | Use pipes rather than temporary files for communication between the |
817 | various stages of compilation. This fails to work on some systems where | |
818 | the assembler is unable to read from a pipe; but the GNU assembler has | |
819 | no trouble. | |
844642e6 NC |
820 | |
821 | @item --help | |
cd3bb277 | 822 | @opindex help |
844642e6 | 823 | Print (on the standard output) a description of the command line options |
bedc7537 NC |
824 | understood by @command{gcc}. If the @option{-v} option is also specified |
825 | then @option{--help} will also be passed on to the various processes | |
826 | invoked by @command{gcc}, so that they can display the command line options | |
827 | they accept. If the @option{-W} option is also specified then command | |
844642e6 NC |
828 | line options which have no documentation associated with them will also |
829 | be displayed. | |
10501d8f CC |
830 | |
831 | @item --target-help | |
cd3bb277 | 832 | @opindex target-help |
10501d8f CC |
833 | Print (on the standard output) a description of target specific command |
834 | line options for each tool. | |
74291a4b MM |
835 | @end table |
836 | ||
837 | @node Invoking G++ | |
838 | @section Compiling C++ Programs | |
839 | ||
840 | @cindex suffixes for C++ source | |
841 | @cindex C++ source file suffixes | |
842 | C++ source files conventionally use one of the suffixes @samp{.C}, | |
bba975d4 | 843 | @samp{.cc}, @samp{.cpp}, @samp{.c++}, @samp{.cp}, or @samp{.cxx}; |
0c2d1a2a | 844 | preprocessed C++ files use the suffix @samp{.ii}. GCC recognizes |
bba975d4 JM |
845 | files with these names and compiles them as C++ programs even if you |
846 | call the compiler the same way as for compiling C programs (usually with | |
bedc7537 | 847 | the name @command{gcc}). |
74291a4b MM |
848 | |
849 | @findex g++ | |
850 | @findex c++ | |
851 | However, C++ programs often require class libraries as well as a | |
852 | compiler that understands the C++ language---and under some | |
853 | circumstances, you might want to compile programs from standard input, | |
854 | or otherwise without a suffix that flags them as C++ programs. | |
bedc7537 | 855 | @command{g++} is a program that calls GCC with the default language |
e5e809f4 | 856 | set to C++, and automatically specifies linking against the C++ |
bedc7537 NC |
857 | library. On many systems, @command{g++} is also |
858 | installed with the name @command{c++}. | |
74291a4b | 859 | |
bedc7537 | 860 | @cindex invoking @command{g++} |
74291a4b MM |
861 | When you compile C++ programs, you may specify many of the same |
862 | command-line options that you use for compiling programs in any | |
863 | language; or command-line options meaningful for C and related | |
864 | languages; or options that are meaningful only for C++ programs. | |
865 | @xref{C Dialect Options,,Options Controlling C Dialect}, for | |
161d7b59 | 866 | explanations of options for languages related to C@. |
74291a4b MM |
867 | @xref{C++ Dialect Options,,Options Controlling C++ Dialect}, for |
868 | explanations of options that are meaningful only for C++ programs. | |
869 | ||
870 | @node C Dialect Options | |
871 | @section Options Controlling C Dialect | |
872 | @cindex dialect options | |
873 | @cindex language dialect options | |
874 | @cindex options, dialect | |
875 | ||
876 | The following options control the dialect of C (or languages derived | |
2147b154 | 877 | from C, such as C++ and Objective-C) that the compiler accepts: |
74291a4b | 878 | |
2642624b | 879 | @table @gcctabopt |
74291a4b | 880 | @cindex ANSI support |
c1030c7c | 881 | @cindex ISO support |
74291a4b | 882 | @item -ansi |
cd3bb277 | 883 | @opindex ansi |
c1030c7c | 884 | In C mode, support all ISO C89 programs. In C++ mode, |
775afb25 | 885 | remove GNU extensions that conflict with ISO C++. |
74291a4b | 886 | |
c1030c7c | 887 | This turns off certain features of GCC that are incompatible with ISO |
aee96fe9 | 888 | C89 (when compiling C code), or of standard C++ (when compiling C++ code), |
0c2d1a2a | 889 | such as the @code{asm} and @code{typeof} keywords, and |
74291a4b MM |
890 | predefined macros such as @code{unix} and @code{vax} that identify the |
891 | type of system you are using. It also enables the undesirable and | |
02f52e19 | 892 | rarely used ISO trigraph feature. For the C compiler, |
0c2d1a2a | 893 | it disables recognition of C++ style @samp{//} comments as well as |
775afb25 | 894 | the @code{inline} keyword. |
74291a4b MM |
895 | |
896 | The alternate keywords @code{__asm__}, @code{__extension__}, | |
897 | @code{__inline__} and @code{__typeof__} continue to work despite | |
630d3d5a | 898 | @option{-ansi}. You would not want to use them in an ISO C program, of |
74291a4b | 899 | course, but it is useful to put them in header files that might be included |
630d3d5a | 900 | in compilations done with @option{-ansi}. Alternate predefined macros |
74291a4b | 901 | such as @code{__unix__} and @code{__vax__} are also available, with or |
630d3d5a | 902 | without @option{-ansi}. |
74291a4b | 903 | |
630d3d5a JM |
904 | The @option{-ansi} option does not cause non-ISO programs to be |
905 | rejected gratuitously. For that, @option{-pedantic} is required in | |
906 | addition to @option{-ansi}. @xref{Warning Options}. | |
74291a4b | 907 | |
630d3d5a | 908 | The macro @code{__STRICT_ANSI__} is predefined when the @option{-ansi} |
74291a4b MM |
909 | option is used. Some header files may notice this macro and refrain |
910 | from declaring certain functions or defining certain macros that the | |
c1030c7c | 911 | ISO standard doesn't call for; this is to avoid interfering with any |
74291a4b MM |
912 | programs that might use these names for other things. |
913 | ||
c771326b JM |
914 | Functions which would normally be built in but do not have semantics |
915 | defined by ISO C (such as @code{alloca} and @code{ffs}) are not built-in | |
630d3d5a | 916 | functions with @option{-ansi} is used. @xref{Other Builtins,,Other |
f0523f02 | 917 | built-in functions provided by GCC}, for details of the functions |
01702459 | 918 | affected. |
74291a4b | 919 | |
49419c8f | 920 | @item -std= |
cd3bb277 | 921 | @opindex std |
aee96fe9 JM |
922 | Determine the language standard. This option is currently only |
923 | supported when compiling C@. A value for this option must be provided; | |
02f52e19 | 924 | possible values are |
3932261a | 925 | |
ee457005 | 926 | @table @samp |
aee96fe9 JM |
927 | @item c89 |
928 | @itemx iso9899:1990 | |
929 | ISO C89 (same as @option{-ansi}). | |
3043b30e ML |
930 | |
931 | @item iso9899:199409 | |
aee96fe9 | 932 | ISO C89 as modified in amendment 1. |
3043b30e | 933 | |
49419c8f | 934 | @item c99 |
aee96fe9 JM |
935 | @itemx c9x |
936 | @itemx iso9899:1999 | |
937 | @itemx iso9899:199x | |
938 | ISO C99. Note that this standard is not yet fully supported; see | |
939 | @w{@uref{http://gcc.gnu.org/c99status.html}} for more information. The | |
940 | names @samp{c9x} and @samp{iso9899:199x} are deprecated. | |
3043b30e ML |
941 | |
942 | @item gnu89 | |
aee96fe9 | 943 | Default, ISO C89 plus GNU extensions (including some C99 features). |
3043b30e | 944 | |
49419c8f | 945 | @item gnu99 |
7dac2f89 | 946 | @item gnu9x |
d15a05b3 EC |
947 | ISO C99 plus GNU extensions. When ISO C99 is fully implemented in GCC, |
948 | this will become the default. The name @samp{gnu9x} is deprecated. | |
49419c8f | 949 | |
ee457005 | 950 | @end table |
3043b30e ML |
951 | |
952 | Even when this option is not specified, you can still use some of the | |
953 | features of newer standards in so far as they do not conflict with | |
954 | previous C standards. For example, you may use @code{__restrict__} even | |
bedc7537 | 955 | when @option{-std=c99} is not specified. |
3932261a | 956 | |
5490d604 JM |
957 | The @option{-std} options specifying some version of ISO C have the same |
958 | effects as @option{-ansi}, except that features that were not in ISO C89 | |
959 | but are in the specified version (for example, @samp{//} comments and | |
960 | the @code{inline} keyword in ISO C99) are not disabled. | |
961 | ||
c1030c7c JM |
962 | @xref{Standards,,Language Standards Supported by GCC}, for details of |
963 | these standard versions. | |
964 | ||
b1018de6 AO |
965 | @item -aux-info @var{filename} |
966 | @opindex aux-info | |
967 | Output to the given filename prototyped declarations for all functions | |
968 | declared and/or defined in a translation unit, including those in header | |
161d7b59 | 969 | files. This option is silently ignored in any language other than C@. |
b1018de6 AO |
970 | |
971 | Besides declarations, the file indicates, in comments, the origin of | |
972 | each declaration (source file and line), whether the declaration was | |
973 | implicit, prototyped or unprototyped (@samp{I}, @samp{N} for new or | |
974 | @samp{O} for old, respectively, in the first character after the line | |
975 | number and the colon), and whether it came from a declaration or a | |
976 | definition (@samp{C} or @samp{F}, respectively, in the following | |
977 | character). In the case of function definitions, a K&R-style list of | |
978 | arguments followed by their declarations is also provided, inside | |
979 | comments, after the declaration. | |
980 | ||
74291a4b | 981 | @item -fno-asm |
cd3bb277 | 982 | @opindex fno-asm |
74291a4b MM |
983 | Do not recognize @code{asm}, @code{inline} or @code{typeof} as a |
984 | keyword, so that code can use these words as identifiers. You can use | |
985 | the keywords @code{__asm__}, @code{__inline__} and @code{__typeof__} | |
630d3d5a | 986 | instead. @option{-ansi} implies @option{-fno-asm}. |
74291a4b MM |
987 | |
988 | In C++, this switch only affects the @code{typeof} keyword, since | |
989 | @code{asm} and @code{inline} are standard keywords. You may want to | |
630d3d5a | 990 | use the @option{-fno-gnu-keywords} flag instead, which has the same |
5490d604 JM |
991 | effect. In C99 mode (@option{-std=c99} or @option{-std=gnu99}), this |
992 | switch only affects the @code{asm} and @code{typeof} keywords, since | |
993 | @code{inline} is a standard keyword in ISO C99. | |
74291a4b MM |
994 | |
995 | @item -fno-builtin | |
cd3bb277 | 996 | @opindex fno-builtin |
c771326b JM |
997 | @cindex built-in functions |
998 | Don't recognize built-in functions that do not begin with | |
01702459 | 999 | @samp{__builtin_} as prefix. @xref{Other Builtins,,Other built-in |
f0523f02 | 1000 | functions provided by GCC}, for details of the functions affected, |
c771326b | 1001 | including those which are not built-in functions when @option{-ansi} or |
5490d604 JM |
1002 | @option{-std} options for strict ISO C conformance are used because they |
1003 | do not have an ISO standard meaning. | |
74291a4b | 1004 | |
c771326b | 1005 | GCC normally generates special code to handle certain built-in functions |
74291a4b MM |
1006 | more efficiently; for instance, calls to @code{alloca} may become single |
1007 | instructions that adjust the stack directly, and calls to @code{memcpy} | |
1008 | may become inline copy loops. The resulting code is often both smaller | |
1009 | and faster, but since the function calls no longer appear as such, you | |
1010 | cannot set a breakpoint on those calls, nor can you change the behavior | |
1011 | of the functions by linking with a different library. | |
1012 | ||
630d3d5a | 1013 | In C++, @option{-fno-builtin} is always in effect. The @option{-fbuiltin} |
0b1161fc | 1014 | option has no effect. Therefore, in C++, the only way to get the |
c771326b | 1015 | optimization benefits of built-in functions is to call the function |
0b1161fc | 1016 | using the @samp{__builtin_} prefix. The GNU C++ Standard Library uses |
c771326b | 1017 | built-in functions to implement many functions (like |
0b1161fc MM |
1018 | @code{std::strchr}), so that you automatically get efficient code. |
1019 | ||
861bb6c1 | 1020 | @item -fhosted |
cd3bb277 | 1021 | @opindex fhosted |
861bb6c1 JL |
1022 | @cindex hosted environment |
1023 | ||
1024 | Assert that compilation takes place in a hosted environment. This implies | |
630d3d5a | 1025 | @option{-fbuiltin}. A hosted environment is one in which the |
861bb6c1 JL |
1026 | entire standard library is available, and in which @code{main} has a return |
1027 | type of @code{int}. Examples are nearly everything except a kernel. | |
630d3d5a | 1028 | This is equivalent to @option{-fno-freestanding}. |
861bb6c1 JL |
1029 | |
1030 | @item -ffreestanding | |
cd3bb277 | 1031 | @opindex ffreestanding |
861bb6c1 JL |
1032 | @cindex hosted environment |
1033 | ||
1034 | Assert that compilation takes place in a freestanding environment. This | |
630d3d5a | 1035 | implies @option{-fno-builtin}. A freestanding environment |
861bb6c1 JL |
1036 | is one in which the standard library may not exist, and program startup may |
1037 | not necessarily be at @code{main}. The most obvious example is an OS kernel. | |
630d3d5a | 1038 | This is equivalent to @option{-fno-hosted}. |
861bb6c1 | 1039 | |
c1030c7c JM |
1040 | @xref{Standards,,Language Standards Supported by GCC}, for details of |
1041 | freestanding and hosted environments. | |
1042 | ||
74291a4b | 1043 | @item -trigraphs |
cd3bb277 | 1044 | @opindex trigraphs |
3bce8a01 NB |
1045 | Support ISO C trigraphs. The @option{-ansi} option (and @option{-std} |
1046 | options for strict ISO C conformance) implies @option{-trigraphs}. | |
74291a4b MM |
1047 | |
1048 | @cindex traditional C language | |
1049 | @cindex C language, traditional | |
1050 | @item -traditional | |
cd3bb277 | 1051 | @opindex traditional |
74291a4b MM |
1052 | Attempt to support some aspects of traditional C compilers. |
1053 | Specifically: | |
1054 | ||
1055 | @itemize @bullet | |
1056 | @item | |
1057 | All @code{extern} declarations take effect globally even if they | |
1058 | are written inside of a function definition. This includes implicit | |
1059 | declarations of functions. | |
1060 | ||
1061 | @item | |
1062 | The newer keywords @code{typeof}, @code{inline}, @code{signed}, @code{const} | |
1063 | and @code{volatile} are not recognized. (You can still use the | |
1064 | alternative keywords such as @code{__typeof__}, @code{__inline__}, and | |
1065 | so on.) | |
1066 | ||
1067 | @item | |
1068 | Comparisons between pointers and integers are always allowed. | |
1069 | ||
1070 | @item | |
1071 | Integer types @code{unsigned short} and @code{unsigned char} promote | |
1072 | to @code{unsigned int}. | |
1073 | ||
1074 | @item | |
1075 | Out-of-range floating point literals are not an error. | |
1076 | ||
1077 | @item | |
c1030c7c | 1078 | Certain constructs which ISO regards as a single invalid preprocessing |
74291a4b MM |
1079 | number, such as @samp{0xe-0xd}, are treated as expressions instead. |
1080 | ||
1081 | @item | |
1082 | String ``constants'' are not necessarily constant; they are stored in | |
1083 | writable space, and identical looking constants are allocated | |
1084 | separately. (This is the same as the effect of | |
630d3d5a | 1085 | @option{-fwritable-strings}.) |
74291a4b MM |
1086 | |
1087 | @cindex @code{longjmp} and automatic variables | |
1088 | @item | |
1089 | All automatic variables not declared @code{register} are preserved by | |
c1030c7c | 1090 | @code{longjmp}. Ordinarily, GNU C follows ISO C: automatic variables |
74291a4b MM |
1091 | not declared @code{volatile} may be clobbered. |
1092 | ||
1093 | @item | |
cd3bb277 JM |
1094 | @cindex @samp{\x} |
1095 | @cindex @samp{\a} | |
74291a4b MM |
1096 | @cindex escape sequences, traditional |
1097 | The character escape sequences @samp{\x} and @samp{\a} evaluate as the | |
1098 | literal characters @samp{x} and @samp{a} respectively. Without | |
630d3d5a | 1099 | @w{@option{-traditional}}, @samp{\x} is a prefix for the hexadecimal |
74291a4b | 1100 | representation of a character, and @samp{\a} produces a bell. |
ad299d9b | 1101 | @end itemize |
74291a4b | 1102 | |
630d3d5a | 1103 | You may wish to use @option{-fno-builtin} as well as @option{-traditional} |
c771326b | 1104 | if your program uses names that are normally GNU C built-in functions for |
74291a4b MM |
1105 | other purposes of its own. |
1106 | ||
630d3d5a | 1107 | You cannot use @option{-traditional} if you include any header files that |
c1030c7c | 1108 | rely on ISO C features. Some vendors are starting to ship systems with |
630d3d5a | 1109 | ISO C header files and you cannot use @option{-traditional} on such |
74291a4b MM |
1110 | systems to compile files that include any system headers. |
1111 | ||
9c34dbbf | 1112 | The @option{-traditional} option also enables @option{-traditional-cpp}. |
74291a4b MM |
1113 | |
1114 | @item -traditional-cpp | |
cd3bb277 | 1115 | @opindex traditional-cpp |
74291a4b | 1116 | Attempt to support some aspects of traditional C preprocessors. |
9c34dbbf | 1117 | See the GNU CPP manual for details. |
74291a4b MM |
1118 | |
1119 | @item -fcond-mismatch | |
cd3bb277 | 1120 | @opindex fcond-mismatch |
74291a4b | 1121 | Allow conditional expressions with mismatched types in the second and |
a7537031 JM |
1122 | third arguments. The value of such an expression is void. This option |
1123 | is not supported for C++. | |
74291a4b MM |
1124 | |
1125 | @item -funsigned-char | |
cd3bb277 | 1126 | @opindex funsigned-char |
74291a4b MM |
1127 | Let the type @code{char} be unsigned, like @code{unsigned char}. |
1128 | ||
1129 | Each kind of machine has a default for what @code{char} should | |
1130 | be. It is either like @code{unsigned char} by default or like | |
1131 | @code{signed char} by default. | |
1132 | ||
1133 | Ideally, a portable program should always use @code{signed char} or | |
1134 | @code{unsigned char} when it depends on the signedness of an object. | |
1135 | But many programs have been written to use plain @code{char} and | |
1136 | expect it to be signed, or expect it to be unsigned, depending on the | |
1137 | machines they were written for. This option, and its inverse, let you | |
1138 | make such a program work with the opposite default. | |
1139 | ||
1140 | The type @code{char} is always a distinct type from each of | |
1141 | @code{signed char} or @code{unsigned char}, even though its behavior | |
1142 | is always just like one of those two. | |
1143 | ||
1144 | @item -fsigned-char | |
cd3bb277 | 1145 | @opindex fsigned-char |
74291a4b MM |
1146 | Let the type @code{char} be signed, like @code{signed char}. |
1147 | ||
630d3d5a JM |
1148 | Note that this is equivalent to @option{-fno-unsigned-char}, which is |
1149 | the negative form of @option{-funsigned-char}. Likewise, the option | |
1150 | @option{-fno-signed-char} is equivalent to @option{-funsigned-char}. | |
74291a4b | 1151 | |
74291a4b MM |
1152 | @item -fsigned-bitfields |
1153 | @itemx -funsigned-bitfields | |
1154 | @itemx -fno-signed-bitfields | |
1155 | @itemx -fno-unsigned-bitfields | |
cd3bb277 JM |
1156 | @opindex fsigned-bitfields |
1157 | @opindex funsigned-bitfields | |
1158 | @opindex fno-signed-bitfields | |
1159 | @opindex fno-unsigned-bitfields | |
c771326b | 1160 | These options control whether a bit-field is signed or unsigned, when the |
74291a4b | 1161 | declaration does not use either @code{signed} or @code{unsigned}. By |
c771326b | 1162 | default, such a bit-field is signed, because this is consistent: the |
74291a4b MM |
1163 | basic integer types such as @code{int} are signed types. |
1164 | ||
c771326b | 1165 | However, when @option{-traditional} is used, bit-fields are all unsigned |
74291a4b MM |
1166 | no matter what. |
1167 | ||
1168 | @item -fwritable-strings | |
cd3bb277 | 1169 | @opindex fwritable-strings |
74291a4b MM |
1170 | Store string constants in the writable data segment and don't uniquize |
1171 | them. This is for compatibility with old programs which assume they can | |
630d3d5a | 1172 | write into string constants. The option @option{-traditional} also has |
74291a4b MM |
1173 | this effect. |
1174 | ||
1175 | Writing into string constants is a very bad idea; ``constants'' should | |
1176 | be constant. | |
1177 | ||
1178 | @item -fallow-single-precision | |
cd3bb277 | 1179 | @opindex fallow-single-precision |
74291a4b | 1180 | Do not promote single precision math operations to double precision, |
630d3d5a | 1181 | even when compiling with @option{-traditional}. |
74291a4b MM |
1182 | |
1183 | Traditional K&R C promotes all floating point operations to double | |
1184 | precision, regardless of the sizes of the operands. On the | |
1185 | architecture for which you are compiling, single precision may be faster | |
630d3d5a | 1186 | than double precision. If you must use @option{-traditional}, but want |
74291a4b MM |
1187 | to use single precision operations when the operands are single |
1188 | precision, use this option. This option has no effect when compiling | |
c1030c7c | 1189 | with ISO or GNU C conventions (the default). |
74291a4b | 1190 | |
3e37bef5 | 1191 | @item -fshort-wchar |
cd3bb277 | 1192 | @opindex fshort-wchar |
3e37bef5 JM |
1193 | Override the underlying type for @samp{wchar_t} to be @samp{short |
1194 | unsigned int} instead of the default for the target. This option is | |
161d7b59 | 1195 | useful for building programs to run under WINE@. |
74291a4b MM |
1196 | @end table |
1197 | ||
1198 | @node C++ Dialect Options | |
1199 | @section Options Controlling C++ Dialect | |
1200 | ||
1201 | @cindex compiler options, C++ | |
1202 | @cindex C++ options, command line | |
1203 | @cindex options, C++ | |
1204 | This section describes the command-line options that are only meaningful | |
1205 | for C++ programs; but you can also use most of the GNU compiler options | |
1206 | regardless of what language your program is in. For example, you | |
1207 | might compile a file @code{firstClass.C} like this: | |
1208 | ||
1209 | @example | |
1dc5fc4b | 1210 | g++ -g -frepo -O -c firstClass.C |
74291a4b MM |
1211 | @end example |
1212 | ||
1213 | @noindent | |
630d3d5a | 1214 | In this example, only @option{-frepo} is an option meant |
74291a4b | 1215 | only for C++ programs; you can use the other options with any |
161d7b59 | 1216 | language supported by GCC@. |
74291a4b MM |
1217 | |
1218 | Here is a list of options that are @emph{only} for compiling C++ programs: | |
1219 | ||
2642624b | 1220 | @table @gcctabopt |
74291a4b | 1221 | @item -fno-access-control |
cd3bb277 | 1222 | @opindex fno-access-control |
74291a4b MM |
1223 | Turn off all access checking. This switch is mainly useful for working |
1224 | around bugs in the access control code. | |
1225 | ||
74291a4b | 1226 | @item -fcheck-new |
cd3bb277 | 1227 | @opindex fcheck-new |
74291a4b MM |
1228 | Check that the pointer returned by @code{operator new} is non-null |
1229 | before attempting to modify the storage allocated. The current Working | |
1230 | Paper requires that @code{operator new} never return a null pointer, so | |
1231 | this check is normally unnecessary. | |
1232 | ||
1dc5fc4b JM |
1233 | An alternative to using this option is to specify that your |
1234 | @code{operator new} does not throw any exceptions; if you declare it | |
aee96fe9 | 1235 | @samp{throw()}, G++ will check the return value. See also @samp{new |
1dc5fc4b JM |
1236 | (nothrow)}. |
1237 | ||
74291a4b | 1238 | @item -fconserve-space |
cd3bb277 | 1239 | @opindex fconserve-space |
74291a4b MM |
1240 | Put uninitialized or runtime-initialized global variables into the |
1241 | common segment, as C does. This saves space in the executable at the | |
1242 | cost of not diagnosing duplicate definitions. If you compile with this | |
1243 | flag and your program mysteriously crashes after @code{main()} has | |
1244 | completed, you may have an object that is being destroyed twice because | |
1245 | two definitions were merged. | |
1246 | ||
1dc5fc4b JM |
1247 | This option is no longer useful on most targets, now that support has |
1248 | been added for putting variables into BSS without making them common. | |
1249 | ||
02f52e19 | 1250 | @item -fno-const-strings |
cd3bb277 | 1251 | @opindex fno-const-strings |
fcca588c MM |
1252 | Give string constants type @code{char *} instead of type @code{const |
1253 | char *}. By default, G++ uses type @code{const char *} as required by | |
630d3d5a | 1254 | the standard. Even if you use @option{-fno-const-strings}, you cannot |
fcca588c | 1255 | actually modify the value of a string constant, unless you also use |
630d3d5a | 1256 | @option{-fwritable-strings}. |
fcca588c MM |
1257 | |
1258 | This option might be removed in a future release of G++. For maximum | |
1259 | portability, you should structure your code so that it works with | |
1260 | string constants that have type @code{const char *}. | |
1261 | ||
74291a4b | 1262 | @item -fdollars-in-identifiers |
cd3bb277 | 1263 | @opindex fdollars-in-identifiers |
74291a4b | 1264 | Accept @samp{$} in identifiers. You can also explicitly prohibit use of |
630d3d5a | 1265 | @samp{$} with the option @option{-fno-dollars-in-identifiers}. (GNU C allows |
eb795509 | 1266 | @samp{$} by default on most target systems, but there are a few exceptions.) |
74291a4b | 1267 | Traditional C allowed the character @samp{$} to form part of |
c1030c7c | 1268 | identifiers. However, ISO C and C++ forbid @samp{$} in identifiers. |
74291a4b | 1269 | |
1dc5fc4b | 1270 | @item -fno-elide-constructors |
cd3bb277 | 1271 | @opindex fno-elide-constructors |
1dc5fc4b JM |
1272 | The C++ standard allows an implementation to omit creating a temporary |
1273 | which is only used to initialize another object of the same type. | |
aee96fe9 | 1274 | Specifying this option disables that optimization, and forces G++ to |
1dc5fc4b | 1275 | call the copy constructor in all cases. |
74291a4b | 1276 | |
dd1ba632 | 1277 | @item -fno-enforce-eh-specs |
cd3bb277 | 1278 | @opindex fno-enforce-eh-specs |
dd1ba632 JM |
1279 | Don't check for violation of exception specifications at runtime. This |
1280 | option violates the C++ standard, but may be useful for reducing code | |
1281 | size in production builds, much like defining @samp{NDEBUG}. The compiler | |
1282 | will still optimize based on the exception specifications. | |
1283 | ||
74291a4b | 1284 | @item -fexternal-templates |
cd3bb277 | 1285 | @opindex fexternal-templates |
9c34dbbf ZW |
1286 | |
1287 | Cause @samp{#pragma interface} and @samp{implementation} to apply to | |
1288 | template instantiation; template instances are emitted or not according | |
74291a4b MM |
1289 | to the location of the template definition. @xref{Template |
1290 | Instantiation}, for more information. | |
1291 | ||
37f6b6bf MM |
1292 | This option is deprecated. |
1293 | ||
74291a4b | 1294 | @item -falt-external-templates |
cd3bb277 | 1295 | @opindex falt-external-templates |
9c34dbbf ZW |
1296 | Similar to @option{-fexternal-templates}, but template instances are |
1297 | emitted or not according to the place where they are first instantiated. | |
74291a4b MM |
1298 | @xref{Template Instantiation}, for more information. |
1299 | ||
37f6b6bf MM |
1300 | This option is deprecated. |
1301 | ||
74291a4b | 1302 | @item -ffor-scope |
8c81598d | 1303 | @itemx -fno-for-scope |
cd3bb277 JM |
1304 | @opindex ffor-scope |
1305 | @opindex fno-for-scope | |
695ac33f | 1306 | If @option{-ffor-scope} is specified, the scope of variables declared in |
74291a4b | 1307 | a @i{for-init-statement} is limited to the @samp{for} loop itself, |
34527c47 | 1308 | as specified by the C++ standard. |
695ac33f | 1309 | If @option{-fno-for-scope} is specified, the scope of variables declared in |
74291a4b | 1310 | a @i{for-init-statement} extends to the end of the enclosing scope, |
aee96fe9 | 1311 | as was the case in old versions of G++, and other (traditional) |
74291a4b MM |
1312 | implementations of C++. |
1313 | ||
1314 | The default if neither flag is given to follow the standard, | |
1315 | but to allow and give a warning for old-style code that would | |
1316 | otherwise be invalid, or have different behavior. | |
1317 | ||
1318 | @item -fno-gnu-keywords | |
cd3bb277 | 1319 | @opindex fno-gnu-keywords |
9762e8a4 | 1320 | Do not recognize @code{typeof} as a keyword, so that code can use this |
767094dd | 1321 | word as an identifier. You can use the keyword @code{__typeof__} instead. |
630d3d5a | 1322 | @option{-ansi} implies @option{-fno-gnu-keywords}. |
74291a4b | 1323 | |
1dc5fc4b | 1324 | @item -fno-implicit-templates |
cd3bb277 | 1325 | @opindex fno-implicit-templates |
bba975d4 | 1326 | Never emit code for non-inline templates which are instantiated |
e979f9e8 | 1327 | implicitly (i.e.@: by use); only emit code for explicit instantiations. |
bba975d4 JM |
1328 | @xref{Template Instantiation}, for more information. |
1329 | ||
1330 | @item -fno-implicit-inline-templates | |
cd3bb277 | 1331 | @opindex fno-implicit-inline-templates |
bba975d4 JM |
1332 | Don't emit code for implicit instantiations of inline templates, either. |
1333 | The default is to handle inlines differently so that compiles with and | |
1334 | without optimization will need the same set of explicit instantiations. | |
1dc5fc4b | 1335 | |
74291a4b | 1336 | @item -fno-implement-inlines |
cd3bb277 | 1337 | @opindex fno-implement-inlines |
74291a4b MM |
1338 | To save space, do not emit out-of-line copies of inline functions |
1339 | controlled by @samp{#pragma implementation}. This will cause linker | |
1340 | errors if these functions are not inlined everywhere they are called. | |
1341 | ||
631cf95d | 1342 | @item -fms-extensions |
cd3bb277 | 1343 | @opindex fms-extensions |
32fb1fb2 PE |
1344 | Disable pedantic warnings about constructs used in MFC, such as implicit |
1345 | int and getting a pointer to member function via non-standard syntax. | |
631cf95d | 1346 | |
fcca588c | 1347 | @item -fno-nonansi-builtins |
cd3bb277 | 1348 | @opindex fno-nonansi-builtins |
c771326b | 1349 | Disable built-in declarations of functions that are not mandated by |
161d7b59 | 1350 | ANSI/ISO C@. These include @code{ffs}, @code{alloca}, @code{_exit}, |
fcca588c MM |
1351 | @code{index}, @code{bzero}, @code{conjf}, and other related functions. |
1352 | ||
775afb25 | 1353 | @item -fno-operator-names |
cd3bb277 | 1354 | @opindex fno-operator-names |
775afb25 | 1355 | Do not treat the operator name keywords @code{and}, @code{bitand}, |
74291a4b | 1356 | @code{bitor}, @code{compl}, @code{not}, @code{or} and @code{xor} as |
775afb25 | 1357 | synonyms as keywords. |
74291a4b | 1358 | |
4f8b4fd9 | 1359 | @item -fno-optional-diags |
cd3bb277 | 1360 | @opindex fno-optional-diags |
4f8b4fd9 | 1361 | Disable diagnostics that the standard says a compiler does not need to |
aee96fe9 | 1362 | issue. Currently, the only such diagnostic issued by G++ is the one for |
bba975d4 | 1363 | a name having multiple meanings within a class. |
4f8b4fd9 | 1364 | |
8c7707b0 | 1365 | @item -fpermissive |
cd3bb277 | 1366 | @opindex fpermissive |
8c7707b0 | 1367 | Downgrade messages about nonconformant code from errors to warnings. By |
aee96fe9 | 1368 | default, G++ effectively sets @option{-pedantic-errors} without |
630d3d5a | 1369 | @option{-pedantic}; this option reverses that. This behavior and this |
161d7b59 | 1370 | option are superseded by @option{-pedantic}, which works as it does for GNU C@. |
8c7707b0 | 1371 | |
8c81598d | 1372 | @item -frepo |
cd3bb277 | 1373 | @opindex frepo |
9c34dbbf ZW |
1374 | Enable automatic template instantiation at link time. This option also |
1375 | implies @option{-fno-implicit-templates}. @xref{Template | |
1376 | Instantiation}, for more information. | |
8c81598d | 1377 | |
8c7707b0 | 1378 | @item -fno-rtti |
cd3bb277 | 1379 | @opindex fno-rtti |
a7fbfcf9 JM |
1380 | Disable generation of information about every class with virtual |
1381 | functions for use by the C++ runtime type identification features | |
1382 | (@samp{dynamic_cast} and @samp{typeid}). If you don't use those parts | |
1383 | of the language, you can save some space by using this flag. Note that | |
1384 | exception handling uses the same information, but it will generate it as | |
1385 | needed. | |
8c7707b0 | 1386 | |
fcca588c | 1387 | @item -fstats |
cd3bb277 | 1388 | @opindex fstats |
fcca588c MM |
1389 | Emit statistics about front-end processing at the end of the compilation. |
1390 | This information is generally only useful to the G++ development team. | |
1391 | ||
1dc5fc4b | 1392 | @item -ftemplate-depth-@var{n} |
cd3bb277 | 1393 | @opindex ftemplate-depth |
1dc5fc4b JM |
1394 | Set the maximum instantiation depth for template classes to @var{n}. |
1395 | A limit on the template instantiation depth is needed to detect | |
767094dd | 1396 | endless recursions during template class instantiation. ANSI/ISO C++ |
1dc5fc4b JM |
1397 | conforming programs must not rely on a maximum depth greater than 17. |
1398 | ||
fc693822 | 1399 | @item -fuse-cxa-atexit |
cd3bb277 | 1400 | @opindex fuse-cxa-atexit |
fc693822 MM |
1401 | Register destructors for objects with static storage duration with the |
1402 | @code{__cxa_atexit} function rather than the @code{atexit} function. | |
1403 | This option is required for fully standards-compliant handling of static | |
1404 | destructors, but will only work if your C library supports | |
1405 | @code{__cxa_atexit}. | |
1406 | ||
90ecce3e | 1407 | @item -fvtable-gc |
cd3bb277 | 1408 | @opindex fvtable-gc |
90ecce3e JM |
1409 | Emit special relocations for vtables and virtual function references |
1410 | so that the linker can identify unused virtual functions and zero out | |
1411 | vtable slots that refer to them. This is most useful with | |
630d3d5a | 1412 | @option{-ffunction-sections} and @option{-Wl,--gc-sections}, in order to |
90ecce3e | 1413 | also discard the functions themselves. |
f5a1b0d2 | 1414 | |
90ecce3e | 1415 | This optimization requires GNU as and GNU ld. Not all systems support |
630d3d5a | 1416 | this option. @option{-Wl,--gc-sections} is ignored without @option{-static}. |
861bb6c1 | 1417 | |
02f52e19 | 1418 | @item -fno-weak |
cd3bb277 | 1419 | @opindex fno-weak |
90ecce3e | 1420 | Do not use weak symbol support, even if it is provided by the linker. |
fcca588c MM |
1421 | By default, G++ will use weak symbols if they are available. This |
1422 | option exists only for testing, and should not be used by end-users; | |
1423 | it will result in inferior code and has no benefits. This option may | |
1424 | be removed in a future release of G++. | |
1425 | ||
74291a4b | 1426 | @item -nostdinc++ |
cd3bb277 | 1427 | @opindex nostdinc++ |
74291a4b MM |
1428 | Do not search for header files in the standard directories specific to |
1429 | C++, but do still search the other standard directories. (This option | |
e5e809f4 | 1430 | is used when building the C++ library.) |
74291a4b MM |
1431 | @end table |
1432 | ||
1433 | In addition, these optimization, warning, and code generation options | |
1434 | have meanings only for C++ programs: | |
1435 | ||
2642624b | 1436 | @table @gcctabopt |
74291a4b | 1437 | @item -fno-default-inline |
cd3bb277 | 1438 | @opindex fno-default-inline |
74291a4b | 1439 | Do not assume @samp{inline} for functions defined inside a class scope. |
1dc5fc4b JM |
1440 | @xref{Optimize Options,,Options That Control Optimization}. Note that these |
1441 | functions will have linkage like inline functions; they just won't be | |
1442 | inlined by default. | |
74291a4b | 1443 | |
aee96fe9 | 1444 | @item -Wctor-dtor-privacy @r{(C++ only)} |
cd3bb277 | 1445 | @opindex Wctor-dtor-privacy |
bba975d4 JM |
1446 | Warn when a class seems unusable, because all the constructors or |
1447 | destructors in a class are private and the class has no friends or | |
1448 | public static member functions. | |
1449 | ||
aee96fe9 | 1450 | @item -Wnon-virtual-dtor @r{(C++ only)} |
cd3bb277 | 1451 | @opindex Wnon-virtual-dtor |
bba975d4 JM |
1452 | Warn when a class declares a non-virtual destructor that should probably |
1453 | be virtual, because it looks like the class will be used polymorphically. | |
1454 | ||
aee96fe9 | 1455 | @item -Wreorder @r{(C++ only)} |
cd3bb277 | 1456 | @opindex Wreorder |
bba975d4 JM |
1457 | @cindex reordering, warning |
1458 | @cindex warning for reordering of member initializers | |
1459 | Warn when the order of member initializers given in the code does not | |
1460 | match the order in which they must be executed. For instance: | |
1461 | ||
1462 | @smallexample | |
1463 | struct A @{ | |
1464 | int i; | |
1465 | int j; | |
1466 | A(): j (0), i (1) @{ @} | |
1467 | @}; | |
1468 | @end smallexample | |
1469 | ||
1470 | Here the compiler will warn that the member initializers for @samp{i} | |
1471 | and @samp{j} will be rearranged to match the declaration order of the | |
1472 | members. | |
1473 | @end table | |
1474 | ||
630d3d5a | 1475 | The following @option{-W@dots{}} options are not affected by @option{-Wall}. |
bba975d4 | 1476 | |
2642624b | 1477 | @table @gcctabopt |
aee96fe9 | 1478 | @item -Weffc++ @r{(C++ only)} |
cd3bb277 | 1479 | @opindex Weffc++ |
bba975d4 JM |
1480 | Warn about violations of various style guidelines from Scott Meyers' |
1481 | @cite{Effective C++} books. If you use this option, you should be aware | |
1482 | that the standard library headers do not obey all of these guidelines; | |
1483 | you can use @samp{grep -v} to filter out those warnings. | |
1484 | ||
aee96fe9 | 1485 | @item -Wno-deprecated @r{(C++ only)} |
cd3bb277 | 1486 | @opindex Wno-deprecated |
767094dd | 1487 | Do not warn about usage of deprecated features. @xref{Deprecated Features}. |
2de45c06 | 1488 | |
aee96fe9 | 1489 | @item -Wno-non-template-friend @r{(C++ only)} |
cd3bb277 | 1490 | @opindex Wno-non-template-friend |
bba975d4 | 1491 | Disable warnings when non-templatized friend functions are declared |
767094dd | 1492 | within a template. With the advent of explicit template specification |
aee96fe9 | 1493 | support in G++, if the name of the friend is an unqualified-id (i.e., |
bba975d4 | 1494 | @samp{friend foo(int)}), the C++ language specification demands that the |
767094dd | 1495 | friend declare or define an ordinary, nontemplate function. (Section |
aee96fe9 | 1496 | 14.5.3). Before G++ implemented explicit specification, unqualified-ids |
bba975d4 | 1497 | could be interpreted as a particular specialization of a templatized |
767094dd | 1498 | function. Because this non-conforming behavior is no longer the default |
aee96fe9 | 1499 | behavior for G++, @option{-Wnon-template-friend} allows the compiler to |
bba975d4 | 1500 | check existing code for potential trouble spots, and is on by default. |
2228d450 | 1501 | This new compiler behavior can be turned off with |
630d3d5a | 1502 | @option{-Wno-non-template-friend} which keeps the conformant compiler code |
2228d450 | 1503 | but disables the helpful warning. |
bba975d4 | 1504 | |
aee96fe9 | 1505 | @item -Wold-style-cast @r{(C++ only)} |
cd3bb277 | 1506 | @opindex Wold-style-cast |
bba975d4 JM |
1507 | Warn if an old-style (C-style) cast is used within a C++ program. The |
1508 | new-style casts (@samp{static_cast}, @samp{reinterpret_cast}, and | |
90ecce3e JM |
1509 | @samp{const_cast}) are less vulnerable to unintended effects, and much |
1510 | easier to grep for. | |
bba975d4 | 1511 | |
aee96fe9 | 1512 | @item -Woverloaded-virtual @r{(C++ only)} |
cd3bb277 | 1513 | @opindex Woverloaded-virtual |
bba975d4 JM |
1514 | @cindex overloaded virtual fn, warning |
1515 | @cindex warning for overloaded virtual fn | |
3747f3dc MM |
1516 | Warn when a function declaration hides virtual functions from a |
1517 | base class. For example, in: | |
1518 | ||
1519 | @smallexample | |
1520 | struct A @{ | |
1521 | virtual void f(); | |
1522 | @}; | |
1523 | ||
1524 | struct B: public A @{ | |
1525 | void f(int); | |
1526 | @}; | |
1527 | @end smallexample | |
1528 | ||
1529 | the @code{A} class version of @code{f} is hidden in @code{B}, and code | |
1530 | like this: | |
1531 | ||
1532 | @smallexample | |
1533 | B* b; | |
1534 | b->f(); | |
1535 | @end smallexample | |
1536 | ||
1537 | will fail to compile. | |
bba975d4 | 1538 | |
aee96fe9 | 1539 | @item -Wno-pmf-conversions @r{(C++ only)} |
cd3bb277 | 1540 | @opindex Wno-pmf-conversions |
bba975d4 JM |
1541 | Disable the diagnostic for converting a bound pointer to member function |
1542 | to a plain pointer. | |
1543 | ||
aee96fe9 | 1544 | @item -Wsign-promo @r{(C++ only)} |
cd3bb277 | 1545 | @opindex Wsign-promo |
bba975d4 JM |
1546 | Warn when overload resolution chooses a promotion from unsigned or |
1547 | enumeral type to a signed type over a conversion to an unsigned type of | |
aee96fe9 | 1548 | the same size. Previous versions of G++ would try to preserve |
bba975d4 JM |
1549 | unsignedness, but the standard mandates the current behavior. |
1550 | ||
aee96fe9 | 1551 | @item -Wsynth @r{(C++ only)} |
cd3bb277 | 1552 | @opindex Wsynth |
bba975d4 JM |
1553 | @cindex warning for synthesized methods |
1554 | @cindex synthesized methods, warning | |
aee96fe9 | 1555 | Warn when G++'s synthesis behavior does not match that of cfront. For |
bba975d4 JM |
1556 | instance: |
1557 | ||
1558 | @smallexample | |
1559 | struct A @{ | |
1560 | operator int (); | |
1561 | A& operator = (int); | |
1562 | @}; | |
1563 | ||
1564 | main () | |
1565 | @{ | |
1566 | A a,b; | |
1567 | a = b; | |
1568 | @} | |
1569 | @end smallexample | |
74291a4b | 1570 | |
aee96fe9 | 1571 | In this example, G++ will synthesize a default @samp{A& operator = |
bba975d4 | 1572 | (const A&);}, while cfront will use the user-defined @samp{operator =}. |
74291a4b MM |
1573 | @end table |
1574 | ||
60de6385 SS |
1575 | @node Objective-C Dialect Options |
1576 | @section Options Controlling Objective-C Dialect | |
1577 | ||
1578 | @cindex compiler options, Objective-C | |
1579 | @cindex Objective-C options, command line | |
1580 | @cindex options, Objective-C | |
1581 | This section describes the command-line options that are only meaningful | |
1582 | for Objective-C programs; but you can also use most of the GNU compiler | |
1583 | options regardless of what language your program is in. For example, | |
1584 | you might compile a file @code{some_class.m} like this: | |
1585 | ||
1586 | @example | |
1587 | gcc -g -fgnu-runtime -O -c some_class.m | |
1588 | @end example | |
1589 | ||
1590 | @noindent | |
630d3d5a | 1591 | In this example, only @option{-fgnu-runtime} is an option meant only for |
60de6385 | 1592 | Objective-C programs; you can use the other options with any language |
161d7b59 | 1593 | supported by GCC@. |
60de6385 SS |
1594 | |
1595 | Here is a list of options that are @emph{only} for compiling Objective-C | |
1596 | programs: | |
1597 | ||
1598 | @table @gcctabopt | |
630d3d5a | 1599 | @item -fconstant-string-class=@var{class-name} |
cd3bb277 | 1600 | @opindex fconstant-string-class |
630d3d5a | 1601 | Use @var{class-name} as the name of the class to instantiate for each |
695ac33f | 1602 | literal string specified with the syntax @code{@@"@dots{}"}. The default |
60de6385 SS |
1603 | class name is @code{NXConstantString}. |
1604 | ||
1605 | @item -fgnu-runtime | |
cd3bb277 | 1606 | @opindex fgnu-runtime |
60de6385 SS |
1607 | Generate object code compatible with the standard GNU Objective-C |
1608 | runtime. This is the default for most types of systems. | |
1609 | ||
1610 | @item -fnext-runtime | |
cd3bb277 | 1611 | @opindex fnext-runtime |
60de6385 | 1612 | Generate output compatible with the NeXT runtime. This is the default |
161d7b59 | 1613 | for NeXT-based systems, including Darwin and Mac OS X@. |
60de6385 SS |
1614 | |
1615 | @item -gen-decls | |
cd3bb277 | 1616 | @opindex gen-decls |
60de6385 SS |
1617 | Dump interface declarations for all classes seen in the source file to a |
1618 | file named @file{@var{sourcename}.decl}. | |
1619 | ||
1620 | @item -Wno-protocol | |
cd3bb277 | 1621 | @opindex Wno-protocol |
60de6385 SS |
1622 | Do not warn if methods required by a protocol are not implemented |
1623 | in the class adopting it. | |
1624 | ||
1625 | @item -Wselector | |
cd3bb277 | 1626 | @opindex Wselector |
60de6385 SS |
1627 | Warn if a selector has multiple methods of different types defined. |
1628 | ||
1629 | @c not documented because only avail via -Wp | |
1630 | @c @item -print-objc-runtime-info | |
1631 | ||
1632 | @end table | |
1633 | ||
764dbbf2 GDR |
1634 | @node Language Independent Options |
1635 | @section Options to Control Diagnostic Messages Formatting | |
1636 | @cindex options to control diagnostics formatting | |
1637 | @cindex diagnostic messages | |
1638 | @cindex message formatting | |
1639 | ||
b192711e | 1640 | Traditionally, diagnostic messages have been formatted irrespective of |
e979f9e8 | 1641 | the output device's aspect (e.g.@: its width, @dots{}). The options described |
764dbbf2 | 1642 | below can be used to control the diagnostic messages formatting |
e979f9e8 | 1643 | algorithm, e.g.@: how many characters per line, how often source location |
6c0a4eab | 1644 | information should be reported. Right now, only the C++ front end can |
764dbbf2 | 1645 | honor these options. However it is expected, in the near future, that |
6c0a4eab | 1646 | the remaining front ends would be able to digest them correctly. |
764dbbf2 | 1647 | |
2642624b | 1648 | @table @gcctabopt |
764dbbf2 | 1649 | @item -fmessage-length=@var{n} |
cd3bb277 | 1650 | @opindex fmessage-length |
764dbbf2 | 1651 | Try to format error messages so that they fit on lines of about @var{n} |
aee96fe9 | 1652 | characters. The default is 72 characters for @command{g++} and 0 for the rest of |
161d7b59 | 1653 | the front ends supported by GCC@. If @var{n} is zero, then no |
02f52e19 | 1654 | line-wrapping will be done; each error message will appear on a single |
764dbbf2 GDR |
1655 | line. |
1656 | ||
cd3bb277 | 1657 | @opindex fdiagnostics-show-location |
764dbbf2 | 1658 | @item -fdiagnostics-show-location=once |
b192711e | 1659 | Only meaningful in line-wrapping mode. Instructs the diagnostic messages |
764dbbf2 GDR |
1660 | reporter to emit @emph{once} source location information; that is, in |
1661 | case the message is too long to fit on a single physical line and has to | |
1662 | be wrapped, the source location won't be emitted (as prefix) again, | |
1663 | over and over, in subsequent continuation lines. This is the default | |
02f52e19 | 1664 | behaviour. |
764dbbf2 GDR |
1665 | |
1666 | @item -fdiagnostics-show-location=every-line | |
1667 | Only meaningful in line-wrapping mode. Instructs the diagnostic | |
1668 | messages reporter to emit the same source location information (as | |
1669 | prefix) for physical lines that result from the process of breaking a | |
b192711e | 1670 | a message which is too long to fit on a single line. |
764dbbf2 GDR |
1671 | |
1672 | @end table | |
1673 | ||
74291a4b MM |
1674 | @node Warning Options |
1675 | @section Options to Request or Suppress Warnings | |
1676 | @cindex options to control warnings | |
1677 | @cindex warning messages | |
1678 | @cindex messages, warning | |
1679 | @cindex suppressing warnings | |
1680 | ||
1681 | Warnings are diagnostic messages that report constructions which | |
1682 | are not inherently erroneous but which are risky or suggest there | |
1683 | may have been an error. | |
1684 | ||
1685 | You can request many specific warnings with options beginning @samp{-W}, | |
630d3d5a | 1686 | for example @option{-Wimplicit} to request warnings on implicit |
74291a4b MM |
1687 | declarations. Each of these specific warning options also has a |
1688 | negative form beginning @samp{-Wno-} to turn off warnings; | |
630d3d5a | 1689 | for example, @option{-Wno-implicit}. This manual lists only one of the |
74291a4b MM |
1690 | two forms, whichever is not the default. |
1691 | ||
0c2d1a2a | 1692 | These options control the amount and kinds of warnings produced by GCC: |
74291a4b | 1693 | |
2642624b | 1694 | @table @gcctabopt |
74291a4b MM |
1695 | @cindex syntax checking |
1696 | @item -fsyntax-only | |
cd3bb277 | 1697 | @opindex fsyntax-only |
74291a4b MM |
1698 | Check the code for syntax errors, but don't do anything beyond that. |
1699 | ||
1700 | @item -pedantic | |
cd3bb277 | 1701 | @opindex pedantic |
074e95e3 JM |
1702 | Issue all the warnings demanded by strict ISO C and ISO C++; |
1703 | reject all programs that use forbidden extensions, and some other | |
1704 | programs that do not follow ISO C and ISO C++. For ISO C, follows the | |
630d3d5a | 1705 | version of the ISO C standard specified by any @option{-std} option used. |
74291a4b | 1706 | |
074e95e3 | 1707 | Valid ISO C and ISO C++ programs should compile properly with or without |
5490d604 | 1708 | this option (though a rare few will require @option{-ansi} or a |
161d7b59 | 1709 | @option{-std} option specifying the required version of ISO C)@. However, |
b1d16193 JL |
1710 | without this option, certain GNU extensions and traditional C and C++ |
1711 | features are supported as well. With this option, they are rejected. | |
74291a4b | 1712 | |
630d3d5a | 1713 | @option{-pedantic} does not cause warning messages for use of the |
74291a4b MM |
1714 | alternate keywords whose names begin and end with @samp{__}. Pedantic |
1715 | warnings are also disabled in the expression that follows | |
1716 | @code{__extension__}. However, only system header files should use | |
1717 | these escape routes; application programs should avoid them. | |
1718 | @xref{Alternate Keywords}. | |
1719 | ||
630d3d5a | 1720 | Some users try to use @option{-pedantic} to check programs for strict ISO |
74291a4b | 1721 | C conformance. They soon find that it does not do quite what they want: |
c1030c7c | 1722 | it finds some non-ISO practices, but not all---only those for which |
074e95e3 JM |
1723 | ISO C @emph{requires} a diagnostic, and some others for which |
1724 | diagnostics have been added. | |
74291a4b | 1725 | |
074e95e3 | 1726 | A feature to report any failure to conform to ISO C might be useful in |
74291a4b | 1727 | some instances, but would require considerable additional work and would |
630d3d5a | 1728 | be quite different from @option{-pedantic}. We don't have plans to |
892d0a6d | 1729 | support such a feature in the near future. |
74291a4b | 1730 | |
91ea548a JM |
1731 | Where the standard specified with @option{-std} represents a GNU |
1732 | extended dialect of C, such as @samp{gnu89} or @samp{gnu99}, there is a | |
1733 | corresponding @dfn{base standard}, the version of ISO C on which the GNU | |
1734 | extended dialect is based. Warnings from @option{-pedantic} are given | |
1735 | where they are required by the base standard. (It would not make sense | |
1736 | for such warnings to be given only for features not in the specified GNU | |
1737 | C dialect, since by definition the GNU dialects of C include all | |
1738 | features the compiler supports with the given option, and there would be | |
1739 | nothing to warn about.) | |
1740 | ||
74291a4b | 1741 | @item -pedantic-errors |
cd3bb277 | 1742 | @opindex pedantic-errors |
630d3d5a | 1743 | Like @option{-pedantic}, except that errors are produced rather than |
74291a4b MM |
1744 | warnings. |
1745 | ||
1746 | @item -w | |
cd3bb277 | 1747 | @opindex w |
74291a4b MM |
1748 | Inhibit all warning messages. |
1749 | ||
1750 | @item -Wno-import | |
cd3bb277 | 1751 | @opindex Wno-import |
74291a4b MM |
1752 | Inhibit warning messages about the use of @samp{#import}. |
1753 | ||
1754 | @item -Wchar-subscripts | |
cd3bb277 | 1755 | @opindex Wchar-subscripts |
74291a4b MM |
1756 | Warn if an array subscript has type @code{char}. This is a common cause |
1757 | of error, as programmers often forget that this type is signed on some | |
1758 | machines. | |
1759 | ||
1760 | @item -Wcomment | |
cd3bb277 | 1761 | @opindex Wcomment |
74291a4b MM |
1762 | Warn whenever a comment-start sequence @samp{/*} appears in a @samp{/*} |
1763 | comment, or whenever a Backslash-Newline appears in a @samp{//} comment. | |
1764 | ||
1765 | @item -Wformat | |
cd3bb277 | 1766 | @opindex Wformat |
74291a4b MM |
1767 | Check calls to @code{printf} and @code{scanf}, etc., to make sure that |
1768 | the arguments supplied have types appropriate to the format string | |
26f6672d JM |
1769 | specified, and that the conversions specified in the format string make |
1770 | sense. This includes standard functions, and others specified by format | |
1771 | attributes (@pxref{Function Attributes}), in the @code{printf}, | |
1772 | @code{scanf}, @code{strftime} and @code{strfmon} (an X/Open extension, | |
1773 | not in the C standard) families. | |
74291a4b | 1774 | |
8308e0b7 JM |
1775 | The formats are checked against the format features supported by GNU |
1776 | libc version 2.2. These include all ISO C89 and C99 features, as well | |
1777 | as features from the Single Unix Specification and some BSD and GNU | |
1778 | extensions. Other library implementations may not support all these | |
1779 | features; GCC does not support warning about features that go beyond a | |
630d3d5a JM |
1780 | particular library's limitations. However, if @option{-pedantic} is used |
1781 | with @option{-Wformat}, warnings will be given about format features not | |
26f6672d JM |
1782 | in the selected standard version (but not for @code{strfmon} formats, |
1783 | since those are not in any version of the C standard). @xref{C Dialect | |
1784 | Options,,Options Controlling C Dialect}. | |
8308e0b7 | 1785 | |
630d3d5a JM |
1786 | @option{-Wformat} is included in @option{-Wall}. For more control over some |
1787 | aspects of format checking, the options @option{-Wno-format-y2k}, | |
1788 | @option{-Wno-format-extra-args}, @option{-Wformat-nonliteral}, | |
1789 | @option{-Wformat-security} and @option{-Wformat=2} are available, but are | |
1790 | not included in @option{-Wall}. | |
4d808927 JM |
1791 | |
1792 | @item -Wno-format-y2k | |
cd3bb277 | 1793 | @opindex Wno-format-y2k |
630d3d5a | 1794 | If @option{-Wformat} is specified, do not warn about @code{strftime} |
4d808927 JM |
1795 | formats which may yield only a two-digit year. |
1796 | ||
1797 | @item -Wno-format-extra-args | |
cd3bb277 | 1798 | @opindex Wno-format-extra-args |
630d3d5a | 1799 | If @option{-Wformat} is specified, do not warn about excess arguments to a |
4d808927 JM |
1800 | @code{printf} or @code{scanf} format function. The C standard specifies |
1801 | that such arguments are ignored. | |
1802 | ||
1803 | @item -Wformat-nonliteral | |
cd3bb277 | 1804 | @opindex Wformat-nonliteral |
630d3d5a | 1805 | If @option{-Wformat} is specified, also warn if the format string is not a |
4d808927 JM |
1806 | string literal and so cannot be checked, unless the format function |
1807 | takes its format arguments as a @code{va_list}. | |
1808 | ||
c907e684 | 1809 | @item -Wformat-security |
cd3bb277 | 1810 | @opindex Wformat-security |
630d3d5a | 1811 | If @option{-Wformat} is specified, also warn about uses of format |
c907e684 JM |
1812 | functions that represent possible security problems. At present, this |
1813 | warns about calls to @code{printf} and @code{scanf} functions where the | |
1814 | format string is not a string literal and there are no format arguments, | |
1815 | as in @code{printf (foo);}. This may be a security hole if the format | |
1816 | string came from untrusted input and contains @samp{%n}. (This is | |
630d3d5a JM |
1817 | currently a subset of what @option{-Wformat-nonliteral} warns about, but |
1818 | in future warnings may be added to @option{-Wformat-security} that are not | |
1819 | included in @option{-Wformat-nonliteral}.) | |
c907e684 | 1820 | |
4d808927 | 1821 | @item -Wformat=2 |
cd3bb277 | 1822 | @opindex Wformat=2 |
630d3d5a JM |
1823 | Enable @option{-Wformat} plus format checks not included in |
1824 | @option{-Wformat}. Currently equivalent to @samp{-Wformat | |
c907e684 | 1825 | -Wformat-nonliteral -Wformat-security}. |
4d808927 | 1826 | |
e9a25f70 | 1827 | @item -Wimplicit-int |
cd3bb277 | 1828 | @opindex Wimplicit-int |
e9a25f70 JL |
1829 | Warn when a declaration does not specify a type. |
1830 | ||
f5963e61 JL |
1831 | @item -Wimplicit-function-declaration |
1832 | @itemx -Werror-implicit-function-declaration | |
cd3bb277 JM |
1833 | @opindex Wimplicit-function-declaration |
1834 | @opindex Werror-implicit-function-declaration | |
f5963e61 JL |
1835 | Give a warning (or error) whenever a function is used before being |
1836 | declared. | |
e9a25f70 | 1837 | |
74291a4b | 1838 | @item -Wimplicit |
cd3bb277 | 1839 | @opindex Wimplicit |
630d3d5a | 1840 | Same as @option{-Wimplicit-int} and @option{-Wimplicit-function-declaration}. |
861bb6c1 JL |
1841 | |
1842 | @item -Wmain | |
cd3bb277 | 1843 | @opindex Wmain |
861bb6c1 JL |
1844 | Warn if the type of @samp{main} is suspicious. @samp{main} should be a |
1845 | function with external linkage, returning int, taking either zero | |
1846 | arguments, two, or three arguments of appropriate types. | |
4a870dba | 1847 | |
1f0c3120 | 1848 | @item -Wmissing-braces |
cd3bb277 | 1849 | @opindex Wmissing-braces |
1f0c3120 JM |
1850 | Warn if an aggregate or union initializer is not fully bracketed. In |
1851 | the following example, the initializer for @samp{a} is not fully | |
1852 | bracketed, but that for @samp{b} is fully bracketed. | |
1853 | ||
1854 | @smallexample | |
1855 | int a[2][2] = @{ 0, 1, 2, 3 @}; | |
1856 | int b[2][2] = @{ @{ 0, 1 @}, @{ 2, 3 @} @}; | |
1857 | @end smallexample | |
1858 | ||
4a870dba | 1859 | @item -Wmultichar |
cd3bb277 | 1860 | @opindex Wmultichar |
4a870dba JM |
1861 | Warn if a multicharacter constant (@samp{'FOOF'}) is used. Usually they |
1862 | indicate a typo in the user's code, as they have implementation-defined | |
1863 | values, and should not be used in portable code. | |
3c12fcc2 | 1864 | |
74291a4b | 1865 | @item -Wparentheses |
cd3bb277 | 1866 | @opindex Wparentheses |
74291a4b MM |
1867 | Warn if parentheses are omitted in certain contexts, such |
1868 | as when there is an assignment in a context where a truth value | |
1869 | is expected, or when operators are nested whose precedence people | |
1870 | often get confused about. | |
1871 | ||
e9a25f70 JL |
1872 | Also warn about constructions where there may be confusion to which |
1873 | @code{if} statement an @code{else} branch belongs. Here is an example of | |
1874 | such a case: | |
1875 | ||
1876 | @smallexample | |
aee96fe9 | 1877 | @group |
e9a25f70 JL |
1878 | @{ |
1879 | if (a) | |
1880 | if (b) | |
1881 | foo (); | |
1882 | else | |
1883 | bar (); | |
1884 | @} | |
aee96fe9 | 1885 | @end group |
e9a25f70 JL |
1886 | @end smallexample |
1887 | ||
1888 | In C, every @code{else} branch belongs to the innermost possible @code{if} | |
1889 | statement, which in this example is @code{if (b)}. This is often not | |
1890 | what the programmer expected, as illustrated in the above example by | |
1891 | indentation the programmer chose. When there is the potential for this | |
f0523f02 | 1892 | confusion, GCC will issue a warning when this flag is specified. |
e9a25f70 JL |
1893 | To eliminate the warning, add explicit braces around the innermost |
1894 | @code{if} statement so there is no way the @code{else} could belong to | |
1895 | the enclosing @code{if}. The resulting code would look like this: | |
1896 | ||
1897 | @smallexample | |
aee96fe9 | 1898 | @group |
e9a25f70 JL |
1899 | @{ |
1900 | if (a) | |
1901 | @{ | |
1902 | if (b) | |
1903 | foo (); | |
1904 | else | |
1905 | bar (); | |
1906 | @} | |
1907 | @} | |
aee96fe9 | 1908 | @end group |
e9a25f70 JL |
1909 | @end smallexample |
1910 | ||
bb58bec5 | 1911 | @item -Wsequence-point |
cd3bb277 | 1912 | @opindex Wsequence-point |
bb58bec5 JM |
1913 | Warn about code that may have undefined semantics because of violations |
1914 | of sequence point rules in the C standard. | |
1915 | ||
1916 | The C standard defines the order in which expressions in a C program are | |
1917 | evaluated in terms of @dfn{sequence points}, which represent a partial | |
1918 | ordering between the execution of parts of the program: those executed | |
1919 | before the sequence point, and those executed after it. These occur | |
1920 | after the evaluation of a full expression (one which is not part of a | |
1921 | larger expression), after the evaluation of the first operand of a | |
1922 | @code{&&}, @code{||}, @code{? :} or @code{,} (comma) operator, before a | |
1923 | function is called (but after the evaluation of its arguments and the | |
1924 | expression denoting the called function), and in certain other places. | |
1925 | Other than as expressed by the sequence point rules, the order of | |
1926 | evaluation of subexpressions of an expression is not specified. All | |
1927 | these rules describe only a partial order rather than a total order, | |
1928 | since, for example, if two functions are called within one expression | |
1929 | with no sequence point between them, the order in which the functions | |
1930 | are called is not specified. However, the standards committee have | |
1931 | ruled that function calls do not overlap. | |
1932 | ||
1933 | It is not specified when between sequence points modifications to the | |
1934 | values of objects take effect. Programs whose behavior depends on this | |
1935 | have undefined behavior; the C standard specifies that ``Between the | |
1936 | previous and next sequence point an object shall have its stored value | |
1937 | modified at most once by the evaluation of an expression. Furthermore, | |
1938 | the prior value shall be read only to determine the value to be | |
1939 | stored.''. If a program breaks these rules, the results on any | |
1940 | particular implementation are entirely unpredictable. | |
1941 | ||
1942 | Examples of code with undefined behavior are @code{a = a++;}, @code{a[n] | |
1943 | = b[n++]} and @code{a[i++] = i;}. Some more complicated cases are not | |
1944 | diagnosed by this option, and it may give an occasional false positive | |
1945 | result, but in general it has been found fairly effective at detecting | |
1946 | this sort of problem in programs. | |
1947 | ||
1948 | The present implementation of this option only works for C programs. A | |
1949 | future implementation may also work for C++ programs. | |
1950 | ||
9c34dbbf ZW |
1951 | The C standard is worded confusingly, therefore there is some debate |
1952 | over the precise meaning of the sequence point rules in subtle cases. | |
1953 | Links to discussions of the problem, including proposed formal | |
1954 | definitions, may be found on our readings page, at | |
c5122d75 | 1955 | @w{@uref{http://gcc.gnu.org/readings.html}}. |
bb58bec5 | 1956 | |
74291a4b | 1957 | @item -Wreturn-type |
cd3bb277 | 1958 | @opindex Wreturn-type |
32c4c36c ML |
1959 | Warn whenever a function is defined with a return-type that defaults to |
1960 | @code{int}. Also warn about any @code{return} statement with no | |
02f52e19 | 1961 | return-value in a function whose return-type is not @code{void}. |
32c4c36c ML |
1962 | |
1963 | For C++, a function without return type always produces a diagnostic | |
767094dd | 1964 | message, even when @option{-Wno-return-type} is specified. The only |
32c4c36c | 1965 | exceptions are @samp{main} and functions defined in system headers. |
74291a4b MM |
1966 | |
1967 | @item -Wswitch | |
cd3bb277 | 1968 | @opindex Wswitch |
74291a4b MM |
1969 | Warn whenever a @code{switch} statement has an index of enumeral type |
1970 | and lacks a @code{case} for one or more of the named codes of that | |
1971 | enumeration. (The presence of a @code{default} label prevents this | |
1972 | warning.) @code{case} labels outside the enumeration range also | |
1973 | provoke warnings when this option is used. | |
1974 | ||
1975 | @item -Wtrigraphs | |
cd3bb277 | 1976 | @opindex Wtrigraphs |
f2ecb02d JM |
1977 | Warn if any trigraphs are encountered that might change the meaning of |
1978 | the program (trigraphs within comments are not warned about). | |
74291a4b | 1979 | |
078721e1 | 1980 | @item -Wunused-function |
cd3bb277 | 1981 | @opindex Wunused-function |
078721e1 AC |
1982 | Warn whenever a static function is declared but not defined or a |
1983 | non\-inline static function is unused. | |
74291a4b | 1984 | |
078721e1 | 1985 | @item -Wunused-label |
cd3bb277 | 1986 | @opindex Wunused-label |
078721e1 AC |
1987 | Warn whenever a label is declared but not used. |
1988 | ||
1989 | To suppress this warning use the @samp{unused} attribute | |
1990 | (@pxref{Variable Attributes}). | |
1991 | ||
1992 | @item -Wunused-parameter | |
cd3bb277 | 1993 | @opindex Wunused-parameter |
078721e1 AC |
1994 | Warn whenever a function parameter is unused aside from its declaration. |
1995 | ||
1996 | To suppress this warning use the @samp{unused} attribute | |
1997 | (@pxref{Variable Attributes}). | |
956d6950 | 1998 | |
078721e1 | 1999 | @item -Wunused-variable |
cd3bb277 | 2000 | @opindex Wunused-variable |
078721e1 AC |
2001 | Warn whenever a local variable or non-constant static variable is unused |
2002 | aside from its declaration | |
2003 | ||
2004 | To suppress this warning use the @samp{unused} attribute | |
74291a4b MM |
2005 | (@pxref{Variable Attributes}). |
2006 | ||
078721e1 | 2007 | @item -Wunused-value |
cd3bb277 | 2008 | @opindex Wunused-value |
078721e1 AC |
2009 | Warn whenever a statement computes a result that is explicitly not used. |
2010 | ||
2011 | To suppress this warning cast the expression to @samp{void}. | |
2012 | ||
2013 | @item -Wunused | |
cd3bb277 | 2014 | @opindex Wunused |
630d3d5a | 2015 | All all the above @option{-Wunused} options combined. |
078721e1 AC |
2016 | |
2017 | In order to get a warning about an unused function parameter, you must | |
b192711e | 2018 | either specify @samp{-W -Wunused} or separately specify |
630d3d5a | 2019 | @option{-Wunused-parameter}. |
078721e1 | 2020 | |
74291a4b | 2021 | @item -Wuninitialized |
cd3bb277 | 2022 | @opindex Wuninitialized |
c5c76735 JL |
2023 | Warn if an automatic variable is used without first being initialized or |
2024 | if a variable may be clobbered by a @code{setjmp} call. | |
74291a4b MM |
2025 | |
2026 | These warnings are possible only in optimizing compilation, | |
2027 | because they require data flow information that is computed only | |
630d3d5a | 2028 | when optimizing. If you don't specify @option{-O}, you simply won't |
74291a4b MM |
2029 | get these warnings. |
2030 | ||
2031 | These warnings occur only for variables that are candidates for | |
2032 | register allocation. Therefore, they do not occur for a variable that | |
2033 | is declared @code{volatile}, or whose address is taken, or whose size | |
2034 | is other than 1, 2, 4 or 8 bytes. Also, they do not occur for | |
2035 | structures, unions or arrays, even when they are in registers. | |
2036 | ||
2037 | Note that there may be no warning about a variable that is used only | |
2038 | to compute a value that itself is never used, because such | |
2039 | computations may be deleted by data flow analysis before the warnings | |
2040 | are printed. | |
2041 | ||
0c2d1a2a | 2042 | These warnings are made optional because GCC is not smart |
74291a4b MM |
2043 | enough to see all the reasons why the code might be correct |
2044 | despite appearing to have an error. Here is one example of how | |
2045 | this can happen: | |
2046 | ||
2047 | @smallexample | |
aee96fe9 | 2048 | @group |
74291a4b MM |
2049 | @{ |
2050 | int x; | |
2051 | switch (y) | |
2052 | @{ | |
2053 | case 1: x = 1; | |
2054 | break; | |
2055 | case 2: x = 4; | |
2056 | break; | |
2057 | case 3: x = 5; | |
2058 | @} | |
2059 | foo (x); | |
2060 | @} | |
aee96fe9 | 2061 | @end group |
74291a4b MM |
2062 | @end smallexample |
2063 | ||
2064 | @noindent | |
2065 | If the value of @code{y} is always 1, 2 or 3, then @code{x} is | |
0c2d1a2a | 2066 | always initialized, but GCC doesn't know this. Here is |
74291a4b MM |
2067 | another common case: |
2068 | ||
2069 | @smallexample | |
2070 | @{ | |
2071 | int save_y; | |
2072 | if (change_y) save_y = y, y = new_y; | |
2073 | @dots{} | |
2074 | if (change_y) y = save_y; | |
2075 | @} | |
2076 | @end smallexample | |
2077 | ||
2078 | @noindent | |
2079 | This has no bug because @code{save_y} is used only if it is set. | |
2080 | ||
20300b05 | 2081 | @cindex @code{longjmp} warnings |
b192711e | 2082 | This option also warns when a non-volatile automatic variable might be |
c5c76735 JL |
2083 | changed by a call to @code{longjmp}. These warnings as well are possible |
2084 | only in optimizing compilation. | |
20300b05 GK |
2085 | |
2086 | The compiler sees only the calls to @code{setjmp}. It cannot know | |
2087 | where @code{longjmp} will be called; in fact, a signal handler could | |
2088 | call it at any point in the code. As a result, you may get a warning | |
2089 | even when there is in fact no problem because @code{longjmp} cannot | |
2090 | in fact be called at the place which would cause a problem. | |
2091 | ||
74291a4b MM |
2092 | Some spurious warnings can be avoided if you declare all the functions |
2093 | you use that never return as @code{noreturn}. @xref{Function | |
2094 | Attributes}. | |
2095 | ||
aee96fe9 | 2096 | @item -Wreorder @r{(C++ only)} |
cd3bb277 | 2097 | @opindex Wreorder |
c5c76735 JL |
2098 | @cindex reordering, warning |
2099 | @cindex warning for reordering of member initializers | |
2100 | Warn when the order of member initializers given in the code does not | |
2101 | match the order in which they must be executed. For instance: | |
2102 | ||
d300e551 | 2103 | @item -Wunknown-pragmas |
cd3bb277 | 2104 | @opindex Wunknown-pragmas |
d300e551 NC |
2105 | @cindex warning for unknown pragmas |
2106 | @cindex unknown pragmas, warning | |
2107 | @cindex pragmas, warning of unknown | |
2108 | Warn when a #pragma directive is encountered which is not understood by | |
161d7b59 | 2109 | GCC@. If this command line option is used, warnings will even be issued |
d300e551 | 2110 | for unknown pragmas in system header files. This is not the case if |
630d3d5a | 2111 | the warnings were only enabled by the @option{-Wall} command line option. |
d300e551 | 2112 | |
74291a4b | 2113 | @item -Wall |
cd3bb277 | 2114 | @opindex Wall |
74291a4b MM |
2115 | All of the above @samp{-W} options combined. This enables all the |
2116 | warnings about constructions that some users consider questionable, and | |
2117 | that are easy to avoid (or modify to prevent the warning), even in | |
2118 | conjunction with macros. | |
317639a8 BC |
2119 | |
2120 | @item -Wsystem-headers | |
cd3bb277 | 2121 | @opindex Wsystem-headers |
317639a8 BC |
2122 | @cindex warnings from system headers |
2123 | @cindex system headers, warnings from | |
2124 | Print warning messages for constructs found in system header files. | |
2125 | Warnings from system headers are normally suppressed, on the assumption | |
2126 | that they usually do not indicate real problems and would only make the | |
2127 | compiler output harder to read. Using this command line option tells | |
2128 | GCC to emit warnings from system headers as if they occurred in user | |
630d3d5a | 2129 | code. However, note that using @option{-Wall} in conjunction with this |
317639a8 | 2130 | option will @emph{not} warn about unknown pragmas in system |
630d3d5a | 2131 | headers---for that, @option{-Wunknown-pragmas} must also be used. |
74291a4b MM |
2132 | @end table |
2133 | ||
630d3d5a | 2134 | The following @option{-W@dots{}} options are not implied by @option{-Wall}. |
74291a4b MM |
2135 | Some of them warn about constructions that users generally do not |
2136 | consider questionable, but which occasionally you might wish to check | |
2137 | for; others warn about constructions that are necessary or hard to avoid | |
2138 | in some cases, and there is no simple way to modify the code to suppress | |
2139 | the warning. | |
2140 | ||
2642624b | 2141 | @table @gcctabopt |
74291a4b | 2142 | @item -W |
cd3bb277 | 2143 | @opindex W |
74291a4b MM |
2144 | Print extra warning messages for these events: |
2145 | ||
2146 | @itemize @bullet | |
74291a4b MM |
2147 | @item |
2148 | A function can return either with or without a value. (Falling | |
2149 | off the end of the function body is considered returning without | |
2150 | a value.) For example, this function would evoke such a | |
2151 | warning: | |
2152 | ||
2153 | @smallexample | |
2154 | @group | |
2155 | foo (a) | |
2156 | @{ | |
2157 | if (a > 0) | |
2158 | return a; | |
2159 | @} | |
2160 | @end group | |
2161 | @end smallexample | |
2162 | ||
2163 | @item | |
2164 | An expression-statement or the left-hand side of a comma expression | |
2165 | contains no side effects. | |
2166 | To suppress the warning, cast the unused expression to void. | |
2167 | For example, an expression such as @samp{x[i,j]} will cause a warning, | |
2168 | but @samp{x[(void)i,j]} will not. | |
2169 | ||
2170 | @item | |
2171 | An unsigned value is compared against zero with @samp{<} or @samp{<=}. | |
2172 | ||
2173 | @item | |
2174 | A comparison like @samp{x<=y<=z} appears; this is equivalent to | |
2175 | @samp{(x<=y ? 1 : 0) <= z}, which is a different interpretation from | |
2176 | that of ordinary mathematical notation. | |
2177 | ||
2178 | @item | |
2179 | Storage-class specifiers like @code{static} are not the first things in | |
2180 | a declaration. According to the C Standard, this usage is obsolescent. | |
2181 | ||
e0c9fbb7 JM |
2182 | @item |
2183 | The return type of a function has a type qualifier such as @code{const}. | |
2184 | Such a type qualifier has no effect, since the value returned by a | |
2185 | function is not an lvalue. (But don't warn about the GNU extension of | |
2186 | @code{volatile void} return types. That extension will be warned about | |
630d3d5a | 2187 | if @option{-pedantic} is specified.) |
e0c9fbb7 | 2188 | |
74291a4b | 2189 | @item |
630d3d5a | 2190 | If @option{-Wall} or @option{-Wunused} is also specified, warn about unused |
74291a4b MM |
2191 | arguments. |
2192 | ||
e9a25f70 JL |
2193 | @item |
2194 | A comparison between signed and unsigned values could produce an | |
2195 | incorrect result when the signed value is converted to unsigned. | |
630d3d5a | 2196 | (But don't warn if @option{-Wno-sign-compare} is also specified.) |
e9a25f70 | 2197 | |
74291a4b MM |
2198 | @item |
2199 | An aggregate has a partly bracketed initializer. | |
2200 | For example, the following code would evoke such a warning, | |
2201 | because braces are missing around the initializer for @code{x.h}: | |
2202 | ||
2203 | @smallexample | |
2204 | struct s @{ int f, g; @}; | |
2205 | struct t @{ struct s h; int i; @}; | |
2206 | struct t x = @{ 1, 2, 3 @}; | |
2207 | @end smallexample | |
dbde0d5d BH |
2208 | |
2209 | @item | |
2210 | An aggregate has an initializer which does not initialize all members. | |
2211 | For example, the following code would cause such a warning, because | |
2212 | @code{x.h} would be implicitly initialized to zero: | |
2213 | ||
2214 | @smallexample | |
2215 | struct s @{ int f, g, h; @}; | |
2216 | struct s x = @{ 3, 4 @}; | |
2217 | @end smallexample | |
74291a4b MM |
2218 | @end itemize |
2219 | ||
f793a95e | 2220 | @item -Wfloat-equal |
cd3bb277 | 2221 | @opindex Wfloat-equal |
f793a95e JL |
2222 | Warn if floating point values are used in equality comparisons. |
2223 | ||
488d3985 GK |
2224 | The idea behind this is that sometimes it is convenient (for the |
2225 | programmer) to consider floating-point values as approximations to | |
2226 | infinitely precise real numbers. If you are doing this, then you need | |
2227 | to compute (by analysing the code, or in some other way) the maximum or | |
2228 | likely maximum error that the computation introduces, and allow for it | |
2229 | when performing comparisons (and when producing output, but that's a | |
2230 | different problem). In particular, instead of testing for equality, you | |
2231 | would check to see whether the two values have ranges that overlap; and | |
2232 | this is done with the relational operators, so equality comparisons are | |
2233 | probably mistaken. | |
2234 | ||
aee96fe9 | 2235 | @item -Wtraditional @r{(C only)} |
cd3bb277 | 2236 | @opindex Wtraditional |
74291a4b | 2237 | Warn about certain constructs that behave differently in traditional and |
161d7b59 | 2238 | ISO C@. Also warn about ISO C constructs that have no traditional C |
c8abc684 | 2239 | equivalent, and/or problematic constructs which should be avoided. |
74291a4b MM |
2240 | |
2241 | @itemize @bullet | |
2242 | @item | |
da312b55 NB |
2243 | Macro parameters that appear within string literals in the macro body. |
2244 | In traditional C macro replacement takes place within string literals, | |
161d7b59 | 2245 | but does not in ISO C@. |
da312b55 NB |
2246 | |
2247 | @item | |
2248 | In traditional C, some preprocessor directives did not exist. | |
2249 | Traditional preprocessors would only consider a line to be a directive | |
2250 | if the @samp{#} appeared in column 1 on the line. Therefore | |
630d3d5a | 2251 | @option{-Wtraditional} warns about directives that traditional C |
da312b55 NB |
2252 | understands but would ignore because the @samp{#} does not appear as the |
2253 | first character on the line. It also suggests you hide directives like | |
2254 | @samp{#pragma} not understood by traditional C by indenting them. Some | |
2255 | traditional implementations would not recognise @samp{#elif}, so it | |
2256 | suggests avoiding it altogether. | |
2257 | ||
2258 | @item | |
2259 | A function-like macro that appears without arguments. | |
2260 | ||
2261 | @item | |
2262 | The unary plus operator. | |
2263 | ||
2264 | @item | |
c771326b JM |
2265 | The @samp{U} integer constant suffix, or the @samp{F} or @samp{L} floating point |
2266 | constant suffixes. (Traditional C does support the @samp{L} suffix on integer | |
da312b55 | 2267 | constants.) Note, these suffixes appear in macros defined in the system |
e979f9e8 | 2268 | headers of most modern systems, e.g.@: the @samp{_MIN}/@samp{_MAX} macros in @code{<limits.h>}. |
c8abc684 KG |
2269 | Use of these macros in user code might normally lead to spurious |
2270 | warnings, however gcc's integrated preprocessor has enough context to | |
2271 | avoid warning in these cases. | |
74291a4b MM |
2272 | |
2273 | @item | |
2274 | A function declared external in one block and then used after the end of | |
2275 | the block. | |
2276 | ||
2277 | @item | |
2278 | A @code{switch} statement has an operand of type @code{long}. | |
db838bb8 KG |
2279 | |
2280 | @item | |
2281 | A non-@code{static} function declaration follows a @code{static} one. | |
2282 | This construct is not accepted by some traditional C compilers. | |
48776cde KG |
2283 | |
2284 | @item | |
c1030c7c | 2285 | The ISO type of an integer constant has a different width or |
48776cde | 2286 | signedness from its traditional type. This warning is only issued if |
e979f9e8 | 2287 | the base of the constant is ten. I.e.@: hexadecimal or octal values, which |
48776cde | 2288 | typically represent bit patterns, are not warned about. |
bb66adca KG |
2289 | |
2290 | @item | |
c1030c7c | 2291 | Usage of ISO string concatenation is detected. |
7f094a94 | 2292 | |
895ea614 KG |
2293 | @item |
2294 | Initialization of automatic aggregates. | |
2295 | ||
2296 | @item | |
2297 | Identifier conflicts with labels. Traditional C lacks a separate | |
2298 | namespace for labels. | |
253b6b82 KG |
2299 | |
2300 | @item | |
2301 | Initialization of unions. If the initializer is zero, the warning is | |
2302 | omitted. This is done under the assumption that the zero initializer in | |
e979f9e8 | 2303 | user code appears conditioned on e.g.@: @code{__STDC__} to avoid missing |
253b6b82 KG |
2304 | initializer warnings and relies on default initialization to zero in the |
2305 | traditional C case. | |
03829ad2 KG |
2306 | |
2307 | @item | |
3ed56f8a KG |
2308 | Conversions by prototypes between fixed/floating point values and vice |
2309 | versa. The absence of these prototypes when compiling with traditional | |
2310 | C would cause serious problems. This is a subset of the possible | |
630d3d5a | 2311 | conversion warnings, for the full set use @option{-Wconversion}. |
74291a4b MM |
2312 | @end itemize |
2313 | ||
861bb6c1 | 2314 | @item -Wundef |
cd3bb277 | 2315 | @opindex Wundef |
861bb6c1 JL |
2316 | Warn if an undefined identifier is evaluated in an @samp{#if} directive. |
2317 | ||
74291a4b | 2318 | @item -Wshadow |
cd3bb277 | 2319 | @opindex Wshadow |
d773df5a DB |
2320 | Warn whenever a local variable shadows another local variable, parameter or |
2321 | global variable or whenever a built-in function is shadowed. | |
74291a4b | 2322 | |
74291a4b | 2323 | @item -Wlarger-than-@var{len} |
cd3bb277 | 2324 | @opindex Wlarger-than |
74291a4b MM |
2325 | Warn whenever an object of larger than @var{len} bytes is defined. |
2326 | ||
2327 | @item -Wpointer-arith | |
cd3bb277 | 2328 | @opindex Wpointer-arith |
74291a4b MM |
2329 | Warn about anything that depends on the ``size of'' a function type or |
2330 | of @code{void}. GNU C assigns these types a size of 1, for | |
2331 | convenience in calculations with @code{void *} pointers and pointers | |
2332 | to functions. | |
2333 | ||
aee96fe9 | 2334 | @item -Wbad-function-cast @r{(C only)} |
cd3bb277 | 2335 | @opindex Wbad-function-cast |
74291a4b MM |
2336 | Warn whenever a function call is cast to a non-matching type. |
2337 | For example, warn if @code{int malloc()} is cast to @code{anything *}. | |
2338 | ||
2339 | @item -Wcast-qual | |
cd3bb277 | 2340 | @opindex Wcast-qual |
74291a4b MM |
2341 | Warn whenever a pointer is cast so as to remove a type qualifier from |
2342 | the target type. For example, warn if a @code{const char *} is cast | |
2343 | to an ordinary @code{char *}. | |
2344 | ||
2345 | @item -Wcast-align | |
cd3bb277 | 2346 | @opindex Wcast-align |
74291a4b MM |
2347 | Warn whenever a pointer is cast such that the required alignment of the |
2348 | target is increased. For example, warn if a @code{char *} is cast to | |
2349 | an @code{int *} on machines where integers can only be accessed at | |
2350 | two- or four-byte boundaries. | |
2351 | ||
2352 | @item -Wwrite-strings | |
cd3bb277 | 2353 | @opindex Wwrite-strings |
aee96fe9 JM |
2354 | When compiling C, give string constants the type @code{const |
2355 | char[@var{length}]} so that | |
74291a4b | 2356 | copying the address of one into a non-@code{const} @code{char *} |
aee96fe9 JM |
2357 | pointer will get a warning; when compiling C++, warn about the |
2358 | deprecated conversion from string constants to @code{char *}. | |
2359 | These warnings will help you find at | |
74291a4b MM |
2360 | compile time code that can try to write into a string constant, but |
2361 | only if you have been very careful about using @code{const} in | |
2362 | declarations and prototypes. Otherwise, it will just be a nuisance; | |
630d3d5a | 2363 | this is why we did not make @option{-Wall} request these warnings. |
74291a4b MM |
2364 | |
2365 | @item -Wconversion | |
cd3bb277 | 2366 | @opindex Wconversion |
74291a4b MM |
2367 | Warn if a prototype causes a type conversion that is different from what |
2368 | would happen to the same argument in the absence of a prototype. This | |
2369 | includes conversions of fixed point to floating and vice versa, and | |
2370 | conversions changing the width or signedness of a fixed point argument | |
2371 | except when the same as the default promotion. | |
2372 | ||
2373 | Also, warn if a negative integer constant expression is implicitly | |
2374 | converted to an unsigned type. For example, warn about the assignment | |
2375 | @code{x = -1} if @code{x} is unsigned. But do not warn about explicit | |
2376 | casts like @code{(unsigned) -1}. | |
2377 | ||
e9a25f70 | 2378 | @item -Wsign-compare |
cd3bb277 | 2379 | @opindex Wsign-compare |
e9a25f70 JL |
2380 | @cindex warning for comparison of signed and unsigned values |
2381 | @cindex comparison of signed and unsigned values, warning | |
2382 | @cindex signed and unsigned values, comparison warning | |
2383 | Warn when a comparison between signed and unsigned values could produce | |
2384 | an incorrect result when the signed value is converted to unsigned. | |
630d3d5a JM |
2385 | This warning is also enabled by @option{-W}; to get the other warnings |
2386 | of @option{-W} without this warning, use @samp{-W -Wno-sign-compare}. | |
e9a25f70 | 2387 | |
74291a4b | 2388 | @item -Waggregate-return |
cd3bb277 | 2389 | @opindex Waggregate-return |
74291a4b MM |
2390 | Warn if any functions that return structures or unions are defined or |
2391 | called. (In languages where you can return an array, this also elicits | |
2392 | a warning.) | |
2393 | ||
aee96fe9 | 2394 | @item -Wstrict-prototypes @r{(C only)} |
cd3bb277 | 2395 | @opindex Wstrict-prototypes |
74291a4b MM |
2396 | Warn if a function is declared or defined without specifying the |
2397 | argument types. (An old-style function definition is permitted without | |
2398 | a warning if preceded by a declaration which specifies the argument | |
2399 | types.) | |
2400 | ||
aee96fe9 | 2401 | @item -Wmissing-prototypes @r{(C only)} |
cd3bb277 | 2402 | @opindex Wmissing-prototypes |
74291a4b MM |
2403 | Warn if a global function is defined without a previous prototype |
2404 | declaration. This warning is issued even if the definition itself | |
2405 | provides a prototype. The aim is to detect global functions that fail | |
2406 | to be declared in header files. | |
2407 | ||
2408 | @item -Wmissing-declarations | |
cd3bb277 | 2409 | @opindex Wmissing-declarations |
74291a4b MM |
2410 | Warn if a global function is defined without a previous declaration. |
2411 | Do so even if the definition itself provides a prototype. | |
2412 | Use this option to detect global functions that are not declared in | |
2413 | header files. | |
2414 | ||
0ca3fb0a | 2415 | @item -Wmissing-noreturn |
cd3bb277 | 2416 | @opindex Wmissing-noreturn |
0ca3fb0a KG |
2417 | Warn about functions which might be candidates for attribute @code{noreturn}. |
2418 | Note these are only possible candidates, not absolute ones. Care should | |
2419 | be taken to manually verify functions actually do not ever return before | |
2420 | adding the @code{noreturn} attribute, otherwise subtle code generation | |
21c7361e AJ |
2421 | bugs could be introduced. You will not get a warning for @code{main} in |
2422 | hosted C environments. | |
0ca3fb0a | 2423 | |
74ff4629 | 2424 | @item -Wmissing-format-attribute |
cd3bb277 JM |
2425 | @opindex Wmissing-format-attribute |
2426 | @opindex Wformat | |
630d3d5a | 2427 | If @option{-Wformat} is enabled, also warn about functions which might be |
74ff4629 JM |
2428 | candidates for @code{format} attributes. Note these are only possible |
2429 | candidates, not absolute ones. GCC will guess that @code{format} | |
2430 | attributes might be appropriate for any function that calls a function | |
2431 | like @code{vprintf} or @code{vscanf}, but this might not always be the | |
2432 | case, and some functions for which @code{format} attributes are | |
2433 | appropriate may not be detected. This option has no effect unless | |
630d3d5a | 2434 | @option{-Wformat} is enabled (possibly by @option{-Wall}). |
74ff4629 | 2435 | |
3c12fcc2 | 2436 | @item -Wpacked |
cd3bb277 | 2437 | @opindex Wpacked |
3c12fcc2 | 2438 | Warn if a structure is given the packed attribute, but the packed |
02f52e19 | 2439 | attribute has no effect on the layout or size of the structure. |
3c12fcc2 GM |
2440 | Such structures may be mis-aligned for little benefit. For |
2441 | instance, in this code, the variable @code{f.x} in @code{struct bar} | |
2442 | will be misaligned even though @code{struct bar} does not itself | |
2443 | have the packed attribute: | |
2444 | ||
2445 | @smallexample | |
2446 | @group | |
2447 | struct foo @{ | |
2448 | int x; | |
2449 | char a, b, c, d; | |
2450 | @} __attribute__((packed)); | |
2451 | struct bar @{ | |
2452 | char z; | |
2453 | struct foo f; | |
2454 | @}; | |
2455 | @end group | |
2456 | @end smallexample | |
2457 | ||
2458 | @item -Wpadded | |
cd3bb277 | 2459 | @opindex Wpadded |
3c12fcc2 GM |
2460 | Warn if padding is included in a structure, either to align an element |
2461 | of the structure or to align the whole structure. Sometimes when this | |
2462 | happens it is possible to rearrange the fields of the structure to | |
2463 | reduce the padding and so make the structure smaller. | |
2464 | ||
74291a4b | 2465 | @item -Wredundant-decls |
cd3bb277 | 2466 | @opindex Wredundant-decls |
74291a4b MM |
2467 | Warn if anything is declared more than once in the same scope, even in |
2468 | cases where multiple declaration is valid and changes nothing. | |
2469 | ||
aee96fe9 | 2470 | @item -Wnested-externs @r{(C only)} |
cd3bb277 | 2471 | @opindex Wnested-externs |
252215a7 | 2472 | Warn if an @code{extern} declaration is encountered within a function. |
74291a4b | 2473 | |
312f6255 | 2474 | @item -Wunreachable-code |
cd3bb277 | 2475 | @opindex Wunreachable-code |
312f6255 GK |
2476 | Warn if the compiler detects that code will never be executed. |
2477 | ||
2478 | This option is intended to warn when the compiler detects that at | |
2479 | least a whole line of source code will never be executed, because | |
2480 | some condition is never satisfied or because it is after a | |
2481 | procedure that never returns. | |
2482 | ||
2483 | It is possible for this option to produce a warning even though there | |
2484 | are circumstances under which part of the affected line can be executed, | |
2485 | so care should be taken when removing apparently-unreachable code. | |
2486 | ||
2487 | For instance, when a function is inlined, a warning may mean that the | |
02f52e19 | 2488 | line is unreachable in only one inlined copy of the function. |
312f6255 | 2489 | |
630d3d5a | 2490 | This option is not made part of @option{-Wall} because in a debugging |
312f6255 GK |
2491 | version of a program there is often substantial code which checks |
2492 | correct functioning of the program and is, hopefully, unreachable | |
2493 | because the program does work. Another common use of unreachable | |
2494 | code is to provide behaviour which is selectable at compile-time. | |
2495 | ||
74291a4b | 2496 | @item -Winline |
cd3bb277 | 2497 | @opindex Winline |
c5c76735 | 2498 | Warn if a function can not be inlined and it was declared as inline. |
74291a4b | 2499 | |
795add94 | 2500 | @item -Wlong-long |
cd3bb277 JM |
2501 | @opindex Wlong-long |
2502 | @opindex Wno-long-long | |
795add94 | 2503 | Warn if @samp{long long} type is used. This is default. To inhibit |
630d3d5a JM |
2504 | the warning messages, use @option{-Wno-long-long}. Flags |
2505 | @option{-Wlong-long} and @option{-Wno-long-long} are taken into account | |
2506 | only when @option{-pedantic} flag is used. | |
795add94 | 2507 | |
18424ae1 | 2508 | @item -Wdisabled-optimization |
cd3bb277 | 2509 | @opindex Wdisabled-optimization |
18424ae1 BL |
2510 | Warn if a requested optimization pass is disabled. This warning does |
2511 | not generally indicate that there is anything wrong with your code; it | |
2512 | merely indicates that GCC's optimizers were unable to handle the code | |
2513 | effectively. Often, the problem is that your code is too big or too | |
2514 | complex; GCC will refuse to optimize programs when the optimization | |
2515 | itself is likely to take inordinate amounts of time. | |
2516 | ||
74291a4b | 2517 | @item -Werror |
cd3bb277 | 2518 | @opindex Werror |
74291a4b MM |
2519 | Make all warnings into errors. |
2520 | @end table | |
2521 | ||
2522 | @node Debugging Options | |
0c2d1a2a | 2523 | @section Options for Debugging Your Program or GCC |
74291a4b MM |
2524 | @cindex options, debugging |
2525 | @cindex debugging information options | |
2526 | ||
0c2d1a2a | 2527 | GCC has various special options that are used for debugging |
74291a4b MM |
2528 | either your program or GCC: |
2529 | ||
2642624b | 2530 | @table @gcctabopt |
74291a4b | 2531 | @item -g |
cd3bb277 | 2532 | @opindex g |
74291a4b | 2533 | Produce debugging information in the operating system's native format |
161d7b59 | 2534 | (stabs, COFF, XCOFF, or DWARF)@. GDB can work with this debugging |
74291a4b MM |
2535 | information. |
2536 | ||
630d3d5a | 2537 | On most systems that use stabs format, @option{-g} enables use of extra |
74291a4b MM |
2538 | debugging information that only GDB can use; this extra information |
2539 | makes debugging work better in GDB but will probably make other debuggers | |
2540 | crash or | |
2541 | refuse to read the program. If you want to control for certain whether | |
630d3d5a JM |
2542 | to generate the extra information, use @option{-gstabs+}, @option{-gstabs}, |
2543 | @option{-gxcoff+}, @option{-gxcoff}, @option{-gdwarf-1+}, or @option{-gdwarf-1} | |
74291a4b MM |
2544 | (see below). |
2545 | ||
630d3d5a JM |
2546 | Unlike most other C compilers, GCC allows you to use @option{-g} with |
2547 | @option{-O}. The shortcuts taken by optimized code may occasionally | |
74291a4b MM |
2548 | produce surprising results: some variables you declared may not exist |
2549 | at all; flow of control may briefly move where you did not expect it; | |
2550 | some statements may not be executed because they compute constant | |
2551 | results or their values were already at hand; some statements may | |
2552 | execute in different places because they were moved out of loops. | |
2553 | ||
2554 | Nevertheless it proves possible to debug optimized output. This makes | |
2555 | it reasonable to use the optimizer for programs that might have bugs. | |
2556 | ||
0c2d1a2a | 2557 | The following options are useful when GCC is generated with the |
74291a4b MM |
2558 | capability for more than one debugging format. |
2559 | ||
2560 | @item -ggdb | |
cd3bb277 | 2561 | @opindex ggdb |
161d7b59 | 2562 | Produce debugging information for use by GDB@. This means to use the |
861bb6c1 JL |
2563 | most expressive format available (DWARF 2, stabs, or the native format |
2564 | if neither of those are supported), including GDB extensions if at all | |
2565 | possible. | |
74291a4b MM |
2566 | |
2567 | @item -gstabs | |
cd3bb277 | 2568 | @opindex gstabs |
74291a4b MM |
2569 | Produce debugging information in stabs format (if that is supported), |
2570 | without GDB extensions. This is the format used by DBX on most BSD | |
2571 | systems. On MIPS, Alpha and System V Release 4 systems this option | |
161d7b59 | 2572 | produces stabs debugging output which is not understood by DBX or SDB@. |
74291a4b MM |
2573 | On System V Release 4 systems this option requires the GNU assembler. |
2574 | ||
2575 | @item -gstabs+ | |
cd3bb277 | 2576 | @opindex gstabs+ |
74291a4b | 2577 | Produce debugging information in stabs format (if that is supported), |
161d7b59 | 2578 | using GNU extensions understood only by the GNU debugger (GDB)@. The |
74291a4b MM |
2579 | use of these extensions is likely to make other debuggers crash or |
2580 | refuse to read the program. | |
2581 | ||
2582 | @item -gcoff | |
cd3bb277 | 2583 | @opindex gcoff |
74291a4b MM |
2584 | Produce debugging information in COFF format (if that is supported). |
2585 | This is the format used by SDB on most System V systems prior to | |
2586 | System V Release 4. | |
2587 | ||
2588 | @item -gxcoff | |
cd3bb277 | 2589 | @opindex gxcoff |
74291a4b MM |
2590 | Produce debugging information in XCOFF format (if that is supported). |
2591 | This is the format used by the DBX debugger on IBM RS/6000 systems. | |
2592 | ||
2593 | @item -gxcoff+ | |
cd3bb277 | 2594 | @opindex gxcoff+ |
74291a4b | 2595 | Produce debugging information in XCOFF format (if that is supported), |
161d7b59 | 2596 | using GNU extensions understood only by the GNU debugger (GDB)@. The |
74291a4b MM |
2597 | use of these extensions is likely to make other debuggers crash or |
2598 | refuse to read the program, and may cause assemblers other than the GNU | |
2599 | assembler (GAS) to fail with an error. | |
2600 | ||
2601 | @item -gdwarf | |
cd3bb277 | 2602 | @opindex gdwarf |
861bb6c1 JL |
2603 | Produce debugging information in DWARF version 1 format (if that is |
2604 | supported). This is the format used by SDB on most System V Release 4 | |
2605 | systems. | |
74291a4b MM |
2606 | |
2607 | @item -gdwarf+ | |
cd3bb277 | 2608 | @opindex gdwarf+ |
861bb6c1 JL |
2609 | Produce debugging information in DWARF version 1 format (if that is |
2610 | supported), using GNU extensions understood only by the GNU debugger | |
161d7b59 | 2611 | (GDB)@. The use of these extensions is likely to make other debuggers |
861bb6c1 JL |
2612 | crash or refuse to read the program. |
2613 | ||
2614 | @item -gdwarf-2 | |
cd3bb277 | 2615 | @opindex gdwarf-2 |
861bb6c1 JL |
2616 | Produce debugging information in DWARF version 2 format (if that is |
2617 | supported). This is the format used by DBX on IRIX 6. | |
74291a4b MM |
2618 | |
2619 | @item -g@var{level} | |
2620 | @itemx -ggdb@var{level} | |
2621 | @itemx -gstabs@var{level} | |
2622 | @itemx -gcoff@var{level} | |
2623 | @itemx -gxcoff@var{level} | |
2624 | @itemx -gdwarf@var{level} | |
861bb6c1 | 2625 | @itemx -gdwarf-2@var{level} |
74291a4b MM |
2626 | Request debugging information and also use @var{level} to specify how |
2627 | much information. The default level is 2. | |
2628 | ||
2629 | Level 1 produces minimal information, enough for making backtraces in | |
2630 | parts of the program that you don't plan to debug. This includes | |
2631 | descriptions of functions and external variables, but no information | |
2632 | about local variables and no line numbers. | |
2633 | ||
2634 | Level 3 includes extra information, such as all the macro definitions | |
2635 | present in the program. Some debuggers support macro expansion when | |
630d3d5a | 2636 | you use @option{-g3}. |
74291a4b MM |
2637 | |
2638 | @cindex @code{prof} | |
2639 | @item -p | |
cd3bb277 | 2640 | @opindex p |
74291a4b MM |
2641 | Generate extra code to write profile information suitable for the |
2642 | analysis program @code{prof}. You must use this option when compiling | |
2643 | the source files you want data about, and you must also use it when | |
2644 | linking. | |
2645 | ||
2646 | @cindex @code{gprof} | |
2647 | @item -pg | |
cd3bb277 | 2648 | @opindex pg |
74291a4b MM |
2649 | Generate extra code to write profile information suitable for the |
2650 | analysis program @code{gprof}. You must use this option when compiling | |
2651 | the source files you want data about, and you must also use it when | |
2652 | linking. | |
2653 | ||
2654 | @cindex @code{tcov} | |
2655 | @item -a | |
cd3bb277 | 2656 | @opindex a |
74291a4b MM |
2657 | Generate extra code to write profile information for basic blocks, which will |
2658 | record the number of times each basic block is executed, the basic block start | |
630d3d5a | 2659 | address, and the function name containing the basic block. If @option{-g} is |
74291a4b MM |
2660 | used, the line number and filename of the start of the basic block will also be |
2661 | recorded. If not overridden by the machine description, the default action is | |
2662 | to append to the text file @file{bb.out}. | |
2663 | ||
2664 | This data could be analyzed by a program like @code{tcov}. Note, | |
2665 | however, that the format of the data is not what @code{tcov} expects. | |
2666 | Eventually GNU @code{gprof} should be extended to process this data. | |
2667 | ||
898f531b | 2668 | @item -Q |
cd3bb277 | 2669 | @opindex Q |
898f531b JL |
2670 | Makes the compiler print out each function name as it is compiled, and |
2671 | print some statistics about each pass when it finishes. | |
2672 | ||
1f0c3120 | 2673 | @item -ftime-report |
cd3bb277 | 2674 | @opindex ftime-report |
1f0c3120 JM |
2675 | Makes the compiler print some statistics about the time consumed by each |
2676 | pass when it finishes. | |
2677 | ||
2678 | @item -fmem-report | |
cd3bb277 | 2679 | @opindex fmem-report |
1f0c3120 JM |
2680 | Makes the compiler print some statistics about permanent memory |
2681 | allocation when it finishes. | |
2682 | ||
74291a4b | 2683 | @item -ax |
cd3bb277 | 2684 | @opindex ax |
74291a4b | 2685 | Generate extra code to profile basic blocks. Your executable will |
630d3d5a | 2686 | produce output that is a superset of that produced when @option{-a} is |
74291a4b MM |
2687 | used. Additional output is the source and target address of the basic |
2688 | blocks where a jump takes place, the number of times a jump is executed, | |
2689 | and (optionally) the complete sequence of basic blocks being executed. | |
2690 | The output is appended to file @file{bb.out}. | |
2691 | ||
2692 | You can examine different profiling aspects without recompilation. Your | |
956d6950 | 2693 | executable will read a list of function names from file @file{bb.in}. |
74291a4b MM |
2694 | Profiling starts when a function on the list is entered and stops when |
2695 | that invocation is exited. To exclude a function from profiling, prefix | |
c771326b | 2696 | its name with @samp{-}. If a function name is not unique, you can |
74291a4b MM |
2697 | disambiguate it by writing it in the form |
2698 | @samp{/path/filename.d:functionname}. Your executable will write the | |
2699 | available paths and filenames in file @file{bb.out}. | |
2700 | ||
2701 | Several function names have a special meaning: | |
2702 | @table @code | |
2703 | @item __bb_jumps__ | |
2704 | Write source, target and frequency of jumps to file @file{bb.out}. | |
2705 | @item __bb_hidecall__ | |
2706 | Exclude function calls from frequency count. | |
2707 | @item __bb_showret__ | |
2708 | Include function returns in frequency count. | |
2709 | @item __bb_trace__ | |
2710 | Write the sequence of basic blocks executed to file @file{bbtrace.gz}. | |
2711 | The file will be compressed using the program @samp{gzip}, which must | |
bedc7537 | 2712 | exist in your @env{PATH}. On systems without the @samp{popen} |
74291a4b MM |
2713 | function, the file will be named @file{bbtrace} and will not be |
2714 | compressed. @strong{Profiling for even a few seconds on these systems | |
2715 | will produce a very large file.} Note: @code{__bb_hidecall__} and | |
2716 | @code{__bb_showret__} will not affect the sequence written to | |
2717 | @file{bbtrace.gz}. | |
2718 | @end table | |
2719 | ||
2720 | Here's a short example using different profiling parameters | |
2721 | in file @file{bb.in}. Assume function @code{foo} consists of basic blocks | |
2722 | 1 and 2 and is called twice from block 3 of function @code{main}. After | |
2723 | the calls, block 3 transfers control to block 4 of @code{main}. | |
2724 | ||
2725 | With @code{__bb_trace__} and @code{main} contained in file @file{bb.in}, | |
2726 | the following sequence of blocks is written to file @file{bbtrace.gz}: | |
2727 | 0 3 1 2 1 2 4. The return from block 2 to block 3 is not shown, because | |
2728 | the return is to a point inside the block and not to the top. The | |
2729 | block address 0 always indicates, that control is transferred | |
2730 | to the trace from somewhere outside the observed functions. With | |
2731 | @samp{-foo} added to @file{bb.in}, the blocks of function | |
2732 | @code{foo} are removed from the trace, so only 0 3 4 remains. | |
2733 | ||
2734 | With @code{__bb_jumps__} and @code{main} contained in file @file{bb.in}, | |
2735 | jump frequencies will be written to file @file{bb.out}. The | |
2736 | frequencies are obtained by constructing a trace of blocks | |
2737 | and incrementing a counter for every neighbouring pair of blocks | |
2738 | in the trace. The trace 0 3 1 2 1 2 4 displays the following | |
2739 | frequencies: | |
2740 | ||
2741 | @example | |
2742 | Jump from block 0x0 to block 0x3 executed 1 time(s) | |
2743 | Jump from block 0x3 to block 0x1 executed 1 time(s) | |
2744 | Jump from block 0x1 to block 0x2 executed 2 time(s) | |
2745 | Jump from block 0x2 to block 0x1 executed 1 time(s) | |
2746 | Jump from block 0x2 to block 0x4 executed 1 time(s) | |
2747 | @end example | |
2748 | ||
2749 | With @code{__bb_hidecall__}, control transfer due to call instructions | |
2750 | is removed from the trace, that is the trace is cut into three parts: 0 | |
2751 | 3 4, 0 1 2 and 0 1 2. With @code{__bb_showret__}, control transfer due | |
2752 | to return instructions is added to the trace. The trace becomes: 0 3 1 | |
2753 | 2 3 1 2 3 4. Note, that this trace is not the same, as the sequence | |
2754 | written to @file{bbtrace.gz}. It is solely used for counting jump | |
2755 | frequencies. | |
2756 | ||
861bb6c1 | 2757 | @item -fprofile-arcs |
cd3bb277 | 2758 | @opindex fprofile-arcs |
3de87bf2 JJ |
2759 | Instrument @dfn{arcs} during compilation to generate coverage data |
2760 | or for profile-directed block ordering. During execution the program | |
2761 | records how many times each branch is executed and how many times it is | |
2762 | taken. When the compiled program exits it saves this data to a file | |
2763 | called @file{@var{sourcename}.da} for each source file. | |
2764 | ||
2765 | For profile-directed block ordering, compile the program with | |
2766 | @option{-fprofile-arcs} plus optimization and code generation options, | |
2767 | generate the arc profile information by running the program on a | |
2768 | selected workload, and then compile the program again with the same | |
2769 | optimization and code generation options plus | |
630d3d5a | 2770 | @option{-fbranch-probabilities} (@pxref{Optimize Options,,Options that |
3de87bf2 JJ |
2771 | Control Optimization}). |
2772 | ||
2773 | The other use of @option{-fprofile-arcs} is for use with @code{gcov}, | |
2774 | when it is used with the @option{-ftest-coverage} option. GCC | |
2775 | supports two methods of determining code coverage: the options that | |
2776 | support @code{gcov}, and options @option{-a} and @option{-ax}, which | |
2777 | write information to text files. The options that support @code{gcov} | |
2778 | do not need to instrument every arc in the program, so a program compiled | |
2779 | with them runs faster than a program compiled with @option{-a}, which | |
2780 | adds instrumentation code to every basic block in the program. The | |
2781 | tradeoff: since @code{gcov} does not have execution counts for all | |
2782 | branches, it must start with the execution counts for the instrumented | |
2783 | branches, and then iterate over the program flow graph until the entire | |
2784 | graph has been solved. Hence, @code{gcov} runs a little more slowly than | |
2785 | a program which uses information from @option{-a} and @option{-ax}. | |
2786 | ||
2787 | With @option{-fprofile-arcs}, for each function of your program GCC | |
2788 | creates a program flow graph, then finds a spanning tree for the graph. | |
2789 | Only arcs that are not on the spanning tree have to be instrumented: the | |
2790 | compiler adds code to count the number of times that these arcs are | |
2791 | executed. When an arc is the only exit or only entrance to a block, the | |
2792 | instrumentation code can be added to the block; otherwise, a new basic | |
2793 | block must be created to hold the instrumentation code. | |
2794 | ||
2795 | This option makes it possible to estimate branch probabilities and to | |
2796 | calculate basic block execution counts. In general, basic block | |
2797 | execution counts as provided by @option{-a} do not give enough | |
2798 | information to estimate all branch probabilities. | |
861bb6c1 JL |
2799 | |
2800 | @need 2000 | |
2801 | @item -ftest-coverage | |
cd3bb277 | 2802 | @opindex ftest-coverage |
861bb6c1 | 2803 | Create data files for the @code{gcov} code-coverage utility |
0c2d1a2a | 2804 | (@pxref{Gcov,, @code{gcov}: a GCC Test Coverage Program}). |
861bb6c1 JL |
2805 | The data file names begin with the name of your source file: |
2806 | ||
2642624b | 2807 | @table @gcctabopt |
861bb6c1 JL |
2808 | @item @var{sourcename}.bb |
2809 | A mapping from basic blocks to line numbers, which @code{gcov} uses to | |
2810 | associate basic block execution counts with line numbers. | |
2811 | ||
2812 | @item @var{sourcename}.bbg | |
2813 | A list of all arcs in the program flow graph. This allows @code{gcov} | |
2814 | to reconstruct the program flow graph, so that it can compute all basic | |
2815 | block and arc execution counts from the information in the | |
3de87bf2 | 2816 | @code{@var{sourcename}.da} file. |
861bb6c1 JL |
2817 | @end table |
2818 | ||
3de87bf2 JJ |
2819 | Use @option{-ftest-coverage} with @option{-fprofile-arcs}; the latter |
2820 | option adds instrumentation to the program, which then writes | |
2821 | execution counts to another data file: | |
2822 | ||
2823 | @table @gcctabopt | |
2824 | @item @var{sourcename}.da | |
2825 | Runtime arc execution counts, used in conjunction with the arc | |
2826 | information in the file @code{@var{sourcename}.bbg}. | |
2827 | @end table | |
2828 | ||
2829 | Coverage data will map better to the source files if | |
2830 | @option{-ftest-coverage} is used without optimization. | |
2831 | ||
74291a4b | 2832 | @item -d@var{letters} |
cd3bb277 | 2833 | @opindex d |
74291a4b MM |
2834 | Says to make debugging dumps during compilation at times specified by |
2835 | @var{letters}. This is used for debugging the compiler. The file names | |
375e2d5c | 2836 | for most of the dumps are made by appending a pass number and a word to |
02f52e19 | 2837 | the source file name (e.g. @file{foo.c.00.rtl} or @file{foo.c.01.sibling}). |
375e2d5c | 2838 | Here are the possible letters for use in @var{letters}, and their meanings: |
74291a4b MM |
2839 | |
2840 | @table @samp | |
375e2d5c | 2841 | @item A |
cd3bb277 | 2842 | @opindex dA |
375e2d5c | 2843 | Annotate the assembler output with miscellaneous debugging information. |
956d6950 | 2844 | @item b |
cd3bb277 | 2845 | @opindex db |
0b47e4c1 | 2846 | Dump after computing branch probabilities, to @file{@var{file}.14.bp}. |
48d9ade5 | 2847 | @item B |
cd3bb277 | 2848 | @opindex dB |
0b47e4c1 | 2849 | Dump after block reordering, to @file{@var{file}.28.bbro}. |
032713aa | 2850 | @item c |
cd3bb277 | 2851 | @opindex dc |
0b47e4c1 | 2852 | Dump after instruction combination, to the file @file{@var{file}.16.combine}. |
470fc13d | 2853 | @item C |
cd3bb277 | 2854 | @opindex dC |
0b47e4c1 | 2855 | Dump after the first if conversion, to the file @file{@var{file}.17.ce}. |
032713aa | 2856 | @item d |
cd3bb277 | 2857 | @opindex dd |
0b47e4c1 | 2858 | Dump after delayed branch scheduling, to @file{@var{file}.31.dbr}. |
032713aa | 2859 | @item D |
cd3bb277 | 2860 | @opindex dD |
f5963e61 JL |
2861 | Dump all macro definitions, at the end of preprocessing, in addition to |
2862 | normal output. | |
48d9ade5 | 2863 | @item e |
cd3bb277 | 2864 | @opindex de |
0826f1d8 | 2865 | Dump after SSA optimizations, to @file{@var{file}.04.ssa} and |
0b47e4c1 | 2866 | @file{@var{file}.07.ussa}. |
470fc13d | 2867 | @item E |
cd3bb277 | 2868 | @opindex dE |
0b47e4c1 | 2869 | Dump after the second if conversion, to @file{@var{file}.26.ce2}. |
74291a4b | 2870 | @item f |
cd3bb277 | 2871 | @opindex df |
0b47e4c1 | 2872 | Dump after life analysis, to @file{@var{file}.15.life}. |
48d9ade5 | 2873 | @item F |
cd3bb277 | 2874 | @opindex dF |
0b47e4c1 | 2875 | Dump after purging @code{ADDRESSOF} codes, to @file{@var{file}.09.addressof}. |
74291a4b | 2876 | @item g |
cd3bb277 | 2877 | @opindex dg |
0b47e4c1 | 2878 | Dump after global register allocation, to @file{@var{file}.21.greg}. |
0826f1d8 JL |
2879 | @item h |
2880 | @opindex dh | |
2881 | Dump after finalization of EH handling code, to @file{@var{file}.02.eh}. | |
2882 | @item o | |
cd3bb277 | 2883 | @opindex do |
9c34dbbf | 2884 | Dump after post-reload optimizations, to @file{@var{file}.22.postreload}. |
02f52e19 | 2885 | @item G |
cd3bb277 | 2886 | @opindex dG |
0b47e4c1 | 2887 | Dump after GCSE, to @file{@var{file}.10.gcse}. |
48d9ade5 | 2888 | @item i |
cd3bb277 | 2889 | @opindex di |
48d9ade5 | 2890 | Dump after sibling call optimizations, to @file{@var{file}.01.sibling}. |
032713aa | 2891 | @item j |
cd3bb277 | 2892 | @opindex dj |
0826f1d8 | 2893 | Dump after the first jump optimization, to @file{@var{file}.03.jump}. |
74291a4b | 2894 | @item k |
cd3bb277 | 2895 | @opindex dk |
0b47e4c1 | 2896 | Dump after conversion from registers to stack, to @file{@var{file}.32.stack}. |
032713aa | 2897 | @item l |
cd3bb277 | 2898 | @opindex dl |
0b47e4c1 | 2899 | Dump after local register allocation, to @file{@var{file}.20.lreg}. |
032713aa | 2900 | @item L |
cd3bb277 | 2901 | @opindex dL |
0b47e4c1 | 2902 | Dump after loop optimization, to @file{@var{file}.11.loop}. |
032713aa | 2903 | @item M |
cd3bb277 | 2904 | @opindex dM |
032713aa | 2905 | Dump after performing the machine dependent reorganisation pass, to |
0b47e4c1 | 2906 | @file{@var{file}.30.mach}. |
48d9ade5 | 2907 | @item n |
cd3bb277 | 2908 | @opindex dn |
0b47e4c1 | 2909 | Dump after register renumbering, to @file{@var{file}.25.rnreg}. |
032713aa | 2910 | @item N |
cd3bb277 | 2911 | @opindex dN |
0b47e4c1 | 2912 | Dump after the register move pass, to @file{@var{file}.18.regmove}. |
032713aa | 2913 | @item r |
cd3bb277 | 2914 | @opindex dr |
375e2d5c | 2915 | Dump after RTL generation, to @file{@var{file}.00.rtl}. |
032713aa | 2916 | @item R |
cd3bb277 | 2917 | @opindex dR |
9c34dbbf | 2918 | Dump after the second scheduling pass, to @file{@var{file}.27.sched2}. |
032713aa | 2919 | @item s |
cd3bb277 | 2920 | @opindex ds |
032713aa | 2921 | Dump after CSE (including the jump optimization that sometimes follows |
0b47e4c1 | 2922 | CSE), to @file{@var{file}.08.cse}. |
032713aa | 2923 | @item S |
cd3bb277 | 2924 | @opindex dS |
9c34dbbf | 2925 | Dump after the first scheduling pass, to @file{@var{file}.19.sched}. |
032713aa | 2926 | @item t |
cd3bb277 | 2927 | @opindex dt |
032713aa | 2928 | Dump after the second CSE pass (including the jump optimization that |
0b47e4c1 | 2929 | sometimes follows CSE), to @file{@var{file}.12.cse2}. |
48d9ade5 | 2930 | @item w |
cd3bb277 | 2931 | @opindex dw |
0b47e4c1 | 2932 | Dump after the second flow pass, to @file{@var{file}.23.flow2}. |
470fc13d | 2933 | @item X |
cd3bb277 | 2934 | @opindex dX |
9c34dbbf | 2935 | Dump after SSA dead code elimination, to @file{@var{file}.06.ssadce}. |
48d9ade5 | 2936 | @item z |
cd3bb277 | 2937 | @opindex dz |
0b47e4c1 | 2938 | Dump after the peephole pass, to @file{@var{file}.24.peephole2}. |
74291a4b | 2939 | @item a |
cd3bb277 | 2940 | @opindex da |
74291a4b MM |
2941 | Produce all the dumps listed above. |
2942 | @item m | |
cd3bb277 | 2943 | @opindex dm |
74291a4b MM |
2944 | Print statistics on memory usage, at the end of the run, to |
2945 | standard error. | |
2946 | @item p | |
cd3bb277 | 2947 | @opindex dp |
74291a4b | 2948 | Annotate the assembler output with a comment indicating which |
f20b5577 MM |
2949 | pattern and alternative was used. The length of each instruction is |
2950 | also printed. | |
2856c3e3 | 2951 | @item P |
cd3bb277 | 2952 | @opindex dP |
2856c3e3 | 2953 | Dump the RTL in the assembler output as a comment before each instruction. |
630d3d5a | 2954 | Also turns on @option{-dp} annotation. |
375e2d5c | 2955 | @item v |
cd3bb277 | 2956 | @opindex dv |
375e2d5c RH |
2957 | For each of the other indicated dump files (except for |
2958 | @file{@var{file}.00.rtl}), dump a representation of the control flow graph | |
b192711e | 2959 | suitable for viewing with VCG to @file{@var{file}.@var{pass}.vcg}. |
62a1403d | 2960 | @item x |
cd3bb277 | 2961 | @opindex dx |
62a1403d AS |
2962 | Just generate RTL for a function instead of compiling it. Usually used |
2963 | with @samp{r}. | |
032713aa | 2964 | @item y |
cd3bb277 | 2965 | @opindex dy |
032713aa | 2966 | Dump debugging information during parsing, to standard error. |
74291a4b MM |
2967 | @end table |
2968 | ||
b707b450 | 2969 | @item -fdump-unnumbered |
cd3bb277 | 2970 | @opindex fdump-unnumbered |
695ac33f | 2971 | When doing debugging dumps (see @option{-d} option above), suppress instruction |
b707b450 | 2972 | numbers and line number note output. This makes it more feasible to |
b192711e | 2973 | use diff on debugging dumps for compiler invocations with different |
695ac33f | 2974 | options, in particular with and without @option{-g}. |
b707b450 | 2975 | |
aee96fe9 | 2976 | @item -fdump-translation-unit @r{(C and C++ only)} |
22367161 | 2977 | @itemx -fdump-translation-unit-@var{options} @r{(C and C++ only)} |
cd3bb277 | 2978 | @opindex fdump-translation-unit |
f71f87f9 | 2979 | Dump a representation of the tree structure for the entire translation |
767094dd | 2980 | unit to a file. The file name is made by appending @file{.tu} to the |
22367161 NS |
2981 | source file name. If the @samp{-@var{options}} form is used, @var{options} |
2982 | controls the details of the dump as described for the | |
2983 | @option{-fdump-tree} options. | |
e76b4820 | 2984 | |
aee96fe9 | 2985 | @item -fdump-class-hierarchy @r{(C++ only)} |
22367161 | 2986 | @itemx -fdump-class-hierarchy-@var{options} @r{(C++ only)} |
cd3bb277 | 2987 | @opindex fdump-class-hierarchy |
e76b4820 | 2988 | Dump a representation of each class's hierarchy and virtual function |
767094dd | 2989 | table layout to a file. The file name is made by appending @file{.class} |
22367161 NS |
2990 | to the source file name. If the @samp{-@var{options}} form is used, |
2991 | @var{options} controls the details of the dump as described for the | |
2992 | @option{-fdump-tree} options. | |
2993 | ||
2994 | @item -fdump-tree-@var{switch} @r{(C++ only)} | |
2995 | @itemx -fdump-tree-@var{switch}-@var{options} @r{(C++ only)} | |
2996 | @opindex fdump-tree | |
2997 | Control the dumping at various stages of processing the intermediate | |
2998 | language tree to a file. The file name is generated by appending a switch | |
2999 | specific suffix to the source file name. If the @samp{-@var{options}} | |
3000 | form is used, @var{options} is a list of @samp{-} separated options that | |
3001 | control the details of the dump. Not all options are applicable to all | |
3002 | dumps, those which are not meaningful will be ignored. The following | |
3003 | options are available | |
f71f87f9 | 3004 | |
e76b4820 | 3005 | @table @samp |
22367161 | 3006 | @item address |
767094dd | 3007 | Print the address of each node. Usually this is not meaningful as it |
22367161 NS |
3008 | changes according to the environment and source file. Its primary use |
3009 | is for tying up a dump file with a debug environment. | |
3010 | @item slim | |
3011 | Inhibit dumping of members of a scope or body of a function merely | |
3012 | because that scope has been reached. Only dump such items when they | |
3013 | are directly reachable by some other path. | |
3014 | @item all | |
3015 | Turn on all options. | |
e76b4820 NS |
3016 | @end table |
3017 | ||
3018 | The following tree dumps are possible: | |
3019 | @table @samp | |
3020 | @item original | |
3021 | Dump before any tree based optimization, to @file{@var{file}.original}. | |
3022 | @item optimized | |
3023 | Dump after all tree based optimization, to @file{@var{file}.optimized}. | |
6be77748 | 3024 | @item inlined |
9c34dbbf | 3025 | Dump after function inlining, to @file{@var{file}.inlined}. |
e76b4820 | 3026 | @end table |
9965d119 | 3027 | |
74291a4b | 3028 | @item -fpretend-float |
cd3bb277 | 3029 | @opindex fpretend-float |
74291a4b MM |
3030 | When running a cross-compiler, pretend that the target machine uses the |
3031 | same floating point format as the host machine. This causes incorrect | |
3032 | output of the actual floating constants, but the actual instruction | |
0c2d1a2a | 3033 | sequence will probably be the same as GCC would make when running on |
74291a4b MM |
3034 | the target machine. |
3035 | ||
3036 | @item -save-temps | |
cd3bb277 | 3037 | @opindex save-temps |
74291a4b MM |
3038 | Store the usual ``temporary'' intermediate files permanently; place them |
3039 | in the current directory and name them based on the source file. Thus, | |
3040 | compiling @file{foo.c} with @samp{-c -save-temps} would produce files | |
f2ecb02d JM |
3041 | @file{foo.i} and @file{foo.s}, as well as @file{foo.o}. This creates a |
3042 | preprocessed @file{foo.i} output file even though the compiler now | |
3043 | normally uses an integrated preprocessor. | |
74291a4b | 3044 | |
03c41c05 | 3045 | @item -time |
cd3bb277 | 3046 | @opindex time |
03c41c05 | 3047 | Report the CPU time taken by each subprocess in the compilation |
f2ecb02d JM |
3048 | sequence. For C source files, this is the compiler proper and assembler |
3049 | (plus the linker if linking is done). The output looks like this: | |
03c41c05 ZW |
3050 | |
3051 | @smallexample | |
03c41c05 ZW |
3052 | # cc1 0.12 0.01 |
3053 | # as 0.00 0.01 | |
3054 | @end smallexample | |
3055 | ||
3056 | The first number on each line is the ``user time,'' that is time spent | |
3057 | executing the program itself. The second number is ``system time,'' | |
3058 | time spent executing operating system routines on behalf of the program. | |
3059 | Both numbers are in seconds. | |
3060 | ||
74291a4b | 3061 | @item -print-file-name=@var{library} |
cd3bb277 | 3062 | @opindex print-file-name |
74291a4b MM |
3063 | Print the full absolute name of the library file @var{library} that |
3064 | would be used when linking---and don't do anything else. With this | |
0c2d1a2a | 3065 | option, GCC does not compile or link anything; it just prints the |
74291a4b MM |
3066 | file name. |
3067 | ||
b1018de6 AO |
3068 | @item -print-multi-directory |
3069 | @opindex print-multi-directory | |
3070 | Print the directory name corresponding to the multilib selected by any | |
3071 | other switches present in the command line. This directory is supposed | |
3072 | to exist in @env{GCC_EXEC_PREFIX}. | |
3073 | ||
3074 | @item -print-multi-lib | |
3075 | @opindex print-multi-lib | |
3076 | Print the mapping from multilib directory names to compiler switches | |
3077 | that enable them. The directory name is separated from the switches by | |
3078 | @samp{;}, and each switch starts with an @samp{@@} instead of the | |
3079 | @samp{-}, without spaces between multiple switches. This is supposed to | |
3080 | ease shell-processing. | |
3081 | ||
74291a4b | 3082 | @item -print-prog-name=@var{program} |
cd3bb277 | 3083 | @opindex print-prog-name |
630d3d5a | 3084 | Like @option{-print-file-name}, but searches for a program such as @samp{cpp}. |
74291a4b MM |
3085 | |
3086 | @item -print-libgcc-file-name | |
cd3bb277 | 3087 | @opindex print-libgcc-file-name |
630d3d5a | 3088 | Same as @option{-print-file-name=libgcc.a}. |
74291a4b | 3089 | |
630d3d5a | 3090 | This is useful when you use @option{-nostdlib} or @option{-nodefaultlibs} |
74291a4b MM |
3091 | but you do want to link with @file{libgcc.a}. You can do |
3092 | ||
3093 | @example | |
3094 | gcc -nostdlib @var{files}@dots{} `gcc -print-libgcc-file-name` | |
3095 | @end example | |
3096 | ||
3097 | @item -print-search-dirs | |
cd3bb277 | 3098 | @opindex print-search-dirs |
74291a4b MM |
3099 | Print the name of the configured installation directory and a list of |
3100 | program and library directories gcc will search---and don't do anything else. | |
3101 | ||
3102 | This is useful when gcc prints the error message | |
3c0b7970 JM |
3103 | @samp{installation problem, cannot exec cpp0: No such file or directory}. |
3104 | To resolve this you either need to put @file{cpp0} and the other compiler | |
74291a4b | 3105 | components where gcc expects to find them, or you can set the environment |
bedc7537 | 3106 | variable @env{GCC_EXEC_PREFIX} to the directory where you installed them. |
74291a4b MM |
3107 | Don't forget the trailing '/'. |
3108 | @xref{Environment Variables}. | |
1f0c3120 JM |
3109 | |
3110 | @item -dumpmachine | |
cd3bb277 | 3111 | @opindex dumpmachine |
1f0c3120 JM |
3112 | Print the compiler's target machine (for example, |
3113 | @samp{i686-pc-linux-gnu})---and don't do anything else. | |
3114 | ||
3115 | @item -dumpversion | |
cd3bb277 | 3116 | @opindex dumpversion |
1f0c3120 JM |
3117 | Print the compiler version (for example, @samp{3.0})---and don't do |
3118 | anything else. | |
3119 | ||
3120 | @item -dumpspecs | |
cd3bb277 | 3121 | @opindex dumpspecs |
1f0c3120 JM |
3122 | Print the compiler's built-in specs---and don't do anything else. (This |
3123 | is used when GCC itself is being built.) @xref{Spec Files}. | |
74291a4b MM |
3124 | @end table |
3125 | ||
3126 | @node Optimize Options | |
3127 | @section Options That Control Optimization | |
3128 | @cindex optimize options | |
3129 | @cindex options, optimization | |
3130 | ||
3131 | These options control various sorts of optimizations: | |
3132 | ||
2642624b | 3133 | @table @gcctabopt |
74291a4b MM |
3134 | @item -O |
3135 | @itemx -O1 | |
cd3bb277 JM |
3136 | @opindex O |
3137 | @opindex O1 | |
74291a4b MM |
3138 | Optimize. Optimizing compilation takes somewhat more time, and a lot |
3139 | more memory for a large function. | |
3140 | ||
630d3d5a | 3141 | Without @option{-O}, the compiler's goal is to reduce the cost of |
74291a4b MM |
3142 | compilation and to make debugging produce the expected results. |
3143 | Statements are independent: if you stop the program with a breakpoint | |
3144 | between statements, you can then assign a new value to any variable or | |
3145 | change the program counter to any other statement in the function and | |
3146 | get exactly the results you would expect from the source code. | |
3147 | ||
630d3d5a | 3148 | With @option{-O}, the compiler tries to reduce code size and execution |
9c34dbbf ZW |
3149 | time, without performing any optimizations that take a great deal of |
3150 | compilation time. | |
74291a4b MM |
3151 | |
3152 | @item -O2 | |
cd3bb277 | 3153 | @opindex O2 |
0c2d1a2a | 3154 | Optimize even more. GCC performs nearly all supported optimizations |
74291a4b | 3155 | that do not involve a space-speed tradeoff. The compiler does not |
630d3d5a JM |
3156 | perform loop unrolling or function inlining when you specify @option{-O2}. |
3157 | As compared to @option{-O}, this option increases both compilation time | |
74291a4b MM |
3158 | and the performance of the generated code. |
3159 | ||
630d3d5a | 3160 | @option{-O2} turns on all optional optimizations except for loop unrolling, |
2b2a8f1f | 3161 | function inlining, and register renaming. It also turns on the |
630d3d5a | 3162 | @option{-fforce-mem} option on all machines and frame pointer elimination |
2b2a8f1f | 3163 | on machines where doing so does not interfere with debugging. |
74291a4b | 3164 | |
081ca317 BL |
3165 | Please note the warning under @option{-fgcse} about |
3166 | invoking @option{-O2} on programs that use computed gotos. | |
3167 | ||
74291a4b | 3168 | @item -O3 |
cd3bb277 | 3169 | @opindex O3 |
630d3d5a JM |
3170 | Optimize yet more. @option{-O3} turns on all optimizations specified by |
3171 | @option{-O2} and also turns on the @option{-finline-functions} and | |
3172 | @option{-frename-registers} options. | |
74291a4b MM |
3173 | |
3174 | @item -O0 | |
cd3bb277 | 3175 | @opindex O0 |
74291a4b MM |
3176 | Do not optimize. |
3177 | ||
c6aded7c | 3178 | @item -Os |
cd3bb277 | 3179 | @opindex Os |
630d3d5a | 3180 | Optimize for size. @option{-Os} enables all @option{-O2} optimizations that |
c6aded7c AG |
3181 | do not typically increase code size. It also performs further |
3182 | optimizations designed to reduce code size. | |
3183 | ||
630d3d5a | 3184 | If you use multiple @option{-O} options, with or without level numbers, |
74291a4b MM |
3185 | the last such option is the one that is effective. |
3186 | @end table | |
3187 | ||
630d3d5a | 3188 | Options of the form @option{-f@var{flag}} specify machine-independent |
74291a4b | 3189 | flags. Most flags have both positive and negative forms; the negative |
630d3d5a | 3190 | form of @option{-ffoo} would be @option{-fno-foo}. In the table below, |
74291a4b MM |
3191 | only one of the forms is listed---the one which is not the default. |
3192 | You can figure out the other form by either removing @samp{no-} or | |
3193 | adding it. | |
3194 | ||
2642624b | 3195 | @table @gcctabopt |
74291a4b | 3196 | @item -ffloat-store |
cd3bb277 | 3197 | @opindex ffloat-store |
74291a4b MM |
3198 | Do not store floating point variables in registers, and inhibit other |
3199 | options that might change whether a floating point value is taken from a | |
3200 | register or memory. | |
3201 | ||
3202 | @cindex floating point precision | |
3203 | This option prevents undesirable excess precision on machines such as | |
3204 | the 68000 where the floating registers (of the 68881) keep more | |
3205 | precision than a @code{double} is supposed to have. Similarly for the | |
3206 | x86 architecture. For most programs, the excess precision does only | |
3207 | good, but a few programs rely on the precise definition of IEEE floating | |
630d3d5a | 3208 | point. Use @option{-ffloat-store} for such programs, after modifying |
6fd74494 | 3209 | them to store all pertinent intermediate computations into variables. |
74291a4b MM |
3210 | |
3211 | @item -fno-default-inline | |
cd3bb277 | 3212 | @opindex fno-default-inline |
74291a4b MM |
3213 | Do not make member functions inline by default merely because they are |
3214 | defined inside the class scope (C++ only). Otherwise, when you specify | |
630d3d5a | 3215 | @w{@option{-O}}, member functions defined inside class scope are compiled |
74291a4b MM |
3216 | inline by default; i.e., you don't need to add @samp{inline} in front of |
3217 | the member function name. | |
3218 | ||
3219 | @item -fno-defer-pop | |
cd3bb277 | 3220 | @opindex fno-defer-pop |
74291a4b MM |
3221 | Always pop the arguments to each function call as soon as that function |
3222 | returns. For machines which must pop arguments after a function call, | |
3223 | the compiler normally lets arguments accumulate on the stack for several | |
3224 | function calls and pops them all at once. | |
3225 | ||
3226 | @item -fforce-mem | |
cd3bb277 | 3227 | @opindex fforce-mem |
74291a4b MM |
3228 | Force memory operands to be copied into registers before doing |
3229 | arithmetic on them. This produces better code by making all memory | |
3230 | references potential common subexpressions. When they are not common | |
3231 | subexpressions, instruction combination should eliminate the separate | |
630d3d5a | 3232 | register-load. The @option{-O2} option turns on this option. |
74291a4b MM |
3233 | |
3234 | @item -fforce-addr | |
cd3bb277 | 3235 | @opindex fforce-addr |
74291a4b MM |
3236 | Force memory address constants to be copied into registers before |
3237 | doing arithmetic on them. This may produce better code just as | |
630d3d5a | 3238 | @option{-fforce-mem} may. |
74291a4b MM |
3239 | |
3240 | @item -fomit-frame-pointer | |
cd3bb277 | 3241 | @opindex fomit-frame-pointer |
74291a4b MM |
3242 | Don't keep the frame pointer in a register for functions that |
3243 | don't need one. This avoids the instructions to save, set up and | |
3244 | restore frame pointers; it also makes an extra register available | |
3245 | in many functions. @strong{It also makes debugging impossible on | |
3246 | some machines.} | |
3247 | ||
3248 | @ifset INTERNALS | |
8aeea6e6 | 3249 | On some machines, such as the VAX, this flag has no effect, because |
74291a4b MM |
3250 | the standard calling sequence automatically handles the frame pointer |
3251 | and nothing is saved by pretending it doesn't exist. The | |
3252 | machine-description macro @code{FRAME_POINTER_REQUIRED} controls | |
bd819a4a | 3253 | whether a target machine supports this flag. @xref{Registers}. |
74291a4b MM |
3254 | @end ifset |
3255 | @ifclear INTERNALS | |
8aeea6e6 | 3256 | On some machines, such as the VAX, this flag has no effect, because |
74291a4b MM |
3257 | the standard calling sequence automatically handles the frame pointer |
3258 | and nothing is saved by pretending it doesn't exist. The | |
3259 | machine-description macro @code{FRAME_POINTER_REQUIRED} controls | |
3260 | whether a target machine supports this flag. @xref{Registers,,Register | |
bd819a4a | 3261 | Usage, gcc.info, Using and Porting GCC}. |
74291a4b MM |
3262 | @end ifclear |
3263 | ||
1aaef9c1 | 3264 | @item -foptimize-sibling-calls |
cd3bb277 | 3265 | @opindex foptimize-sibling-calls |
1aaef9c1 JH |
3266 | Optimize sibling and tail recursive calls. |
3267 | ||
91ce572a | 3268 | @item -ftrapv |
cd3bb277 | 3269 | @opindex ftrapv |
91ce572a CC |
3270 | This option generates traps for signed overflow on addition, subtraction, |
3271 | multiplication operations. | |
3272 | ||
74291a4b | 3273 | @item -fno-inline |
cd3bb277 | 3274 | @opindex fno-inline |
74291a4b MM |
3275 | Don't pay attention to the @code{inline} keyword. Normally this option |
3276 | is used to keep the compiler from expanding any functions inline. | |
3277 | Note that if you are not optimizing, no functions can be expanded inline. | |
3278 | ||
3279 | @item -finline-functions | |
cd3bb277 | 3280 | @opindex finline-functions |
74291a4b MM |
3281 | Integrate all simple functions into their callers. The compiler |
3282 | heuristically decides which functions are simple enough to be worth | |
3283 | integrating in this way. | |
3284 | ||
3285 | If all calls to a given function are integrated, and the function is | |
3286 | declared @code{static}, then the function is normally not output as | |
3287 | assembler code in its own right. | |
3288 | ||
efa3896a | 3289 | @item -finline-limit=@var{n} |
cd3bb277 | 3290 | @opindex finline-limit |
f9e814f1 TP |
3291 | By default, gcc limits the size of functions that can be inlined. This flag |
3292 | allows the control of this limit for functions that are explicitly marked as | |
02f52e19 AJ |
3293 | inline (ie marked with the inline keyword or defined within the class |
3294 | definition in c++). @var{n} is the size of functions that can be inlined in | |
f9e814f1 | 3295 | number of pseudo instructions (not counting parameter handling). The default |
93ee12c4 GP |
3296 | value of @var{n} is 600. |
3297 | Increasing this value can result in more inlined code at | |
f9e814f1 | 3298 | the cost of compilation time and memory consumption. Decreasing usually makes |
02f52e19 AJ |
3299 | the compilation faster and less code will be inlined (which presumably |
3300 | means slower programs). This option is particularly useful for programs that | |
aee96fe9 | 3301 | use inlining heavily such as those based on recursive templates with C++. |
f9e814f1 TP |
3302 | |
3303 | @emph{Note:} pseudo instruction represents, in this particular context, an | |
3304 | abstract measurement of function's size. In no way, it represents a count | |
3305 | of assembly instructions and as such its exact meaning might change from one | |
3306 | release to an another. | |
3307 | ||
74291a4b | 3308 | @item -fkeep-inline-functions |
cd3bb277 | 3309 | @opindex fkeep-inline-functions |
74291a4b MM |
3310 | Even if all calls to a given function are integrated, and the function |
3311 | is declared @code{static}, nevertheless output a separate run-time | |
3312 | callable version of the function. This switch does not affect | |
3313 | @code{extern inline} functions. | |
3314 | ||
3315 | @item -fkeep-static-consts | |
cd3bb277 | 3316 | @opindex fkeep-static-consts |
74291a4b MM |
3317 | Emit variables declared @code{static const} when optimization isn't turned |
3318 | on, even if the variables aren't referenced. | |
3319 | ||
0c2d1a2a | 3320 | GCC enables this option by default. If you want to force the compiler to |
74291a4b | 3321 | check if the variable was referenced, regardless of whether or not |
630d3d5a | 3322 | optimization is turned on, use the @option{-fno-keep-static-consts} option. |
74291a4b | 3323 | |
201556f0 JJ |
3324 | @item -fmerge-constants |
3325 | Attempt to merge identical constants (string constants and floating point | |
3326 | constants) accross compilation units. | |
3327 | ||
3328 | This option is default for optimized compilation if assembler and linker | |
3329 | support it. Use @option{-fno-merge-constants} to inhibit this behaviour. | |
3330 | ||
3331 | @item -fmerge-all-constants | |
3332 | Attempt to merge identical constants and identical variables. | |
3333 | ||
3334 | This option implies @option{-fmerge-constants}. In addition to | |
3335 | @option{-fmerge-constants} this considers e.g. even constant initialized | |
3336 | arrays or initialized constant variables with integral or floating point | |
3337 | types. Languages like C or C++ require each non-automatic variable to | |
3338 | have distinct location, so using this option will result in non-conforming | |
3339 | behaviour. | |
3340 | ||
74291a4b | 3341 | @item -fno-function-cse |
cd3bb277 | 3342 | @opindex fno-function-cse |
74291a4b MM |
3343 | Do not put function addresses in registers; make each instruction that |
3344 | calls a constant function contain the function's address explicitly. | |
3345 | ||
3346 | This option results in less efficient code, but some strange hacks | |
3347 | that alter the assembler output may be confused by the optimizations | |
3348 | performed when this option is not used. | |
3349 | ||
3350 | @item -ffast-math | |
cd3bb277 | 3351 | @opindex ffast-math |
9c34dbbf ZW |
3352 | Sets @option{-fno-math-errno}, @option{-funsafe-math-optimizations}, and @* |
3353 | @option{-fno-trapping-math}. | |
de6c5979 | 3354 | |
630d3d5a | 3355 | This option causes the preprocessor macro @code{__FAST_MATH__} to be defined. |
74291a4b | 3356 | |
630d3d5a | 3357 | This option should never be turned on by any @option{-O} option since |
74291a4b | 3358 | it can result in incorrect output for programs which depend on |
c1030c7c | 3359 | an exact implementation of IEEE or ISO rules/specifications for |
74291a4b | 3360 | math functions. |
9605da8a BL |
3361 | |
3362 | @item -fno-math-errno | |
cd3bb277 | 3363 | @opindex fno-math-errno |
9605da8a BL |
3364 | Do not set ERRNO after calling math functions that are executed |
3365 | with a single instruction, e.g., sqrt. A program that relies on | |
3366 | IEEE exceptions for math error handling may want to use this flag | |
3367 | for speed while maintaining IEEE arithmetic compatibility. | |
3368 | ||
630d3d5a | 3369 | This option should never be turned on by any @option{-O} option since |
de6c5979 BL |
3370 | it can result in incorrect output for programs which depend on |
3371 | an exact implementation of IEEE or ISO rules/specifications for | |
3372 | math functions. | |
3373 | ||
9c34dbbf | 3374 | The default is @option{-fmath-errno}. |
de6c5979 BL |
3375 | |
3376 | @item -funsafe-math-optimizations | |
cd3bb277 | 3377 | @opindex funsafe-math-optimizations |
de6c5979 BL |
3378 | Allow optimizations for floating-point arithmetic that (a) assume |
3379 | that arguments and results are valid and (b) may violate IEEE or | |
237b14f7 RH |
3380 | ANSI standards. When used at link-time, it may include libraries |
3381 | or startup files that change the default FPU control word or other | |
3382 | similar optimizations. | |
de6c5979 | 3383 | |
630d3d5a | 3384 | This option should never be turned on by any @option{-O} option since |
de6c5979 BL |
3385 | it can result in incorrect output for programs which depend on |
3386 | an exact implementation of IEEE or ISO rules/specifications for | |
3387 | math functions. | |
3388 | ||
9c34dbbf | 3389 | The default is @option{-fno-unsafe-math-optimizations}. |
de6c5979 BL |
3390 | |
3391 | @item -fno-trapping-math | |
cd3bb277 | 3392 | @opindex fno-trapping-math |
de6c5979 BL |
3393 | Compile code assuming that floating-point operations cannot generate |
3394 | user-visible traps. Setting this option may allow faster code | |
3395 | if one relies on ``non-stop'' IEEE arithmetic, for example. | |
3396 | ||
630d3d5a | 3397 | This option should never be turned on by any @option{-O} option since |
de6c5979 BL |
3398 | it can result in incorrect output for programs which depend on |
3399 | an exact implementation of IEEE or ISO rules/specifications for | |
3400 | math functions. | |
3401 | ||
9c34dbbf | 3402 | The default is @option{-ftrapping-math}. |
74291a4b MM |
3403 | @end table |
3404 | ||
630d3d5a JM |
3405 | The following options control specific optimizations. The @option{-O2} |
3406 | option turns on all of these optimizations except @option{-funroll-loops} | |
3407 | and @option{-funroll-all-loops}. On most machines, the @option{-O} option | |
3408 | turns on the @option{-fthread-jumps} and @option{-fdelayed-branch} options, | |
74291a4b MM |
3409 | but specific machines may handle it differently. |
3410 | ||
3411 | You can use the following flags in the rare cases when ``fine-tuning'' | |
3412 | of optimizations to be performed is desired. | |
3413 | ||
9c34dbbf ZW |
3414 | Not all of the optimizations performed by GCC have @option{-f} options |
3415 | to control them. | |
3416 | ||
2642624b | 3417 | @table @gcctabopt |
74291a4b | 3418 | @item -fstrength-reduce |
cd3bb277 | 3419 | @opindex fstrength-reduce |
74291a4b MM |
3420 | Perform the optimizations of loop strength reduction and |
3421 | elimination of iteration variables. | |
3422 | ||
3423 | @item -fthread-jumps | |
cd3bb277 | 3424 | @opindex fthread-jumps |
74291a4b MM |
3425 | Perform optimizations where we check to see if a jump branches to a |
3426 | location where another comparison subsumed by the first is found. If | |
3427 | so, the first branch is redirected to either the destination of the | |
3428 | second branch or a point immediately following it, depending on whether | |
3429 | the condition is known to be true or false. | |
3430 | ||
3431 | @item -fcse-follow-jumps | |
cd3bb277 | 3432 | @opindex fcse-follow-jumps |
74291a4b MM |
3433 | In common subexpression elimination, scan through jump instructions |
3434 | when the target of the jump is not reached by any other path. For | |
3435 | example, when CSE encounters an @code{if} statement with an | |
3436 | @code{else} clause, CSE will follow the jump when the condition | |
3437 | tested is false. | |
3438 | ||
3439 | @item -fcse-skip-blocks | |
cd3bb277 | 3440 | @opindex fcse-skip-blocks |
630d3d5a | 3441 | This is similar to @option{-fcse-follow-jumps}, but causes CSE to |
74291a4b MM |
3442 | follow jumps which conditionally skip over blocks. When CSE |
3443 | encounters a simple @code{if} statement with no else clause, | |
630d3d5a | 3444 | @option{-fcse-skip-blocks} causes CSE to follow the jump around the |
74291a4b MM |
3445 | body of the @code{if}. |
3446 | ||
3447 | @item -frerun-cse-after-loop | |
cd3bb277 | 3448 | @opindex frerun-cse-after-loop |
74291a4b MM |
3449 | Re-run common subexpression elimination after loop optimizations has been |
3450 | performed. | |
3451 | ||
6d6d0fa0 | 3452 | @item -frerun-loop-opt |
cd3bb277 | 3453 | @opindex frerun-loop-opt |
6d6d0fa0 JL |
3454 | Run the loop optimizer twice. |
3455 | ||
7506f491 | 3456 | @item -fgcse |
cd3bb277 | 3457 | @opindex fgcse |
7506f491 DE |
3458 | Perform a global common subexpression elimination pass. |
3459 | This pass also performs global constant and copy propagation. | |
3460 | ||
081ca317 BL |
3461 | @emph{Note:} When compiling a program using computed gotos, a GCC |
3462 | extension, you may get better runtime performance if you disable | |
3463 | the global common subexpression elmination pass by adding | |
3464 | @option{-fno-gcse} to the command line. | |
3465 | ||
a13d4ebf | 3466 | @item -fgcse-lm |
cd3bb277 | 3467 | @opindex fgcse-lm |
695ac33f | 3468 | When @option{-fgcse-lm} is enabled, global common subexpression elimination will |
767094dd | 3469 | attempt to move loads which are only killed by stores into themselves. This |
a13d4ebf | 3470 | allows a loop containing a load/store sequence to be changed to a load outside |
02f52e19 | 3471 | the loop, and a copy/store within the loop. |
a13d4ebf AM |
3472 | |
3473 | @item -fgcse-sm | |
cd3bb277 | 3474 | @opindex fgcse-sm |
695ac33f | 3475 | When @option{-fgcse-sm} is enabled, A store motion pass is run after global common |
767094dd | 3476 | subexpression elimination. This pass will attempt to move stores out of loops. |
695ac33f | 3477 | When used in conjunction with @option{-fgcse-lm}, loops containing a load/store sequence |
a13d4ebf AM |
3478 | can be changed to a load before the loop and a store after the loop. |
3479 | ||
b6d24183 | 3480 | @item -fdelete-null-pointer-checks |
cd3bb277 | 3481 | @opindex fdelete-null-pointer-checks |
9c34dbbf ZW |
3482 | Use global dataflow analysis to identify and eliminate useless checks |
3483 | for null pointers. The compiler assumes that dereferencing a null | |
3484 | pointer would have halted the program. If a pointer is checked after | |
3485 | it has already been dereferenced, it cannot be null. | |
3486 | ||
3487 | In some environments, this assumption is not true, and programs can | |
3488 | safely dereference null pointers. Use | |
3489 | @option{-fno-delete-null-pointer-checks} to disable this optimization | |
3490 | for programs which depend on that behavior. | |
b6d24183 | 3491 | |
74291a4b | 3492 | @item -fexpensive-optimizations |
cd3bb277 | 3493 | @opindex fexpensive-optimizations |
74291a4b MM |
3494 | Perform a number of minor optimizations that are relatively expensive. |
3495 | ||
639726ba | 3496 | @item -foptimize-register-move |
59d40964 | 3497 | @itemx -fregmove |
cd3bb277 JM |
3498 | @opindex foptimize-register-move |
3499 | @opindex fregmove | |
9ec36da5 JL |
3500 | Attempt to reassign register numbers in move instructions and as |
3501 | operands of other simple instructions in order to maximize the amount of | |
56159047 | 3502 | register tying. This is especially helpful on machines with two-operand |
630d3d5a | 3503 | instructions. GCC enables this optimization by default with @option{-O2} |
9ec36da5 JL |
3504 | or higher. |
3505 | ||
bedc7537 | 3506 | Note @option{-fregmove} and @option{-foptimize-register-move} are the same |
9ec36da5 JL |
3507 | optimization. |
3508 | ||
74291a4b | 3509 | @item -fdelayed-branch |
cd3bb277 | 3510 | @opindex fdelayed-branch |
74291a4b MM |
3511 | If supported for the target machine, attempt to reorder instructions |
3512 | to exploit instruction slots available after delayed branch | |
3513 | instructions. | |
3514 | ||
3515 | @item -fschedule-insns | |
cd3bb277 | 3516 | @opindex fschedule-insns |
74291a4b MM |
3517 | If supported for the target machine, attempt to reorder instructions to |
3518 | eliminate execution stalls due to required data being unavailable. This | |
3519 | helps machines that have slow floating point or memory load instructions | |
3520 | by allowing other instructions to be issued until the result of the load | |
3521 | or floating point instruction is required. | |
3522 | ||
3523 | @item -fschedule-insns2 | |
cd3bb277 | 3524 | @opindex fschedule-insns2 |
630d3d5a | 3525 | Similar to @option{-fschedule-insns}, but requests an additional pass of |
74291a4b MM |
3526 | instruction scheduling after register allocation has been done. This is |
3527 | especially useful on machines with a relatively small number of | |
3528 | registers and where memory load instructions take more than one cycle. | |
3529 | ||
3530 | @item -ffunction-sections | |
59d40964 | 3531 | @itemx -fdata-sections |
cd3bb277 JM |
3532 | @opindex ffunction-sections |
3533 | @opindex fdata-sections | |
7d0756fb CM |
3534 | Place each function or data item into its own section in the output |
3535 | file if the target supports arbitrary sections. The name of the | |
3536 | function or the name of the data item determines the section's name | |
3537 | in the output file. | |
74291a4b | 3538 | |
7d0756fb | 3539 | Use these options on systems where the linker can perform optimizations |
74291a4b MM |
3540 | to improve locality of reference in the instruction space. HPPA |
3541 | processors running HP-UX and Sparc processors running Solaris 2 have | |
3542 | linkers with such optimizations. Other systems using the ELF object format | |
3543 | as well as AIX may have these optimizations in the future. | |
3544 | ||
7d0756fb CM |
3545 | Only use these options when there are significant benefits from doing |
3546 | so. When you specify these options, the assembler and linker will | |
74291a4b MM |
3547 | create larger object and executable files and will also be slower. |
3548 | You will not be able to use @code{gprof} on all systems if you | |
3549 | specify this option and you may have problems with debugging if | |
630d3d5a | 3550 | you specify both this option and @option{-g}. |
74291a4b MM |
3551 | |
3552 | @item -fcaller-saves | |
cd3bb277 | 3553 | @opindex fcaller-saves |
74291a4b MM |
3554 | Enable values to be allocated in registers that will be clobbered by |
3555 | function calls, by emitting extra instructions to save and restore the | |
3556 | registers around such calls. Such allocation is done only when it | |
3557 | seems to result in better code than would otherwise be produced. | |
3558 | ||
81610a0d HPN |
3559 | This option is always enabled by default on certain machines, usually |
3560 | those which have no call-preserved registers to use instead. | |
3561 | ||
3562 | For all machines, optimization level 2 and higher enables this flag by | |
3563 | default. | |
74291a4b MM |
3564 | |
3565 | @item -funroll-loops | |
cd3bb277 | 3566 | @opindex funroll-loops |
9c34dbbf ZW |
3567 | Unroll loops whose number of iterations can be determined at compile |
3568 | time or upon entry to the loop. @option{-funroll-loops} implies both | |
3569 | @option{-fstrength-reduce} and @option{-frerun-cse-after-loop}. This | |
3570 | option makes code larger, and may or may not make it run faster. | |
74291a4b MM |
3571 | |
3572 | @item -funroll-all-loops | |
cd3bb277 | 3573 | @opindex funroll-all-loops |
9c34dbbf ZW |
3574 | Unroll all loops, even if their number of iterations is uncertain when |
3575 | the loop is entered. This usually makes programs run more slowly. | |
3576 | @option{-funroll-all-loops} implies the same options as | |
3577 | @option{-funroll-loops}, | |
3578 | ||
74291a4b | 3579 | |
e5eb27e5 | 3580 | @item -fmove-all-movables |
cd3bb277 | 3581 | @opindex fmove-all-movables |
e5eb27e5 JL |
3582 | Forces all invariant computations in loops to be moved |
3583 | outside the loop. | |
3584 | ||
3585 | @item -freduce-all-givs | |
cd3bb277 | 3586 | @opindex freduce-all-givs |
e5eb27e5 JL |
3587 | Forces all general-induction variables in loops to be |
3588 | strength-reduced. | |
3589 | ||
3590 | @emph{Note:} When compiling programs written in Fortran, | |
630d3d5a | 3591 | @option{-fmove-all-movables} and @option{-freduce-all-givs} are enabled |
e5eb27e5 JL |
3592 | by default when you use the optimizer. |
3593 | ||
3594 | These options may generate better or worse code; results are highly | |
3595 | dependent on the structure of loops within the source code. | |
3596 | ||
3597 | These two options are intended to be removed someday, once | |
3598 | they have helped determine the efficacy of various | |
3599 | approaches to improving loop optimizations. | |
3600 | ||
2642624b | 3601 | Please let us (@w{@email{gcc@@gcc.gnu.org}} and @w{@email{fortran@@gnu.org}}) |
e5eb27e5 JL |
3602 | know how use of these options affects |
3603 | the performance of your production code. | |
3604 | We're very interested in code that runs @emph{slower} | |
3605 | when these options are @emph{enabled}. | |
3606 | ||
74291a4b | 3607 | @item -fno-peephole |
6cfc0341 | 3608 | @itemx -fno-peephole2 |
cd3bb277 | 3609 | @opindex fno-peephole |
6cfc0341 RH |
3610 | @opindex fno-peephole2 |
3611 | Disable any machine-specific peephole optimizations. The difference | |
630d3d5a | 3612 | between @option{-fno-peephole} and @option{-fno-peephole2} is in how they |
6cfc0341 RH |
3613 | are implemented in the compiler; some targets use one, some use the |
3614 | other, a few use both. | |
861bb6c1 JL |
3615 | |
3616 | @item -fbranch-probabilities | |
cd3bb277 | 3617 | @opindex fbranch-probabilities |
630d3d5a | 3618 | After running a program compiled with @option{-fprofile-arcs} |
861bb6c1 | 3619 | (@pxref{Debugging Options,, Options for Debugging Your Program or |
bedc7537 | 3620 | @command{gcc}}), you can compile it a second time using |
630d3d5a | 3621 | @option{-fbranch-probabilities}, to improve optimizations based on |
3de87bf2 JJ |
3622 | the number of times each branch was taken. When the program |
3623 | compiled with @option{-fprofile-arcs} exits it saves arc execution | |
3624 | counts to a file called @file{@var{sourcename}.da} for each source | |
3625 | file The information in this data file is very dependent on the | |
3626 | structure of the generated code, so you must use the same source code | |
3627 | and the same optimization options for both compilations. | |
861bb6c1 JL |
3628 | |
3629 | @ifset INTERNALS | |
630d3d5a | 3630 | With @option{-fbranch-probabilities}, GCC puts a @samp{REG_EXEC_COUNT} |
861bb6c1 JL |
3631 | note on the first instruction of each basic block, and a |
3632 | @samp{REG_BR_PROB} note on each @samp{JUMP_INSN} and @samp{CALL_INSN}. | |
3633 | These can be used to improve optimization. Currently, they are only | |
3634 | used in one place: in @file{reorg.c}, instead of guessing which path a | |
3635 | branch is mostly to take, the @samp{REG_BR_PROB} values are used to | |
3636 | exactly determine which path is taken more often. | |
3637 | @end ifset | |
8c660648 | 3638 | |
454d0cc7 | 3639 | @item -fno-guess-branch-probability |
cd3bb277 | 3640 | @opindex fno-guess-branch-probability |
9c34dbbf ZW |
3641 | Do not guess branch probabilities using a randomized model. |
3642 | ||
3643 | Sometimes gcc will opt to use a randomized model to guess branch | |
3644 | probabilities, when none are available from either profiling feedback | |
3645 | (@option{-fprofile-arcs}) or @samp{__builtin_expect}. This means that | |
3646 | different runs of the compiler on the same program may produce different | |
3647 | object code. | |
3648 | ||
3649 | In a hard real-time system, people don't want different runs of the | |
3650 | compiler to produce code that has different behavior; minimizing | |
3651 | non-determinism is of paramount import. This switch allows users to | |
3652 | reduce non-determinism, possibly at the expense of inferior | |
3653 | optimization. | |
454d0cc7 | 3654 | |
41472af8 | 3655 | @item -fstrict-aliasing |
cd3bb277 | 3656 | @opindex fstrict-aliasing |
41472af8 MM |
3657 | Allows the compiler to assume the strictest aliasing rules applicable to |
3658 | the language being compiled. For C (and C++), this activates | |
3659 | optimizations based on the type of expressions. In particular, an | |
3660 | object of one type is assumed never to reside at the same address as an | |
3661 | object of a different type, unless the types are almost the same. For | |
3662 | example, an @code{unsigned int} can alias an @code{int}, but not a | |
3663 | @code{void*} or a @code{double}. A character type may alias any other | |
02f52e19 | 3664 | type. |
41472af8 MM |
3665 | |
3666 | Pay special attention to code like this: | |
3667 | @example | |
02f52e19 | 3668 | union a_union @{ |
41472af8 MM |
3669 | int i; |
3670 | double d; | |
3671 | @}; | |
3672 | ||
3673 | int f() @{ | |
3674 | a_union t; | |
3675 | t.d = 3.0; | |
3676 | return t.i; | |
3677 | @} | |
3678 | @end example | |
3679 | The practice of reading from a different union member than the one most | |
3680 | recently written to (called ``type-punning'') is common. Even with | |
630d3d5a | 3681 | @option{-fstrict-aliasing}, type-punning is allowed, provided the memory |
41472af8 MM |
3682 | is accessed through the union type. So, the code above will work as |
3683 | expected. However, this code might not: | |
3684 | @example | |
02f52e19 | 3685 | int f() @{ |
41472af8 MM |
3686 | a_union t; |
3687 | int* ip; | |
3688 | t.d = 3.0; | |
3689 | ip = &t.i; | |
3690 | return *ip; | |
3691 | @} | |
3692 | @end example | |
3693 | ||
41472af8 MM |
3694 | @ifset INTERNALS |
3695 | Every language that wishes to perform language-specific alias analysis | |
3696 | should define a function that computes, given an @code{tree} | |
3697 | node, an alias set for the node. Nodes in different alias sets are not | |
3698 | allowed to alias. For an example, see the C front-end function | |
3699 | @code{c_get_alias_set}. | |
3700 | @end ifset | |
3701 | ||
efa3896a GK |
3702 | @item -falign-functions |
3703 | @itemx -falign-functions=@var{n} | |
cd3bb277 | 3704 | @opindex falign-functions |
efa3896a GK |
3705 | Align the start of functions to the next power-of-two greater than |
3706 | @var{n}, skipping up to @var{n} bytes. For instance, | |
630d3d5a JM |
3707 | @option{-falign-functions=32} aligns functions to the next 32-byte |
3708 | boundary, but @option{-falign-functions=24} would align to the next | |
efa3896a GK |
3709 | 32-byte boundary only if this can be done by skipping 23 bytes or less. |
3710 | ||
630d3d5a | 3711 | @option{-fno-align-functions} and @option{-falign-functions=1} are |
efa3896a GK |
3712 | equivalent and mean that functions will not be aligned. |
3713 | ||
3714 | Some assemblers only support this flag when @var{n} is a power of two; | |
3715 | in that case, it is rounded up. | |
3716 | ||
3717 | If @var{n} is not specified, use a machine-dependent default. | |
3718 | ||
3719 | @item -falign-labels | |
3720 | @itemx -falign-labels=@var{n} | |
cd3bb277 | 3721 | @opindex falign-labels |
efa3896a | 3722 | Align all branch targets to a power-of-two boundary, skipping up to |
630d3d5a | 3723 | @var{n} bytes like @option{-falign-functions}. This option can easily |
efa3896a GK |
3724 | make code slower, because it must insert dummy operations for when the |
3725 | branch target is reached in the usual flow of the code. | |
3726 | ||
630d3d5a | 3727 | If @option{-falign-loops} or @option{-falign-jumps} are applicable and |
efa3896a GK |
3728 | are greater than this value, then their values are used instead. |
3729 | ||
3730 | If @var{n} is not specified, use a machine-dependent default which is | |
3731 | very likely to be @samp{1}, meaning no alignment. | |
3732 | ||
3733 | @item -falign-loops | |
3734 | @itemx -falign-loops=@var{n} | |
cd3bb277 | 3735 | @opindex falign-loops |
efa3896a | 3736 | Align loops to a power-of-two boundary, skipping up to @var{n} bytes |
630d3d5a | 3737 | like @option{-falign-functions}. The hope is that the loop will be |
efa3896a GK |
3738 | executed many times, which will make up for any execution of the dummy |
3739 | operations. | |
3740 | ||
3741 | If @var{n} is not specified, use a machine-dependent default. | |
3742 | ||
3743 | @item -falign-jumps | |
3744 | @itemx -falign-jumps=@var{n} | |
cd3bb277 | 3745 | @opindex falign-jumps |
efa3896a GK |
3746 | Align branch targets to a power-of-two boundary, for branch targets |
3747 | where the targets can only be reached by jumping, skipping up to @var{n} | |
630d3d5a | 3748 | bytes like @option{-falign-functions}. In this case, no dummy operations |
efa3896a GK |
3749 | need be executed. |
3750 | ||
3751 | If @var{n} is not specified, use a machine-dependent default. | |
3752 | ||
4bae0b47 | 3753 | @item -fssa |
cd3bb277 | 3754 | @opindex fssa |
4bae0b47 AS |
3755 | Perform optimizations in static single assignment form. Each function's |
3756 | flow graph is translated into SSA form, optimizations are performed, and | |
90ecce3e | 3757 | the flow graph is translated back from SSA form. Users should not |
b53978a3 JO |
3758 | specify this option, since it is not yet ready for production use. |
3759 | ||
0b47e4c1 JL |
3760 | @item -fssa-ccp |
3761 | @opindex fssa-ccp | |
3762 | Perform Sparse Conditional Constant Propagation in SSA form. Requires | |
3763 | @option{-fssa}. Like @option{-fssa}, this is an experimental feature. | |
3764 | ||
62d285ff JL |
3765 | @item -fssa-dce |
3766 | @opindex fssa-dce | |
3767 | Perform aggressive dead-code elimination in SSA form. Requires @option{-fssa}. | |
3768 | Like @option{-fssa}, this is an experimental feature. | |
4bae0b47 | 3769 | |
46d3a873 | 3770 | @item -fsingle-precision-constant |
cd3bb277 | 3771 | @opindex fsingle-precision-constant |
46d3a873 CC |
3772 | Treat floating point constant as single precision constant instead of |
3773 | implicitly converting it to double precision constant. | |
3774 | ||
2b2a8f1f | 3775 | @item -frename-registers |
cd3bb277 | 3776 | @opindex frename-registers |
c771326b | 3777 | Attempt to avoid false dependencies in scheduled code by making use |
2b2a8f1f RH |
3778 | of registers left over after register allocation. This optimization |
3779 | will most benefit processors with lots of registers. It can, however, | |
3780 | make debugging impossible, since variables will no longer stay in | |
3781 | a ``home register''. | |
3af64fd6 MM |
3782 | |
3783 | @item --param @var{name}=@var{value} | |
cd3bb277 | 3784 | @opindex param |
3af64fd6 MM |
3785 | In some places, GCC uses various constants to control the amount of |
3786 | optimization that is done. For example, GCC will not inline functions | |
3787 | that contain more that a certain number of instructions. You can | |
3788 | control some of these constants on the command-line using the | |
630d3d5a | 3789 | @option{--param} option. |
3af64fd6 MM |
3790 | |
3791 | In each case, the @var{value} is a integer. The allowable choices for | |
3792 | @var{name} are given in the following table: | |
3793 | ||
3794 | @table @gcctabopt | |
1c4c47db JO |
3795 | @item max-delay-slot-insn-search |
3796 | The maximum number of instructions to consider when looking for an | |
3797 | instruction to fill a delay slot. If more than this arbitrary number of | |
3798 | instructions is searched, the time savings from filling the delay slot | |
3799 | will be minimal so stop searching. Increasing values mean more | |
3800 | aggressive optimization, making the compile time increase with probably | |
3801 | small improvement in executable run time. | |
3802 | ||
3803 | @item max-delay-slot-live-search | |
3804 | When trying to fill delay slots, the maximum number of instructions to | |
3805 | consider when searching for a block with valid live register | |
3806 | information. Increasing this arbitrarily chosen value means more | |
3807 | aggressive optimization, increasing the compile time. This parameter | |
3808 | should be removed when the delay slot code is rewritten to maintain the | |
3809 | control-flow graph. | |
33d3b05b MM |
3810 | |
3811 | @item max-gcse-memory | |
3812 | The approximate maximum amount of memory that will be allocated in | |
3813 | order to perform the global common subexpression elimination | |
3814 | optimization. If more memory than specified is required, the | |
3815 | optimization will not be done. | |
3af64fd6 | 3816 | |
740f35a0 | 3817 | @item max-gcse-passes |
7dac2f89 | 3818 | The maximum number of passes of GCSE to run. |
740f35a0 | 3819 | |
4a121cc3 AM |
3820 | @item max-pending-list-length |
3821 | The maximum number of pending dependancies scheduling will allow | |
3822 | before flushing the current state and starting over. Large functions | |
3823 | with few branches or calls can create excessively large lists which | |
3824 | needlessly consume memory and resources. | |
3825 | ||
1c4c47db JO |
3826 | @item max-inline-insns |
3827 | If an function contains more than this many instructions, it | |
3828 | will not be inlined. This option is precisely equivalent to | |
630d3d5a | 3829 | @option{-finline-limit}. |
1c4c47db JO |
3830 | |
3831 | @end table | |
74291a4b MM |
3832 | @end table |
3833 | ||
3834 | @node Preprocessor Options | |
3835 | @section Options Controlling the Preprocessor | |
3836 | @cindex preprocessor options | |
3837 | @cindex options, preprocessor | |
3838 | ||
3839 | These options control the C preprocessor, which is run on each C source | |
3840 | file before actual compilation. | |
3841 | ||
630d3d5a JM |
3842 | If you use the @option{-E} option, nothing is done except preprocessing. |
3843 | Some of these options make sense only together with @option{-E} because | |
74291a4b MM |
3844 | they cause the preprocessor output to be unsuitable for actual |
3845 | compilation. | |
3846 | ||
2642624b | 3847 | @table @gcctabopt |
74291a4b | 3848 | @item -include @var{file} |
cd3bb277 | 3849 | @opindex include |
74291a4b | 3850 | Process @var{file} as input before processing the regular input file. |
630d3d5a JM |
3851 | In effect, the contents of @var{file} are compiled first. Any @option{-D} |
3852 | and @option{-U} options on the command line are always processed before | |
3853 | @option{-include @var{file}}, regardless of the order in which they are | |
3854 | written. All the @option{-include} and @option{-imacros} options are | |
74291a4b MM |
3855 | processed in the order in which they are written. |
3856 | ||
3857 | @item -imacros @var{file} | |
cd3bb277 | 3858 | @opindex imacros |
74291a4b MM |
3859 | Process @var{file} as input, discarding the resulting output, before |
3860 | processing the regular input file. Because the output generated from | |
630d3d5a | 3861 | @var{file} is discarded, the only effect of @option{-imacros @var{file}} |
74291a4b | 3862 | is to make the macros defined in @var{file} available for use in the |
630d3d5a | 3863 | main input. All the @option{-include} and @option{-imacros} options are |
e582248c | 3864 | processed in the order in which they are written. |
74291a4b MM |
3865 | |
3866 | @item -idirafter @var{dir} | |
cd3bb277 | 3867 | @opindex idirafter |
74291a4b MM |
3868 | @cindex second include path |
3869 | Add the directory @var{dir} to the second include path. The directories | |
3870 | on the second include path are searched when a header file is not found | |
3871 | in any of the directories in the main include path (the one that | |
630d3d5a | 3872 | @option{-I} adds to). |
74291a4b MM |
3873 | |
3874 | @item -iprefix @var{prefix} | |
cd3bb277 | 3875 | @opindex iprefix |
630d3d5a | 3876 | Specify @var{prefix} as the prefix for subsequent @option{-iwithprefix} |
74291a4b MM |
3877 | options. |
3878 | ||
3879 | @item -iwithprefix @var{dir} | |
cd3bb277 | 3880 | @opindex iwithprefix |
74291a4b MM |
3881 | Add a directory to the second include path. The directory's name is |
3882 | made by concatenating @var{prefix} and @var{dir}, where @var{prefix} was | |
630d3d5a | 3883 | specified previously with @option{-iprefix}. If you have not specified a |
74291a4b MM |
3884 | prefix yet, the directory containing the installed passes of the |
3885 | compiler is used as the default. | |
3886 | ||
3887 | @item -iwithprefixbefore @var{dir} | |
cd3bb277 | 3888 | @opindex iwithprefixbefore |
74291a4b MM |
3889 | Add a directory to the main include path. The directory's name is made |
3890 | by concatenating @var{prefix} and @var{dir}, as in the case of | |
630d3d5a | 3891 | @option{-iwithprefix}. |
74291a4b MM |
3892 | |
3893 | @item -isystem @var{dir} | |
cd3bb277 | 3894 | @opindex isystem |
74291a4b MM |
3895 | Add a directory to the beginning of the second include path, marking it |
3896 | as a system directory, so that it gets the same special treatment as | |
3897 | is applied to the standard system directories. | |
3898 | ||
3899 | @item -nostdinc | |
cd3bb277 | 3900 | @opindex nostdinc |
74291a4b | 3901 | Do not search the standard system directories for header files. Only |
630d3d5a | 3902 | the directories you have specified with @option{-I} options (and the |
74291a4b | 3903 | current directory, if appropriate) are searched. @xref{Directory |
630d3d5a | 3904 | Options}, for information on @option{-I}. |
74291a4b | 3905 | |
dfb5868d NS |
3906 | By using both @option{-nostdinc} and @option{-I-}, you can limit the include-file |
3907 | search path to only those directories you specify explicitly. | |
74291a4b | 3908 | |
e582248c | 3909 | @item -remap |
cd3bb277 | 3910 | @opindex remap |
e582248c NB |
3911 | When searching for a header file in a directory, remap file names if a |
3912 | file named @file{header.gcc} exists in that directory. This can be used | |
3913 | to work around limitations of file systems with file name restrictions. | |
3914 | The @file{header.gcc} file should contain a series of lines with two | |
3915 | tokens on each line: the first token is the name to map, and the second | |
3916 | token is the actual name to use. | |
3917 | ||
74291a4b | 3918 | @item -undef |
cd3bb277 | 3919 | @opindex undef |
74291a4b MM |
3920 | Do not predefine any nonstandard macros. (Including architecture flags). |
3921 | ||
3922 | @item -E | |
cd3bb277 | 3923 | @opindex E |
74291a4b MM |
3924 | Run only the C preprocessor. Preprocess all the C source files |
3925 | specified and output the results to standard output or to the | |
3926 | specified output file. | |
3927 | ||
3928 | @item -C | |
cd3bb277 | 3929 | @opindex C |
74291a4b | 3930 | Tell the preprocessor not to discard comments. Used with the |
630d3d5a | 3931 | @option{-E} option. |
74291a4b MM |
3932 | |
3933 | @item -P | |
cd3bb277 | 3934 | @opindex P |
74291a4b | 3935 | Tell the preprocessor not to generate @samp{#line} directives. |
630d3d5a | 3936 | Used with the @option{-E} option. |
74291a4b MM |
3937 | |
3938 | @cindex make | |
3939 | @cindex dependencies, make | |
3940 | @item -M | |
cd3bb277 | 3941 | @opindex M |
e582248c NB |
3942 | Instead of outputting the result of preprocessing, output a rule |
3943 | suitable for @code{make} describing the dependencies of the main source | |
3944 | file. The preprocessor outputs one @code{make} rule containing the | |
3945 | object file name for that source file, a colon, and the names of all the | |
48ce6bbb NS |
3946 | included files. Unless overridden explicitly, the object file name |
3947 | consists of the basename of the source file with any suffix replaced with | |
767094dd | 3948 | object file suffix. If there are many included files then the |
48ce6bbb | 3949 | rule is split into several lines using @samp{\}-newline. |
74291a4b | 3950 | |
630d3d5a | 3951 | @option{-M} implies @option{-E}. |
74291a4b | 3952 | |
e582248c | 3953 | @item -MM |
cd3bb277 | 3954 | @opindex MM |
630d3d5a | 3955 | Like @option{-M}, but mention only the files included with @samp{#include |
e582248c NB |
3956 | "@var{file}"}. System header files included with @samp{#include |
3957 | <@var{file}>} are omitted. | |
3958 | ||
7da723ef | 3959 | @item -MD |
cd3bb277 | 3960 | @opindex MD |
630d3d5a | 3961 | Like @option{-M} but the dependency information is written to a file |
7da723ef | 3962 | rather than stdout. @code{gcc} will use the same file name and |
695ac33f | 3963 | directory as the object file, but with the suffix @file{.d} instead. |
7da723ef | 3964 | |
630d3d5a JM |
3965 | This is in addition to compiling the main file as specified---@option{-MD} |
3966 | does not inhibit ordinary compilation the way @option{-M} does, | |
3967 | unless you also specify @option{-MG}. | |
7da723ef NB |
3968 | |
3969 | With Mach, you can use the utility @code{md} to merge multiple | |
3970 | dependency files into a single dependency file suitable for using with | |
3971 | the @samp{make} command. | |
3972 | ||
d396403a | 3973 | @item -MMD |
cd3bb277 | 3974 | @opindex MMD |
630d3d5a | 3975 | Like @option{-MD} except mention only user header files, not system |
7da723ef NB |
3976 | -header files. |
3977 | ||
e582248c | 3978 | @item -MF @var{file} |
cd3bb277 | 3979 | @opindex MF |
630d3d5a | 3980 | When used with @option{-M} or @option{-MM}, specifies a file to write the |
e582248c | 3981 | dependencies to. This allows the preprocessor to write the preprocessed |
630d3d5a | 3982 | file to stdout normally. If no @option{-MF} switch is given, CPP sends |
e582248c NB |
3983 | the rules to stdout and suppresses normal preprocessed output. |
3984 | ||
74291a4b | 3985 | Another way to specify output of a @code{make} rule is by setting |
bedc7537 | 3986 | the environment variable @env{DEPENDENCIES_OUTPUT} (@pxref{Environment |
74291a4b MM |
3987 | Variables}). |
3988 | ||
74291a4b | 3989 | @item -MG |
cd3bb277 | 3990 | @opindex MG |
630d3d5a | 3991 | When used with @option{-M} or @option{-MM}, @option{-MG} says to treat missing |
e582248c NB |
3992 | header files as generated files and assume they live in the same |
3993 | directory as the source file. It suppresses preprocessed output, as a | |
3994 | missing header file is ordinarily an error. | |
3995 | ||
3996 | This feature is used in automatic updating of makefiles. | |
3997 | ||
3998 | @item -MP | |
cd3bb277 | 3999 | @opindex MP |
e582248c NB |
4000 | This option instructs CPP to add a phony target for each dependency |
4001 | other than the main file, causing each to depend on nothing. These | |
4002 | dummy rules work around errors @code{make} gives if you remove header | |
4003 | files without updating the @code{Makefile} to match. | |
4004 | ||
4005 | This is typical output:- | |
4006 | ||
4007 | @smallexample | |
4008 | /tmp/test.o: /tmp/test.c /tmp/test.h | |
4009 | ||
4010 | /tmp/test.h: | |
4011 | @end smallexample | |
4012 | ||
4013 | @item -MQ @var{target} | |
4014 | @item -MT @var{target} | |
cd3bb277 JM |
4015 | @opindex MQ |
4016 | @opindex MT | |
e582248c NB |
4017 | By default CPP uses the main file name, including any path, and appends |
4018 | the object suffix, normally ``.o'', to it to obtain the name of the | |
630d3d5a | 4019 | target for dependency generation. With @option{-MT} you can specify a |
e582248c NB |
4020 | target yourself, overriding the default one. |
4021 | ||
4022 | If you want multiple targets, you can specify them as a single argument | |
630d3d5a | 4023 | to @option{-MT}, or use multiple @option{-MT} options. |
e582248c NB |
4024 | |
4025 | The targets you specify are output in the order they appear on the | |
630d3d5a JM |
4026 | command line. @option{-MQ} is identical to @option{-MT}, except that the |
4027 | target name is quoted for Make, but with @option{-MT} it isn't. For | |
4028 | example, @option{-MT '$(objpfx)foo.o'} gives | |
e582248c NB |
4029 | |
4030 | @smallexample | |
4031 | $(objpfx)foo.o: /tmp/foo.c | |
4032 | @end smallexample | |
4033 | ||
630d3d5a | 4034 | but @option{-MQ '$(objpfx)foo.o'} gives |
e582248c NB |
4035 | |
4036 | @smallexample | |
4037 | $$(objpfx)foo.o: /tmp/foo.c | |
4038 | @end smallexample | |
4039 | ||
4040 | The default target is automatically quoted, as if it were given with | |
630d3d5a | 4041 | @option{-MQ}. |
74291a4b MM |
4042 | |
4043 | @item -H | |
cd3bb277 | 4044 | @opindex H |
74291a4b MM |
4045 | Print the name of each header file used, in addition to other normal |
4046 | activities. | |
4047 | ||
4048 | @item -A@var{question}(@var{answer}) | |
cd3bb277 | 4049 | @opindex A |
74291a4b MM |
4050 | Assert the answer @var{answer} for @var{question}, in case it is tested |
4051 | with a preprocessing conditional such as @samp{#if | |
630d3d5a | 4052 | #@var{question}(@var{answer})}. @option{-A-} disables the standard |
74291a4b MM |
4053 | assertions that normally describe the target machine. |
4054 | ||
4055 | @item -D@var{macro} | |
cd3bb277 | 4056 | @opindex D |
74291a4b MM |
4057 | Define macro @var{macro} with the string @samp{1} as its definition. |
4058 | ||
4059 | @item -D@var{macro}=@var{defn} | |
630d3d5a JM |
4060 | Define macro @var{macro} as @var{defn}. All instances of @option{-D} on |
4061 | the command line are processed before any @option{-U} options. | |
74291a4b | 4062 | |
630d3d5a JM |
4063 | Any @option{-D} and @option{-U} options on the command line are processed in |
4064 | order, and always before @option{-imacros @var{file}}, regardless of the | |
e582248c NB |
4065 | order in which they are written. |
4066 | ||
74291a4b | 4067 | @item -U@var{macro} |
cd3bb277 | 4068 | @opindex U |
630d3d5a JM |
4069 | Undefine macro @var{macro}. @option{-U} options are evaluated after all |
4070 | @option{-D} options, but before any @option{-include} and @option{-imacros} | |
74291a4b MM |
4071 | options. |
4072 | ||
630d3d5a JM |
4073 | Any @option{-D} and @option{-U} options on the command line are processed in |
4074 | order, and always before @option{-imacros @var{file}}, regardless of the | |
e582248c NB |
4075 | order in which they are written. |
4076 | ||
74291a4b | 4077 | @item -dM |
cd3bb277 | 4078 | @opindex dM |
74291a4b | 4079 | Tell the preprocessor to output only a list of the macro definitions |
630d3d5a | 4080 | that are in effect at the end of preprocessing. Used with the @option{-E} |
74291a4b MM |
4081 | option. |
4082 | ||
4083 | @item -dD | |
cd3bb277 | 4084 | @opindex dD |
74291a4b MM |
4085 | Tell the preprocessing to pass all macro definitions into the output, in |
4086 | their proper sequence in the rest of the output. | |
4087 | ||
4088 | @item -dN | |
cd3bb277 | 4089 | @opindex dN |
630d3d5a | 4090 | Like @option{-dD} except that the macro arguments and contents are omitted. |
74291a4b MM |
4091 | Only @samp{#define @var{name}} is included in the output. |
4092 | ||
e582248c | 4093 | @item -dI |
cd3bb277 | 4094 | @opindex dI |
e582248c NB |
4095 | Output @samp{#include} directives in addition to the result of |
4096 | preprocessing. | |
4097 | ||
3bce8a01 NB |
4098 | @item -fpreprocessed |
4099 | @opindex fpreprocessed | |
4100 | Indicate to the preprocessor that the input file has already been | |
4101 | preprocessed. This suppresses things like macro expansion, trigraph | |
4102 | conversion, escaped newline splicing, and processing of most directives. | |
6d34c1c4 NB |
4103 | The preprocessor still recognizes and removes comments, so that you can |
4104 | pass a file preprocessed with @option{-C} to the compiler without | |
4105 | problems. In this mode the integrated preprocessor is little more than | |
4106 | a tokenizer for the front ends. | |
3bce8a01 | 4107 | |
630d3d5a | 4108 | @option{-fpreprocessed} is implicit if the input file has one of the |
6d34c1c4 NB |
4109 | extensions @samp{i}, @samp{ii} or @samp{mi}. These are the extensions |
4110 | that GCC uses for preprocessed files created by @option{-save-temps}. | |
3bce8a01 | 4111 | |
74291a4b | 4112 | @item -trigraphs |
cd3bb277 | 4113 | @opindex trigraphs |
e582248c NB |
4114 | Process ISO standard trigraph sequences. These are three-character |
4115 | sequences, all starting with @samp{??}, that are defined by ISO C to | |
4116 | stand for single characters. For example, @samp{??/} stands for | |
4117 | @samp{\}, so @samp{'??/n'} is a character constant for a newline. By | |
4118 | default, GCC ignores trigraphs, but in standard-conforming modes it | |
630d3d5a | 4119 | converts them. See the @option{-std} and @option{-ansi} options. |
e582248c NB |
4120 | |
4121 | The nine trigraph sequences are | |
4122 | @table @samp | |
4123 | @item ??( | |
aee96fe9 | 4124 | @expansion{} @samp{[} |
e582248c NB |
4125 | |
4126 | @item ??) | |
aee96fe9 | 4127 | @expansion{} @samp{]} |
e582248c NB |
4128 | |
4129 | @item ??< | |
aee96fe9 | 4130 | @expansion{} @samp{@{} |
e582248c NB |
4131 | |
4132 | @item ??> | |
aee96fe9 | 4133 | @expansion{} @samp{@}} |
e582248c NB |
4134 | |
4135 | @item ??= | |
aee96fe9 | 4136 | @expansion{} @samp{#} |
e582248c NB |
4137 | |
4138 | @item ??/ | |
aee96fe9 | 4139 | @expansion{} @samp{\} |
e582248c NB |
4140 | |
4141 | @item ??' | |
aee96fe9 | 4142 | @expansion{} @samp{^} |
e582248c NB |
4143 | |
4144 | @item ??! | |
aee96fe9 | 4145 | @expansion{} @samp{|} |
e582248c NB |
4146 | |
4147 | @item ??- | |
aee96fe9 | 4148 | @expansion{} @samp{~} |
e582248c NB |
4149 | |
4150 | @end table | |
4151 | ||
4152 | Trigraph support is not popular, so many compilers do not implement it | |
4153 | properly. Portable code should not rely on trigraphs being either | |
4154 | converted or ignored. | |
74291a4b | 4155 | |
aee96fe9 | 4156 | @item -Wp,@var{option} |
cd3bb277 | 4157 | @opindex Wp |
bedc7537 | 4158 | Pass @var{option} as an option to the preprocessor. If @var{option} |
74291a4b MM |
4159 | contains commas, it is split into multiple options at the commas. |
4160 | @end table | |
4161 | ||
4162 | @node Assembler Options | |
4163 | @section Passing Options to the Assembler | |
4164 | ||
4165 | @c prevent bad page break with this line | |
4166 | You can pass options to the assembler. | |
4167 | ||
2642624b | 4168 | @table @gcctabopt |
aee96fe9 | 4169 | @item -Wa,@var{option} |
cd3bb277 | 4170 | @opindex Wa |
74291a4b MM |
4171 | Pass @var{option} as an option to the assembler. If @var{option} |
4172 | contains commas, it is split into multiple options at the commas. | |
4173 | @end table | |
4174 | ||
4175 | @node Link Options | |
4176 | @section Options for Linking | |
4177 | @cindex link options | |
4178 | @cindex options, linking | |
4179 | ||
4180 | These options come into play when the compiler links object files into | |
4181 | an executable output file. They are meaningless if the compiler is | |
4182 | not doing a link step. | |
4183 | ||
2642624b | 4184 | @table @gcctabopt |
74291a4b MM |
4185 | @cindex file names |
4186 | @item @var{object-file-name} | |
4187 | A file name that does not end in a special recognized suffix is | |
4188 | considered to name an object file or library. (Object files are | |
4189 | distinguished from libraries by the linker according to the file | |
4190 | contents.) If linking is done, these object files are used as input | |
4191 | to the linker. | |
4192 | ||
4193 | @item -c | |
4194 | @itemx -S | |
4195 | @itemx -E | |
cd3bb277 JM |
4196 | @opindex c |
4197 | @opindex S | |
4198 | @opindex E | |
74291a4b MM |
4199 | If any of these options is used, then the linker is not run, and |
4200 | object file names should not be used as arguments. @xref{Overall | |
4201 | Options}. | |
4202 | ||
4203 | @cindex Libraries | |
4204 | @item -l@var{library} | |
4275c4c4 | 4205 | @itemx -l @var{library} |
cd3bb277 | 4206 | @opindex l |
4275c4c4 JS |
4207 | Search the library named @var{library} when linking. (The second |
4208 | alternative with the library as a separate argument is only for | |
4209 | POSIX compliance and is not recommended.) | |
74291a4b MM |
4210 | |
4211 | It makes a difference where in the command you write this option; the | |
4275c4c4 | 4212 | linker searches and processes libraries and object files in the order they |
74291a4b MM |
4213 | are specified. Thus, @samp{foo.o -lz bar.o} searches library @samp{z} |
4214 | after file @file{foo.o} but before @file{bar.o}. If @file{bar.o} refers | |
4215 | to functions in @samp{z}, those functions may not be loaded. | |
4216 | ||
4217 | The linker searches a standard list of directories for the library, | |
4218 | which is actually a file named @file{lib@var{library}.a}. The linker | |
4219 | then uses this file as if it had been specified precisely by name. | |
4220 | ||
4221 | The directories searched include several standard system directories | |
630d3d5a | 4222 | plus any that you specify with @option{-L}. |
74291a4b MM |
4223 | |
4224 | Normally the files found this way are library files---archive files | |
4225 | whose members are object files. The linker handles an archive file by | |
4226 | scanning through it for members which define symbols that have so far | |
4227 | been referenced but not defined. But if the file that is found is an | |
4228 | ordinary object file, it is linked in the usual fashion. The only | |
630d3d5a JM |
4229 | difference between using an @option{-l} option and specifying a file name |
4230 | is that @option{-l} surrounds @var{library} with @samp{lib} and @samp{.a} | |
74291a4b MM |
4231 | and searches several directories. |
4232 | ||
4233 | @item -lobjc | |
cd3bb277 | 4234 | @opindex lobjc |
630d3d5a | 4235 | You need this special case of the @option{-l} option in order to |
2147b154 | 4236 | link an Objective-C program. |
74291a4b MM |
4237 | |
4238 | @item -nostartfiles | |
cd3bb277 | 4239 | @opindex nostartfiles |
74291a4b | 4240 | Do not use the standard system startup files when linking. |
bedc7537 NC |
4241 | The standard system libraries are used normally, unless @option{-nostdlib} |
4242 | or @option{-nodefaultlibs} is used. | |
74291a4b MM |
4243 | |
4244 | @item -nodefaultlibs | |
cd3bb277 | 4245 | @opindex nodefaultlibs |
74291a4b MM |
4246 | Do not use the standard system libraries when linking. |
4247 | Only the libraries you specify will be passed to the linker. | |
bedc7537 | 4248 | The standard startup files are used normally, unless @option{-nostartfiles} |
4754172c | 4249 | is used. The compiler may generate calls to memcmp, memset, and memcpy |
c1030c7c | 4250 | for System V (and ISO C) environments or to bcopy and bzero for |
4754172c CM |
4251 | BSD environments. These entries are usually resolved by entries in |
4252 | libc. These entry points should be supplied through some other | |
4253 | mechanism when this option is specified. | |
74291a4b MM |
4254 | |
4255 | @item -nostdlib | |
cd3bb277 | 4256 | @opindex nostdlib |
74291a4b MM |
4257 | Do not use the standard system startup files or libraries when linking. |
4258 | No startup files and only the libraries you specify will be passed to | |
767094dd | 4259 | the linker. The compiler may generate calls to memcmp, memset, and memcpy |
c1030c7c | 4260 | for System V (and ISO C) environments or to bcopy and bzero for |
4754172c CM |
4261 | BSD environments. These entries are usually resolved by entries in |
4262 | libc. These entry points should be supplied through some other | |
4263 | mechanism when this option is specified. | |
74291a4b | 4264 | |
630d3d5a JM |
4265 | @cindex @option{-lgcc}, use with @option{-nostdlib} |
4266 | @cindex @option{-nostdlib} and unresolved references | |
4267 | @cindex unresolved references and @option{-nostdlib} | |
4268 | @cindex @option{-lgcc}, use with @option{-nodefaultlibs} | |
4269 | @cindex @option{-nodefaultlibs} and unresolved references | |
4270 | @cindex unresolved references and @option{-nodefaultlibs} | |
4271 | One of the standard libraries bypassed by @option{-nostdlib} and | |
4272 | @option{-nodefaultlibs} is @file{libgcc.a}, a library of internal subroutines | |
0c2d1a2a | 4273 | that GCC uses to overcome shortcomings of particular machines, or special |
74291a4b MM |
4274 | needs for some languages. |
4275 | @ifset INTERNALS | |
0c2d1a2a | 4276 | (@xref{Interface,,Interfacing to GCC Output}, for more discussion of |
74291a4b MM |
4277 | @file{libgcc.a}.) |
4278 | @end ifset | |
4279 | @ifclear INTERNALS | |
0c2d1a2a | 4280 | (@xref{Interface,,Interfacing to GCC Output,gcc.info,Porting GCC}, |
74291a4b MM |
4281 | for more discussion of @file{libgcc.a}.) |
4282 | @end ifclear | |
4283 | In most cases, you need @file{libgcc.a} even when you want to avoid | |
630d3d5a JM |
4284 | other standard libraries. In other words, when you specify @option{-nostdlib} |
4285 | or @option{-nodefaultlibs} you should usually specify @option{-lgcc} as well. | |
0c2d1a2a | 4286 | This ensures that you have no unresolved references to internal GCC |
74291a4b | 4287 | library subroutines. (For example, @samp{__main}, used to ensure C++ |
bedc7537 | 4288 | constructors will be called; @pxref{Collect2,,@command{collect2}}.) |
74291a4b MM |
4289 | |
4290 | @item -s | |
cd3bb277 | 4291 | @opindex s |
74291a4b MM |
4292 | Remove all symbol table and relocation information from the executable. |
4293 | ||
4294 | @item -static | |
cd3bb277 | 4295 | @opindex static |
74291a4b MM |
4296 | On systems that support dynamic linking, this prevents linking with the shared |
4297 | libraries. On other systems, this option has no effect. | |
4298 | ||
4299 | @item -shared | |
cd3bb277 | 4300 | @opindex shared |
74291a4b | 4301 | Produce a shared object which can then be linked with other objects to |
1d3b0e2c | 4302 | form an executable. Not all systems support this option. For predictable |
02f52e19 | 4303 | results, you must also specify the same set of options that were used to |
630d3d5a | 4304 | generate code (@option{-fpic}, @option{-fPIC}, or model suboptions) |
2642624b | 4305 | when you specify this option.@footnote{On some systems, @samp{gcc -shared} |
767094dd | 4306 | needs to build supplementary stub code for constructors to work. On |
2642624b | 4307 | multi-libbed systems, @samp{gcc -shared} must select the correct support |
1d3b0e2c | 4308 | libraries to link against. Failing to supply the correct flags may lead |
767094dd | 4309 | to subtle defects. Supplying them in cases where they are not necessary |
1d3b0e2c | 4310 | is innocuous.} |
74291a4b | 4311 | |
9db0819e RH |
4312 | @item -shared-libgcc |
4313 | @itemx -static-libgcc | |
cd3bb277 JM |
4314 | @opindex shared-libgcc |
4315 | @opindex static-libgcc | |
9db0819e RH |
4316 | On systems that provide @file{libgcc} as a shared library, these options |
4317 | force the use of either the shared or static version respectively. | |
4318 | If no shared version of @file{libgcc} was built when the compiler was | |
4319 | configured, these options have no effect. | |
4320 | ||
4321 | There are several situations in which an application should use the | |
4322 | shared @file{libgcc} instead of the static version. The most common | |
4323 | of these is when the application wishes to throw and catch exceptions | |
4324 | across different shared libraries. In that case, each of the libraries | |
4325 | as well as the application itself should use the shared @file{libgcc}. | |
4326 | ||
630d3d5a JM |
4327 | Therefore, whenever you specify the @option{-shared} option, the GCC |
4328 | driver automatically adds @option{-shared-libgcc}, unless you explicitly | |
4329 | specify @option{-static-libgcc}. The G++ driver automatically adds | |
4330 | @option{-shared-libgcc} when you build a main executable as well because | |
049f6ec9 MM |
4331 | for C++ programs that is typically the right thing to do. |
4332 | (Exception-handling will not work reliably otherwise.) | |
4333 | ||
4334 | However, when linking a main executable written in C, you must | |
630d3d5a | 4335 | explicitly say @option{-shared-libgcc} if you want to use the shared |
049f6ec9 | 4336 | @file{libgcc}. |
9db0819e | 4337 | |
74291a4b | 4338 | @item -symbolic |
cd3bb277 | 4339 | @opindex symbolic |
74291a4b MM |
4340 | Bind references to global symbols when building a shared object. Warn |
4341 | about any unresolved references (unless overridden by the link editor | |
4342 | option @samp{-Xlinker -z -Xlinker defs}). Only a few systems support | |
4343 | this option. | |
4344 | ||
4345 | @item -Xlinker @var{option} | |
cd3bb277 | 4346 | @opindex Xlinker |
74291a4b | 4347 | Pass @var{option} as an option to the linker. You can use this to |
0c2d1a2a | 4348 | supply system-specific linker options which GCC does not know how to |
74291a4b MM |
4349 | recognize. |
4350 | ||
4351 | If you want to pass an option that takes an argument, you must use | |
630d3d5a JM |
4352 | @option{-Xlinker} twice, once for the option and once for the argument. |
4353 | For example, to pass @option{-assert definitions}, you must write | |
74291a4b | 4354 | @samp{-Xlinker -assert -Xlinker definitions}. It does not work to write |
630d3d5a | 4355 | @option{-Xlinker "-assert definitions"}, because this passes the entire |
74291a4b MM |
4356 | string as a single argument, which is not what the linker expects. |
4357 | ||
aee96fe9 | 4358 | @item -Wl,@var{option} |
cd3bb277 | 4359 | @opindex Wl |
74291a4b MM |
4360 | Pass @var{option} as an option to the linker. If @var{option} contains |
4361 | commas, it is split into multiple options at the commas. | |
4362 | ||
4363 | @item -u @var{symbol} | |
cd3bb277 | 4364 | @opindex u |
74291a4b | 4365 | Pretend the symbol @var{symbol} is undefined, to force linking of |
630d3d5a | 4366 | library modules to define it. You can use @option{-u} multiple times with |
74291a4b MM |
4367 | different symbols to force loading of additional library modules. |
4368 | @end table | |
4369 | ||
4370 | @node Directory Options | |
4371 | @section Options for Directory Search | |
4372 | @cindex directory options | |
4373 | @cindex options, directory search | |
4374 | @cindex search path | |
4375 | ||
4376 | These options specify directories to search for header files, for | |
4377 | libraries and for parts of the compiler: | |
4378 | ||
2642624b | 4379 | @table @gcctabopt |
74291a4b | 4380 | @item -I@var{dir} |
cd3bb277 | 4381 | @opindex I |
861bb6c1 JL |
4382 | Add the directory @var{dir} to the head of the list of directories to be |
4383 | searched for header files. This can be used to override a system header | |
4384 | file, substituting your own version, since these directories are | |
d0a5eb32 RK |
4385 | searched before the system header file directories. However, you should |
4386 | not use this option to add directories that contain vendor-supplied | |
767094dd | 4387 | system header files (use @option{-isystem} for that). If you use more than |
630d3d5a | 4388 | one @option{-I} option, the directories are scanned in left-to-right |
74291a4b MM |
4389 | order; the standard system directories come after. |
4390 | ||
dbead49c NS |
4391 | If a standard system include directory, or a directory specified with |
4392 | @option{-isystem}, is also specified with @option{-I}, it will be | |
4393 | searched only in the position requested by @option{-I}. Also, it will | |
4394 | not be considered a system include directory. If that directory really | |
4395 | does contain system headers, there is a good chance that they will | |
4396 | break. For instance, if GCC's installation procedure edited the headers | |
4397 | in @file{/usr/include} to fix bugs, @samp{-I/usr/include} will cause the | |
4398 | original, buggy headers to be found instead of the corrected ones. GCC | |
4399 | will issue a warning when a system include directory is hidden in this | |
4400 | way. | |
4401 | ||
74291a4b | 4402 | @item -I- |
cd3bb277 | 4403 | @opindex I- |
630d3d5a | 4404 | Any directories you specify with @option{-I} options before the @option{-I-} |
74291a4b MM |
4405 | option are searched only for the case of @samp{#include "@var{file}"}; |
4406 | they are not searched for @samp{#include <@var{file}>}. | |
4407 | ||
630d3d5a JM |
4408 | If additional directories are specified with @option{-I} options after |
4409 | the @option{-I-}, these directories are searched for all @samp{#include} | |
4410 | directives. (Ordinarily @emph{all} @option{-I} directories are used | |
74291a4b MM |
4411 | this way.) |
4412 | ||
630d3d5a | 4413 | In addition, the @option{-I-} option inhibits the use of the current |
74291a4b MM |
4414 | directory (where the current input file came from) as the first search |
4415 | directory for @samp{#include "@var{file}"}. There is no way to | |
630d3d5a | 4416 | override this effect of @option{-I-}. With @option{-I.} you can specify |
74291a4b MM |
4417 | searching the directory which was current when the compiler was |
4418 | invoked. That is not exactly the same as what the preprocessor does | |
4419 | by default, but it is often satisfactory. | |
4420 | ||
630d3d5a JM |
4421 | @option{-I-} does not inhibit the use of the standard system directories |
4422 | for header files. Thus, @option{-I-} and @option{-nostdinc} are | |
74291a4b MM |
4423 | independent. |
4424 | ||
4425 | @item -L@var{dir} | |
cd3bb277 | 4426 | @opindex L |
74291a4b | 4427 | Add directory @var{dir} to the list of directories to be searched |
630d3d5a | 4428 | for @option{-l}. |
74291a4b MM |
4429 | |
4430 | @item -B@var{prefix} | |
cd3bb277 | 4431 | @opindex B |
74291a4b MM |
4432 | This option specifies where to find the executables, libraries, |
4433 | include files, and data files of the compiler itself. | |
4434 | ||
4435 | The compiler driver program runs one or more of the subprograms | |
4436 | @file{cpp}, @file{cc1}, @file{as} and @file{ld}. It tries | |
4437 | @var{prefix} as a prefix for each program it tries to run, both with and | |
4438 | without @samp{@var{machine}/@var{version}/} (@pxref{Target Options}). | |
4439 | ||
4440 | For each subprogram to be run, the compiler driver first tries the | |
630d3d5a | 4441 | @option{-B} prefix, if any. If that name is not found, or if @option{-B} |
74291a4b MM |
4442 | was not specified, the driver tries two standard prefixes, which are |
4443 | @file{/usr/lib/gcc/} and @file{/usr/local/lib/gcc-lib/}. If neither of | |
4444 | those results in a file name that is found, the unmodified program | |
4445 | name is searched for using the directories specified in your | |
bedc7537 | 4446 | @env{PATH} environment variable. |
74291a4b | 4447 | |
07804c3b NC |
4448 | The compiler will check to see if the path provided by the @option{-B} |
4449 | refers to a directory, and if necessary it will add a directory | |
4450 | separator character at the end of the path. | |
4451 | ||
630d3d5a | 4452 | @option{-B} prefixes that effectively specify directory names also apply |
74291a4b | 4453 | to libraries in the linker, because the compiler translates these |
630d3d5a | 4454 | options into @option{-L} options for the linker. They also apply to |
74291a4b | 4455 | includes files in the preprocessor, because the compiler translates these |
630d3d5a | 4456 | options into @option{-isystem} options for the preprocessor. In this case, |
74291a4b MM |
4457 | the compiler appends @samp{include} to the prefix. |
4458 | ||
4459 | The run-time support file @file{libgcc.a} can also be searched for using | |
630d3d5a | 4460 | the @option{-B} prefix, if needed. If it is not found there, the two |
74291a4b MM |
4461 | standard prefixes above are tried, and that is all. The file is left |
4462 | out of the link if it is not found by those means. | |
4463 | ||
630d3d5a | 4464 | Another way to specify a prefix much like the @option{-B} prefix is to use |
bedc7537 | 4465 | the environment variable @env{GCC_EXEC_PREFIX}. @xref{Environment |
74291a4b | 4466 | Variables}. |
861bb6c1 | 4467 | |
07804c3b | 4468 | As a special kludge, if the path provided by @option{-B} is |
bf4eebe0 NC |
4469 | @file{[dir/]stage@var{N}/}, where @var{N} is a number in the range 0 to |
4470 | 9, then it will be replaced by @file{[dir/]include}. This is to help | |
7dac2f89 | 4471 | with boot-strapping the compiler. |
07804c3b | 4472 | |
861bb6c1 | 4473 | @item -specs=@var{file} |
cd3bb277 | 4474 | @opindex specs |
861bb6c1 JL |
4475 | Process @var{file} after the compiler reads in the standard @file{specs} |
4476 | file, in order to override the defaults that the @file{gcc} driver | |
4477 | program uses when determining what switches to pass to @file{cc1}, | |
4478 | @file{cc1plus}, @file{as}, @file{ld}, etc. More than one | |
630d3d5a | 4479 | @option{-specs=@var{file}} can be specified on the command line, and they |
861bb6c1 | 4480 | are processed in order, from left to right. |
74291a4b MM |
4481 | @end table |
4482 | ||
ee457005 JM |
4483 | @c man end |
4484 | ||
a743d340 NC |
4485 | @node Spec Files |
4486 | @section Specifying subprocesses and the switches to pass to them | |
4487 | @cindex Spec Files | |
bedc7537 | 4488 | @command{gcc} is a driver program. It performs its job by invoking a |
a743d340 NC |
4489 | sequence of other programs to do the work of compiling, assembling and |
4490 | linking. GCC interprets its command-line parameters and uses these to | |
4491 | deduce which programs it should invoke, and which command-line options | |
4492 | it ought to place on their command lines. This behaviour is controlled | |
4493 | by @dfn{spec strings}. In most cases there is one spec string for each | |
4494 | program that GCC can invoke, but a few programs have multiple spec | |
4495 | strings to control their behaviour. The spec strings built into GCC can | |
630d3d5a | 4496 | be overridden by using the @option{-specs=} command-line switch to specify |
a743d340 NC |
4497 | a spec file. |
4498 | ||
4499 | @dfn{Spec files} are plaintext files that are used to construct spec | |
4500 | strings. They consist of a sequence of directives separated by blank | |
4501 | lines. The type of directive is determined by the first non-whitespace | |
4502 | character on the line and it can be one of the following: | |
4503 | ||
4504 | @table @code | |
4505 | @item %@var{command} | |
4506 | Issues a @var{command} to the spec file processor. The commands that can | |
02f52e19 | 4507 | appear here are: |
a743d340 NC |
4508 | |
4509 | @table @code | |
4510 | @item %include <@var{file}> | |
4511 | @cindex %include | |
4512 | Search for @var{file} and insert its text at the current point in the | |
4513 | specs file. | |
4514 | ||
4515 | @item %include_noerr <@var{file}> | |
4516 | @cindex %include_noerr | |
4517 | Just like @samp{%include}, but do not generate an error message if the include | |
4518 | file cannot be found. | |
4519 | ||
4520 | @item %rename @var{old_name} @var{new_name} | |
4521 | @cindex %rename | |
4522 | Rename the spec string @var{old_name} to @var{new_name}. | |
4523 | ||
4524 | @end table | |
4525 | ||
4526 | @item *[@var{spec_name}]: | |
4527 | This tells the compiler to create, override or delete the named spec | |
4528 | string. All lines after this directive up to the next directive or | |
4529 | blank line are considered to be the text for the spec string. If this | |
4530 | results in an empty string then the spec will be deleted. (Or, if the | |
4531 | spec did not exist, then nothing will happened.) Otherwise, if the spec | |
4532 | does not currently exist a new spec will be created. If the spec does | |
4533 | exist then its contents will be overridden by the text of this | |
4534 | directive, unless the first character of that text is the @samp{+} | |
4535 | character, in which case the text will be appended to the spec. | |
4536 | ||
4537 | @item [@var{suffix}]: | |
4538 | Creates a new @samp{[@var{suffix}] spec} pair. All lines after this directive | |
4539 | and up to the next directive or blank line are considered to make up the | |
02f52e19 | 4540 | spec string for the indicated suffix. When the compiler encounters an |
a743d340 NC |
4541 | input file with the named suffix, it will processes the spec string in |
4542 | order to work out how to compile that file. For example: | |
4543 | ||
4544 | @smallexample | |
4545 | .ZZ: | |
4546 | z-compile -input %i | |
4547 | @end smallexample | |
4548 | ||
4549 | This says that any input file whose name ends in @samp{.ZZ} should be | |
4550 | passed to the program @samp{z-compile}, which should be invoked with the | |
630d3d5a | 4551 | command-line switch @option{-input} and with the result of performing the |
a743d340 NC |
4552 | @samp{%i} substitution. (See below.) |
4553 | ||
4554 | As an alternative to providing a spec string, the text that follows a | |
4555 | suffix directive can be one of the following: | |
4556 | ||
4557 | @table @code | |
4558 | @item @@@var{language} | |
4559 | This says that the suffix is an alias for a known @var{language}. This is | |
bedc7537 | 4560 | similar to using the @option{-x} command-line switch to GCC to specify a |
a743d340 NC |
4561 | language explicitly. For example: |
4562 | ||
4563 | @smallexample | |
4564 | .ZZ: | |
4565 | @@c++ | |
4566 | @end smallexample | |
4567 | ||
4568 | Says that .ZZ files are, in fact, C++ source files. | |
4569 | ||
4570 | @item #@var{name} | |
4571 | This causes an error messages saying: | |
4572 | ||
4573 | @smallexample | |
4574 | @var{name} compiler not installed on this system. | |
4575 | @end smallexample | |
4576 | @end table | |
4577 | ||
4578 | GCC already has an extensive list of suffixes built into it. | |
4579 | This directive will add an entry to the end of the list of suffixes, but | |
4580 | since the list is searched from the end backwards, it is effectively | |
4581 | possible to override earlier entries using this technique. | |
4582 | ||
4583 | @end table | |
4584 | ||
4585 | GCC has the following spec strings built into it. Spec files can | |
4586 | override these strings or create their own. Note that individual | |
02f52e19 | 4587 | targets can also add their own spec strings to this list. |
a743d340 NC |
4588 | |
4589 | @smallexample | |
4590 | asm Options to pass to the assembler | |
4591 | asm_final Options to pass to the assembler post-processor | |
4592 | cpp Options to pass to the C preprocessor | |
4593 | cc1 Options to pass to the C compiler | |
4594 | cc1plus Options to pass to the C++ compiler | |
4595 | endfile Object files to include at the end of the link | |
4596 | link Options to pass to the linker | |
4597 | lib Libraries to include on the command line to the linker | |
4598 | libgcc Decides which GCC support library to pass to the linker | |
4599 | linker Sets the name of the linker | |
4600 | predefines Defines to be passed to the C preprocessor | |
310668e8 JM |
4601 | signed_char Defines to pass to CPP to say whether @code{char} is signed |
4602 | by default | |
a743d340 NC |
4603 | startfile Object files to include at the start of the link |
4604 | @end smallexample | |
4605 | ||
4606 | Here is a small example of a spec file: | |
4607 | ||
4608 | @smallexample | |
4609 | %rename lib old_lib | |
4610 | ||
4611 | *lib: | |
4612 | --start-group -lgcc -lc -leval1 --end-group %(old_lib) | |
4613 | @end smallexample | |
4614 | ||
4615 | This example renames the spec called @samp{lib} to @samp{old_lib} and | |
4616 | then overrides the previous definition of @samp{lib} with a new one. | |
4617 | The new definition adds in some extra command-line options before | |
4618 | including the text of the old definition. | |
4619 | ||
4620 | @dfn{Spec strings} are a list of command-line options to be passed to their | |
4621 | corresponding program. In addition, the spec strings can contain | |
4622 | @samp{%}-prefixed sequences to substitute variable text or to | |
4623 | conditionally insert text into the command line. Using these constructs | |
4624 | it is possible to generate quite complex command lines. | |
4625 | ||
4626 | Here is a table of all defined @samp{%}-sequences for spec | |
4627 | strings. Note that spaces are not generated automatically around the | |
4628 | results of expanding these sequences. Therefore you can concatenate them | |
02f52e19 | 4629 | together or combine them with constant text in a single argument. |
a743d340 NC |
4630 | |
4631 | @table @code | |
4632 | @item %% | |
4633 | Substitute one @samp{%} into the program name or argument. | |
4634 | ||
4635 | @item %i | |
4636 | Substitute the name of the input file being processed. | |
4637 | ||
4638 | @item %b | |
4639 | Substitute the basename of the input file being processed. | |
4640 | This is the substring up to (and not including) the last period | |
4641 | and not including the directory. | |
4642 | ||
371e300b NC |
4643 | @item %B |
4644 | This is the same as @samp{%b}, but include the file suffix (text after | |
4645 | the last period). | |
4646 | ||
a743d340 NC |
4647 | @item %d |
4648 | Marks the argument containing or following the @samp{%d} as a | |
4649 | temporary file name, so that that file will be deleted if GCC exits | |
4650 | successfully. Unlike @samp{%g}, this contributes no text to the | |
02f52e19 | 4651 | argument. |
a743d340 NC |
4652 | |
4653 | @item %g@var{suffix} | |
4654 | Substitute a file name that has suffix @var{suffix} and is chosen | |
4655 | once per compilation, and mark the argument in the same way as | |
4656 | @samp{%d}. To reduce exposure to denial-of-service attacks, the file | |
02f52e19 | 4657 | name is now chosen in a way that is hard to predict even when previously |
695ac33f | 4658 | chosen file names are known. For example, @samp{%g.s @dots{} %g.o @dots{} %g.s} |
a743d340 NC |
4659 | might turn into @samp{ccUVUUAU.s ccXYAXZ12.o ccUVUUAU.s}. @var{suffix} matches |
4660 | the regexp @samp{[.A-Za-z]*} or the special string @samp{%O}, which is | |
4661 | treated exactly as if @samp{%O} had been preprocessed. Previously, @samp{%g} | |
4662 | was simply substituted with a file name chosen once per compilation, | |
4663 | without regard to any appended suffix (which was therefore treated | |
4664 | just like ordinary text), making such attacks more likely to succeed. | |
4665 | ||
4666 | @item %u@var{suffix} | |
4667 | Like @samp{%g}, but generates a new temporary file name even if | |
4668 | @samp{%u@var{suffix}} was already seen. | |
4669 | ||
4670 | @item %U@var{suffix} | |
4671 | Substitutes the last file name generated with @samp{%u@var{suffix}}, generating a | |
4672 | new one if there is no such last file name. In the absence of any | |
4673 | @samp{%u@var{suffix}}, this is just like @samp{%g@var{suffix}}, except they don't share | |
695ac33f | 4674 | the same suffix @emph{space}, so @samp{%g.s @dots{} %U.s @dots{} %g.s @dots{} %U.s} |
a743d340 NC |
4675 | would involve the generation of two distinct file names, one |
4676 | for each @samp{%g.s} and another for each @samp{%U.s}. Previously, @samp{%U} was | |
4677 | simply substituted with a file name chosen for the previous @samp{%u}, | |
4678 | without regard to any appended suffix. | |
4679 | ||
371e300b | 4680 | @item %j@var{SUFFIX} |
aee96fe9 | 4681 | Substitutes the name of the @code{HOST_BIT_BUCKET}, if any, and if it is |
371e300b NC |
4682 | writable, and if save-temps is off; otherwise, substitute the name |
4683 | of a temporary file, just like @samp{%u}. This temporary file is not | |
4684 | meant for communication between processes, but rather as a junk | |
4685 | disposal mechanism. | |
4686 | ||
4687 | @item %.@var{SUFFIX} | |
4688 | Substitutes @var{.SUFFIX} for the suffixes of a matched switch's args | |
767094dd | 4689 | when it is subsequently output with @samp{%*}. @var{SUFFIX} is |
371e300b NC |
4690 | terminated by the next space or %. |
4691 | ||
a743d340 NC |
4692 | @item %w |
4693 | Marks the argument containing or following the @samp{%w} as the | |
4694 | designated output file of this compilation. This puts the argument | |
4695 | into the sequence of arguments that @samp{%o} will substitute later. | |
4696 | ||
4697 | @item %o | |
4698 | Substitutes the names of all the output files, with spaces | |
4699 | automatically placed around them. You should write spaces | |
4700 | around the @samp{%o} as well or the results are undefined. | |
4701 | @samp{%o} is for use in the specs for running the linker. | |
4702 | Input files whose names have no recognized suffix are not compiled | |
4703 | at all, but they are included among the output files, so they will | |
4704 | be linked. | |
4705 | ||
4706 | @item %O | |
4707 | Substitutes the suffix for object files. Note that this is | |
4708 | handled specially when it immediately follows @samp{%g, %u, or %U}, | |
4709 | because of the need for those to form complete file names. The | |
4710 | handling is such that @samp{%O} is treated exactly as if it had already | |
4711 | been substituted, except that @samp{%g, %u, and %U} do not currently | |
4712 | support additional @var{suffix} characters following @samp{%O} as they would | |
4713 | following, for example, @samp{.o}. | |
4714 | ||
4715 | @item %p | |
4716 | Substitutes the standard macro predefinitions for the | |
4717 | current target machine. Use this when running @code{cpp}. | |
4718 | ||
4719 | @item %P | |
4720 | Like @samp{%p}, but puts @samp{__} before and after the name of each | |
4721 | predefined macro, except for macros that start with @samp{__} or with | |
c1030c7c | 4722 | @samp{_@var{L}}, where @var{L} is an uppercase letter. This is for ISO |
161d7b59 | 4723 | C@. |
a743d340 NC |
4724 | |
4725 | @item %I | |
aee96fe9 | 4726 | Substitute a @option{-iprefix} option made from @env{GCC_EXEC_PREFIX}. |
a743d340 NC |
4727 | |
4728 | @item %s | |
4729 | Current argument is the name of a library or startup file of some sort. | |
4730 | Search for that file in a standard list of directories and substitute | |
02f52e19 | 4731 | the full name found. |
a743d340 NC |
4732 | |
4733 | @item %e@var{str} | |
4734 | Print @var{str} as an error message. @var{str} is terminated by a newline. | |
4735 | Use this when inconsistent options are detected. | |
4736 | ||
4737 | @item %| | |
4738 | Output @samp{-} if the input for the current command is coming from a pipe. | |
4739 | ||
4740 | @item %(@var{name}) | |
4741 | Substitute the contents of spec string @var{name} at this point. | |
4742 | ||
4743 | @item %[@var{name}] | |
630d3d5a | 4744 | Like @samp{%(@dots{})} but put @samp{__} around @option{-D} arguments. |
a743d340 NC |
4745 | |
4746 | @item %x@{@var{option}@} | |
4747 | Accumulate an option for @samp{%X}. | |
4748 | ||
4749 | @item %X | |
630d3d5a | 4750 | Output the accumulated linker options specified by @option{-Wl} or a @samp{%x} |
a743d340 NC |
4751 | spec string. |
4752 | ||
4753 | @item %Y | |
630d3d5a | 4754 | Output the accumulated assembler options specified by @option{-Wa}. |
a743d340 NC |
4755 | |
4756 | @item %Z | |
630d3d5a | 4757 | Output the accumulated preprocessor options specified by @option{-Wp}. |
a743d340 NC |
4758 | |
4759 | @item %v1 | |
161d7b59 | 4760 | Substitute the major version number of GCC@. |
a743d340 NC |
4761 | (For version 2.9.5, this is 2.) |
4762 | ||
4763 | @item %v2 | |
161d7b59 | 4764 | Substitute the minor version number of GCC@. |
a743d340 NC |
4765 | (For version 2.9.5, this is 9.) |
4766 | ||
371e300b | 4767 | @item %v3 |
161d7b59 | 4768 | Substitute the patch level number of GCC@. |
371e300b NC |
4769 | (For version 2.9.5, this is 5.) |
4770 | ||
a743d340 NC |
4771 | @item %a |
4772 | Process the @code{asm} spec. This is used to compute the | |
4773 | switches to be passed to the assembler. | |
4774 | ||
4775 | @item %A | |
4776 | Process the @code{asm_final} spec. This is a spec string for | |
4777 | passing switches to an assembler post-processor, if such a program is | |
4778 | needed. | |
4779 | ||
4780 | @item %l | |
4781 | Process the @code{link} spec. This is the spec for computing the | |
4782 | command line passed to the linker. Typically it will make use of the | |
4783 | @samp{%L %G %S %D and %E} sequences. | |
4784 | ||
4785 | @item %D | |
630d3d5a | 4786 | Dump out a @option{-L} option for each directory that GCC believes might |
a743d340 | 4787 | contain startup files. If the target supports multilibs then the |
02f52e19 | 4788 | current multilib directory will be prepended to each of these paths. |
a743d340 | 4789 | |
371e300b | 4790 | @item %M |
c771326b | 4791 | Output the multilib directory with directory separators replaced with |
695ac33f JM |
4792 | @samp{_}. If multilib directories are not set, or the multilib directory is |
4793 | @file{.} then this option emits nothing. | |
371e300b | 4794 | |
a743d340 NC |
4795 | @item %L |
4796 | Process the @code{lib} spec. This is a spec string for deciding which | |
02f52e19 | 4797 | libraries should be included on the command line to the linker. |
a743d340 NC |
4798 | |
4799 | @item %G | |
4800 | Process the @code{libgcc} spec. This is a spec string for deciding | |
02f52e19 | 4801 | which GCC support library should be included on the command line to the linker. |
a743d340 NC |
4802 | |
4803 | @item %S | |
4804 | Process the @code{startfile} spec. This is a spec for deciding which | |
4805 | object files should be the first ones passed to the linker. Typically | |
02f52e19 | 4806 | this might be a file named @file{crt0.o}. |
a743d340 NC |
4807 | |
4808 | @item %E | |
4809 | Process the @code{endfile} spec. This is a spec string that specifies | |
02f52e19 | 4810 | the last object files that will be passed to the linker. |
a743d340 NC |
4811 | |
4812 | @item %C | |
4813 | Process the @code{cpp} spec. This is used to construct the arguments | |
4814 | to be passed to the C preprocessor. | |
4815 | ||
4816 | @item %c | |
4817 | Process the @code{signed_char} spec. This is intended to be used | |
02f52e19 | 4818 | to tell cpp whether a char is signed. It typically has the definition: |
a743d340 NC |
4819 | @smallexample |
4820 | %@{funsigned-char:-D__CHAR_UNSIGNED__@} | |
4821 | @end smallexample | |
4822 | ||
4823 | @item %1 | |
4824 | Process the @code{cc1} spec. This is used to construct the options to be | |
4825 | passed to the actual C compiler (@samp{cc1}). | |
4826 | ||
4827 | @item %2 | |
4828 | Process the @code{cc1plus} spec. This is used to construct the options to be | |
4829 | passed to the actual C++ compiler (@samp{cc1plus}). | |
4830 | ||
4831 | @item %* | |
4832 | Substitute the variable part of a matched option. See below. | |
4833 | Note that each comma in the substituted string is replaced by | |
4834 | a single space. | |
4835 | ||
4836 | @item %@{@code{S}@} | |
161d7b59 | 4837 | Substitutes the @code{-S} switch, if that switch was given to GCC@. |
a743d340 NC |
4838 | If that switch was not specified, this substitutes nothing. Note that |
4839 | the leading dash is omitted when specifying this option, and it is | |
4840 | automatically inserted if the substitution is performed. Thus the spec | |
630d3d5a JM |
4841 | string @samp{%@{foo@}} would match the command-line option @option{-foo} |
4842 | and would output the command line option @option{-foo}. | |
a743d340 NC |
4843 | |
4844 | @item %W@{@code{S}@} | |
4845 | Like %@{@code{S}@} but mark last argument supplied within as a file to be | |
02f52e19 | 4846 | deleted on failure. |
a743d340 NC |
4847 | |
4848 | @item %@{@code{S}*@} | |
4849 | Substitutes all the switches specified to GCC whose names start | |
4850 | with @code{-S}, but which also take an argument. This is used for | |
695ac33f | 4851 | switches like @option{-o}, @option{-D}, @option{-I}, etc. |
630d3d5a | 4852 | GCC considers @option{-o foo} as being |
a743d340 | 4853 | one switch whose names starts with @samp{o}. %@{o*@} would substitute this |
02f52e19 | 4854 | text, including the space. Thus two arguments would be generated. |
a743d340 NC |
4855 | |
4856 | @item %@{^@code{S}*@} | |
4857 | Like %@{@code{S}*@}, but don't put a blank between a switch and its | |
4858 | argument. Thus %@{^o*@} would only generate one argument, not two. | |
4859 | ||
371e300b NC |
4860 | @item %@{@code{S}*&@code{T}*@} |
4861 | Like %@{@code{S}*@}, but preserve order of @code{S} and @code{T} options | |
4862 | (the order of @code{S} and @code{T} in the spec is not significant). | |
4863 | There can be any number of ampersand-separated variables; for each the | |
4864 | wild card is optional. Useful for CPP as @samp{%@{D*&U*&A*@}}. | |
4865 | ||
d630442f | 4866 | @item %@{<@code{S}@} |
695ac33f | 4867 | Remove all occurrences of @code{-S} from the command line. Note---this |
d630442f | 4868 | command is position dependent. @samp{%} commands in the spec string |
50c57e7b | 4869 | before this option will see @code{-S}, @samp{%} commands in the spec |
d630442f NC |
4870 | string after this option will not. |
4871 | ||
a743d340 NC |
4872 | @item %@{@code{S}*:@code{X}@} |
4873 | Substitutes @code{X} if one or more switches whose names start with | |
161d7b59 | 4874 | @code{-S} are specified to GCC@. Note that the tail part of the |
e979f9e8 | 4875 | @code{-S} option (i.e.@: the part matched by the @samp{*}) will be substituted |
02f52e19 | 4876 | for each occurrence of @samp{%*} within @code{X}. |
a743d340 NC |
4877 | |
4878 | @item %@{@code{S}:@code{X}@} | |
161d7b59 | 4879 | Substitutes @code{X}, but only if the @samp{-S} switch was given to GCC@. |
a743d340 NC |
4880 | |
4881 | @item %@{!@code{S}:@code{X}@} | |
161d7b59 | 4882 | Substitutes @code{X}, but only if the @samp{-S} switch was @emph{not} given to GCC@. |
a743d340 NC |
4883 | |
4884 | @item %@{|@code{S}:@code{X}@} | |
4885 | Like %@{@code{S}:@code{X}@}, but if no @code{S} switch, substitute @samp{-}. | |
4886 | ||
4887 | @item %@{|!@code{S}:@code{X}@} | |
4888 | Like %@{!@code{S}:@code{X}@}, but if there is an @code{S} switch, substitute @samp{-}. | |
4889 | ||
4890 | @item %@{.@code{S}:@code{X}@} | |
4891 | Substitutes @code{X}, but only if processing a file with suffix @code{S}. | |
4892 | ||
4893 | @item %@{!.@code{S}:@code{X}@} | |
4894 | Substitutes @code{X}, but only if @emph{not} processing a file with suffix @code{S}. | |
4895 | ||
4896 | @item %@{@code{S}|@code{P}:@code{X}@} | |
161d7b59 | 4897 | Substitutes @code{X} if either @code{-S} or @code{-P} was given to GCC@. This may be |
a743d340 NC |
4898 | combined with @samp{!} and @samp{.} sequences as well, although they |
4899 | have a stronger binding than the @samp{|}. For example a spec string | |
4900 | like this: | |
4901 | ||
4902 | @smallexample | |
4903 | %@{.c:-foo@} %@{!.c:-bar@} %@{.c|d:-baz@} %@{!.c|d:-boggle@} | |
4904 | @end smallexample | |
4905 | ||
4906 | will output the following command-line options from the following input | |
4907 | command-line options: | |
4908 | ||
4909 | @smallexample | |
4910 | fred.c -foo -baz | |
4911 | jim.d -bar -boggle | |
4912 | -d fred.c -foo -baz -boggle | |
4913 | -d jim.d -bar -baz -boggle | |
4914 | @end smallexample | |
4915 | ||
4916 | @end table | |
4917 | ||
4918 | The conditional text @code{X} in a %@{@code{S}:@code{X}@} or | |
4919 | %@{!@code{S}:@code{X}@} construct may contain other nested @samp{%} constructs | |
4920 | or spaces, or even newlines. They are processed as usual, as described | |
02f52e19 | 4921 | above. |
a743d340 | 4922 | |
695ac33f JM |
4923 | The @option{-O}, @option{-f}, @option{-m}, and @option{-W} |
4924 | switches are handled specifically in these | |
630d3d5a JM |
4925 | constructs. If another value of @option{-O} or the negated form of a @option{-f}, @option{-m}, or |
4926 | @option{-W} switch is found later in the command line, the earlier switch | |
a743d340 NC |
4927 | value is ignored, except with @{@code{S}*@} where @code{S} is just one |
4928 | letter, which passes all matching options. | |
4929 | ||
4930 | The character @samp{|} at the beginning of the predicate text is used to indicate | |
630d3d5a | 4931 | that a command should be piped to the following command, but only if @option{-pipe} |
a743d340 NC |
4932 | is specified. |
4933 | ||
4934 | It is built into GCC which switches take arguments and which do not. | |
4935 | (You might think it would be useful to generalize this to allow each | |
4936 | compiler's spec to say which switches take arguments. But this cannot | |
4937 | be done in a consistent fashion. GCC cannot even decide which input | |
4938 | files have been specified without knowing which switches take arguments, | |
4939 | and it must know which input files to compile in order to tell which | |
02f52e19 | 4940 | compilers to run). |
a743d340 | 4941 | |
630d3d5a | 4942 | GCC also knows implicitly that arguments starting in @option{-l} are to be |
a743d340 NC |
4943 | treated as compiler output files, and passed to the linker in their |
4944 | proper position among the other output files. | |
4945 | ||
ee457005 JM |
4946 | @c man begin OPTIONS |
4947 | ||
74291a4b MM |
4948 | @node Target Options |
4949 | @section Specifying Target Machine and Compiler Version | |
4950 | @cindex target options | |
4951 | @cindex cross compiling | |
4952 | @cindex specifying machine version | |
4953 | @cindex specifying compiler version and target machine | |
4954 | @cindex compiler version, specifying | |
4955 | @cindex target machine, specifying | |
4956 | ||
0c2d1a2a | 4957 | By default, GCC compiles code for the same type of machine that you |
74291a4b MM |
4958 | are using. However, it can also be installed as a cross-compiler, to |
4959 | compile for some other type of machine. In fact, several different | |
0c2d1a2a | 4960 | configurations of GCC, for different target machines, can be |
74291a4b | 4961 | installed side by side. Then you specify which one to use with the |
630d3d5a | 4962 | @option{-b} option. |
74291a4b | 4963 | |
0c2d1a2a | 4964 | In addition, older and newer versions of GCC can be installed side |
74291a4b MM |
4965 | by side. One of them (probably the newest) will be the default, but |
4966 | you may sometimes wish to use another. | |
4967 | ||
2642624b | 4968 | @table @gcctabopt |
74291a4b | 4969 | @item -b @var{machine} |
cd3bb277 | 4970 | @opindex b |
74291a4b | 4971 | The argument @var{machine} specifies the target machine for compilation. |
0c2d1a2a | 4972 | This is useful when you have installed GCC as a cross-compiler. |
74291a4b MM |
4973 | |
4974 | The value to use for @var{machine} is the same as was specified as the | |
0c2d1a2a | 4975 | machine type when configuring GCC as a cross-compiler. For |
74291a4b MM |
4976 | example, if a cross-compiler was configured with @samp{configure |
4977 | i386v}, meaning to compile for an 80386 running System V, then you | |
630d3d5a | 4978 | would specify @option{-b i386v} to run that cross compiler. |
74291a4b | 4979 | |
630d3d5a | 4980 | When you do not specify @option{-b}, it normally means to compile for |
74291a4b MM |
4981 | the same type of machine that you are using. |
4982 | ||
4983 | @item -V @var{version} | |
cd3bb277 | 4984 | @opindex V |
0c2d1a2a | 4985 | The argument @var{version} specifies which version of GCC to run. |
74291a4b | 4986 | This is useful when multiple versions are installed. For example, |
0c2d1a2a | 4987 | @var{version} might be @samp{2.0}, meaning to run GCC version 2.0. |
74291a4b | 4988 | |
630d3d5a | 4989 | The default version, when you do not specify @option{-V}, is the last |
0c2d1a2a | 4990 | version of GCC that you installed. |
74291a4b MM |
4991 | @end table |
4992 | ||
630d3d5a | 4993 | The @option{-b} and @option{-V} options actually work by controlling part of |
74291a4b | 4994 | the file name used for the executable files and libraries used for |
0c2d1a2a | 4995 | compilation. A given version of GCC, for a given target machine, is |
bd819a4a | 4996 | normally kept in the directory @file{/usr/local/lib/gcc-lib/@var{machine}/@var{version}}. |
74291a4b | 4997 | |
630d3d5a | 4998 | Thus, sites can customize the effect of @option{-b} or @option{-V} either by |
74291a4b MM |
4999 | changing the names of these directories or adding alternate names (or |
5000 | symbolic links). If in directory @file{/usr/local/lib/gcc-lib/} the | |
630d3d5a JM |
5001 | file @file{80386} is a link to the file @file{i386v}, then @option{-b |
5002 | 80386} becomes an alias for @option{-b i386v}. | |
74291a4b | 5003 | |
630d3d5a | 5004 | In one respect, the @option{-b} or @option{-V} do not completely change |
bedc7537 | 5005 | to a different compiler: the top-level driver program @command{gcc} |
74291a4b MM |
5006 | that you originally invoked continues to run and invoke the other |
5007 | executables (preprocessor, compiler per se, assembler and linker) | |
5008 | that do the real work. However, since no real work is done in the | |
5009 | driver program, it usually does not matter that the driver program | |
8c7b74b9 JM |
5010 | in use is not the one for the specified target. It is common for the |
5011 | interface to the other executables to change incompatibly between | |
5012 | compiler versions, so unless the version specified is very close to that | |
630d3d5a JM |
5013 | of the driver (for example, @option{-V 3.0} with a driver program from GCC |
5014 | version 3.0.1), use of @option{-V} may not work; for example, using | |
5015 | @option{-V 2.95.2} will not work with a driver program from GCC 3.0. | |
74291a4b MM |
5016 | |
5017 | The only way that the driver program depends on the target machine is | |
5018 | in the parsing and handling of special machine-specific options. | |
5019 | However, this is controlled by a file which is found, along with the | |
5020 | other executables, in the directory for the specified version and | |
5021 | target machine. As a result, a single installed driver program adapts | |
8c7b74b9 JM |
5022 | to any specified target machine, and sufficiently similar compiler |
5023 | versions. | |
74291a4b MM |
5024 | |
5025 | The driver program executable does control one significant thing, | |
5026 | however: the default version and target machine. Therefore, you can | |
5027 | install different instances of the driver program, compiled for | |
5028 | different targets or versions, under different names. | |
5029 | ||
bedc7537 NC |
5030 | For example, if the driver for version 2.0 is installed as @command{ogcc} |
5031 | and that for version 2.1 is installed as @command{gcc}, then the command | |
5032 | @command{gcc} will use version 2.1 by default, while @command{ogcc} will use | |
74291a4b | 5033 | 2.0 by default. However, you can choose either version with either |
630d3d5a | 5034 | command with the @option{-V} option. |
74291a4b MM |
5035 | |
5036 | @node Submodel Options | |
5037 | @section Hardware Models and Configurations | |
5038 | @cindex submodel options | |
5039 | @cindex specifying hardware config | |
5040 | @cindex hardware models and configurations, specifying | |
5041 | @cindex machine dependent options | |
5042 | ||
630d3d5a | 5043 | Earlier we discussed the standard option @option{-b} which chooses among |
74291a4b | 5044 | different installed compilers for completely different target |
8aeea6e6 | 5045 | machines, such as VAX vs.@: 68000 vs.@: 80386. |
74291a4b MM |
5046 | |
5047 | In addition, each of these target machine types can have its own | |
5048 | special options, starting with @samp{-m}, to choose among various | |
5049 | hardware models or configurations---for example, 68010 vs 68020, | |
5050 | floating coprocessor or none. A single installed version of the | |
5051 | compiler can compile for any model or configuration, according to the | |
5052 | options specified. | |
5053 | ||
5054 | Some configurations of the compiler also support additional special | |
5055 | options, usually for compatibility with other compilers on the same | |
5056 | platform. | |
5057 | ||
5058 | @ifset INTERNALS | |
5059 | These options are defined by the macro @code{TARGET_SWITCHES} in the | |
5060 | machine description. The default for the options is also defined by | |
5061 | that macro, which enables you to change the defaults. | |
5062 | @end ifset | |
5063 | ||
5064 | @menu | |
5065 | * M680x0 Options:: | |
2856c3e3 | 5066 | * M68hc1x Options:: |
74291a4b MM |
5067 | * VAX Options:: |
5068 | * SPARC Options:: | |
5069 | * Convex Options:: | |
5070 | * AMD29K Options:: | |
5071 | * ARM Options:: | |
ecff22ab | 5072 | * MN10200 Options:: |
6d6d0fa0 | 5073 | * MN10300 Options:: |
861bb6c1 | 5074 | * M32R/D Options:: |
74291a4b MM |
5075 | * M88K Options:: |
5076 | * RS/6000 and PowerPC Options:: | |
5077 | * RT Options:: | |
5078 | * MIPS Options:: | |
5079 | * i386 Options:: | |
5080 | * HPPA Options:: | |
5081 | * Intel 960 Options:: | |
5082 | * DEC Alpha Options:: | |
5083 | * Clipper Options:: | |
5084 | * H8/300 Options:: | |
5085 | * SH Options:: | |
5086 | * System V Options:: | |
282a61e6 | 5087 | * TMS320C3x/C4x Options:: |
f84271d9 | 5088 | * V850 Options:: |
56b2d7a7 | 5089 | * ARC Options:: |
83575957 | 5090 | * NS32K Options:: |
052a4b28 DC |
5091 | * AVR Options:: |
5092 | * MCore Options:: | |
df6194d4 | 5093 | * IA-64 Options:: |
e8ad90e5 | 5094 | * D30V Options:: |
91abf72d | 5095 | * S/390 and zSeries Options:: |
74291a4b MM |
5096 | @end menu |
5097 | ||
5098 | @node M680x0 Options | |
5099 | @subsection M680x0 Options | |
5100 | @cindex M680x0 options | |
5101 | ||
5102 | These are the @samp{-m} options defined for the 68000 series. The default | |
5103 | values for these options depends on which style of 68000 was selected when | |
5104 | the compiler was configured; the defaults for the most common choices are | |
5105 | given below. | |
5106 | ||
2642624b | 5107 | @table @gcctabopt |
74291a4b MM |
5108 | @item -m68000 |
5109 | @itemx -mc68000 | |
cd3bb277 JM |
5110 | @opindex m68000 |
5111 | @opindex mc68000 | |
74291a4b MM |
5112 | Generate output for a 68000. This is the default |
5113 | when the compiler is configured for 68000-based systems. | |
5114 | ||
74cf1c6d RK |
5115 | Use this option for microcontrollers with a 68000 or EC000 core, |
5116 | including the 68008, 68302, 68306, 68307, 68322, 68328 and 68356. | |
5117 | ||
74291a4b MM |
5118 | @item -m68020 |
5119 | @itemx -mc68020 | |
cd3bb277 JM |
5120 | @opindex m68020 |
5121 | @opindex mc68020 | |
74291a4b MM |
5122 | Generate output for a 68020. This is the default |
5123 | when the compiler is configured for 68020-based systems. | |
5124 | ||
5125 | @item -m68881 | |
cd3bb277 | 5126 | @opindex m68881 |
74291a4b | 5127 | Generate output containing 68881 instructions for floating point. |
630d3d5a | 5128 | This is the default for most 68020 systems unless @option{--nfp} was |
74291a4b MM |
5129 | specified when the compiler was configured. |
5130 | ||
5131 | @item -m68030 | |
cd3bb277 | 5132 | @opindex m68030 |
74291a4b MM |
5133 | Generate output for a 68030. This is the default when the compiler is |
5134 | configured for 68030-based systems. | |
5135 | ||
5136 | @item -m68040 | |
cd3bb277 | 5137 | @opindex m68040 |
74291a4b MM |
5138 | Generate output for a 68040. This is the default when the compiler is |
5139 | configured for 68040-based systems. | |
5140 | ||
5141 | This option inhibits the use of 68881/68882 instructions that have to be | |
74cf1c6d RK |
5142 | emulated by software on the 68040. Use this option if your 68040 does not |
5143 | have code to emulate those instructions. | |
74291a4b MM |
5144 | |
5145 | @item -m68060 | |
cd3bb277 | 5146 | @opindex m68060 |
74291a4b MM |
5147 | Generate output for a 68060. This is the default when the compiler is |
5148 | configured for 68060-based systems. | |
5149 | ||
5150 | This option inhibits the use of 68020 and 68881/68882 instructions that | |
74cf1c6d RK |
5151 | have to be emulated by software on the 68060. Use this option if your 68060 |
5152 | does not have code to emulate those instructions. | |
5153 | ||
5154 | @item -mcpu32 | |
cd3bb277 | 5155 | @opindex mcpu32 |
767094dd | 5156 | Generate output for a CPU32. This is the default |
74cf1c6d RK |
5157 | when the compiler is configured for CPU32-based systems. |
5158 | ||
5159 | Use this option for microcontrollers with a | |
5160 | CPU32 or CPU32+ core, including the 68330, 68331, 68332, 68333, 68334, | |
5161 | 68336, 68340, 68341, 68349 and 68360. | |
74291a4b MM |
5162 | |
5163 | @item -m5200 | |
cd3bb277 | 5164 | @opindex m5200 |
695ac33f | 5165 | Generate output for a 520X ``coldfire'' family cpu. This is the default |
74291a4b MM |
5166 | when the compiler is configured for 520X-based systems. |
5167 | ||
02f52e19 | 5168 | Use this option for microcontroller with a 5200 core, including |
74cf1c6d RK |
5169 | the MCF5202, MCF5203, MCF5204 and MCF5202. |
5170 | ||
74291a4b MM |
5171 | |
5172 | @item -m68020-40 | |
cd3bb277 | 5173 | @opindex m68020-40 |
74291a4b MM |
5174 | Generate output for a 68040, without using any of the new instructions. |
5175 | This results in code which can run relatively efficiently on either a | |
5176 | 68020/68881 or a 68030 or a 68040. The generated code does use the | |
5177 | 68881 instructions that are emulated on the 68040. | |
5178 | ||
861bb6c1 | 5179 | @item -m68020-60 |
cd3bb277 | 5180 | @opindex m68020-60 |
861bb6c1 JL |
5181 | Generate output for a 68060, without using any of the new instructions. |
5182 | This results in code which can run relatively efficiently on either a | |
5183 | 68020/68881 or a 68030 or a 68040. The generated code does use the | |
5184 | 68881 instructions that are emulated on the 68060. | |
5185 | ||
74291a4b | 5186 | @item -mfpa |
cd3bb277 | 5187 | @opindex mfpa |
74291a4b MM |
5188 | Generate output containing Sun FPA instructions for floating point. |
5189 | ||
5190 | @item -msoft-float | |
cd3bb277 | 5191 | @opindex msoft-float |
74291a4b MM |
5192 | Generate output containing library calls for floating point. |
5193 | @strong{Warning:} the requisite libraries are not available for all m68k | |
5194 | targets. Normally the facilities of the machine's usual C compiler are | |
5195 | used, but this can't be done directly in cross-compilation. You must | |
5196 | make your own arrangements to provide suitable library functions for | |
5197 | cross-compilation. The embedded targets @samp{m68k-*-aout} and | |
5198 | @samp{m68k-*-coff} do provide software floating point support. | |
5199 | ||
5200 | @item -mshort | |
cd3bb277 | 5201 | @opindex mshort |
74291a4b MM |
5202 | Consider type @code{int} to be 16 bits wide, like @code{short int}. |
5203 | ||
5204 | @item -mnobitfield | |
cd3bb277 | 5205 | @opindex mnobitfield |
630d3d5a JM |
5206 | Do not use the bit-field instructions. The @option{-m68000}, @option{-mcpu32} |
5207 | and @option{-m5200} options imply @w{@option{-mnobitfield}}. | |
74291a4b MM |
5208 | |
5209 | @item -mbitfield | |
cd3bb277 | 5210 | @opindex mbitfield |
630d3d5a JM |
5211 | Do use the bit-field instructions. The @option{-m68020} option implies |
5212 | @option{-mbitfield}. This is the default if you use a configuration | |
74291a4b MM |
5213 | designed for a 68020. |
5214 | ||
5215 | @item -mrtd | |
cd3bb277 | 5216 | @opindex mrtd |
74291a4b MM |
5217 | Use a different function-calling convention, in which functions |
5218 | that take a fixed number of arguments return with the @code{rtd} | |
5219 | instruction, which pops their arguments while returning. This | |
5220 | saves one instruction in the caller since there is no need to pop | |
5221 | the arguments there. | |
5222 | ||
5223 | This calling convention is incompatible with the one normally | |
5224 | used on Unix, so you cannot use it if you need to call libraries | |
5225 | compiled with the Unix compiler. | |
5226 | ||
5227 | Also, you must provide function prototypes for all functions that | |
5228 | take variable numbers of arguments (including @code{printf}); | |
5229 | otherwise incorrect code will be generated for calls to those | |
5230 | functions. | |
5231 | ||
5232 | In addition, seriously incorrect code will result if you call a | |
5233 | function with too many arguments. (Normally, extra arguments are | |
5234 | harmlessly ignored.) | |
5235 | ||
5236 | The @code{rtd} instruction is supported by the 68010, 68020, 68030, | |
74cf1c6d | 5237 | 68040, 68060 and CPU32 processors, but not by the 68000 or 5200. |
861bb6c1 JL |
5238 | |
5239 | @item -malign-int | |
5240 | @itemx -mno-align-int | |
cd3bb277 JM |
5241 | @opindex malign-int |
5242 | @opindex mno-align-int | |
02f52e19 | 5243 | Control whether GCC aligns @code{int}, @code{long}, @code{long long}, |
861bb6c1 | 5244 | @code{float}, @code{double}, and @code{long double} variables on a 32-bit |
630d3d5a | 5245 | boundary (@option{-malign-int}) or a 16-bit boundary (@option{-mno-align-int}). |
861bb6c1 JL |
5246 | Aligning variables on 32-bit boundaries produces code that runs somewhat |
5247 | faster on processors with 32-bit busses at the expense of more memory. | |
5248 | ||
630d3d5a | 5249 | @strong{Warning:} if you use the @option{-malign-int} switch, GCC will |
861bb6c1 JL |
5250 | align structures containing the above types differently than |
5251 | most published application binary interface specifications for the m68k. | |
5252 | ||
fb868474 | 5253 | @item -mpcrel |
cd3bb277 | 5254 | @opindex mpcrel |
fb868474 | 5255 | Use the pc-relative addressing mode of the 68000 directly, instead of |
695ac33f JM |
5256 | using a global offset table. At present, this option implies @option{-fpic}, |
5257 | allowing at most a 16-bit offset for pc-relative addressing. @option{-fPIC} is | |
5258 | not presently supported with @option{-mpcrel}, though this could be supported for | |
fb868474 DL |
5259 | 68020 and higher processors. |
5260 | ||
b71733d5 GM |
5261 | @item -mno-strict-align |
5262 | @itemx -mstrict-align | |
cd3bb277 JM |
5263 | @opindex mno-strict-align |
5264 | @opindex mstrict-align | |
b71733d5 GM |
5265 | Do not (do) assume that unaligned memory references will be handled by |
5266 | the system. | |
5267 | ||
74291a4b MM |
5268 | @end table |
5269 | ||
2856c3e3 SC |
5270 | @node M68hc1x Options |
5271 | @subsection M68hc1x Options | |
5272 | @cindex M68hc1x options | |
5273 | ||
5274 | These are the @samp{-m} options defined for the 68hc11 and 68hc12 | |
02f52e19 | 5275 | microcontrollers. The default values for these options depends on |
2856c3e3 SC |
5276 | which style of microcontroller was selected when the compiler was configured; |
5277 | the defaults for the most common choices are given below. | |
5278 | ||
2642624b | 5279 | @table @gcctabopt |
2856c3e3 SC |
5280 | @item -m6811 |
5281 | @itemx -m68hc11 | |
cd3bb277 JM |
5282 | @opindex m6811 |
5283 | @opindex m68hc11 | |
2856c3e3 SC |
5284 | Generate output for a 68HC11. This is the default |
5285 | when the compiler is configured for 68HC11-based systems. | |
5286 | ||
5287 | @item -m6812 | |
5288 | @itemx -m68hc12 | |
cd3bb277 JM |
5289 | @opindex m6812 |
5290 | @opindex m68hc12 | |
2856c3e3 SC |
5291 | Generate output for a 68HC12. This is the default |
5292 | when the compiler is configured for 68HC12-based systems. | |
5293 | ||
5294 | @item -mauto-incdec | |
cd3bb277 | 5295 | @opindex mauto-incdec |
2856c3e3 SC |
5296 | Enable the use of 68HC12 pre and post auto-increment and auto-decrement |
5297 | addressing modes. | |
5298 | ||
5299 | @item -mshort | |
cd3bb277 | 5300 | @opindex mshort |
2856c3e3 SC |
5301 | Consider type @code{int} to be 16 bits wide, like @code{short int}. |
5302 | ||
5303 | @item -msoft-reg-count=@var{count} | |
cd3bb277 | 5304 | @opindex msoft-reg-count |
2856c3e3 SC |
5305 | Specify the number of pseudo-soft registers which are used for the |
5306 | code generation. The maximum number is 32. Using more pseudo-soft | |
5307 | register may or may not result in better code depending on the program. | |
5308 | The default is 4 for 68HC11 and 2 for 68HC12. | |
5309 | ||
5310 | @end table | |
5311 | ||
74291a4b MM |
5312 | @node VAX Options |
5313 | @subsection VAX Options | |
5314 | @cindex VAX options | |
5315 | ||
8aeea6e6 | 5316 | These @samp{-m} options are defined for the VAX: |
74291a4b | 5317 | |
2642624b | 5318 | @table @gcctabopt |
74291a4b | 5319 | @item -munix |
cd3bb277 | 5320 | @opindex munix |
74291a4b | 5321 | Do not output certain jump instructions (@code{aobleq} and so on) |
8aeea6e6 | 5322 | that the Unix assembler for the VAX cannot handle across long |
74291a4b MM |
5323 | ranges. |
5324 | ||
5325 | @item -mgnu | |
cd3bb277 | 5326 | @opindex mgnu |
74291a4b MM |
5327 | Do output those jump instructions, on the assumption that you |
5328 | will assemble with the GNU assembler. | |
5329 | ||
5330 | @item -mg | |
cd3bb277 | 5331 | @opindex mg |
74291a4b MM |
5332 | Output code for g-format floating point numbers instead of d-format. |
5333 | @end table | |
5334 | ||
5335 | @node SPARC Options | |
5336 | @subsection SPARC Options | |
5337 | @cindex SPARC options | |
5338 | ||
5339 | These @samp{-m} switches are supported on the SPARC: | |
5340 | ||
2642624b | 5341 | @table @gcctabopt |
74291a4b MM |
5342 | @item -mno-app-regs |
5343 | @itemx -mapp-regs | |
cd3bb277 JM |
5344 | @opindex mno-app-regs |
5345 | @opindex mapp-regs | |
630d3d5a | 5346 | Specify @option{-mapp-regs} to generate output using the global registers |
74291a4b MM |
5347 | 2 through 4, which the SPARC SVR4 ABI reserves for applications. This |
5348 | is the default. | |
5349 | ||
5350 | To be fully SVR4 ABI compliant at the cost of some performance loss, | |
630d3d5a | 5351 | specify @option{-mno-app-regs}. You should compile libraries and system |
74291a4b MM |
5352 | software with this option. |
5353 | ||
5354 | @item -mfpu | |
5355 | @itemx -mhard-float | |
cd3bb277 JM |
5356 | @opindex mfpu |
5357 | @opindex mhard-float | |
74291a4b MM |
5358 | Generate output containing floating point instructions. This is the |
5359 | default. | |
5360 | ||
5361 | @item -mno-fpu | |
5362 | @itemx -msoft-float | |
cd3bb277 JM |
5363 | @opindex mno-fpu |
5364 | @opindex msoft-float | |
74291a4b MM |
5365 | Generate output containing library calls for floating point. |
5366 | @strong{Warning:} the requisite libraries are not available for all SPARC | |
5367 | targets. Normally the facilities of the machine's usual C compiler are | |
5368 | used, but this cannot be done directly in cross-compilation. You must make | |
5369 | your own arrangements to provide suitable library functions for | |
5370 | cross-compilation. The embedded targets @samp{sparc-*-aout} and | |
5371 | @samp{sparclite-*-*} do provide software floating point support. | |
5372 | ||
630d3d5a | 5373 | @option{-msoft-float} changes the calling convention in the output file; |
74291a4b MM |
5374 | therefore, it is only useful if you compile @emph{all} of a program with |
5375 | this option. In particular, you need to compile @file{libgcc.a}, the | |
630d3d5a | 5376 | library that comes with GCC, with @option{-msoft-float} in order for |
74291a4b MM |
5377 | this to work. |
5378 | ||
5379 | @item -mhard-quad-float | |
cd3bb277 | 5380 | @opindex mhard-quad-float |
74291a4b MM |
5381 | Generate output containing quad-word (long double) floating point |
5382 | instructions. | |
5383 | ||
5384 | @item -msoft-quad-float | |
cd3bb277 | 5385 | @opindex msoft-quad-float |
74291a4b MM |
5386 | Generate output containing library calls for quad-word (long double) |
5387 | floating point instructions. The functions called are those specified | |
161d7b59 | 5388 | in the SPARC ABI@. This is the default. |
74291a4b MM |
5389 | |
5390 | As of this writing, there are no sparc implementations that have hardware | |
5391 | support for the quad-word floating point instructions. They all invoke | |
5392 | a trap handler for one of these instructions, and then the trap handler | |
5393 | emulates the effect of the instruction. Because of the trap handler overhead, | |
5394 | this is much slower than calling the ABI library routines. Thus the | |
630d3d5a | 5395 | @option{-msoft-quad-float} option is the default. |
74291a4b MM |
5396 | |
5397 | @item -mno-epilogue | |
5398 | @itemx -mepilogue | |
cd3bb277 JM |
5399 | @opindex mno-epilogue |
5400 | @opindex mepilogue | |
630d3d5a | 5401 | With @option{-mepilogue} (the default), the compiler always emits code for |
74291a4b MM |
5402 | function exit at the end of each function. Any function exit in |
5403 | the middle of the function (such as a return statement in C) will | |
5404 | generate a jump to the exit code at the end of the function. | |
5405 | ||
630d3d5a | 5406 | With @option{-mno-epilogue}, the compiler tries to emit exit code inline |
74291a4b MM |
5407 | at every function exit. |
5408 | ||
5409 | @item -mno-flat | |
5410 | @itemx -mflat | |
cd3bb277 JM |
5411 | @opindex mno-flat |
5412 | @opindex mflat | |
630d3d5a | 5413 | With @option{-mflat}, the compiler does not generate save/restore instructions |
695ac33f | 5414 | and will use a ``flat'' or single register window calling convention. |
74291a4b MM |
5415 | This model uses %i7 as the frame pointer and is compatible with the normal |
5416 | register window model. Code from either may be intermixed. | |
aee96fe9 | 5417 | The local registers and the input registers (0--5) are still treated as |
695ac33f | 5418 | ``call saved'' registers and will be saved on the stack as necessary. |
74291a4b | 5419 | |
630d3d5a | 5420 | With @option{-mno-flat} (the default), the compiler emits save/restore |
74291a4b MM |
5421 | instructions (except for leaf functions) and is the normal mode of operation. |
5422 | ||
5423 | @item -mno-unaligned-doubles | |
5424 | @itemx -munaligned-doubles | |
cd3bb277 JM |
5425 | @opindex mno-unaligned-doubles |
5426 | @opindex munaligned-doubles | |
74291a4b MM |
5427 | Assume that doubles have 8 byte alignment. This is the default. |
5428 | ||
630d3d5a | 5429 | With @option{-munaligned-doubles}, GCC assumes that doubles have 8 byte |
74291a4b MM |
5430 | alignment only if they are contained in another type, or if they have an |
5431 | absolute address. Otherwise, it assumes they have 4 byte alignment. | |
5432 | Specifying this option avoids some rare compatibility problems with code | |
5433 | generated by other compilers. It is not the default because it results | |
5434 | in a performance loss, especially for floating point code. | |
5435 | ||
c219ddf7 BK |
5436 | @item -mno-faster-structs |
5437 | @itemx -mfaster-structs | |
cd3bb277 JM |
5438 | @opindex mno-faster-structs |
5439 | @opindex mfaster-structs | |
630d3d5a | 5440 | With @option{-mfaster-structs}, the compiler assumes that structures |
c219ddf7 BK |
5441 | should have 8 byte alignment. This enables the use of pairs of |
5442 | @code{ldd} and @code{std} instructions for copies in structure | |
5443 | assignment, in place of twice as many @code{ld} and @code{st} pairs. | |
5444 | However, the use of this changed alignment directly violates the Sparc | |
161d7b59 | 5445 | ABI@. Thus, it's intended only for use on targets where the developer |
c219ddf7 | 5446 | acknowledges that their resulting code will not be directly in line with |
161d7b59 | 5447 | the rules of the ABI@. |
c219ddf7 | 5448 | |
74291a4b MM |
5449 | @item -mv8 |
5450 | @itemx -msparclite | |
cd3bb277 JM |
5451 | @opindex mv8 |
5452 | @opindex msparclite | |
74291a4b MM |
5453 | These two options select variations on the SPARC architecture. |
5454 | ||
5455 | By default (unless specifically configured for the Fujitsu SPARClite), | |
5456 | GCC generates code for the v7 variant of the SPARC architecture. | |
5457 | ||
630d3d5a | 5458 | @option{-mv8} will give you SPARC v8 code. The only difference from v7 |
74291a4b MM |
5459 | code is that the compiler emits the integer multiply and integer |
5460 | divide instructions which exist in SPARC v8 but not in SPARC v7. | |
5461 | ||
630d3d5a | 5462 | @option{-msparclite} will give you SPARClite code. This adds the integer |
74291a4b MM |
5463 | multiply, integer divide step and scan (@code{ffs}) instructions which |
5464 | exist in SPARClite but not in SPARC v7. | |
5465 | ||
0c2d1a2a | 5466 | These options are deprecated and will be deleted in a future GCC release. |
630d3d5a | 5467 | They have been replaced with @option{-mcpu=xxx}. |
74291a4b MM |
5468 | |
5469 | @item -mcypress | |
5470 | @itemx -msupersparc | |
cd3bb277 JM |
5471 | @opindex mcypress |
5472 | @opindex msupersparc | |
74291a4b MM |
5473 | These two options select the processor for which the code is optimised. |
5474 | ||
630d3d5a | 5475 | With @option{-mcypress} (the default), the compiler optimizes code for the |
74291a4b MM |
5476 | Cypress CY7C602 chip, as used in the SparcStation/SparcServer 3xx series. |
5477 | This is also appropriate for the older SparcStation 1, 2, IPX etc. | |
5478 | ||
630d3d5a | 5479 | With @option{-msupersparc} the compiler optimizes code for the SuperSparc cpu, as |
767094dd | 5480 | used in the SparcStation 10, 1000 and 2000 series. This flag also enables use |
74291a4b MM |
5481 | of the full SPARC v8 instruction set. |
5482 | ||
0c2d1a2a | 5483 | These options are deprecated and will be deleted in a future GCC release. |
630d3d5a | 5484 | They have been replaced with @option{-mcpu=xxx}. |
74291a4b MM |
5485 | |
5486 | @item -mcpu=@var{cpu_type} | |
cd3bb277 | 5487 | @opindex mcpu |
c0498f43 DE |
5488 | Set the instruction set, register set, and instruction scheduling parameters |
5489 | for machine type @var{cpu_type}. Supported values for @var{cpu_type} are | |
5490 | @samp{v7}, @samp{cypress}, @samp{v8}, @samp{supersparc}, @samp{sparclite}, | |
ad6843d7 RH |
5491 | @samp{hypersparc}, @samp{sparclite86x}, @samp{f930}, @samp{f934}, |
5492 | @samp{sparclet}, @samp{tsc701}, @samp{v9}, and @samp{ultrasparc}. | |
c0498f43 DE |
5493 | |
5494 | Default instruction scheduling parameters are used for values that select | |
5495 | an architecture and not an implementation. These are @samp{v7}, @samp{v8}, | |
5496 | @samp{sparclite}, @samp{sparclet}, @samp{v9}. | |
5497 | ||
5498 | Here is a list of each supported architecture and their supported | |
5499 | implementations. | |
5500 | ||
5501 | @smallexample | |
5502 | v7: cypress | |
ad6843d7 RH |
5503 | v8: supersparc, hypersparc |
5504 | sparclite: f930, f934, sparclite86x | |
c0498f43 DE |
5505 | sparclet: tsc701 |
5506 | v9: ultrasparc | |
5507 | @end smallexample | |
74291a4b MM |
5508 | |
5509 | @item -mtune=@var{cpu_type} | |
cd3bb277 | 5510 | @opindex mtune |
74291a4b | 5511 | Set the instruction scheduling parameters for machine type |
c0498f43 | 5512 | @var{cpu_type}, but do not set the instruction set or register set that the |
630d3d5a | 5513 | option @option{-mcpu=@var{cpu_type}} would. |
c0498f43 | 5514 | |
9c34dbbf ZW |
5515 | The same values for @option{-mcpu=@var{cpu_type}} can be used for |
5516 | @option{-mtune=@var{cpu_type}}, but the only useful values are those | |
5517 | that select a particular cpu implementation. Those are @samp{cypress}, | |
5518 | @samp{supersparc}, @samp{hypersparc}, @samp{f930}, @samp{f934}, | |
5519 | @samp{sparclite86x}, @samp{tsc701}, and @samp{ultrasparc}. | |
74291a4b MM |
5520 | |
5521 | @end table | |
5522 | ||
5523 | These @samp{-m} switches are supported in addition to the above | |
5524 | on the SPARCLET processor. | |
5525 | ||
2642624b | 5526 | @table @gcctabopt |
74291a4b | 5527 | @item -mlittle-endian |
cd3bb277 | 5528 | @opindex mlittle-endian |
74291a4b MM |
5529 | Generate code for a processor running in little-endian mode. |
5530 | ||
5531 | @item -mlive-g0 | |
cd3bb277 | 5532 | @opindex mlive-g0 |
74291a4b MM |
5533 | Treat register @code{%g0} as a normal register. |
5534 | GCC will continue to clobber it as necessary but will not assume | |
5535 | it always reads as 0. | |
5536 | ||
5537 | @item -mbroken-saverestore | |
cd3bb277 | 5538 | @opindex mbroken-saverestore |
74291a4b MM |
5539 | Generate code that does not use non-trivial forms of the @code{save} and |
5540 | @code{restore} instructions. Early versions of the SPARCLET processor do | |
5541 | not correctly handle @code{save} and @code{restore} instructions used with | |
5542 | arguments. They correctly handle them used without arguments. A @code{save} | |
5543 | instruction used without arguments increments the current window pointer | |
5544 | but does not allocate a new stack frame. It is assumed that the window | |
5545 | overflow trap handler will properly handle this case as will interrupt | |
5546 | handlers. | |
5547 | @end table | |
5548 | ||
5549 | These @samp{-m} switches are supported in addition to the above | |
02f52e19 | 5550 | on SPARC V9 processors in 64-bit environments. |
74291a4b | 5551 | |
2642624b | 5552 | @table @gcctabopt |
74291a4b | 5553 | @item -mlittle-endian |
cd3bb277 | 5554 | @opindex mlittle-endian |
74291a4b MM |
5555 | Generate code for a processor running in little-endian mode. |
5556 | ||
ded17aad DE |
5557 | @item -m32 |
5558 | @itemx -m64 | |
cd3bb277 JM |
5559 | @opindex m32 |
5560 | @opindex m64 | |
02f52e19 AJ |
5561 | Generate code for a 32-bit or 64-bit environment. |
5562 | The 32-bit environment sets int, long and pointer to 32 bits. | |
5563 | The 64-bit environment sets int to 32 bits and long and pointer | |
ded17aad DE |
5564 | to 64 bits. |
5565 | ||
5566 | @item -mcmodel=medlow | |
cd3bb277 | 5567 | @opindex mcmodel=medlow |
ded17aad DE |
5568 | Generate code for the Medium/Low code model: the program must be linked |
5569 | in the low 32 bits of the address space. Pointers are 64 bits. | |
5570 | Programs can be statically or dynamically linked. | |
5571 | ||
5572 | @item -mcmodel=medmid | |
cd3bb277 | 5573 | @opindex mcmodel=medmid |
ded17aad DE |
5574 | Generate code for the Medium/Middle code model: the program must be linked |
5575 | in the low 44 bits of the address space, the text segment must be less than | |
5576 | 2G bytes, and data segment must be within 2G of the text segment. | |
5577 | Pointers are 64 bits. | |
5578 | ||
5579 | @item -mcmodel=medany | |
cd3bb277 | 5580 | @opindex mcmodel=medany |
ded17aad DE |
5581 | Generate code for the Medium/Anywhere code model: the program may be linked |
5582 | anywhere in the address space, the text segment must be less than | |
5583 | 2G bytes, and data segment must be within 2G of the text segment. | |
5584 | Pointers are 64 bits. | |
5585 | ||
5586 | @item -mcmodel=embmedany | |
cd3bb277 | 5587 | @opindex mcmodel=embmedany |
ded17aad | 5588 | Generate code for the Medium/Anywhere code model for embedded systems: |
02f52e19 | 5589 | assume a 32-bit text and a 32-bit data segment, both starting anywhere |
ded17aad | 5590 | (determined at link time). Register %g4 points to the base of the |
02f52e19 | 5591 | data segment. Pointers are still 64 bits. |
ded17aad | 5592 | Programs are statically linked, PIC is not supported. |
74291a4b MM |
5593 | |
5594 | @item -mstack-bias | |
5595 | @itemx -mno-stack-bias | |
cd3bb277 JM |
5596 | @opindex mstack-bias |
5597 | @opindex mno-stack-bias | |
630d3d5a JM |
5598 | With @option{-mstack-bias}, GCC assumes that the stack pointer, and |
5599 | frame pointer if present, are offset by @minus{}2047 which must be added back | |
74291a4b MM |
5600 | when making stack frame references. |
5601 | Otherwise, assume no such offset is present. | |
5602 | @end table | |
5603 | ||
5604 | @node Convex Options | |
5605 | @subsection Convex Options | |
5606 | @cindex Convex options | |
5607 | ||
5608 | These @samp{-m} options are defined for Convex: | |
5609 | ||
2642624b | 5610 | @table @gcctabopt |
74291a4b | 5611 | @item -mc1 |
cd3bb277 | 5612 | @opindex mc1 |
74291a4b MM |
5613 | Generate output for C1. The code will run on any Convex machine. |
5614 | The preprocessor symbol @code{__convex__c1__} is defined. | |
5615 | ||
5616 | @item -mc2 | |
cd3bb277 | 5617 | @opindex mc2 |
74291a4b MM |
5618 | Generate output for C2. Uses instructions not available on C1. |
5619 | Scheduling and other optimizations are chosen for max performance on C2. | |
5620 | The preprocessor symbol @code{__convex_c2__} is defined. | |
5621 | ||
5622 | @item -mc32 | |
cd3bb277 | 5623 | @opindex mc32 |
74291a4b MM |
5624 | Generate output for C32xx. Uses instructions not available on C1. |
5625 | Scheduling and other optimizations are chosen for max performance on C32. | |
5626 | The preprocessor symbol @code{__convex_c32__} is defined. | |
5627 | ||
5628 | @item -mc34 | |
cd3bb277 | 5629 | @opindex mc34 |
74291a4b MM |
5630 | Generate output for C34xx. Uses instructions not available on C1. |
5631 | Scheduling and other optimizations are chosen for max performance on C34. | |
5632 | The preprocessor symbol @code{__convex_c34__} is defined. | |
5633 | ||
5634 | @item -mc38 | |
cd3bb277 | 5635 | @opindex mc38 |
74291a4b MM |
5636 | Generate output for C38xx. Uses instructions not available on C1. |
5637 | Scheduling and other optimizations are chosen for max performance on C38. | |
5638 | The preprocessor symbol @code{__convex_c38__} is defined. | |
5639 | ||
5640 | @item -margcount | |
cd3bb277 | 5641 | @opindex margcount |
74291a4b MM |
5642 | Generate code which puts an argument count in the word preceding each |
5643 | argument list. This is compatible with regular CC, and a few programs | |
5644 | may need the argument count word. GDB and other source-level debuggers | |
5645 | do not need it; this info is in the symbol table. | |
5646 | ||
5647 | @item -mnoargcount | |
cd3bb277 | 5648 | @opindex mnoargcount |
74291a4b MM |
5649 | Omit the argument count word. This is the default. |
5650 | ||
5651 | @item -mvolatile-cache | |
cd3bb277 | 5652 | @opindex mvolatile-cache |
74291a4b MM |
5653 | Allow volatile references to be cached. This is the default. |
5654 | ||
5655 | @item -mvolatile-nocache | |
cd3bb277 | 5656 | @opindex mvolatile-nocache |
74291a4b MM |
5657 | Volatile references bypass the data cache, going all the way to memory. |
5658 | This is only needed for multi-processor code that does not use standard | |
5659 | synchronization instructions. Making non-volatile references to volatile | |
5660 | locations will not necessarily work. | |
5661 | ||
5662 | @item -mlong32 | |
cd3bb277 | 5663 | @opindex mlong32 |
74291a4b MM |
5664 | Type long is 32 bits, the same as type int. This is the default. |
5665 | ||
5666 | @item -mlong64 | |
cd3bb277 | 5667 | @opindex mlong64 |
74291a4b MM |
5668 | Type long is 64 bits, the same as type long long. This option is useless, |
5669 | because no library support exists for it. | |
5670 | @end table | |
5671 | ||
5672 | @node AMD29K Options | |
5673 | @subsection AMD29K Options | |
5674 | @cindex AMD29K options | |
5675 | ||
5676 | These @samp{-m} options are defined for the AMD Am29000: | |
5677 | ||
2642624b | 5678 | @table @gcctabopt |
74291a4b | 5679 | @item -mdw |
cd3bb277 | 5680 | @opindex mdw |
74291a4b MM |
5681 | @cindex DW bit (29k) |
5682 | Generate code that assumes the @code{DW} bit is set, i.e., that byte and | |
5683 | halfword operations are directly supported by the hardware. This is the | |
5684 | default. | |
5685 | ||
5686 | @item -mndw | |
cd3bb277 | 5687 | @opindex mndw |
74291a4b MM |
5688 | Generate code that assumes the @code{DW} bit is not set. |
5689 | ||
5690 | @item -mbw | |
cd3bb277 | 5691 | @opindex mbw |
74291a4b MM |
5692 | @cindex byte writes (29k) |
5693 | Generate code that assumes the system supports byte and halfword write | |
5694 | operations. This is the default. | |
5695 | ||
5696 | @item -mnbw | |
cd3bb277 | 5697 | @opindex mnbw |
74291a4b | 5698 | Generate code that assumes the systems does not support byte and |
630d3d5a | 5699 | halfword write operations. @option{-mnbw} implies @option{-mndw}. |
74291a4b MM |
5700 | |
5701 | @item -msmall | |
cd3bb277 | 5702 | @opindex msmall |
74291a4b MM |
5703 | @cindex memory model (29k) |
5704 | Use a small memory model that assumes that all function addresses are | |
5705 | either within a single 256 KB segment or at an absolute address of less | |
5706 | than 256k. This allows the @code{call} instruction to be used instead | |
5707 | of a @code{const}, @code{consth}, @code{calli} sequence. | |
5708 | ||
5709 | @item -mnormal | |
cd3bb277 | 5710 | @opindex mnormal |
74291a4b MM |
5711 | Use the normal memory model: Generate @code{call} instructions only when |
5712 | calling functions in the same file and @code{calli} instructions | |
5713 | otherwise. This works if each file occupies less than 256 KB but allows | |
161d7b59 | 5714 | the entire executable to be larger than 256 KB@. This is the default. |
74291a4b MM |
5715 | |
5716 | @item -mlarge | |
cd3bb277 | 5717 | @opindex mlarge |
74291a4b MM |
5718 | Always use @code{calli} instructions. Specify this option if you expect |
5719 | a single file to compile into more than 256 KB of code. | |
5720 | ||
5721 | @item -m29050 | |
cd3bb277 | 5722 | @opindex m29050 |
74291a4b MM |
5723 | @cindex processor selection (29k) |
5724 | Generate code for the Am29050. | |
5725 | ||
5726 | @item -m29000 | |
cd3bb277 | 5727 | @opindex m29000 |
74291a4b MM |
5728 | Generate code for the Am29000. This is the default. |
5729 | ||
5730 | @item -mkernel-registers | |
cd3bb277 | 5731 | @opindex mkernel-registers |
74291a4b MM |
5732 | @cindex kernel and user registers (29k) |
5733 | Generate references to registers @code{gr64-gr95} instead of to | |
5734 | registers @code{gr96-gr127}. This option can be used when compiling | |
5735 | kernel code that wants a set of global registers disjoint from that used | |
5736 | by user-mode code. | |
5737 | ||
5738 | Note that when this option is used, register names in @samp{-f} flags | |
5739 | must use the normal, user-mode, names. | |
5740 | ||
5741 | @item -muser-registers | |
cd3bb277 | 5742 | @opindex muser-registers |
74291a4b MM |
5743 | Use the normal set of global registers, @code{gr96-gr127}. This is the |
5744 | default. | |
5745 | ||
5746 | @item -mstack-check | |
5747 | @itemx -mno-stack-check | |
cd3bb277 JM |
5748 | @opindex mstack-check |
5749 | @opindex mno-stack-check | |
74291a4b MM |
5750 | @cindex stack checks (29k) |
5751 | Insert (or do not insert) a call to @code{__msp_check} after each stack | |
5752 | adjustment. This is often used for kernel code. | |
5753 | ||
5754 | @item -mstorem-bug | |
5755 | @itemx -mno-storem-bug | |
cd3bb277 JM |
5756 | @opindex mstorem-bug |
5757 | @opindex mno-storem-bug | |
74291a4b | 5758 | @cindex storem bug (29k) |
630d3d5a | 5759 | @option{-mstorem-bug} handles 29k processors which cannot handle the |
74291a4b MM |
5760 | separation of a mtsrim insn and a storem instruction (most 29000 chips |
5761 | to date, but not the 29050). | |
5762 | ||
5763 | @item -mno-reuse-arg-regs | |
5764 | @itemx -mreuse-arg-regs | |
cd3bb277 JM |
5765 | @opindex mno-reuse-arg-regs |
5766 | @opindex mreuse-arg-regs | |
630d3d5a | 5767 | @option{-mno-reuse-arg-regs} tells the compiler to only use incoming argument |
74291a4b MM |
5768 | registers for copying out arguments. This helps detect calling a function |
5769 | with fewer arguments than it was declared with. | |
5770 | ||
861bb6c1 JL |
5771 | @item -mno-impure-text |
5772 | @itemx -mimpure-text | |
cd3bb277 JM |
5773 | @opindex mno-impure-text |
5774 | @opindex mimpure-text | |
630d3d5a JM |
5775 | @option{-mimpure-text}, used in addition to @option{-shared}, tells the compiler to |
5776 | not pass @option{-assert pure-text} to the linker when linking a shared object. | |
861bb6c1 | 5777 | |
74291a4b | 5778 | @item -msoft-float |
cd3bb277 | 5779 | @opindex msoft-float |
74291a4b | 5780 | Generate output containing library calls for floating point. |
161d7b59 | 5781 | @strong{Warning:} the requisite libraries are not part of GCC@. |
74291a4b MM |
5782 | Normally the facilities of the machine's usual C compiler are used, but |
5783 | this can't be done directly in cross-compilation. You must make your | |
5784 | own arrangements to provide suitable library functions for | |
5785 | cross-compilation. | |
4e8d7ddc JW |
5786 | |
5787 | @item -mno-multm | |
cd3bb277 | 5788 | @opindex mno-multm |
4e8d7ddc JW |
5789 | Do not generate multm or multmu instructions. This is useful for some embedded |
5790 | systems which do not have trap handlers for these instructions. | |
74291a4b MM |
5791 | @end table |
5792 | ||
5793 | @node ARM Options | |
5794 | @subsection ARM Options | |
5795 | @cindex ARM options | |
5796 | ||
5797 | These @samp{-m} options are defined for Advanced RISC Machines (ARM) | |
5798 | architectures: | |
5799 | ||
2642624b | 5800 | @table @gcctabopt |
74291a4b | 5801 | @item -mapcs-frame |
cd3bb277 | 5802 | @opindex mapcs-frame |
74291a4b MM |
5803 | Generate a stack frame that is compliant with the ARM Procedure Call |
5804 | Standard for all functions, even if this is not strictly necessary for | |
630d3d5a | 5805 | correct execution of the code. Specifying @option{-fomit-frame-pointer} |
157a620e | 5806 | with this option will cause the stack frames not to be generated for |
630d3d5a | 5807 | leaf functions. The default is @option{-mno-apcs-frame}. |
157a620e NC |
5808 | |
5809 | @item -mapcs | |
cd3bb277 | 5810 | @opindex mapcs |
630d3d5a | 5811 | This is a synonym for @option{-mapcs-frame}. |
74291a4b MM |
5812 | |
5813 | @item -mapcs-26 | |
cd3bb277 | 5814 | @opindex mapcs-26 |
74291a4b MM |
5815 | Generate code for a processor running with a 26-bit program counter, |
5816 | and conforming to the function calling standards for the APCS 26-bit | |
630d3d5a | 5817 | option. This option replaces the @option{-m2} and @option{-m3} options |
74291a4b MM |
5818 | of previous releases of the compiler. |
5819 | ||
5820 | @item -mapcs-32 | |
cd3bb277 | 5821 | @opindex mapcs-32 |
74291a4b MM |
5822 | Generate code for a processor running with a 32-bit program counter, |
5823 | and conforming to the function calling standards for the APCS 32-bit | |
630d3d5a | 5824 | option. This option replaces the @option{-m6} option of previous releases |
74291a4b MM |
5825 | of the compiler. |
5826 | ||
247f8561 PB |
5827 | @ignore |
5828 | @c not currently implemented | |
157a620e | 5829 | @item -mapcs-stack-check |
cd3bb277 | 5830 | @opindex mapcs-stack-check |
157a620e NC |
5831 | Generate code to check the amount of stack space available upon entry to |
5832 | every function (that actually uses some stack space). If there is | |
5833 | insufficient space available then either the function | |
5834 | @samp{__rt_stkovf_split_small} or @samp{__rt_stkovf_split_big} will be | |
5835 | called, depending upon the amount of stack space required. The run time | |
5836 | system is required to provide these functions. The default is | |
630d3d5a | 5837 | @option{-mno-apcs-stack-check}, since this produces smaller code. |
157a620e | 5838 | |
247f8561 | 5839 | @c not currently implemented |
157a620e | 5840 | @item -mapcs-float |
cd3bb277 | 5841 | @opindex mapcs-float |
157a620e | 5842 | Pass floating point arguments using the float point registers. This is |
161d7b59 | 5843 | one of the variants of the APCS@. This option is recommended if the |
157a620e NC |
5844 | target hardware has a floating point unit or if a lot of floating point |
5845 | arithmetic is going to be performed by the code. The default is | |
630d3d5a JM |
5846 | @option{-mno-apcs-float}, since integer only code is slightly increased in |
5847 | size if @option{-mapcs-float} is used. | |
157a620e | 5848 | |
247f8561 | 5849 | @c not currently implemented |
157a620e | 5850 | @item -mapcs-reentrant |
cd3bb277 | 5851 | @opindex mapcs-reentrant |
247f8561 | 5852 | Generate reentrant, position independent code. The default is |
630d3d5a | 5853 | @option{-mno-apcs-reentrant}. |
247f8561 | 5854 | @end ignore |
157a620e NC |
5855 | |
5856 | @item -mthumb-interwork | |
cd3bb277 | 5857 | @opindex mthumb-interwork |
247f8561 | 5858 | Generate code which supports calling between the ARM and Thumb |
157a620e NC |
5859 | instruction sets. Without this option the two instruction sets cannot |
5860 | be reliably used inside one program. The default is | |
630d3d5a JM |
5861 | @option{-mno-thumb-interwork}, since slightly larger code is generated |
5862 | when @option{-mthumb-interwork} is specified. | |
157a620e NC |
5863 | |
5864 | @item -mno-sched-prolog | |
cd3bb277 | 5865 | @opindex mno-sched-prolog |
157a620e NC |
5866 | Prevent the reordering of instructions in the function prolog, or the |
5867 | merging of those instruction with the instructions in the function's | |
ed0e6530 PB |
5868 | body. This means that all functions will start with a recognizable set |
5869 | of instructions (or in fact one of a choice from a small set of | |
157a620e NC |
5870 | different function prologues), and this information can be used to |
5871 | locate the start if functions inside an executable piece of code. The | |
630d3d5a | 5872 | default is @option{-msched-prolog}. |
157a620e | 5873 | |
74291a4b | 5874 | @item -mhard-float |
cd3bb277 | 5875 | @opindex mhard-float |
74291a4b MM |
5876 | Generate output containing floating point instructions. This is the |
5877 | default. | |
5878 | ||
5879 | @item -msoft-float | |
cd3bb277 | 5880 | @opindex msoft-float |
74291a4b MM |
5881 | Generate output containing library calls for floating point. |
5882 | @strong{Warning:} the requisite libraries are not available for all ARM | |
5883 | targets. Normally the facilities of the machine's usual C compiler are | |
5884 | used, but this cannot be done directly in cross-compilation. You must make | |
5885 | your own arrangements to provide suitable library functions for | |
5886 | cross-compilation. | |
5887 | ||
630d3d5a | 5888 | @option{-msoft-float} changes the calling convention in the output file; |
74291a4b MM |
5889 | therefore, it is only useful if you compile @emph{all} of a program with |
5890 | this option. In particular, you need to compile @file{libgcc.a}, the | |
630d3d5a | 5891 | library that comes with GCC, with @option{-msoft-float} in order for |
74291a4b MM |
5892 | this to work. |
5893 | ||
5894 | @item -mlittle-endian | |
cd3bb277 | 5895 | @opindex mlittle-endian |
74291a4b MM |
5896 | Generate code for a processor running in little-endian mode. This is |
5897 | the default for all standard configurations. | |
5898 | ||
5899 | @item -mbig-endian | |
cd3bb277 | 5900 | @opindex mbig-endian |
74291a4b MM |
5901 | Generate code for a processor running in big-endian mode; the default is |
5902 | to compile code for a little-endian processor. | |
5903 | ||
5904 | @item -mwords-little-endian | |
cd3bb277 | 5905 | @opindex mwords-little-endian |
74291a4b MM |
5906 | This option only applies when generating code for big-endian processors. |
5907 | Generate code for a little-endian word order but a big-endian byte | |
5908 | order. That is, a byte order of the form @samp{32107654}. Note: this | |
5909 | option should only be used if you require compatibility with code for | |
5910 | big-endian ARM processors generated by versions of the compiler prior to | |
5911 | 2.8. | |
5912 | ||
5f1e6755 | 5913 | @item -malignment-traps |
cd3bb277 | 5914 | @opindex malignment-traps |
5f1e6755 NC |
5915 | Generate code that will not trap if the MMU has alignment traps enabled. |
5916 | On ARM architectures prior to ARMv4, there were no instructions to | |
5917 | access half-word objects stored in memory. However, when reading from | |
5918 | memory a feature of the ARM architecture allows a word load to be used, | |
5919 | even if the address is unaligned, and the processor core will rotate the | |
5920 | data as it is being loaded. This option tells the compiler that such | |
5921 | misaligned accesses will cause a MMU trap and that it should instead | |
5922 | synthesise the access as a series of byte accesses. The compiler can | |
5923 | still use word accesses to load half-word data if it knows that the | |
5924 | address is aligned to a word boundary. | |
5925 | ||
5926 | This option is ignored when compiling for ARM architecture 4 or later, | |
5927 | since these processors have instructions to directly access half-word | |
02f52e19 AJ |
5928 | objects in memory. |
5929 | ||
5f1e6755 | 5930 | @item -mno-alignment-traps |
cd3bb277 | 5931 | @opindex mno-alignment-traps |
5f1e6755 NC |
5932 | Generate code that assumes that the MMU will not trap unaligned |
5933 | accesses. This produces better code when the target instruction set | |
e979f9e8 | 5934 | does not have half-word memory operations (i.e.@: implementations prior to |
02f52e19 | 5935 | ARMv4). |
5f1e6755 NC |
5936 | |
5937 | Note that you cannot use this option to access unaligned word objects, | |
5938 | since the processor will only fetch one 32-bit aligned object from | |
02f52e19 | 5939 | memory. |
5f1e6755 | 5940 | |
695ac33f | 5941 | The default setting for most targets is @option{-mno-alignment-traps}, since |
5f1e6755 | 5942 | this produces better code when there are no half-word memory |
02f52e19 | 5943 | instructions available. |
5f1e6755 | 5944 | |
74291a4b | 5945 | @item -mshort-load-bytes |
247f8561 | 5946 | @itemx -mno-short-load-words |
cd3bb277 JM |
5947 | @opindex mshort-load-bytes |
5948 | @opindex mno-short-load-words | |
630d3d5a | 5949 | These are deprecated aliases for @option{-malignment-traps}. |
74291a4b MM |
5950 | |
5951 | @item -mno-short-load-bytes | |
247f8561 | 5952 | @itemx -mshort-load-words |
cd3bb277 JM |
5953 | @opindex mno-short-load-bytes |
5954 | @opindex mshort-load-words | |
630d3d5a | 5955 | This are deprecated aliases for @option{-mno-alignment-traps}. |
157a620e | 5956 | |
74291a4b | 5957 | @item -mbsd |
cd3bb277 | 5958 | @opindex mbsd |
161d7b59 | 5959 | This option only applies to RISC iX@. Emulate the native BSD-mode |
630d3d5a | 5960 | compiler. This is the default if @option{-ansi} is not specified. |
74291a4b MM |
5961 | |
5962 | @item -mxopen | |
cd3bb277 | 5963 | @opindex mxopen |
161d7b59 | 5964 | This option only applies to RISC iX@. Emulate the native X/Open-mode |
74291a4b MM |
5965 | compiler. |
5966 | ||
5967 | @item -mno-symrename | |
cd3bb277 | 5968 | @opindex mno-symrename |
161d7b59 | 5969 | This option only applies to RISC iX@. Do not run the assembler |
74291a4b MM |
5970 | post-processor, @samp{symrename}, after code has been assembled. |
5971 | Normally it is necessary to modify some of the standard symbols in | |
5972 | preparation for linking with the RISC iX C library; this option | |
5973 | suppresses this pass. The post-processor is never run when the | |
5974 | compiler is built for cross-compilation. | |
157a620e | 5975 | |
cd3bb277 JM |
5976 | @item -mcpu=@var{name} |
5977 | @opindex mcpu | |
157a620e | 5978 | This specifies the name of the target ARM processor. GCC uses this name |
247f8561 | 5979 | to determine what kind of instructions it can emit when generating |
aee96fe9 JM |
5980 | assembly code. Permissible names are: @samp{arm2}, @samp{arm250}, |
5981 | @samp{arm3}, @samp{arm6}, @samp{arm60}, @samp{arm600}, @samp{arm610}, | |
5982 | @samp{arm620}, @samp{arm7}, @samp{arm7m}, @samp{arm7d}, @samp{arm7dm}, | |
5983 | @samp{arm7di}, @samp{arm7dmi}, @samp{arm70}, @samp{arm700}, | |
5984 | @samp{arm700i}, @samp{arm710}, @samp{arm710c}, @samp{arm7100}, | |
5985 | @samp{arm7500}, @samp{arm7500fe}, @samp{arm7tdmi}, @samp{arm8}, | |
5986 | @samp{strongarm}, @samp{strongarm110}, @samp{strongarm1100}, | |
5987 | @samp{arm8}, @samp{arm810}, @samp{arm9}, @samp{arm9e}, @samp{arm920}, | |
5988 | @samp{arm920t}, @samp{arm940t}, @samp{arm9tdmi}, @samp{arm10tdmi}, | |
5989 | @samp{arm1020t}, @samp{xscale}. | |
62b10bbc | 5990 | |
cd3bb277 JM |
5991 | @itemx -mtune=@var{name} |
5992 | @opindex mtune | |
630d3d5a | 5993 | This option is very similar to the @option{-mcpu=} option, except that |
62b10bbc NC |
5994 | instead of specifying the actual target processor type, and hence |
5995 | restricting which instructions can be used, it specifies that GCC should | |
5996 | tune the performance of the code as if the target were of the type | |
5997 | specified in this option, but still choosing the instructions that it | |
630d3d5a | 5998 | will generate based on the cpu specified by a @option{-mcpu=} option. |
247f8561 | 5999 | For some ARM implementations better performance can be obtained by using |
62b10bbc | 6000 | this option. |
157a620e | 6001 | |
cd3bb277 JM |
6002 | @item -march=@var{name} |
6003 | @opindex march | |
157a620e | 6004 | This specifies the name of the target ARM architecture. GCC uses this |
247f8561 | 6005 | name to determine what kind of instructions it can emit when generating |
157a620e | 6006 | assembly code. This option can be used in conjunction with or instead |
aee96fe9 JM |
6007 | of the @option{-mcpu=} option. Permissible names are: @samp{armv2}, |
6008 | @samp{armv2a}, @samp{armv3}, @samp{armv3m}, @samp{armv4}, @samp{armv4t}, | |
6009 | @samp{armv5}, @samp{armv5t}, @samp{armv5te}. | |
157a620e | 6010 | |
cd3bb277 JM |
6011 | @item -mfpe=@var{number} |
6012 | @itemx -mfp=@var{number} | |
6013 | @opindex mfpe | |
6014 | @opindex mfp | |
b192711e | 6015 | This specifies the version of the floating point emulation available on |
630d3d5a | 6016 | the target. Permissible values are 2 and 3. @option{-mfp=} is a synonym |
161d7b59 | 6017 | for @option{-mfpe=}, for compatibility with older versions of GCC@. |
157a620e | 6018 | |
cd3bb277 JM |
6019 | @item -mstructure-size-boundary=@var{n} |
6020 | @opindex mstructure-size-boundary | |
157a620e | 6021 | The size of all structures and unions will be rounded up to a multiple |
ed0e6530 | 6022 | of the number of bits set by this option. Permissible values are 8 and |
157a620e NC |
6023 | 32. The default value varies for different toolchains. For the COFF |
6024 | targeted toolchain the default value is 8. Specifying the larger number | |
ed0e6530 | 6025 | can produce faster, more efficient code, but can also increase the size |
157a620e NC |
6026 | of the program. The two values are potentially incompatible. Code |
6027 | compiled with one value cannot necessarily expect to work with code or | |
6028 | libraries compiled with the other value, if they exchange information | |
247f8561 | 6029 | using structures or unions. |
157a620e | 6030 | |
f5a1b0d2 | 6031 | @item -mabort-on-noreturn |
cd3bb277 | 6032 | @opindex mabort-on-noreturn |
247f8561 PB |
6033 | Generate a call to the function @code{abort} at the end of a |
6034 | @code{noreturn} function. It will be executed if the function tries to | |
6035 | return. | |
f5a1b0d2 | 6036 | |
c27ba912 DM |
6037 | @item -mlong-calls |
6038 | @itemx -mno-long-calls | |
cd3bb277 JM |
6039 | @opindex mlong-calls |
6040 | @opindex mno-long-calls | |
c27ba912 DM |
6041 | Tells the compiler to perform function calls by first loading the |
6042 | address of the function into a register and then performing a subroutine | |
6043 | call on this register. This switch is needed if the target function | |
6044 | will lie outside of the 64 megabyte addressing range of the offset based | |
02f52e19 | 6045 | version of subroutine call instruction. |
c27ba912 DM |
6046 | |
6047 | Even if this switch is enabled, not all function calls will be turned | |
6048 | into long calls. The heuristic is that static functions, functions | |
6049 | which have the @samp{short-call} attribute, functions that are inside | |
6050 | the scope of a @samp{#pragma no_long_calls} directive and functions whose | |
6051 | definitions have already been compiled within the current compilation | |
6052 | unit, will not be turned into long calls. The exception to this rule is | |
b192711e | 6053 | that weak function definitions, functions with the @samp{long-call} |
c27ba912 DM |
6054 | attribute or the @samp{section} attribute, and functions that are within |
6055 | the scope of a @samp{#pragma long_calls} directive, will always be | |
6056 | turned into long calls. | |
6057 | ||
6058 | This feature is not enabled by default. Specifying | |
630d3d5a | 6059 | @option{-mno-long-calls} will restore the default behaviour, as will |
c27ba912 DM |
6060 | placing the function calls within the scope of a @samp{#pragma |
6061 | long_calls_off} directive. Note these switches have no effect on how | |
6062 | the compiler generates code to handle function calls via function | |
02f52e19 | 6063 | pointers. |
c27ba912 | 6064 | |
62b10bbc | 6065 | @item -mnop-fun-dllimport |
cd3bb277 | 6066 | @opindex mnop-fun-dllimport |
aee96fe9 | 6067 | Disable support for the @code{dllimport} attribute. |
62b10bbc | 6068 | |
ed0e6530 | 6069 | @item -msingle-pic-base |
cd3bb277 | 6070 | @opindex msingle-pic-base |
ed0e6530 PB |
6071 | Treat the register used for PIC addressing as read-only, rather than |
6072 | loading it in the prologue for each function. The run-time system is | |
6073 | responsible for initialising this register with an appropriate value | |
6074 | before execution begins. | |
6075 | ||
cd3bb277 JM |
6076 | @item -mpic-register=@var{reg} |
6077 | @opindex mpic-register | |
ed0e6530 PB |
6078 | Specify the register to be used for PIC addressing. The default is R10 |
6079 | unless stack-checking is enabled, when R9 is used. | |
6080 | ||
247f8561 | 6081 | @item -mpoke-function-name |
cd3bb277 | 6082 | @opindex mpoke-function-name |
247f8561 PB |
6083 | Write the name of each function into the text section, directly |
6084 | preceding the function prologue. The generated code is similar to this: | |
74291a4b | 6085 | |
247f8561 PB |
6086 | @smallexample |
6087 | t0 | |
6088 | .ascii "arm_poke_function_name", 0 | |
6089 | .align | |
6090 | t1 | |
6091 | .word 0xff000000 + (t1 - t0) | |
6092 | arm_poke_function_name | |
6093 | mov ip, sp | |
6094 | stmfd sp!, @{fp, ip, lr, pc@} | |
6095 | sub fp, ip, #4 | |
6096 | @end smallexample | |
157a620e | 6097 | |
247f8561 PB |
6098 | When performing a stack backtrace, code can inspect the value of |
6099 | @code{pc} stored at @code{fp + 0}. If the trace function then looks at | |
6100 | location @code{pc - 12} and the top 8 bits are set, then we know that | |
6101 | there is a function name embedded immediately preceding this location | |
6102 | and has length @code{((pc[-3]) & 0xff000000)}. | |
157a620e | 6103 | |
247f8561 | 6104 | @item -mthumb |
cd3bb277 | 6105 | @opindex mthumb |
247f8561 PB |
6106 | Generate code for the 16-bit Thumb instruction set. The default is to |
6107 | use the 32-bit ARM instruction set. | |
157a620e NC |
6108 | |
6109 | @item -mtpcs-frame | |
cd3bb277 | 6110 | @opindex mtpcs-frame |
157a620e NC |
6111 | Generate a stack frame that is compliant with the Thumb Procedure Call |
6112 | Standard for all non-leaf functions. (A leaf function is one that does | |
630d3d5a | 6113 | not call any other functions.) The default is @option{-mno-tpcs-frame}. |
157a620e NC |
6114 | |
6115 | @item -mtpcs-leaf-frame | |
cd3bb277 | 6116 | @opindex mtpcs-leaf-frame |
157a620e NC |
6117 | Generate a stack frame that is compliant with the Thumb Procedure Call |
6118 | Standard for all leaf functions. (A leaf function is one that does | |
630d3d5a | 6119 | not call any other functions.) The default is @option{-mno-apcs-leaf-frame}. |
62b10bbc NC |
6120 | |
6121 | @item -mcallee-super-interworking | |
cd3bb277 | 6122 | @opindex mcallee-super-interworking |
62b10bbc NC |
6123 | Gives all externally visible functions in the file being compiled an ARM |
6124 | instruction set header which switches to Thumb mode before executing the | |
6125 | rest of the function. This allows these functions to be called from | |
6126 | non-interworking code. | |
6127 | ||
6128 | @item -mcaller-super-interworking | |
cd3bb277 | 6129 | @opindex mcaller-super-interworking |
62b10bbc NC |
6130 | Allows calls via function pointers (including virtual functions) to |
6131 | execute correctly regardless of whether the target code has been | |
6132 | compiled for interworking or not. There is a small overhead in the cost | |
4bdc1ac7 PB |
6133 | of executing a function pointer if this option is enabled. |
6134 | ||
157a620e NC |
6135 | @end table |
6136 | ||
ecff22ab JL |
6137 | @node MN10200 Options |
6138 | @subsection MN10200 Options | |
6139 | @cindex MN10200 options | |
630d3d5a | 6140 | These @option{-m} options are defined for Matsushita MN10200 architectures: |
2642624b | 6141 | @table @gcctabopt |
ecff22ab JL |
6142 | |
6143 | @item -mrelax | |
cd3bb277 | 6144 | @opindex mrelax |
ecff22ab JL |
6145 | Indicate to the linker that it should perform a relaxation optimization pass |
6146 | to shorten branches, calls and absolute memory addresses. This option only | |
6147 | has an effect when used on the command line for the final link step. | |
6148 | ||
02f52e19 | 6149 | This option makes symbolic debugging impossible. |
ecff22ab | 6150 | @end table |
157a620e | 6151 | |
6d6d0fa0 JL |
6152 | @node MN10300 Options |
6153 | @subsection MN10300 Options | |
6154 | @cindex MN10300 options | |
630d3d5a | 6155 | These @option{-m} options are defined for Matsushita MN10300 architectures: |
6d6d0fa0 | 6156 | |
2642624b | 6157 | @table @gcctabopt |
6d6d0fa0 | 6158 | @item -mmult-bug |
cd3bb277 | 6159 | @opindex mmult-bug |
6d6d0fa0 JL |
6160 | Generate code to avoid bugs in the multiply instructions for the MN10300 |
6161 | processors. This is the default. | |
6162 | ||
6163 | @item -mno-mult-bug | |
cd3bb277 | 6164 | @opindex mno-mult-bug |
6d6d0fa0 JL |
6165 | Do not generate code to avoid bugs in the multiply instructions for the |
6166 | MN10300 processors. | |
ecff22ab | 6167 | |
705ac34f | 6168 | @item -mam33 |
cd3bb277 | 6169 | @opindex mam33 |
705ac34f JL |
6170 | Generate code which uses features specific to the AM33 processor. |
6171 | ||
6172 | @item -mno-am33 | |
cd3bb277 | 6173 | @opindex mno-am33 |
705ac34f JL |
6174 | Do not generate code which uses features specific to the AM33 processor. This |
6175 | is the default. | |
6176 | ||
c474f76b AO |
6177 | @item -mno-crt0 |
6178 | @opindex mno-crt0 | |
6179 | Do not link in the C run-time initialization object file. | |
6180 | ||
ecff22ab | 6181 | @item -mrelax |
cd3bb277 | 6182 | @opindex mrelax |
ecff22ab JL |
6183 | Indicate to the linker that it should perform a relaxation optimization pass |
6184 | to shorten branches, calls and absolute memory addresses. This option only | |
6185 | has an effect when used on the command line for the final link step. | |
6186 | ||
02f52e19 | 6187 | This option makes symbolic debugging impossible. |
6d6d0fa0 JL |
6188 | @end table |
6189 | ||
ecff22ab | 6190 | |
861bb6c1 JL |
6191 | @node M32R/D Options |
6192 | @subsection M32R/D Options | |
6193 | @cindex M32R/D options | |
6194 | ||
630d3d5a | 6195 | These @option{-m} options are defined for Mitsubishi M32R/D architectures: |
861bb6c1 | 6196 | |
2642624b | 6197 | @table @gcctabopt |
861bb6c1 | 6198 | @item -mcode-model=small |
cd3bb277 | 6199 | @opindex mcode-model=small |
861bb6c1 JL |
6200 | Assume all objects live in the lower 16MB of memory (so that their addresses |
6201 | can be loaded with the @code{ld24} instruction), and assume all subroutines | |
6202 | are reachable with the @code{bl} instruction. | |
6203 | This is the default. | |
6204 | ||
6205 | The addressability of a particular object can be set with the | |
6206 | @code{model} attribute. | |
6207 | ||
6208 | @item -mcode-model=medium | |
cd3bb277 | 6209 | @opindex mcode-model=medium |
02f52e19 | 6210 | Assume objects may be anywhere in the 32-bit address space (the compiler |
861bb6c1 JL |
6211 | will generate @code{seth/add3} instructions to load their addresses), and |
6212 | assume all subroutines are reachable with the @code{bl} instruction. | |
6213 | ||
6214 | @item -mcode-model=large | |
cd3bb277 | 6215 | @opindex mcode-model=large |
02f52e19 | 6216 | Assume objects may be anywhere in the 32-bit address space (the compiler |
861bb6c1 JL |
6217 | will generate @code{seth/add3} instructions to load their addresses), and |
6218 | assume subroutines may not be reachable with the @code{bl} instruction | |
6219 | (the compiler will generate the much slower @code{seth/add3/jl} | |
6220 | instruction sequence). | |
6221 | ||
6222 | @item -msdata=none | |
cd3bb277 | 6223 | @opindex msdata=none |
861bb6c1 JL |
6224 | Disable use of the small data area. Variables will be put into |
6225 | one of @samp{.data}, @samp{bss}, or @samp{.rodata} (unless the | |
6226 | @code{section} attribute has been specified). | |
6227 | This is the default. | |
6228 | ||
6229 | The small data area consists of sections @samp{.sdata} and @samp{.sbss}. | |
6230 | Objects may be explicitly put in the small data area with the | |
6231 | @code{section} attribute using one of these sections. | |
6232 | ||
6233 | @item -msdata=sdata | |
cd3bb277 | 6234 | @opindex msdata=sdata |
861bb6c1 JL |
6235 | Put small global and static data in the small data area, but do not |
6236 | generate special code to reference them. | |
6237 | ||
6238 | @item -msdata=use | |
cd3bb277 | 6239 | @opindex msdata=use |
861bb6c1 JL |
6240 | Put small global and static data in the small data area, and generate |
6241 | special instructions to reference them. | |
6242 | ||
6243 | @item -G @var{num} | |
cd3bb277 | 6244 | @opindex G |
861bb6c1 JL |
6245 | @cindex smaller data references |
6246 | Put global and static objects less than or equal to @var{num} bytes | |
6247 | into the small data or bss sections instead of the normal data or bss | |
6248 | sections. The default value of @var{num} is 8. | |
630d3d5a | 6249 | The @option{-msdata} option must be set to one of @samp{sdata} or @samp{use} |
861bb6c1 JL |
6250 | for this option to have any effect. |
6251 | ||
630d3d5a | 6252 | All modules should be compiled with the same @option{-G @var{num}} value. |
861bb6c1 | 6253 | Compiling with different values of @var{num} may or may not work; if it |
695ac33f | 6254 | doesn't the linker will give an error message---incorrect code will not be |
861bb6c1 JL |
6255 | generated. |
6256 | ||
6257 | @end table | |
6258 | ||
74291a4b MM |
6259 | @node M88K Options |
6260 | @subsection M88K Options | |
6261 | @cindex M88k options | |
6262 | ||
6263 | These @samp{-m} options are defined for Motorola 88k architectures: | |
6264 | ||
2642624b | 6265 | @table @gcctabopt |
74291a4b | 6266 | @item -m88000 |
cd3bb277 | 6267 | @opindex m88000 |
74291a4b MM |
6268 | Generate code that works well on both the m88100 and the |
6269 | m88110. | |
6270 | ||
6271 | @item -m88100 | |
cd3bb277 | 6272 | @opindex m88100 |
74291a4b MM |
6273 | Generate code that works best for the m88100, but that also |
6274 | runs on the m88110. | |
6275 | ||
6276 | @item -m88110 | |
cd3bb277 | 6277 | @opindex m88110 |
74291a4b MM |
6278 | Generate code that works best for the m88110, and may not run |
6279 | on the m88100. | |
6280 | ||
6281 | @item -mbig-pic | |
cd3bb277 | 6282 | @opindex mbig-pic |
74291a4b | 6283 | Obsolete option to be removed from the next revision. |
630d3d5a | 6284 | Use @option{-fPIC}. |
74291a4b MM |
6285 | |
6286 | @item -midentify-revision | |
cd3bb277 | 6287 | @opindex midentify-revision |
74291a4b MM |
6288 | @cindex identifying source, compiler (88k) |
6289 | Include an @code{ident} directive in the assembler output recording the | |
6290 | source file name, compiler name and version, timestamp, and compilation | |
6291 | flags used. | |
6292 | ||
6293 | @item -mno-underscores | |
cd3bb277 | 6294 | @opindex mno-underscores |
74291a4b MM |
6295 | @cindex underscores, avoiding (88k) |
6296 | In assembler output, emit symbol names without adding an underscore | |
6297 | character at the beginning of each name. The default is to use an | |
6298 | underscore as prefix on each name. | |
6299 | ||
6300 | @item -mocs-debug-info | |
6301 | @itemx -mno-ocs-debug-info | |
cd3bb277 JM |
6302 | @opindex mocs-debug-info |
6303 | @opindex mno-ocs-debug-info | |
74291a4b MM |
6304 | @cindex OCS (88k) |
6305 | @cindex debugging, 88k OCS | |
6306 | Include (or omit) additional debugging information (about registers used | |
6307 | in each stack frame) as specified in the 88open Object Compatibility | |
161d7b59 | 6308 | Standard, ``OCS''@. This extra information allows debugging of code that |
74291a4b MM |
6309 | has had the frame pointer eliminated. The default for DG/UX, SVr4, and |
6310 | Delta 88 SVr3.2 is to include this information; other 88k configurations | |
6311 | omit this information by default. | |
6312 | ||
6313 | @item -mocs-frame-position | |
cd3bb277 | 6314 | @opindex mocs-frame-position |
74291a4b MM |
6315 | @cindex register positions in frame (88k) |
6316 | When emitting COFF debugging information for automatic variables and | |
6317 | parameters stored on the stack, use the offset from the canonical frame | |
6318 | address, which is the stack pointer (register 31) on entry to the | |
6319 | function. The DG/UX, SVr4, Delta88 SVr3.2, and BCS configurations use | |
630d3d5a JM |
6320 | @option{-mocs-frame-position}; other 88k configurations have the default |
6321 | @option{-mno-ocs-frame-position}. | |
74291a4b MM |
6322 | |
6323 | @item -mno-ocs-frame-position | |
cd3bb277 | 6324 | @opindex mno-ocs-frame-position |
74291a4b MM |
6325 | @cindex register positions in frame (88k) |
6326 | When emitting COFF debugging information for automatic variables and | |
6327 | parameters stored on the stack, use the offset from the frame pointer | |
6328 | register (register 30). When this option is in effect, the frame | |
6329 | pointer is not eliminated when debugging information is selected by the | |
6330 | -g switch. | |
6331 | ||
6332 | @item -moptimize-arg-area | |
cd3bb277 | 6333 | @opindex moptimize-arg-area |
74291a4b | 6334 | @cindex arguments in frame (88k) |
9c34dbbf ZW |
6335 | Save space by reorganizing the stack frame. This option generates code |
6336 | that does not agree with the 88open specifications, but uses less | |
6337 | memory. | |
6338 | ||
6339 | @itemx -mno-optimize-arg-area | |
6340 | @opindex mno-optimize-arg-area | |
6341 | Do not reorganize the stack frame to save space. This is the default. | |
6342 | The generated conforms to the specification, but uses more memory. | |
74291a4b MM |
6343 | |
6344 | @item -mshort-data-@var{num} | |
cd3bb277 | 6345 | @opindex mshort-data |
74291a4b MM |
6346 | @cindex smaller data references (88k) |
6347 | @cindex r0-relative references (88k) | |
6348 | Generate smaller data references by making them relative to @code{r0}, | |
6349 | which allows loading a value using a single instruction (rather than the | |
6350 | usual two). You control which data references are affected by | |
6351 | specifying @var{num} with this option. For example, if you specify | |
630d3d5a | 6352 | @option{-mshort-data-512}, then the data references affected are those |
74291a4b | 6353 | involving displacements of less than 512 bytes. |
630d3d5a | 6354 | @option{-mshort-data-@var{num}} is not effective for @var{num} greater |
74291a4b MM |
6355 | than 64k. |
6356 | ||
6357 | @item -mserialize-volatile | |
cd3bb277 | 6358 | @opindex mserialize-volatile |
74291a4b | 6359 | @itemx -mno-serialize-volatile |
cd3bb277 | 6360 | @opindex mno-serialize-volatile |
74291a4b MM |
6361 | @cindex sequential consistency on 88k |
6362 | Do, or don't, generate code to guarantee sequential consistency | |
6363 | of volatile memory references. By default, consistency is | |
6364 | guaranteed. | |
6365 | ||
6366 | The order of memory references made by the MC88110 processor does | |
6367 | not always match the order of the instructions requesting those | |
6368 | references. In particular, a load instruction may execute before | |
6369 | a preceding store instruction. Such reordering violates | |
6370 | sequential consistency of volatile memory references, when there | |
6371 | are multiple processors. When consistency must be guaranteed, | |
f0523f02 | 6372 | GCC generates special instructions, as needed, to force |
74291a4b MM |
6373 | execution in the proper order. |
6374 | ||
6375 | The MC88100 processor does not reorder memory references and so | |
f0523f02 JM |
6376 | always provides sequential consistency. However, by default, GCC |
6377 | generates the special instructions to guarantee consistency | |
630d3d5a | 6378 | even when you use @option{-m88100}, so that the code may be run on an |
74291a4b | 6379 | MC88110 processor. If you intend to run your code only on the |
630d3d5a | 6380 | MC88100 processor, you may use @option{-mno-serialize-volatile}. |
74291a4b MM |
6381 | |
6382 | The extra code generated to guarantee consistency may affect the | |
6383 | performance of your application. If you know that you can safely | |
630d3d5a | 6384 | forgo this guarantee, you may use @option{-mno-serialize-volatile}. |
74291a4b MM |
6385 | |
6386 | @item -msvr4 | |
6387 | @itemx -msvr3 | |
cd3bb277 JM |
6388 | @opindex msvr4 |
6389 | @opindex msvr3 | |
74291a4b MM |
6390 | @cindex assembler syntax, 88k |
6391 | @cindex SVr4 | |
630d3d5a | 6392 | Turn on (@option{-msvr4}) or off (@option{-msvr3}) compiler extensions |
74291a4b MM |
6393 | related to System V release 4 (SVr4). This controls the following: |
6394 | ||
6395 | @enumerate | |
6396 | @item | |
6397 | Which variant of the assembler syntax to emit. | |
6398 | @item | |
630d3d5a | 6399 | @option{-msvr4} makes the C preprocessor recognize @samp{#pragma weak} |
74291a4b MM |
6400 | that is used on System V release 4. |
6401 | @item | |
630d3d5a | 6402 | @option{-msvr4} makes GCC issue additional declaration directives used in |
74291a4b MM |
6403 | SVr4. |
6404 | @end enumerate | |
6405 | ||
630d3d5a | 6406 | @option{-msvr4} is the default for the m88k-motorola-sysv4 and |
767094dd | 6407 | m88k-dg-dgux m88k configurations. @option{-msvr3} is the default for all |
74291a4b MM |
6408 | other m88k configurations. |
6409 | ||
6410 | @item -mversion-03.00 | |
cd3bb277 | 6411 | @opindex mversion-03.00 |
74291a4b MM |
6412 | This option is obsolete, and is ignored. |
6413 | @c ??? which asm syntax better for GAS? option there too? | |
6414 | ||
6415 | @item -mno-check-zero-division | |
6416 | @itemx -mcheck-zero-division | |
cd3bb277 JM |
6417 | @opindex mno-check-zero-division |
6418 | @opindex mcheck-zero-division | |
74291a4b MM |
6419 | @cindex zero division on 88k |
6420 | Do, or don't, generate code to guarantee that integer division by | |
6421 | zero will be detected. By default, detection is guaranteed. | |
6422 | ||
6423 | Some models of the MC88100 processor fail to trap upon integer | |
6424 | division by zero under certain conditions. By default, when | |
f0523f02 | 6425 | compiling code that might be run on such a processor, GCC |
74291a4b MM |
6426 | generates code that explicitly checks for zero-valued divisors |
6427 | and traps with exception number 503 when one is detected. Use of | |
9c34dbbf | 6428 | @option{-mno-check-zero-division} suppresses such checking for code |
74291a4b MM |
6429 | generated to run on an MC88100 processor. |
6430 | ||
9c34dbbf ZW |
6431 | GCC assumes that the MC88110 processor correctly detects all instances |
6432 | of integer division by zero. When @option{-m88110} is specified, no | |
6433 | explicit checks for zero-valued divisors are generated, and both | |
6434 | @option{-mcheck-zero-division} and @option{-mno-check-zero-division} are | |
6435 | ignored. | |
74291a4b MM |
6436 | |
6437 | @item -muse-div-instruction | |
cd3bb277 | 6438 | @opindex muse-div-instruction |
74291a4b MM |
6439 | @cindex divide instruction, 88k |
6440 | Use the div instruction for signed integer division on the | |
6441 | MC88100 processor. By default, the div instruction is not used. | |
6442 | ||
6443 | On the MC88100 processor the signed integer division instruction | |
6444 | div) traps to the operating system on a negative operand. The | |
6445 | operating system transparently completes the operation, but at a | |
6446 | large cost in execution time. By default, when compiling code | |
f0523f02 | 6447 | that might be run on an MC88100 processor, GCC emulates signed |
74291a4b MM |
6448 | integer division using the unsigned integer division instruction |
6449 | divu), thereby avoiding the large penalty of a trap to the | |
6450 | operating system. Such emulation has its own, smaller, execution | |
6451 | cost in both time and space. To the extent that your code's | |
6452 | important signed integer division operations are performed on two | |
6453 | nonnegative operands, it may be desirable to use the div | |
6454 | instruction directly. | |
6455 | ||
6456 | On the MC88110 processor the div instruction (also known as the | |
6457 | divs instruction) processes negative operands without trapping to | |
630d3d5a JM |
6458 | the operating system. When @option{-m88110} is specified, |
6459 | @option{-muse-div-instruction} is ignored, and the div instruction is used | |
74291a4b MM |
6460 | for signed integer division. |
6461 | ||
630d3d5a | 6462 | Note that the result of dividing @code{INT_MIN} by @minus{}1 is undefined. In |
74291a4b | 6463 | particular, the behavior of such a division with and without |
630d3d5a | 6464 | @option{-muse-div-instruction} may differ. |
74291a4b MM |
6465 | |
6466 | @item -mtrap-large-shift | |
6467 | @itemx -mhandle-large-shift | |
cd3bb277 JM |
6468 | @opindex mtrap-large-shift |
6469 | @opindex mhandle-large-shift | |
74291a4b MM |
6470 | @cindex bit shift overflow (88k) |
6471 | @cindex large bit shifts (88k) | |
6472 | Include code to detect bit-shifts of more than 31 bits; respectively, | |
0c2d1a2a | 6473 | trap such shifts or emit code to handle them properly. By default GCC |
74291a4b MM |
6474 | makes no special provision for large bit shifts. |
6475 | ||
6476 | @item -mwarn-passed-structs | |
cd3bb277 | 6477 | @opindex mwarn-passed-structs |
74291a4b MM |
6478 | @cindex structure passing (88k) |
6479 | Warn when a function passes a struct as an argument or result. | |
6480 | Structure-passing conventions have changed during the evolution of the C | |
6481 | language, and are often the source of portability problems. By default, | |
0c2d1a2a | 6482 | GCC issues no such warning. |
74291a4b MM |
6483 | @end table |
6484 | ||
9c34dbbf ZW |
6485 | @c break page here to avoid unsightly interparagraph stretch. |
6486 | @c -zw, 2001-8-17 | |
6487 | @page | |
6488 | ||
74291a4b MM |
6489 | @node RS/6000 and PowerPC Options |
6490 | @subsection IBM RS/6000 and PowerPC Options | |
6491 | @cindex RS/6000 and PowerPC Options | |
6492 | @cindex IBM RS/6000 and PowerPC Options | |
6493 | ||
6494 | These @samp{-m} options are defined for the IBM RS/6000 and PowerPC: | |
2642624b | 6495 | @table @gcctabopt |
74291a4b MM |
6496 | @item -mpower |
6497 | @itemx -mno-power | |
6498 | @itemx -mpower2 | |
6499 | @itemx -mno-power2 | |
6500 | @itemx -mpowerpc | |
6501 | @itemx -mno-powerpc | |
6502 | @itemx -mpowerpc-gpopt | |
6503 | @itemx -mno-powerpc-gpopt | |
6504 | @itemx -mpowerpc-gfxopt | |
6505 | @itemx -mno-powerpc-gfxopt | |
7fe90e7b DE |
6506 | @itemx -mpowerpc64 |
6507 | @itemx -mno-powerpc64 | |
cd3bb277 JM |
6508 | @opindex mpower |
6509 | @opindex mno-power | |
6510 | @opindex mpower2 | |
6511 | @opindex mno-power2 | |
6512 | @opindex mpowerpc | |
6513 | @opindex mno-powerpc | |
6514 | @opindex mpowerpc-gpopt | |
6515 | @opindex mno-powerpc-gpopt | |
6516 | @opindex mpowerpc-gfxopt | |
6517 | @opindex mno-powerpc-gfxopt | |
6518 | @opindex mpowerpc64 | |
6519 | @opindex mno-powerpc64 | |
0c2d1a2a | 6520 | GCC supports two related instruction set architectures for the |
161d7b59 | 6521 | RS/6000 and PowerPC@. The @dfn{POWER} instruction set are those |
74291a4b MM |
6522 | instructions supported by the @samp{rios} chip set used in the original |
6523 | RS/6000 systems and the @dfn{PowerPC} instruction set is the | |
6524 | architecture of the Motorola MPC5xx, MPC6xx, MPC8xx microprocessors, and | |
861bb6c1 | 6525 | the IBM 4xx microprocessors. |
74291a4b MM |
6526 | |
6527 | Neither architecture is a subset of the other. However there is a | |
6528 | large common subset of instructions supported by both. An MQ | |
6529 | register is included in processors supporting the POWER architecture. | |
6530 | ||
6531 | You use these options to specify which instructions are available on the | |
6532 | processor you are using. The default value of these options is | |
161d7b59 | 6533 | determined when configuring GCC@. Specifying the |
630d3d5a JM |
6534 | @option{-mcpu=@var{cpu_type}} overrides the specification of these |
6535 | options. We recommend you use the @option{-mcpu=@var{cpu_type}} option | |
74291a4b MM |
6536 | rather than the options listed above. |
6537 | ||
630d3d5a | 6538 | The @option{-mpower} option allows GCC to generate instructions that |
74291a4b | 6539 | are found only in the POWER architecture and to use the MQ register. |
630d3d5a | 6540 | Specifying @option{-mpower2} implies @option{-power} and also allows GCC |
74291a4b MM |
6541 | to generate instructions that are present in the POWER2 architecture but |
6542 | not the original POWER architecture. | |
6543 | ||
630d3d5a | 6544 | The @option{-mpowerpc} option allows GCC to generate instructions that |
74291a4b | 6545 | are found only in the 32-bit subset of the PowerPC architecture. |
630d3d5a | 6546 | Specifying @option{-mpowerpc-gpopt} implies @option{-mpowerpc} and also allows |
0c2d1a2a | 6547 | GCC to use the optional PowerPC architecture instructions in the |
74291a4b | 6548 | General Purpose group, including floating-point square root. Specifying |
630d3d5a | 6549 | @option{-mpowerpc-gfxopt} implies @option{-mpowerpc} and also allows GCC to |
74291a4b MM |
6550 | use the optional PowerPC architecture instructions in the Graphics |
6551 | group, including floating-point select. | |
6552 | ||
630d3d5a | 6553 | The @option{-mpowerpc64} option allows GCC to generate the additional |
7fe90e7b | 6554 | 64-bit instructions that are found in the full PowerPC64 architecture |
0c2d1a2a | 6555 | and to treat GPRs as 64-bit, doubleword quantities. GCC defaults to |
630d3d5a | 6556 | @option{-mno-powerpc64}. |
7fe90e7b | 6557 | |
630d3d5a | 6558 | If you specify both @option{-mno-power} and @option{-mno-powerpc}, GCC |
74291a4b MM |
6559 | will use only the instructions in the common subset of both |
6560 | architectures plus some special AIX common-mode calls, and will not use | |
630d3d5a | 6561 | the MQ register. Specifying both @option{-mpower} and @option{-mpowerpc} |
0c2d1a2a | 6562 | permits GCC to use any instruction from either architecture and to |
74291a4b MM |
6563 | allow use of the MQ register; specify this for the Motorola MPC601. |
6564 | ||
6565 | @item -mnew-mnemonics | |
6566 | @itemx -mold-mnemonics | |
cd3bb277 JM |
6567 | @opindex mnew-mnemonics |
6568 | @opindex mold-mnemonics | |
9c34dbbf ZW |
6569 | Select which mnemonics to use in the generated assembler code. With |
6570 | @option{-mnew-mnemonics}, GCC uses the assembler mnemonics defined for | |
6571 | the PowerPC architecture. With @option{-mold-mnemonics} it uses the | |
6572 | assembler mnemonics defined for the POWER architecture. Instructions | |
6573 | defined in only one architecture have only one mnemonic; GCC uses that | |
6574 | mnemonic irrespective of which of these options is specified. | |
74291a4b | 6575 | |
0c2d1a2a | 6576 | GCC defaults to the mnemonics appropriate for the architecture in |
630d3d5a | 6577 | use. Specifying @option{-mcpu=@var{cpu_type}} sometimes overrides the |
7fe90e7b | 6578 | value of these option. Unless you are building a cross-compiler, you |
630d3d5a JM |
6579 | should normally not specify either @option{-mnew-mnemonics} or |
6580 | @option{-mold-mnemonics}, but should instead accept the default. | |
74291a4b MM |
6581 | |
6582 | @item -mcpu=@var{cpu_type} | |
cd3bb277 | 6583 | @opindex mcpu |
74291a4b MM |
6584 | Set architecture type, register usage, choice of mnemonics, and |
6585 | instruction scheduling parameters for machine type @var{cpu_type}. | |
5f59ecb7 DE |
6586 | Supported values for @var{cpu_type} are @samp{rios}, @samp{rios1}, |
6587 | @samp{rsc}, @samp{rios2}, @samp{rs64a}, @samp{601}, @samp{602}, | |
6588 | @samp{603}, @samp{603e}, @samp{604}, @samp{604e}, @samp{620}, | |
6589 | @samp{630}, @samp{740}, @samp{750}, @samp{power}, @samp{power2}, | |
6590 | @samp{powerpc}, @samp{403}, @samp{505}, @samp{801}, @samp{821}, | |
9c34dbbf ZW |
6591 | @samp{823}, and @samp{860} and @samp{common}. |
6592 | ||
6593 | @option{-mcpu=common} selects a completely generic processor. Code | |
6594 | generated under this option will run on any POWER or PowerPC processor. | |
6595 | GCC will use only the instructions in the common subset of both | |
6596 | architectures, and will not use the MQ register. GCC assumes a generic | |
74291a4b MM |
6597 | processor model for scheduling purposes. |
6598 | ||
9c34dbbf ZW |
6599 | @option{-mcpu=power}, @option{-mcpu=power2}, @option{-mcpu=powerpc}, and |
6600 | @option{-mcpu=powerpc64} specify generic POWER, POWER2, pure 32-bit | |
6601 | PowerPC (i.e., not MPC601), and 64-bit PowerPC architecture machine | |
6602 | types, with an appropriate, generic processor model assumed for | |
6603 | scheduling purposes. | |
74291a4b | 6604 | |
9c34dbbf ZW |
6605 | The other options specify a specific processor. Code generated under |
6606 | those options will run best on that processor, and may not run at all on | |
6607 | others. | |
6608 | ||
6609 | The @option{-mcpu} options automatically enable or disable other | |
6610 | @option{-m} options as follows: | |
6611 | ||
6612 | @table @samp | |
6613 | @item common | |
6614 | @option{-mno-power}, @option{-mno-powerc} | |
6615 | ||
6616 | @item power | |
6617 | @itemx power2 | |
6618 | @itemx rios1 | |
6619 | @itemx rios2 | |
6620 | @itemx rsc | |
6621 | @option{-mpower}, @option{-mno-powerpc}, @option{-mno-new-mnemonics} | |
6622 | ||
6623 | @item powerpc | |
6624 | @itemx rs64a | |
6625 | @itemx 602 | |
6626 | @itemx 603 | |
6627 | @itemx 603e | |
6628 | @itemx 604 | |
6629 | @itemx 620 | |
6630 | @itemx 630 | |
6631 | @itemx 740 | |
6632 | @itemx 750 | |
6633 | @itemx 505 | |
6634 | @option{-mno-power}, @option{-mpowerpc}, @option{-mnew-mnemonics} | |
6635 | ||
6636 | @item 601 | |
6637 | @option{-mpower}, @option{-mpowerpc}, @option{-mnew-mnemonics} | |
6638 | ||
6639 | @item 403 | |
6640 | @itemx 821 | |
6641 | @itemx 860 | |
6642 | @option{-mno-power}, @option{-mpowerpc}, @option{-mnew-mnemonics}, @option{-msoft-float} | |
6643 | @end table | |
74291a4b MM |
6644 | |
6645 | @item -mtune=@var{cpu_type} | |
cd3bb277 | 6646 | @opindex mtune |
74291a4b | 6647 | Set the instruction scheduling parameters for machine type |
9c34dbbf ZW |
6648 | @var{cpu_type}, but do not set the architecture type, register usage, or |
6649 | choice of mnemonics, as @option{-mcpu=@var{cpu_type}} would. The same | |
6650 | values for @var{cpu_type} are used for @option{-mtune} as for | |
6651 | @option{-mcpu}. If both are specified, the code generated will use the | |
6652 | architecture, registers, and mnemonics set by @option{-mcpu}, but the | |
6653 | scheduling parameters set by @option{-mtune}. | |
74291a4b MM |
6654 | |
6655 | @item -mfull-toc | |
6656 | @itemx -mno-fp-in-toc | |
6657 | @itemx -mno-sum-in-toc | |
6658 | @itemx -mminimal-toc | |
cd3bb277 JM |
6659 | @opindex mfull-toc |
6660 | @opindex mno-fp-in-toc | |
6661 | @opindex mno-sum-in-toc | |
6662 | @opindex mminimal-toc | |
74291a4b | 6663 | Modify generation of the TOC (Table Of Contents), which is created for |
630d3d5a | 6664 | every executable file. The @option{-mfull-toc} option is selected by |
0c2d1a2a JB |
6665 | default. In that case, GCC will allocate at least one TOC entry for |
6666 | each unique non-automatic variable reference in your program. GCC | |
161d7b59 JM |
6667 | will also place floating-point constants in the TOC@. However, only |
6668 | 16,384 entries are available in the TOC@. | |
74291a4b MM |
6669 | |
6670 | If you receive a linker error message that saying you have overflowed | |
6671 | the available TOC space, you can reduce the amount of TOC space used | |
630d3d5a JM |
6672 | with the @option{-mno-fp-in-toc} and @option{-mno-sum-in-toc} options. |
6673 | @option{-mno-fp-in-toc} prevents GCC from putting floating-point | |
6674 | constants in the TOC and @option{-mno-sum-in-toc} forces GCC to | |
74291a4b | 6675 | generate code to calculate the sum of an address and a constant at |
161d7b59 | 6676 | run-time instead of putting that sum into the TOC@. You may specify one |
0c2d1a2a | 6677 | or both of these options. Each causes GCC to produce very slightly |
74291a4b MM |
6678 | slower and larger code at the expense of conserving TOC space. |
6679 | ||
6680 | If you still run out of space in the TOC even when you specify both of | |
630d3d5a | 6681 | these options, specify @option{-mminimal-toc} instead. This option causes |
0c2d1a2a JB |
6682 | GCC to make only one TOC entry for every file. When you specify this |
6683 | option, GCC will produce code that is slower and larger but which | |
74291a4b | 6684 | uses extremely little TOC space. You may wish to use this option |
bd819a4a | 6685 | only on files that contain less frequently executed code. |
74291a4b | 6686 | |
fa06229f GK |
6687 | @item -maix64 |
6688 | @itemx -maix32 | |
cd3bb277 JM |
6689 | @opindex maix64 |
6690 | @opindex maix32 | |
fa06229f | 6691 | Enable 64-bit AIX ABI and calling convention: 64-bit pointers, 64-bit |
7fe90e7b | 6692 | @code{long} type, and the infrastructure needed to support them. |
630d3d5a JM |
6693 | Specifying @option{-maix64} implies @option{-mpowerpc64} and |
6694 | @option{-mpowerpc}, while @option{-maix32} disables the 64-bit ABI and | |
6695 | implies @option{-mno-powerpc64}. GCC defaults to @option{-maix32}. | |
7fe90e7b | 6696 | |
74291a4b MM |
6697 | @item -mxl-call |
6698 | @itemx -mno-xl-call | |
cd3bb277 JM |
6699 | @opindex mxl-call |
6700 | @opindex mno-xl-call | |
74291a4b MM |
6701 | On AIX, pass floating-point arguments to prototyped functions beyond the |
6702 | register save area (RSA) on the stack in addition to argument FPRs. The | |
6703 | AIX calling convention was extended but not initially documented to | |
6704 | handle an obscure K&R C case of calling a function that takes the | |
6705 | address of its arguments with fewer arguments than declared. AIX XL | |
7fe90e7b DE |
6706 | compilers access floating point arguments which do not fit in the |
6707 | RSA from the stack when a subroutine is compiled without | |
74291a4b MM |
6708 | optimization. Because always storing floating-point arguments on the |
6709 | stack is inefficient and rarely needed, this option is not enabled by | |
6710 | default and only is necessary when calling subroutines compiled by AIX | |
6711 | XL compilers without optimization. | |
6712 | ||
861bb6c1 | 6713 | @item -mthreads |
cd3bb277 | 6714 | @opindex mthreads |
861bb6c1 JL |
6715 | Support @dfn{AIX Threads}. Link an application written to use |
6716 | @dfn{pthreads} with special libraries and startup code to enable the | |
6717 | application to run. | |
6718 | ||
6719 | @item -mpe | |
cd3bb277 | 6720 | @opindex mpe |
161d7b59 | 6721 | Support @dfn{IBM RS/6000 SP} @dfn{Parallel Environment} (PE)@. Link an |
861bb6c1 JL |
6722 | application written to use message passing with special startup code to |
6723 | enable the application to run. The system must have PE installed in the | |
6724 | standard location (@file{/usr/lpp/ppe.poe/}), or the @file{specs} file | |
630d3d5a | 6725 | must be overridden with the @option{-specs=} option to specify the |
861bb6c1 | 6726 | appropriate directory location. The Parallel Environment does not |
630d3d5a | 6727 | support threads, so the @option{-mpe} option and the @option{-mthreads} |
861bb6c1 JL |
6728 | option are incompatible. |
6729 | ||
74291a4b MM |
6730 | @item -msoft-float |
6731 | @itemx -mhard-float | |
cd3bb277 JM |
6732 | @opindex msoft-float |
6733 | @opindex mhard-float | |
74291a4b MM |
6734 | Generate code that does not use (uses) the floating-point register set. |
6735 | Software floating point emulation is provided if you use the | |
630d3d5a | 6736 | @option{-msoft-float} option, and pass the option to GCC when linking. |
74291a4b MM |
6737 | |
6738 | @item -mmultiple | |
6739 | @itemx -mno-multiple | |
cd3bb277 JM |
6740 | @opindex mmultiple |
6741 | @opindex mno-multiple | |
74291a4b MM |
6742 | Generate code that uses (does not use) the load multiple word |
6743 | instructions and the store multiple word instructions. These | |
6744 | instructions are generated by default on POWER systems, and not | |
630d3d5a | 6745 | generated on PowerPC systems. Do not use @option{-mmultiple} on little |
74291a4b | 6746 | endian PowerPC systems, since those instructions do not work when the |
bef84347 VM |
6747 | processor is in little endian mode. The exceptions are PPC740 and |
6748 | PPC750 which permit the instructions usage in little endian mode. | |
74291a4b MM |
6749 | |
6750 | @item -mstring | |
6751 | @itemx -mno-string | |
cd3bb277 JM |
6752 | @opindex mstring |
6753 | @opindex mno-string | |
bef84347 VM |
6754 | Generate code that uses (does not use) the load string instructions |
6755 | and the store string word instructions to save multiple registers and | |
6756 | do small block moves. These instructions are generated by default on | |
6757 | POWER systems, and not generated on PowerPC systems. Do not use | |
630d3d5a | 6758 | @option{-mstring} on little endian PowerPC systems, since those |
bef84347 VM |
6759 | instructions do not work when the processor is in little endian mode. |
6760 | The exceptions are PPC740 and PPC750 which permit the instructions | |
6761 | usage in little endian mode. | |
74291a4b | 6762 | |
861bb6c1 JL |
6763 | @item -mupdate |
6764 | @itemx -mno-update | |
cd3bb277 JM |
6765 | @opindex mupdate |
6766 | @opindex mno-update | |
861bb6c1 JL |
6767 | Generate code that uses (does not use) the load or store instructions |
6768 | that update the base register to the address of the calculated memory | |
6769 | location. These instructions are generated by default. If you use | |
630d3d5a | 6770 | @option{-mno-update}, there is a small window between the time that the |
861bb6c1 JL |
6771 | stack pointer is updated and the address of the previous frame is |
6772 | stored, which means code that walks the stack frame across interrupts or | |
6773 | signals may get corrupted data. | |
6774 | ||
6775 | @item -mfused-madd | |
6776 | @itemx -mno-fused-madd | |
cd3bb277 JM |
6777 | @opindex mfused-madd |
6778 | @opindex mno-fused-madd | |
861bb6c1 JL |
6779 | Generate code that uses (does not use) the floating point multiply and |
6780 | accumulate instructions. These instructions are generated by default if | |
6781 | hardware floating is used. | |
6782 | ||
74291a4b MM |
6783 | @item -mno-bit-align |
6784 | @itemx -mbit-align | |
cd3bb277 JM |
6785 | @opindex mno-bit-align |
6786 | @opindex mbit-align | |
74291a4b | 6787 | On System V.4 and embedded PowerPC systems do not (do) force structures |
c771326b JM |
6788 | and unions that contain bit-fields to be aligned to the base type of the |
6789 | bit-field. | |
74291a4b MM |
6790 | |
6791 | For example, by default a structure containing nothing but 8 | |
c771326b | 6792 | @code{unsigned} bit-fields of length 1 would be aligned to a 4 byte |
630d3d5a | 6793 | boundary and have a size of 4 bytes. By using @option{-mno-bit-align}, |
74291a4b MM |
6794 | the structure would be aligned to a 1 byte boundary and be one byte in |
6795 | size. | |
6796 | ||
6797 | @item -mno-strict-align | |
6798 | @itemx -mstrict-align | |
cd3bb277 JM |
6799 | @opindex mno-strict-align |
6800 | @opindex mstrict-align | |
74291a4b MM |
6801 | On System V.4 and embedded PowerPC systems do not (do) assume that |
6802 | unaligned memory references will be handled by the system. | |
6803 | ||
6804 | @item -mrelocatable | |
6805 | @itemx -mno-relocatable | |
cd3bb277 JM |
6806 | @opindex mrelocatable |
6807 | @opindex mno-relocatable | |
74291a4b MM |
6808 | On embedded PowerPC systems generate code that allows (does not allow) |
6809 | the program to be relocated to a different address at runtime. If you | |
630d3d5a JM |
6810 | use @option{-mrelocatable} on any module, all objects linked together must |
6811 | be compiled with @option{-mrelocatable} or @option{-mrelocatable-lib}. | |
74291a4b MM |
6812 | |
6813 | @item -mrelocatable-lib | |
6814 | @itemx -mno-relocatable-lib | |
cd3bb277 JM |
6815 | @opindex mrelocatable-lib |
6816 | @opindex mno-relocatable-lib | |
74291a4b MM |
6817 | On embedded PowerPC systems generate code that allows (does not allow) |
6818 | the program to be relocated to a different address at runtime. Modules | |
630d3d5a JM |
6819 | compiled with @option{-mrelocatable-lib} can be linked with either modules |
6820 | compiled without @option{-mrelocatable} and @option{-mrelocatable-lib} or | |
6821 | with modules compiled with the @option{-mrelocatable} options. | |
74291a4b MM |
6822 | |
6823 | @item -mno-toc | |
6824 | @itemx -mtoc | |
cd3bb277 JM |
6825 | @opindex mno-toc |
6826 | @opindex mtoc | |
74291a4b MM |
6827 | On System V.4 and embedded PowerPC systems do not (do) assume that |
6828 | register 2 contains a pointer to a global area pointing to the addresses | |
6829 | used in the program. | |
6830 | ||
74291a4b MM |
6831 | @item -mlittle |
6832 | @itemx -mlittle-endian | |
cd3bb277 JM |
6833 | @opindex mlittle |
6834 | @opindex mlittle-endian | |
74291a4b | 6835 | On System V.4 and embedded PowerPC systems compile code for the |
630d3d5a JM |
6836 | processor in little endian mode. The @option{-mlittle-endian} option is |
6837 | the same as @option{-mlittle}. | |
74291a4b MM |
6838 | |
6839 | @item -mbig | |
6840 | @itemx -mbig-endian | |
cd3bb277 JM |
6841 | @opindex mbig |
6842 | @opindex mbig-endian | |
74291a4b | 6843 | On System V.4 and embedded PowerPC systems compile code for the |
630d3d5a JM |
6844 | processor in big endian mode. The @option{-mbig-endian} option is |
6845 | the same as @option{-mbig}. | |
74291a4b MM |
6846 | |
6847 | @item -mcall-sysv | |
cd3bb277 | 6848 | @opindex mcall-sysv |
74291a4b MM |
6849 | On System V.4 and embedded PowerPC systems compile code using calling |
6850 | conventions that adheres to the March 1995 draft of the System V | |
6851 | Application Binary Interface, PowerPC processor supplement. This is the | |
6852 | default unless you configured GCC using @samp{powerpc-*-eabiaix}. | |
6853 | ||
6854 | @item -mcall-sysv-eabi | |
cd3bb277 | 6855 | @opindex mcall-sysv-eabi |
630d3d5a | 6856 | Specify both @option{-mcall-sysv} and @option{-meabi} options. |
74291a4b MM |
6857 | |
6858 | @item -mcall-sysv-noeabi | |
cd3bb277 | 6859 | @opindex mcall-sysv-noeabi |
630d3d5a | 6860 | Specify both @option{-mcall-sysv} and @option{-mno-eabi} options. |
74291a4b MM |
6861 | |
6862 | @item -mcall-aix | |
cd3bb277 | 6863 | @opindex mcall-aix |
74291a4b | 6864 | On System V.4 and embedded PowerPC systems compile code using calling |
161d7b59 | 6865 | conventions that are similar to those used on AIX@. This is the |
74291a4b MM |
6866 | default if you configured GCC using @samp{powerpc-*-eabiaix}. |
6867 | ||
6868 | @item -mcall-solaris | |
cd3bb277 | 6869 | @opindex mcall-solaris |
74291a4b MM |
6870 | On System V.4 and embedded PowerPC systems compile code for the Solaris |
6871 | operating system. | |
6872 | ||
6873 | @item -mcall-linux | |
cd3bb277 | 6874 | @opindex mcall-linux |
861bb6c1 JL |
6875 | On System V.4 and embedded PowerPC systems compile code for the |
6876 | Linux-based GNU system. | |
74291a4b | 6877 | |
edf1b3f3 AC |
6878 | @item -mcall-netbsd |
6879 | @opindex mcall-netbsd | |
6880 | On System V.4 and embedded PowerPC systems compile code for the | |
6881 | NetBSD operating system. | |
6882 | ||
74291a4b | 6883 | @item -mprototype |
e9a25f70 | 6884 | @itemx -mno-prototype |
cd3bb277 JM |
6885 | @opindex mprototype |
6886 | @opindex mno-prototype | |
74291a4b MM |
6887 | On System V.4 and embedded PowerPC systems assume that all calls to |
6888 | variable argument functions are properly prototyped. Otherwise, the | |
6889 | compiler must insert an instruction before every non prototyped call to | |
6890 | set or clear bit 6 of the condition code register (@var{CR}) to | |
6891 | indicate whether floating point values were passed in the floating point | |
6892 | registers in case the function takes a variable arguments. With | |
630d3d5a | 6893 | @option{-mprototype}, only calls to prototyped variable argument functions |
74291a4b MM |
6894 | will set or clear the bit. |
6895 | ||
6896 | @item -msim | |
cd3bb277 | 6897 | @opindex msim |
74291a4b MM |
6898 | On embedded PowerPC systems, assume that the startup module is called |
6899 | @file{sim-crt0.o} and that the standard C libraries are @file{libsim.a} and | |
6900 | @file{libc.a}. This is the default for @samp{powerpc-*-eabisim}. | |
6901 | configurations. | |
6902 | ||
6903 | @item -mmvme | |
cd3bb277 | 6904 | @opindex mmvme |
74291a4b | 6905 | On embedded PowerPC systems, assume that the startup module is called |
e9a25f70 JL |
6906 | @file{crt0.o} and the standard C libraries are @file{libmvme.a} and |
6907 | @file{libc.a}. | |
6908 | ||
6909 | @item -mads | |
cd3bb277 | 6910 | @opindex mads |
e9a25f70 JL |
6911 | On embedded PowerPC systems, assume that the startup module is called |
6912 | @file{crt0.o} and the standard C libraries are @file{libads.a} and | |
6913 | @file{libc.a}. | |
6914 | ||
6915 | @item -myellowknife | |
cd3bb277 | 6916 | @opindex myellowknife |
e9a25f70 JL |
6917 | On embedded PowerPC systems, assume that the startup module is called |
6918 | @file{crt0.o} and the standard C libraries are @file{libyk.a} and | |
74291a4b MM |
6919 | @file{libc.a}. |
6920 | ||
bff46771 | 6921 | @item -mvxworks |
cd3bb277 | 6922 | @opindex mvxworks |
bff46771 GK |
6923 | On System V.4 and embedded PowerPC systems, specify that you are |
6924 | compiling for a VxWorks system. | |
6925 | ||
74291a4b | 6926 | @item -memb |
cd3bb277 | 6927 | @opindex memb |
74291a4b MM |
6928 | On embedded PowerPC systems, set the @var{PPC_EMB} bit in the ELF flags |
6929 | header to indicate that @samp{eabi} extended relocations are used. | |
6930 | ||
6931 | @item -meabi | |
6932 | @itemx -mno-eabi | |
cd3bb277 JM |
6933 | @opindex meabi |
6934 | @opindex mno-eabi | |
74291a4b MM |
6935 | On System V.4 and embedded PowerPC systems do (do not) adhere to the |
6936 | Embedded Applications Binary Interface (eabi) which is a set of | |
bedc7537 | 6937 | modifications to the System V.4 specifications. Selecting @option{-meabi} |
74291a4b MM |
6938 | means that the stack is aligned to an 8 byte boundary, a function |
6939 | @code{__eabi} is called to from @code{main} to set up the eabi | |
630d3d5a | 6940 | environment, and the @option{-msdata} option can use both @code{r2} and |
74291a4b | 6941 | @code{r13} to point to two separate small data areas. Selecting |
bedc7537 | 6942 | @option{-mno-eabi} means that the stack is aligned to a 16 byte boundary, |
74291a4b | 6943 | do not call an initialization function from @code{main}, and the |
630d3d5a JM |
6944 | @option{-msdata} option will only use @code{r13} to point to a single |
6945 | small data area. The @option{-meabi} option is on by default if you | |
74291a4b MM |
6946 | configured GCC using one of the @samp{powerpc*-*-eabi*} options. |
6947 | ||
6948 | @item -msdata=eabi | |
cd3bb277 | 6949 | @opindex msdata=eabi |
74291a4b MM |
6950 | On System V.4 and embedded PowerPC systems, put small initialized |
6951 | @code{const} global and static data in the @samp{.sdata2} section, which | |
6952 | is pointed to by register @code{r2}. Put small initialized | |
6953 | non-@code{const} global and static data in the @samp{.sdata} section, | |
6954 | which is pointed to by register @code{r13}. Put small uninitialized | |
6955 | global and static data in the @samp{.sbss} section, which is adjacent to | |
630d3d5a JM |
6956 | the @samp{.sdata} section. The @option{-msdata=eabi} option is |
6957 | incompatible with the @option{-mrelocatable} option. The | |
6958 | @option{-msdata=eabi} option also sets the @option{-memb} option. | |
74291a4b MM |
6959 | |
6960 | @item -msdata=sysv | |
cd3bb277 | 6961 | @opindex msdata=sysv |
74291a4b MM |
6962 | On System V.4 and embedded PowerPC systems, put small global and static |
6963 | data in the @samp{.sdata} section, which is pointed to by register | |
6964 | @code{r13}. Put small uninitialized global and static data in the | |
6965 | @samp{.sbss} section, which is adjacent to the @samp{.sdata} section. | |
630d3d5a JM |
6966 | The @option{-msdata=sysv} option is incompatible with the |
6967 | @option{-mrelocatable} option. | |
74291a4b MM |
6968 | |
6969 | @item -msdata=default | |
6970 | @itemx -msdata | |
cd3bb277 JM |
6971 | @opindex msdata=default |
6972 | @opindex msdata | |
630d3d5a JM |
6973 | On System V.4 and embedded PowerPC systems, if @option{-meabi} is used, |
6974 | compile code the same as @option{-msdata=eabi}, otherwise compile code the | |
6975 | same as @option{-msdata=sysv}. | |
74291a4b MM |
6976 | |
6977 | @item -msdata-data | |
cd3bb277 | 6978 | @opindex msdata-data |
74291a4b MM |
6979 | On System V.4 and embedded PowerPC systems, put small global and static |
6980 | data in the @samp{.sdata} section. Put small uninitialized global and | |
6981 | static data in the @samp{.sbss} section. Do not use register @code{r13} | |
6982 | to address small data however. This is the default behavior unless | |
630d3d5a | 6983 | other @option{-msdata} options are used. |
74291a4b MM |
6984 | |
6985 | @item -msdata=none | |
6986 | @itemx -mno-sdata | |
cd3bb277 JM |
6987 | @opindex msdata=none |
6988 | @opindex mno-sdata | |
74291a4b MM |
6989 | On embedded PowerPC systems, put all initialized global and static data |
6990 | in the @samp{.data} section, and all uninitialized data in the | |
6991 | @samp{.bss} section. | |
6992 | ||
6993 | @item -G @var{num} | |
cd3bb277 | 6994 | @opindex G |
74291a4b MM |
6995 | @cindex smaller data references (PowerPC) |
6996 | @cindex .sdata/.sdata2 references (PowerPC) | |
956d6950 | 6997 | On embedded PowerPC systems, put global and static items less than or |
74291a4b MM |
6998 | equal to @var{num} bytes into the small data or bss sections instead of |
6999 | the normal data or bss section. By default, @var{num} is 8. The | |
630d3d5a JM |
7000 | @option{-G @var{num}} switch is also passed to the linker. |
7001 | All modules should be compiled with the same @option{-G @var{num}} value. | |
74291a4b MM |
7002 | |
7003 | @item -mregnames | |
7004 | @itemx -mno-regnames | |
cd3bb277 JM |
7005 | @opindex mregnames |
7006 | @opindex mno-regnames | |
74291a4b MM |
7007 | On System V.4 and embedded PowerPC systems do (do not) emit register |
7008 | names in the assembly language output using symbolic forms. | |
f5a1b0d2 | 7009 | |
74291a4b | 7010 | @end table |
f5a1b0d2 | 7011 | |
74291a4b MM |
7012 | @node RT Options |
7013 | @subsection IBM RT Options | |
7014 | @cindex RT options | |
7015 | @cindex IBM RT options | |
7016 | ||
7017 | These @samp{-m} options are defined for the IBM RT PC: | |
7018 | ||
2642624b | 7019 | @table @gcctabopt |
74291a4b | 7020 | @item -min-line-mul |
cd3bb277 | 7021 | @opindex min-line-mul |
74291a4b MM |
7022 | Use an in-line code sequence for integer multiplies. This is the |
7023 | default. | |
7024 | ||
7025 | @item -mcall-lib-mul | |
cd3bb277 | 7026 | @opindex mcall-lib-mul |
74291a4b MM |
7027 | Call @code{lmul$$} for integer multiples. |
7028 | ||
7029 | @item -mfull-fp-blocks | |
cd3bb277 | 7030 | @opindex mfull-fp-blocks |
74291a4b | 7031 | Generate full-size floating point data blocks, including the minimum |
161d7b59 | 7032 | amount of scratch space recommended by IBM@. This is the default. |
74291a4b MM |
7033 | |
7034 | @item -mminimum-fp-blocks | |
cd3bb277 | 7035 | @opindex mminimum-fp-blocks |
74291a4b MM |
7036 | Do not include extra scratch space in floating point data blocks. This |
7037 | results in smaller code, but slower execution, since scratch space must | |
7038 | be allocated dynamically. | |
7039 | ||
7040 | @cindex @file{varargs.h} and RT PC | |
7041 | @cindex @file{stdarg.h} and RT PC | |
7042 | @item -mfp-arg-in-fpregs | |
cd3bb277 | 7043 | @opindex mfp-arg-in-fpregs |
74291a4b MM |
7044 | Use a calling sequence incompatible with the IBM calling convention in |
7045 | which floating point arguments are passed in floating point registers. | |
c771326b | 7046 | Note that @code{varargs.h} and @code{stdarg.h} will not work with |
74291a4b MM |
7047 | floating point operands if this option is specified. |
7048 | ||
7049 | @item -mfp-arg-in-gregs | |
cd3bb277 | 7050 | @opindex mfp-arg-in-gregs |
74291a4b MM |
7051 | Use the normal calling convention for floating point arguments. This is |
7052 | the default. | |
7053 | ||
7054 | @item -mhc-struct-return | |
cd3bb277 | 7055 | @opindex mhc-struct-return |
74291a4b MM |
7056 | Return structures of more than one word in memory, rather than in a |
7057 | register. This provides compatibility with the MetaWare HighC (hc) | |
630d3d5a | 7058 | compiler. Use the option @option{-fpcc-struct-return} for compatibility |
74291a4b MM |
7059 | with the Portable C Compiler (pcc). |
7060 | ||
7061 | @item -mnohc-struct-return | |
cd3bb277 | 7062 | @opindex mnohc-struct-return |
74291a4b MM |
7063 | Return some structures of more than one word in registers, when |
7064 | convenient. This is the default. For compatibility with the | |
630d3d5a JM |
7065 | IBM-supplied compilers, use the option @option{-fpcc-struct-return} or the |
7066 | option @option{-mhc-struct-return}. | |
74291a4b MM |
7067 | @end table |
7068 | ||
7069 | @node MIPS Options | |
7070 | @subsection MIPS Options | |
7071 | @cindex MIPS options | |
7072 | ||
7073 | These @samp{-m} options are defined for the MIPS family of computers: | |
7074 | ||
2642624b | 7075 | @table @gcctabopt |
7dac2f89 EC |
7076 | |
7077 | @item -march=@var{cpu-type} | |
7078 | @opindex march | |
7079 | Assume the defaults for the machine type @var{cpu-type} when generating | |
7080 | instructions. The choices for @var{cpu-type} are @samp{r2000}, @samp{r3000}, | |
7081 | @samp{r3900}, @samp{r4000}, @samp{r4100}, @samp{r4300}, @samp{r4400}, | |
7082 | @samp{r4600}, @samp{r4650}, @samp{r5000}, @samp{r6000}, @samp{r8000}, | |
7083 | and @samp{orion}. Additionally, the @samp{r2000}, @samp{r3000}, | |
7084 | @samp{r4000}, @samp{r5000}, and @samp{r6000} can be abbreviated as | |
7085 | @samp{r2k} (or @samp{r2K}), @samp{r3k}, etc. | |
7086 | ||
7087 | @item -mtune=@var{cpu-type} | |
7088 | @opindex mtune | |
630d3d5a JM |
7089 | Assume the defaults for the machine type @var{cpu-type} when scheduling |
7090 | instructions. The choices for @var{cpu-type} are @samp{r2000}, @samp{r3000}, | |
8b9243df JJ |
7091 | @samp{r3900}, @samp{r4000}, @samp{r4100}, @samp{r4300}, @samp{r4400}, |
7092 | @samp{r4600}, @samp{r4650}, @samp{r5000}, @samp{r6000}, @samp{r8000}, | |
7093 | and @samp{orion}. Additionally, the @samp{r2000}, @samp{r3000}, | |
7094 | @samp{r4000}, @samp{r5000}, and @samp{r6000} can be abbreviated as | |
7095 | @samp{r2k} (or @samp{r2K}), @samp{r3k}, etc. While picking a specific | |
630d3d5a | 7096 | @var{cpu-type} will schedule things appropriately for that particular |
8b9243df | 7097 | chip, the compiler will not generate any code that does not meet level 1 |
630d3d5a JM |
7098 | of the MIPS ISA (instruction set architecture) without a @option{-mipsX} |
7099 | or @option{-mabi} switch being used. | |
74291a4b | 7100 | |
7dac2f89 EC |
7101 | @item -mcpu=@var{cpu-type} |
7102 | @opindex mcpu | |
7103 | This is identical to specifying both @option{-march} and @option{-mtune}. | |
7104 | ||
74291a4b | 7105 | @item -mips1 |
cd3bb277 | 7106 | @opindex mips1 |
161d7b59 | 7107 | Issue instructions from level 1 of the MIPS ISA@. This is the default. |
630d3d5a | 7108 | @samp{r3000} is the default @var{cpu-type} at this ISA level. |
74291a4b MM |
7109 | |
7110 | @item -mips2 | |
cd3bb277 | 7111 | @opindex mips2 |
74291a4b | 7112 | Issue instructions from level 2 of the MIPS ISA (branch likely, square |
630d3d5a | 7113 | root instructions). @samp{r6000} is the default @var{cpu-type} at this |
74291a4b MM |
7114 | ISA level. |
7115 | ||
7116 | @item -mips3 | |
cd3bb277 | 7117 | @opindex mips3 |
02f52e19 | 7118 | Issue instructions from level 3 of the MIPS ISA (64-bit instructions). |
630d3d5a | 7119 | @samp{r4000} is the default @var{cpu-type} at this ISA level. |
74291a4b | 7120 | |
3398f47f | 7121 | @item -mips4 |
cd3bb277 | 7122 | @opindex mips4 |
8b9243df JJ |
7123 | Issue instructions from level 4 of the MIPS ISA (conditional move, |
7124 | prefetch, enhanced FPU instructions). @samp{r8000} is the default | |
630d3d5a | 7125 | @var{cpu-type} at this ISA level. |
3398f47f | 7126 | |
74291a4b | 7127 | @item -mfp32 |
cd3bb277 | 7128 | @opindex mfp32 |
74291a4b MM |
7129 | Assume that 32 32-bit floating point registers are available. This is |
7130 | the default. | |
7131 | ||
7132 | @item -mfp64 | |
cd3bb277 | 7133 | @opindex mfp64 |
74291a4b | 7134 | Assume that 32 64-bit floating point registers are available. This is |
630d3d5a | 7135 | the default when the @option{-mips3} option is used. |
74291a4b | 7136 | |
13fac94a GK |
7137 | @item -mfused-madd |
7138 | @itemx -mno-fused-madd | |
7139 | @opindex mfused-madd | |
7140 | @opindex mno-fused-madd | |
7141 | Generate code that uses (does not use) the floating point multiply and | |
7142 | accumulate instructions, when they are available. These instructions | |
7143 | are generated by default if they are available, but this may be | |
7144 | undesirable if the extra precision causes problems or on certain chips | |
7145 | in the mode where denormals are rounded to zero where denormals | |
7146 | generated by multiply and accumulate instructions cause exceptions | |
7147 | anyway. | |
7148 | ||
74291a4b | 7149 | @item -mgp32 |
cd3bb277 | 7150 | @opindex mgp32 |
74291a4b MM |
7151 | Assume that 32 32-bit general purpose registers are available. This is |
7152 | the default. | |
7153 | ||
7154 | @item -mgp64 | |
cd3bb277 | 7155 | @opindex mgp64 |
74291a4b | 7156 | Assume that 32 64-bit general purpose registers are available. This is |
630d3d5a | 7157 | the default when the @option{-mips3} option is used. |
74291a4b MM |
7158 | |
7159 | @item -mint64 | |
cd3bb277 | 7160 | @opindex mint64 |
630d3d5a | 7161 | Force int and long types to be 64 bits wide. See @option{-mlong32} for an |
3ce1ba83 | 7162 | explanation of the default, and the width of pointers. |
74291a4b MM |
7163 | |
7164 | @item -mlong64 | |
cd3bb277 | 7165 | @opindex mlong64 |
630d3d5a | 7166 | Force long types to be 64 bits wide. See @option{-mlong32} for an |
3ce1ba83 | 7167 | explanation of the default, and the width of pointers. |
fb1bf66d | 7168 | |
3ce1ba83 | 7169 | @item -mlong32 |
cd3bb277 | 7170 | @opindex mlong32 |
3ce1ba83 GRK |
7171 | Force long, int, and pointer types to be 32 bits wide. |
7172 | ||
630d3d5a | 7173 | If none of @option{-mlong32}, @option{-mlong64}, or @option{-mint64} are set, |
b192711e | 7174 | the size of ints, longs, and pointers depends on the ABI and ISA chosen. |
630d3d5a JM |
7175 | For @option{-mabi=32}, and @option{-mabi=n32}, ints and longs are 32 bits |
7176 | wide. For @option{-mabi=64}, ints are 32 bits, and longs are 64 bits wide. | |
7177 | For @option{-mabi=eabi} and either @option{-mips1} or @option{-mips2}, ints | |
7178 | and longs are 32 bits wide. For @option{-mabi=eabi} and higher ISAs, ints | |
3ce1ba83 GRK |
7179 | are 32 bits, and longs are 64 bits wide. The width of pointer types is |
7180 | the smaller of the width of longs or the width of general purpose | |
161d7b59 | 7181 | registers (which in turn depends on the ISA)@. |
74291a4b | 7182 | |
62a1403d | 7183 | @item -mabi=32 |
8b9243df | 7184 | @itemx -mabi=o64 |
3398f47f MM |
7185 | @itemx -mabi=n32 |
7186 | @itemx -mabi=64 | |
7187 | @itemx -mabi=eabi | |
cd3bb277 JM |
7188 | @opindex mabi=32 |
7189 | @opindex mabi=o64 | |
7190 | @opindex mabi=n32 | |
7191 | @opindex mabi=64 | |
7192 | @opindex mabi=eabi | |
161d7b59 | 7193 | Generate code for the indicated ABI@. The default instruction level is |
630d3d5a JM |
7194 | @option{-mips1} for @samp{32}, @option{-mips3} for @samp{n32}, and |
7195 | @option{-mips4} otherwise. Conversely, with @option{-mips1} or | |
7196 | @option{-mips2}, the default ABI is @samp{32}; otherwise, the default ABI | |
8b9243df | 7197 | is @samp{64}. |
3398f47f | 7198 | |
74291a4b | 7199 | @item -mmips-as |
cd3bb277 | 7200 | @opindex mmips-as |
74291a4b MM |
7201 | Generate code for the MIPS assembler, and invoke @file{mips-tfile} to |
7202 | add normal debug information. This is the default for all | |
7203 | platforms except for the OSF/1 reference platform, using the OSF/rose | |
630d3d5a | 7204 | object format. If the either of the @option{-gstabs} or @option{-gstabs+} |
74291a4b | 7205 | switches are used, the @file{mips-tfile} program will encapsulate the |
161d7b59 | 7206 | stabs within MIPS ECOFF@. |
74291a4b MM |
7207 | |
7208 | @item -mgas | |
cd3bb277 | 7209 | @opindex mgas |
74291a4b | 7210 | Generate code for the GNU assembler. This is the default on the OSF/1 |
861bb6c1 | 7211 | reference platform, using the OSF/rose object format. Also, this is |
630d3d5a | 7212 | the default if the configure option @option{--with-gnu-as} is used. |
861bb6c1 JL |
7213 | |
7214 | @item -msplit-addresses | |
7215 | @itemx -mno-split-addresses | |
cd3bb277 JM |
7216 | @opindex msplit-addresses |
7217 | @opindex mno-split-addresses | |
861bb6c1 | 7218 | Generate code to load the high and low parts of address constants separately. |
aee96fe9 | 7219 | This allows GCC to optimize away redundant loads of the high order |
861bb6c1 JL |
7220 | bits of addresses. This optimization requires GNU as and GNU ld. |
7221 | This optimization is enabled by default for some embedded targets where | |
7222 | GNU as and GNU ld are standard. | |
74291a4b MM |
7223 | |
7224 | @item -mrnames | |
7225 | @itemx -mno-rnames | |
cd3bb277 JM |
7226 | @opindex mrnames |
7227 | @opindex mno-rnames | |
630d3d5a | 7228 | The @option{-mrnames} switch says to output code using the MIPS software |
74291a4b MM |
7229 | names for the registers, instead of the hardware names (ie, @var{a0} |
7230 | instead of @var{$4}). The only known assembler that supports this option | |
7231 | is the Algorithmics assembler. | |
7232 | ||
7233 | @item -mgpopt | |
7234 | @itemx -mno-gpopt | |
cd3bb277 JM |
7235 | @opindex mgpopt |
7236 | @opindex mno-gpopt | |
630d3d5a | 7237 | The @option{-mgpopt} switch says to write all of the data declarations |
74291a4b MM |
7238 | before the instructions in the text section, this allows the MIPS |
7239 | assembler to generate one word memory references instead of using two | |
7240 | words for short global or static data items. This is on by default if | |
7241 | optimization is selected. | |
7242 | ||
7243 | @item -mstats | |
7244 | @itemx -mno-stats | |
cd3bb277 JM |
7245 | @opindex mstats |
7246 | @opindex mno-stats | |
630d3d5a | 7247 | For each non-inline function processed, the @option{-mstats} switch |
74291a4b MM |
7248 | causes the compiler to emit one line to the standard error file to |
7249 | print statistics about the program (number of registers saved, stack | |
7250 | size, etc.). | |
7251 | ||
7252 | @item -mmemcpy | |
7253 | @itemx -mno-memcpy | |
cd3bb277 JM |
7254 | @opindex mmemcpy |
7255 | @opindex mno-memcpy | |
630d3d5a | 7256 | The @option{-mmemcpy} switch makes all block moves call the appropriate |
74291a4b MM |
7257 | string function (@samp{memcpy} or @samp{bcopy}) instead of possibly |
7258 | generating inline code. | |
7259 | ||
7260 | @item -mmips-tfile | |
7261 | @itemx -mno-mips-tfile | |
cd3bb277 JM |
7262 | @opindex mmips-tfile |
7263 | @opindex mno-mips-tfile | |
630d3d5a | 7264 | The @option{-mno-mips-tfile} switch causes the compiler not |
74291a4b MM |
7265 | postprocess the object file with the @file{mips-tfile} program, |
7266 | after the MIPS assembler has generated it to add debug support. If | |
7267 | @file{mips-tfile} is not run, then no local variables will be | |
7268 | available to the debugger. In addition, @file{stage2} and | |
7269 | @file{stage3} objects will have the temporary file names passed to the | |
7270 | assembler embedded in the object file, which means the objects will | |
630d3d5a | 7271 | not compare the same. The @option{-mno-mips-tfile} switch should only |
74291a4b MM |
7272 | be used when there are bugs in the @file{mips-tfile} program that |
7273 | prevents compilation. | |
7274 | ||
7275 | @item -msoft-float | |
cd3bb277 | 7276 | @opindex msoft-float |
74291a4b | 7277 | Generate output containing library calls for floating point. |
161d7b59 | 7278 | @strong{Warning:} the requisite libraries are not part of GCC@. |
74291a4b MM |
7279 | Normally the facilities of the machine's usual C compiler are used, but |
7280 | this can't be done directly in cross-compilation. You must make your | |
7281 | own arrangements to provide suitable library functions for | |
7282 | cross-compilation. | |
7283 | ||
7284 | @item -mhard-float | |
cd3bb277 | 7285 | @opindex mhard-float |
74291a4b MM |
7286 | Generate output containing floating point instructions. This is the |
7287 | default if you use the unmodified sources. | |
7288 | ||
7289 | @item -mabicalls | |
7290 | @itemx -mno-abicalls | |
cd3bb277 JM |
7291 | @opindex mabicalls |
7292 | @opindex mno-abicalls | |
74291a4b MM |
7293 | Emit (or do not emit) the pseudo operations @samp{.abicalls}, |
7294 | @samp{.cpload}, and @samp{.cprestore} that some System V.4 ports use for | |
7295 | position independent code. | |
7296 | ||
7297 | @item -mlong-calls | |
7298 | @itemx -mno-long-calls | |
cd3bb277 JM |
7299 | @opindex mlong-calls |
7300 | @opindex mno-long-calls | |
74291a4b MM |
7301 | Do all calls with the @samp{JALR} instruction, which requires |
7302 | loading up a function's address into a register before the call. | |
7303 | You need to use this switch, if you call outside of the current | |
7304 | 512 megabyte segment to functions that are not through pointers. | |
7305 | ||
7306 | @item -mhalf-pic | |
7307 | @itemx -mno-half-pic | |
cd3bb277 JM |
7308 | @opindex mhalf-pic |
7309 | @opindex mno-half-pic | |
74291a4b MM |
7310 | Put pointers to extern references into the data section and load them |
7311 | up, rather than put the references in the text section. | |
7312 | ||
7313 | @item -membedded-pic | |
7314 | @itemx -mno-embedded-pic | |
cd3bb277 JM |
7315 | @opindex membedded-pic |
7316 | @opindex mno-embedded-pic | |
69fa83cf JW |
7317 | Generate PIC code suitable for some embedded systems. All calls are |
7318 | made using PC relative address, and all data is addressed using the $gp | |
7319 | register. No more than 65536 bytes of global data may be used. This | |
7320 | requires GNU as and GNU ld which do most of the work. This currently | |
161d7b59 | 7321 | only works on targets which use ECOFF; it does not work with ELF@. |
74291a4b MM |
7322 | |
7323 | @item -membedded-data | |
7324 | @itemx -mno-embedded-data | |
cd3bb277 JM |
7325 | @opindex membedded-data |
7326 | @opindex mno-embedded-data | |
74291a4b MM |
7327 | Allocate variables to the read-only data section first if possible, then |
7328 | next in the small data section if possible, otherwise in data. This gives | |
7329 | slightly slower code than the default, but reduces the amount of RAM required | |
7330 | when executing, and thus may be preferred for some embedded systems. | |
7331 | ||
919509ce DN |
7332 | @item -muninit-const-in-rodata |
7333 | @itemx -mno-uninit-const-in-rodata | |
cd3bb277 JM |
7334 | @opindex muninit-const-in-rodata |
7335 | @opindex mno-uninit-const-in-rodata | |
695ac33f | 7336 | When used together with @option{-membedded-data}, it will always store uninitialized |
919509ce | 7337 | const variables in the read-only data section. |
02f52e19 | 7338 | |
74291a4b MM |
7339 | @item -msingle-float |
7340 | @itemx -mdouble-float | |
cd3bb277 JM |
7341 | @opindex msingle-float |
7342 | @opindex mdouble-float | |
630d3d5a | 7343 | The @option{-msingle-float} switch tells gcc to assume that the floating |
74291a4b | 7344 | point coprocessor only supports single precision operations, as on the |
630d3d5a | 7345 | @samp{r4650} chip. The @option{-mdouble-float} switch permits gcc to use |
74291a4b MM |
7346 | double precision operations. This is the default. |
7347 | ||
7348 | @item -mmad | |
7349 | @itemx -mno-mad | |
cd3bb277 JM |
7350 | @opindex mmad |
7351 | @opindex mno-mad | |
74291a4b MM |
7352 | Permit use of the @samp{mad}, @samp{madu} and @samp{mul} instructions, |
7353 | as on the @samp{r4650} chip. | |
7354 | ||
7355 | @item -m4650 | |
cd3bb277 | 7356 | @opindex m4650 |
630d3d5a JM |
7357 | Turns on @option{-msingle-float}, @option{-mmad}, and, at least for now, |
7358 | @option{-mcpu=r4650}. | |
74291a4b | 7359 | |
8b9243df JJ |
7360 | @item -mips16 |
7361 | @itemx -mno-mips16 | |
cd3bb277 JM |
7362 | @opindex mips16 |
7363 | @opindex mno-mips16 | |
8b9243df JJ |
7364 | Enable 16-bit instructions. |
7365 | ||
7366 | @item -mentry | |
cd3bb277 | 7367 | @opindex mentry |
8b9243df | 7368 | Use the entry and exit pseudo ops. This option can only be used with |
630d3d5a | 7369 | @option{-mips16}. |
8b9243df | 7370 | |
74291a4b | 7371 | @item -EL |
cd3bb277 | 7372 | @opindex EL |
74291a4b MM |
7373 | Compile code for the processor in little endian mode. |
7374 | The requisite libraries are assumed to exist. | |
7375 | ||
7376 | @item -EB | |
cd3bb277 | 7377 | @opindex EB |
74291a4b MM |
7378 | Compile code for the processor in big endian mode. |
7379 | The requisite libraries are assumed to exist. | |
7380 | ||
7381 | @item -G @var{num} | |
cd3bb277 | 7382 | @opindex G |
74291a4b MM |
7383 | @cindex smaller data references (MIPS) |
7384 | @cindex gp-relative references (MIPS) | |
7385 | Put global and static items less than or equal to @var{num} bytes into | |
7386 | the small data or bss sections instead of the normal data or bss | |
7387 | section. This allows the assembler to emit one word memory reference | |
7388 | instructions based on the global pointer (@var{gp} or @var{$28}), | |
7389 | instead of the normal two words used. By default, @var{num} is 8 when | |
7390 | the MIPS assembler is used, and 0 when the GNU assembler is used. The | |
630d3d5a JM |
7391 | @option{-G @var{num}} switch is also passed to the assembler and linker. |
7392 | All modules should be compiled with the same @option{-G @var{num}} | |
74291a4b MM |
7393 | value. |
7394 | ||
7395 | @item -nocpp | |
cd3bb277 | 7396 | @opindex nocpp |
9ec36da5 | 7397 | Tell the MIPS assembler to not run its preprocessor over user |
74291a4b | 7398 | assembler files (with a @samp{.s} suffix) when assembling them. |
63357d93 | 7399 | |
1e387156 | 7400 | @item -mfix7000 |
cd3bb277 | 7401 | @opindex mfix7000 |
1e387156 CM |
7402 | Pass an option to gas which will cause nops to be inserted if |
7403 | the read of the destination register of an mfhi or mflo instruction | |
7404 | occurs in the following two instructions. | |
7405 | ||
63357d93 | 7406 | @item -no-crt0 |
cd3bb277 | 7407 | @opindex no-crt0 |
63357d93 | 7408 | Do not include the default crt0. |
74291a4b MM |
7409 | @end table |
7410 | ||
7411 | @ifset INTERNALS | |
7412 | These options are defined by the macro | |
7413 | @code{TARGET_SWITCHES} in the machine description. The default for the | |
7414 | options is also defined by that macro, which enables you to change the | |
7415 | defaults. | |
7416 | @end ifset | |
7417 | ||
7418 | @node i386 Options | |
7419 | @subsection Intel 386 Options | |
7420 | @cindex i386 Options | |
7421 | @cindex Intel 386 Options | |
7422 | ||
7423 | These @samp{-m} options are defined for the i386 family of computers: | |
7424 | ||
2642624b | 7425 | @table @gcctabopt |
630d3d5a | 7426 | @item -mcpu=@var{cpu-type} |
cd3bb277 | 7427 | @opindex mcpu |
630d3d5a JM |
7428 | Assume the defaults for the machine type @var{cpu-type} when scheduling |
7429 | instructions. The choices for @var{cpu-type} are @samp{i386}, | |
9d86bffc | 7430 | @samp{i486}, @samp{i586}, @samp{i686}, @samp{pentium}, |
b4e89e2d | 7431 | @samp{pentiumpro}, @samp{pentium4}, @samp{k6}, and @samp{athlon} |
6f670fde | 7432 | |
630d3d5a | 7433 | While picking a specific @var{cpu-type} will schedule things appropriately |
6f670fde | 7434 | for that particular chip, the compiler will not generate any code that |
630d3d5a | 7435 | does not run on the i386 without the @option{-march=@var{cpu-type}} option |
7001ee2d | 7436 | being used. @samp{i586} is equivalent to @samp{pentium} and @samp{i686} |
6ca3ad1b | 7437 | is equivalent to @samp{pentiumpro}. @samp{k6} and @samp{athlon} are the |
b4e89e2d | 7438 | AMD chips as opposed to the Intel ones. |
a9f3e1a4 | 7439 | |
630d3d5a | 7440 | @item -march=@var{cpu-type} |
cd3bb277 | 7441 | @opindex march |
630d3d5a JM |
7442 | Generate instructions for the machine type @var{cpu-type}. The choices |
7443 | for @var{cpu-type} are the same as for @option{-mcpu}. Moreover, | |
7444 | specifying @option{-march=@var{cpu-type}} implies @option{-mcpu=@var{cpu-type}}. | |
a9f3e1a4 JL |
7445 | |
7446 | @item -m386 | |
7447 | @itemx -m486 | |
7448 | @itemx -mpentium | |
7449 | @itemx -mpentiumpro | |
cd3bb277 JM |
7450 | @opindex m386 |
7451 | @opindex m486 | |
7452 | @opindex mpentium | |
7453 | @opindex mpentiumpro | |
9c34dbbf ZW |
7454 | These options are synonyms for @option{-mcpu=i386}, @option{-mcpu=i486}, |
7455 | @option{-mcpu=pentium}, and @option{-mcpu=pentiumpro} respectively. | |
7456 | These synonyms are deprecated. | |
74291a4b | 7457 | |
04e149ab | 7458 | @item -mintel-syntax |
cd3bb277 | 7459 | @opindex mintel-syntax |
04e149ab KC |
7460 | Emit assembly using Intel syntax opcodes instead of AT&T syntax. |
7461 | ||
74291a4b MM |
7462 | @item -mieee-fp |
7463 | @itemx -mno-ieee-fp | |
cd3bb277 JM |
7464 | @opindex mieee-fp |
7465 | @opindex mno-ieee-fp | |
74291a4b MM |
7466 | Control whether or not the compiler uses IEEE floating point |
7467 | comparisons. These handle correctly the case where the result of a | |
7468 | comparison is unordered. | |
7469 | ||
7470 | @item -msoft-float | |
cd3bb277 | 7471 | @opindex msoft-float |
74291a4b | 7472 | Generate output containing library calls for floating point. |
161d7b59 | 7473 | @strong{Warning:} the requisite libraries are not part of GCC@. |
74291a4b MM |
7474 | Normally the facilities of the machine's usual C compiler are used, but |
7475 | this can't be done directly in cross-compilation. You must make your | |
7476 | own arrangements to provide suitable library functions for | |
7477 | cross-compilation. | |
7478 | ||
7479 | On machines where a function returns floating point results in the 80387 | |
7480 | register stack, some floating point opcodes may be emitted even if | |
630d3d5a | 7481 | @option{-msoft-float} is used. |
74291a4b MM |
7482 | |
7483 | @item -mno-fp-ret-in-387 | |
cd3bb277 | 7484 | @opindex mno-fp-ret-in-387 |
74291a4b MM |
7485 | Do not use the FPU registers for return values of functions. |
7486 | ||
7487 | The usual calling convention has functions return values of types | |
7488 | @code{float} and @code{double} in an FPU register, even if there | |
161d7b59 JM |
7489 | is no FPU@. The idea is that the operating system should emulate |
7490 | an FPU@. | |
74291a4b | 7491 | |
630d3d5a | 7492 | The option @option{-mno-fp-ret-in-387} causes such values to be returned |
74291a4b MM |
7493 | in ordinary CPU registers instead. |
7494 | ||
7495 | @item -mno-fancy-math-387 | |
cd3bb277 | 7496 | @opindex mno-fancy-math-387 |
74291a4b MM |
7497 | Some 387 emulators do not support the @code{sin}, @code{cos} and |
7498 | @code{sqrt} instructions for the 387. Specify this option to avoid | |
161d7b59 | 7499 | generating those instructions. This option is the default on FreeBSD@. |
74291a4b | 7500 | As of revision 2.6.1, these instructions are not generated unless you |
630d3d5a | 7501 | also use the @option{-funsafe-math-optimizations} switch. |
74291a4b MM |
7502 | |
7503 | @item -malign-double | |
7504 | @itemx -mno-align-double | |
cd3bb277 JM |
7505 | @opindex malign-double |
7506 | @opindex mno-align-double | |
0c2d1a2a | 7507 | Control whether GCC aligns @code{double}, @code{long double}, and |
74291a4b MM |
7508 | @code{long long} variables on a two word boundary or a one word |
7509 | boundary. Aligning @code{double} variables on a two word boundary will | |
7510 | produce code that runs somewhat faster on a @samp{Pentium} at the | |
7511 | expense of more memory. | |
7512 | ||
2b589241 | 7513 | @item -m128bit-long-double |
cd3bb277 | 7514 | @opindex m128bit-long-double |
2b589241 JH |
7515 | Control the size of @code{long double} type. i386 application binary interface |
7516 | specify the size to be 12 bytes, while modern architectures (Pentium and newer) | |
c771326b | 7517 | prefer @code{long double} aligned to 8 or 16 byte boundary. This is |
2b589241 JH |
7518 | impossible to reach with 12 byte long doubles in the array accesses. |
7519 | ||
630d3d5a | 7520 | @strong{Warning:} if you use the @option{-m128bit-long-double} switch, the |
2b589241 JH |
7521 | structures and arrays containing @code{long double} will change their size as |
7522 | well as function calling convention for function taking @code{long double} | |
02f52e19 | 7523 | will be modified. |
2b589241 JH |
7524 | |
7525 | @item -m96bit-long-double | |
cd3bb277 | 7526 | @opindex m96bit-long-double |
0a75e5c3 | 7527 | Set the size of @code{long double} to 96 bits as required by the i386 |
2b589241 | 7528 | application binary interface. This is the default. |
74291a4b MM |
7529 | |
7530 | @item -msvr3-shlib | |
7531 | @itemx -mno-svr3-shlib | |
cd3bb277 JM |
7532 | @opindex msvr3-shlib |
7533 | @opindex mno-svr3-shlib | |
9c34dbbf ZW |
7534 | Control whether GCC places uninitialized local variables into the |
7535 | @code{bss} or @code{data} segments. @option{-msvr3-shlib} places them | |
7536 | into @code{bss}. These options are meaningful only on System V Release 3. | |
74291a4b | 7537 | |
74291a4b | 7538 | @item -mrtd |
cd3bb277 | 7539 | @opindex mrtd |
74291a4b MM |
7540 | Use a different function-calling convention, in which functions that |
7541 | take a fixed number of arguments return with the @code{ret} @var{num} | |
7542 | instruction, which pops their arguments while returning. This saves one | |
7543 | instruction in the caller since there is no need to pop the arguments | |
7544 | there. | |
7545 | ||
7546 | You can specify that an individual function is called with this calling | |
7547 | sequence with the function attribute @samp{stdcall}. You can also | |
630d3d5a | 7548 | override the @option{-mrtd} option by using the function attribute |
0b433de6 | 7549 | @samp{cdecl}. @xref{Function Attributes}. |
74291a4b MM |
7550 | |
7551 | @strong{Warning:} this calling convention is incompatible with the one | |
7552 | normally used on Unix, so you cannot use it if you need to call | |
7553 | libraries compiled with the Unix compiler. | |
7554 | ||
7555 | Also, you must provide function prototypes for all functions that | |
7556 | take variable numbers of arguments (including @code{printf}); | |
7557 | otherwise incorrect code will be generated for calls to those | |
7558 | functions. | |
7559 | ||
7560 | In addition, seriously incorrect code will result if you call a | |
7561 | function with too many arguments. (Normally, extra arguments are | |
7562 | harmlessly ignored.) | |
7563 | ||
74291a4b | 7564 | @item -mregparm=@var{num} |
cd3bb277 | 7565 | @opindex mregparm |
74291a4b MM |
7566 | Control how many registers are used to pass integer arguments. By |
7567 | default, no registers are used to pass arguments, and at most 3 | |
7568 | registers can be used. You can control this behavior for a specific | |
0b433de6 JL |
7569 | function by using the function attribute @samp{regparm}. |
7570 | @xref{Function Attributes}. | |
74291a4b MM |
7571 | |
7572 | @strong{Warning:} if you use this switch, and | |
7573 | @var{num} is nonzero, then you must build all modules with the same | |
7574 | value, including any libraries. This includes the system libraries and | |
7575 | startup modules. | |
7576 | ||
3af4bd89 | 7577 | @item -mpreferred-stack-boundary=@var{num} |
cd3bb277 | 7578 | @opindex mpreferred-stack-boundary |
3af4bd89 | 7579 | Attempt to keep the stack boundary aligned to a 2 raised to @var{num} |
630d3d5a | 7580 | byte boundary. If @option{-mpreferred-stack-boundary} is not specified, |
3af4bd89 JH |
7581 | the default is 4 (16 bytes or 128 bits). |
7582 | ||
7583 | The stack is required to be aligned on a 4 byte boundary. On Pentium | |
7584 | and PentiumPro, @code{double} and @code{long double} values should be | |
630d3d5a | 7585 | aligned to an 8 byte boundary (see @option{-malign-double}) or suffer |
3af4bd89 | 7586 | significant run time performance penalties. On Pentium III, the |
b192711e | 7587 | Streaming SIMD Extension (SSE) data type @code{__m128} suffers similar |
3af4bd89 JH |
7588 | penalties if it is not 16 byte aligned. |
7589 | ||
7590 | To ensure proper alignment of this values on the stack, the stack boundary | |
02f52e19 | 7591 | must be as aligned as that required by any value stored on the stack. |
3af4bd89 JH |
7592 | Further, every function must be generated such that it keeps the stack |
7593 | aligned. Thus calling a function compiled with a higher preferred | |
7594 | stack boundary from a function compiled with a lower preferred stack | |
7595 | boundary will most likely misalign the stack. It is recommended that | |
7596 | libraries that use callbacks always use the default setting. | |
7597 | ||
7598 | This extra alignment does consume extra stack space. Code that is sensitive | |
7599 | to stack space usage, such as embedded systems and operating system kernels, | |
7600 | may want to reduce the preferred alignment to | |
630d3d5a | 7601 | @option{-mpreferred-stack-boundary=2}. |
f22a97d2 | 7602 | |
f73ad30e | 7603 | @item -mpush-args |
a7939b1d | 7604 | @itemx -mno-push-args |
cd3bb277 | 7605 | @opindex mpush-args |
a7939b1d | 7606 | @opindex mno-push-args |
767094dd | 7607 | Use PUSH operations to store outgoing parameters. This method is shorter |
f73ad30e | 7608 | and usually equally fast as method using SUB/MOV operations and is enabled |
767094dd | 7609 | by default. In some cases disabling it may improve performance because of |
f73ad30e JH |
7610 | improved scheduling and reduced dependencies. |
7611 | ||
7612 | @item -maccumulate-outgoing-args | |
cd3bb277 | 7613 | @opindex maccumulate-outgoing-args |
f73ad30e | 7614 | If enabled, the maximum amount of space required for outgoing arguments will be |
a7939b1d | 7615 | computed in the function prologue. This is faster on most modern CPUs |
b192711e | 7616 | because of reduced dependencies, improved scheduling and reduced stack usage |
f73ad30e | 7617 | when preferred stack boundary is not equal to 2. The drawback is a notable |
767094dd | 7618 | increase in code size. This switch implies @option{-mno-push-args}. |
f73ad30e | 7619 | |
f22a97d2 | 7620 | @item -mthreads |
cd3bb277 | 7621 | @opindex mthreads |
767094dd | 7622 | Support thread-safe exception handling on @samp{Mingw32}. Code that relies |
02f52e19 | 7623 | on thread-safe exception handling must compile and link all code with the |
767094dd | 7624 | @option{-mthreads} option. When compiling, @option{-mthreads} defines |
630d3d5a JM |
7625 | @option{-D_MT}; when linking, it links in a special thread helper library |
7626 | @option{-lmingwthrd} which cleans up per thread exception handling data. | |
79f05c19 JH |
7627 | |
7628 | @item -mno-align-stringops | |
cd3bb277 | 7629 | @opindex mno-align-stringops |
767094dd | 7630 | Do not align destination of inlined string operations. This switch reduces |
79f05c19 JH |
7631 | code size and improves performance in case the destination is already aligned, |
7632 | but gcc don't know about it. | |
7633 | ||
7634 | @item -minline-all-stringops | |
cd3bb277 | 7635 | @opindex minline-all-stringops |
79f05c19 | 7636 | By default GCC inlines string operations only when destination is known to be |
767094dd | 7637 | aligned at least to 4 byte boundary. This enables more inlining, increase code |
79f05c19 JH |
7638 | size, but may improve performance of code that depends on fast memcpy, strlen |
7639 | and memset for short lengths. | |
762e166b AJ |
7640 | |
7641 | @item -momit-leaf-frame-pointer | |
cd3bb277 | 7642 | @opindex momit-leaf-frame-pointer |
762e166b AJ |
7643 | Don't keep the frame pointer in a register for leaf functions. This |
7644 | avoids the instructions to save, set up and restore frame pointers and | |
7645 | makes an extra register available in leaf functions. The option | |
630d3d5a | 7646 | @option{-fomit-frame-pointer} removes the frame pointer for all functions |
762e166b | 7647 | which might make debugging harder. |
3af4bd89 JH |
7648 | @end table |
7649 | ||
74291a4b MM |
7650 | @node HPPA Options |
7651 | @subsection HPPA Options | |
7652 | @cindex HPPA Options | |
7653 | ||
7654 | These @samp{-m} options are defined for the HPPA family of computers: | |
7655 | ||
2642624b | 7656 | @table @gcctabopt |
630d3d5a | 7657 | @item -march=@var{architecture-type} |
cd3bb277 | 7658 | @opindex march |
ea3bfbfe | 7659 | Generate code for the specified architecture. The choices for |
630d3d5a | 7660 | @var{architecture-type} are @samp{1.0} for PA 1.0, @samp{1.1} for PA |
ea3bfbfe JQ |
7661 | 1.1, and @samp{2.0} for PA 2.0 processors. Refer to |
7662 | @file{/usr/lib/sched.models} on an HP-UX system to determine the proper | |
7663 | architecture option for your machine. Code compiled for lower numbered | |
7664 | architectures will run on higher numbered architectures, but not the | |
7665 | other way around. | |
7666 | ||
7667 | PA 2.0 support currently requires gas snapshot 19990413 or later. The | |
7668 | next release of binutils (current is 2.9.1) will probably contain PA 2.0 | |
02f52e19 | 7669 | support. |
74291a4b | 7670 | |
ea3bfbfe | 7671 | @item -mpa-risc-1-0 |
62a1403d AS |
7672 | @itemx -mpa-risc-1-1 |
7673 | @itemx -mpa-risc-2-0 | |
cd3bb277 JM |
7674 | @opindex mpa-risc-1-0 |
7675 | @opindex mpa-risc-1-1 | |
7676 | @opindex mpa-risc-2-0 | |
695ac33f | 7677 | Synonyms for @option{-march=1.0}, @option{-march=1.1}, and @option{-march=2.0} respectively. |
74291a4b | 7678 | |
861bb6c1 | 7679 | @item -mbig-switch |
cd3bb277 | 7680 | @opindex mbig-switch |
861bb6c1 JL |
7681 | Generate code suitable for big switch tables. Use this option only if |
7682 | the assembler/linker complain about out of range branches within a switch | |
7683 | table. | |
7684 | ||
74291a4b | 7685 | @item -mjump-in-delay |
cd3bb277 | 7686 | @opindex mjump-in-delay |
74291a4b MM |
7687 | Fill delay slots of function calls with unconditional jump instructions |
7688 | by modifying the return pointer for the function call to be the target | |
7689 | of the conditional jump. | |
7690 | ||
7691 | @item -mdisable-fpregs | |
cd3bb277 | 7692 | @opindex mdisable-fpregs |
74291a4b MM |
7693 | Prevent floating point registers from being used in any manner. This is |
7694 | necessary for compiling kernels which perform lazy context switching of | |
7695 | floating point registers. If you use this option and attempt to perform | |
7696 | floating point operations, the compiler will abort. | |
7697 | ||
7698 | @item -mdisable-indexing | |
cd3bb277 | 7699 | @opindex mdisable-indexing |
74291a4b | 7700 | Prevent the compiler from using indexing address modes. This avoids some |
161d7b59 | 7701 | rather obscure problems when compiling MIG generated code under MACH@. |
74291a4b MM |
7702 | |
7703 | @item -mno-space-regs | |
cd3bb277 | 7704 | @opindex mno-space-regs |
74291a4b MM |
7705 | Generate code that assumes the target has no space registers. This allows |
7706 | GCC to generate faster indirect calls and use unscaled index address modes. | |
7707 | ||
7708 | Such code is suitable for level 0 PA systems and kernels. | |
7709 | ||
7710 | @item -mfast-indirect-calls | |
cd3bb277 | 7711 | @opindex mfast-indirect-calls |
74291a4b MM |
7712 | Generate code that assumes calls never cross space boundaries. This |
7713 | allows GCC to emit code which performs faster indirect calls. | |
7714 | ||
b192711e | 7715 | This option will not work in the presence of shared libraries or nested |
74291a4b MM |
7716 | functions. |
7717 | ||
74291a4b | 7718 | @item -mlong-load-store |
cd3bb277 | 7719 | @opindex mlong-load-store |
74291a4b MM |
7720 | Generate 3-instruction load and store sequences as sometimes required by |
7721 | the HP-UX 10 linker. This is equivalent to the @samp{+k} option to | |
7722 | the HP compilers. | |
7723 | ||
7724 | @item -mportable-runtime | |
cd3bb277 | 7725 | @opindex mportable-runtime |
74291a4b MM |
7726 | Use the portable calling conventions proposed by HP for ELF systems. |
7727 | ||
7728 | @item -mgas | |
cd3bb277 | 7729 | @opindex mgas |
74291a4b MM |
7730 | Enable the use of assembler directives only GAS understands. |
7731 | ||
630d3d5a | 7732 | @item -mschedule=@var{cpu-type} |
cd3bb277 | 7733 | @opindex mschedule |
74291a4b | 7734 | Schedule code according to the constraints for the machine type |
630d3d5a | 7735 | @var{cpu-type}. The choices for @var{cpu-type} are @samp{700} |
02f52e19 | 7736 | @samp{7100}, @samp{7100LC}, @samp{7200}, and @samp{8000}. Refer to |
732135bf JL |
7737 | @file{/usr/lib/sched.models} on an HP-UX system to determine the |
7738 | proper scheduling option for your machine. | |
74291a4b MM |
7739 | |
7740 | @item -mlinker-opt | |
cd3bb277 | 7741 | @opindex mlinker-opt |
74291a4b MM |
7742 | Enable the optimization pass in the HPUX linker. Note this makes symbolic |
7743 | debugging impossible. It also triggers a bug in the HPUX 8 and HPUX 9 linkers | |
7744 | in which they give bogus error messages when linking some programs. | |
7745 | ||
7746 | @item -msoft-float | |
cd3bb277 | 7747 | @opindex msoft-float |
74291a4b MM |
7748 | Generate output containing library calls for floating point. |
7749 | @strong{Warning:} the requisite libraries are not available for all HPPA | |
7750 | targets. Normally the facilities of the machine's usual C compiler are | |
7751 | used, but this cannot be done directly in cross-compilation. You must make | |
7752 | your own arrangements to provide suitable library functions for | |
7753 | cross-compilation. The embedded target @samp{hppa1.1-*-pro} | |
7754 | does provide software floating point support. | |
7755 | ||
630d3d5a | 7756 | @option{-msoft-float} changes the calling convention in the output file; |
74291a4b MM |
7757 | therefore, it is only useful if you compile @emph{all} of a program with |
7758 | this option. In particular, you need to compile @file{libgcc.a}, the | |
630d3d5a | 7759 | library that comes with GCC, with @option{-msoft-float} in order for |
74291a4b MM |
7760 | this to work. |
7761 | @end table | |
7762 | ||
7763 | @node Intel 960 Options | |
7764 | @subsection Intel 960 Options | |
7765 | ||
7766 | These @samp{-m} options are defined for the Intel 960 implementations: | |
7767 | ||
2642624b | 7768 | @table @gcctabopt |
cd3bb277 JM |
7769 | @item -m@var{cpu-type} |
7770 | @opindex mka | |
7771 | @opindex mkb | |
7772 | @opindex mmc | |
7773 | @opindex mca | |
7774 | @opindex mcf | |
7775 | @opindex msa | |
7776 | @opindex msb | |
7777 | Assume the defaults for the machine type @var{cpu-type} for some of | |
74291a4b | 7778 | the other options, including instruction scheduling, floating point |
cd3bb277 | 7779 | support, and addressing modes. The choices for @var{cpu-type} are |
74291a4b MM |
7780 | @samp{ka}, @samp{kb}, @samp{mc}, @samp{ca}, @samp{cf}, |
7781 | @samp{sa}, and @samp{sb}. | |
7782 | The default is | |
7783 | @samp{kb}. | |
7784 | ||
7785 | @item -mnumerics | |
7786 | @itemx -msoft-float | |
cd3bb277 JM |
7787 | @opindex mnumerics |
7788 | @opindex msoft-float | |
630d3d5a JM |
7789 | The @option{-mnumerics} option indicates that the processor does support |
7790 | floating-point instructions. The @option{-msoft-float} option indicates | |
74291a4b MM |
7791 | that floating-point support should not be assumed. |
7792 | ||
7793 | @item -mleaf-procedures | |
7794 | @itemx -mno-leaf-procedures | |
cd3bb277 JM |
7795 | @opindex mleaf-procedures |
7796 | @opindex mno-leaf-procedures | |
74291a4b MM |
7797 | Do (or do not) attempt to alter leaf procedures to be callable with the |
7798 | @code{bal} instruction as well as @code{call}. This will result in more | |
7799 | efficient code for explicit calls when the @code{bal} instruction can be | |
7800 | substituted by the assembler or linker, but less efficient code in other | |
7801 | cases, such as calls via function pointers, or using a linker that doesn't | |
7802 | support this optimization. | |
7803 | ||
7804 | @item -mtail-call | |
7805 | @itemx -mno-tail-call | |
cd3bb277 JM |
7806 | @opindex mtail-call |
7807 | @opindex mno-tail-call | |
74291a4b MM |
7808 | Do (or do not) make additional attempts (beyond those of the |
7809 | machine-independent portions of the compiler) to optimize tail-recursive | |
7810 | calls into branches. You may not want to do this because the detection of | |
7811 | cases where this is not valid is not totally complete. The default is | |
630d3d5a | 7812 | @option{-mno-tail-call}. |
74291a4b MM |
7813 | |
7814 | @item -mcomplex-addr | |
7815 | @itemx -mno-complex-addr | |
cd3bb277 JM |
7816 | @opindex mcomplex-addr |
7817 | @opindex mno-complex-addr | |
74291a4b MM |
7818 | Assume (or do not assume) that the use of a complex addressing mode is a |
7819 | win on this implementation of the i960. Complex addressing modes may not | |
7820 | be worthwhile on the K-series, but they definitely are on the C-series. | |
630d3d5a | 7821 | The default is currently @option{-mcomplex-addr} for all processors except |
161d7b59 | 7822 | the CB and CC@. |
74291a4b MM |
7823 | |
7824 | @item -mcode-align | |
7825 | @itemx -mno-code-align | |
cd3bb277 JM |
7826 | @opindex mcode-align |
7827 | @opindex mno-code-align | |
74291a4b MM |
7828 | Align code to 8-byte boundaries for faster fetching (or don't bother). |
7829 | Currently turned on by default for C-series implementations only. | |
7830 | ||
7831 | @ignore | |
7832 | @item -mclean-linkage | |
7833 | @itemx -mno-clean-linkage | |
cd3bb277 JM |
7834 | @opindex mclean-linkage |
7835 | @opindex mno-clean-linkage | |
74291a4b MM |
7836 | These options are not fully implemented. |
7837 | @end ignore | |
7838 | ||
7839 | @item -mic-compat | |
7840 | @itemx -mic2.0-compat | |
7841 | @itemx -mic3.0-compat | |
cd3bb277 JM |
7842 | @opindex mic-compat |
7843 | @opindex mic2.0-compat | |
7844 | @opindex mic3.0-compat | |
74291a4b MM |
7845 | Enable compatibility with iC960 v2.0 or v3.0. |
7846 | ||
7847 | @item -masm-compat | |
7848 | @itemx -mintel-asm | |
cd3bb277 JM |
7849 | @opindex masm-compat |
7850 | @opindex mintel-asm | |
74291a4b MM |
7851 | Enable compatibility with the iC960 assembler. |
7852 | ||
7853 | @item -mstrict-align | |
7854 | @itemx -mno-strict-align | |
cd3bb277 JM |
7855 | @opindex mstrict-align |
7856 | @opindex mno-strict-align | |
74291a4b MM |
7857 | Do not permit (do permit) unaligned accesses. |
7858 | ||
7859 | @item -mold-align | |
cd3bb277 | 7860 | @opindex mold-align |
74291a4b | 7861 | Enable structure-alignment compatibility with Intel's gcc release version |
630d3d5a | 7862 | 1.3 (based on gcc 1.37). This option implies @option{-mstrict-align}. |
eaa4b44c VM |
7863 | |
7864 | @item -mlong-double-64 | |
cd3bb277 | 7865 | @opindex mlong-double-64 |
eaa4b44c VM |
7866 | Implement type @samp{long double} as 64-bit floating point numbers. |
7867 | Without the option @samp{long double} is implemented by 80-bit | |
7868 | floating point numbers. The only reason we have it because there is | |
7869 | no 128-bit @samp{long double} support in @samp{fp-bit.c} yet. So it | |
7870 | is only useful for people using soft-float targets. Otherwise, we | |
7871 | should recommend against use of it. | |
7872 | ||
74291a4b MM |
7873 | @end table |
7874 | ||
7875 | @node DEC Alpha Options | |
7876 | @subsection DEC Alpha Options | |
7877 | ||
7878 | These @samp{-m} options are defined for the DEC Alpha implementations: | |
7879 | ||
2642624b | 7880 | @table @gcctabopt |
74291a4b MM |
7881 | @item -mno-soft-float |
7882 | @itemx -msoft-float | |
cd3bb277 JM |
7883 | @opindex mno-soft-float |
7884 | @opindex msoft-float | |
74291a4b | 7885 | Use (do not use) the hardware floating-point instructions for |
bedc7537 | 7886 | floating-point operations. When @option{-msoft-float} is specified, |
7857f134 | 7887 | functions in @file{libgcc.a} will be used to perform floating-point |
74291a4b MM |
7888 | operations. Unless they are replaced by routines that emulate the |
7889 | floating-point operations, or compiled in such a way as to call such | |
7890 | emulations routines, these routines will issue floating-point | |
7891 | operations. If you are compiling for an Alpha without floating-point | |
7892 | operations, you must ensure that the library is built so as not to call | |
7893 | them. | |
7894 | ||
7895 | Note that Alpha implementations without floating-point operations are | |
7896 | required to have floating-point registers. | |
7897 | ||
7898 | @item -mfp-reg | |
7899 | @itemx -mno-fp-regs | |
cd3bb277 JM |
7900 | @opindex mfp-reg |
7901 | @opindex mno-fp-regs | |
74291a4b | 7902 | Generate code that uses (does not use) the floating-point register set. |
bedc7537 | 7903 | @option{-mno-fp-regs} implies @option{-msoft-float}. If the floating-point |
74291a4b MM |
7904 | register set is not used, floating point operands are passed in integer |
7905 | registers as if they were integers and floating-point results are passed | |
7906 | in $0 instead of $f0. This is a non-standard calling sequence, so any | |
7907 | function with a floating-point argument or return value called by code | |
bedc7537 | 7908 | compiled with @option{-mno-fp-regs} must also be compiled with that |
74291a4b MM |
7909 | option. |
7910 | ||
7911 | A typical use of this option is building a kernel that does not use, | |
7912 | and hence need not save and restore, any floating-point registers. | |
7913 | ||
7914 | @item -mieee | |
cd3bb277 | 7915 | @opindex mieee |
74291a4b MM |
7916 | The Alpha architecture implements floating-point hardware optimized for |
7917 | maximum performance. It is mostly compliant with the IEEE floating | |
7918 | point standard. However, for full compliance, software assistance is | |
7919 | required. This option generates code fully IEEE compliant code | |
630d3d5a | 7920 | @emph{except} that the @var{inexact-flag} is not maintained (see below). |
9c34dbbf ZW |
7921 | If this option is turned on, the preprocessor macro @code{_IEEE_FP} is |
7922 | defined during compilation. The resulting code is less efficient but is | |
7923 | able to correctly support denormalized numbers and exceptional IEEE | |
7924 | values such as not-a-number and plus/minus infinity. Other Alpha | |
7925 | compilers call this option @option{-ieee_with_no_inexact}. | |
74291a4b MM |
7926 | |
7927 | @item -mieee-with-inexact | |
cd3bb277 | 7928 | @opindex mieee-with-inexact |
9c34dbbf ZW |
7929 | This is like @option{-mieee} except the generated code also maintains |
7930 | the IEEE @var{inexact-flag}. Turning on this option causes the | |
7931 | generated code to implement fully-compliant IEEE math. In addition to | |
7932 | @code{_IEEE_FP}, @code{_IEEE_FP_EXACT} is defined as a preprocessor | |
7933 | macro. On some Alpha implementations the resulting code may execute | |
7934 | significantly slower than the code generated by default. Since there is | |
7935 | very little code that depends on the @var{inexact-flag}, you should | |
74291a4b | 7936 | normally not specify this option. Other Alpha compilers call this |
630d3d5a | 7937 | option @option{-ieee_with_inexact}. |
74291a4b | 7938 | |
630d3d5a | 7939 | @item -mfp-trap-mode=@var{trap-mode} |
cd3bb277 | 7940 | @opindex mfp-trap-mode |
74291a4b | 7941 | This option controls what floating-point related traps are enabled. |
630d3d5a | 7942 | Other Alpha compilers call this option @option{-fptm @var{trap-mode}}. |
74291a4b MM |
7943 | The trap mode can be set to one of four values: |
7944 | ||
7945 | @table @samp | |
7946 | @item n | |
7947 | This is the default (normal) setting. The only traps that are enabled | |
7948 | are the ones that cannot be disabled in software (e.g., division by zero | |
7949 | trap). | |
7950 | ||
7951 | @item u | |
7952 | In addition to the traps enabled by @samp{n}, underflow traps are enabled | |
7953 | as well. | |
7954 | ||
7955 | @item su | |
7956 | Like @samp{su}, but the instructions are marked to be safe for software | |
7957 | completion (see Alpha architecture manual for details). | |
7958 | ||
7959 | @item sui | |
7960 | Like @samp{su}, but inexact traps are enabled as well. | |
7961 | @end table | |
7962 | ||
630d3d5a | 7963 | @item -mfp-rounding-mode=@var{rounding-mode} |
cd3bb277 | 7964 | @opindex mfp-rounding-mode |
74291a4b | 7965 | Selects the IEEE rounding mode. Other Alpha compilers call this option |
630d3d5a | 7966 | @option{-fprm @var{rounding-mode}}. The @var{rounding-mode} can be one |
74291a4b MM |
7967 | of: |
7968 | ||
7969 | @table @samp | |
7970 | @item n | |
7971 | Normal IEEE rounding mode. Floating point numbers are rounded towards | |
7972 | the nearest machine number or towards the even machine number in case | |
7973 | of a tie. | |
7974 | ||
7975 | @item m | |
7976 | Round towards minus infinity. | |
7977 | ||
7978 | @item c | |
7979 | Chopped rounding mode. Floating point numbers are rounded towards zero. | |
7980 | ||
7981 | @item d | |
7982 | Dynamic rounding mode. A field in the floating point control register | |
7983 | (@var{fpcr}, see Alpha architecture reference manual) controls the | |
7984 | rounding mode in effect. The C library initializes this register for | |
7985 | rounding towards plus infinity. Thus, unless your program modifies the | |
ec4b2ecb CB |
7986 | @var{fpcr}, @samp{d} corresponds to round towards plus infinity. |
7987 | @end table | |
74291a4b | 7988 | |
630d3d5a | 7989 | @item -mtrap-precision=@var{trap-precision} |
cd3bb277 | 7990 | @opindex mtrap-precision |
74291a4b MM |
7991 | In the Alpha architecture, floating point traps are imprecise. This |
7992 | means without software assistance it is impossible to recover from a | |
7993 | floating trap and program execution normally needs to be terminated. | |
0c2d1a2a | 7994 | GCC can generate code that can assist operating system trap handlers |
74291a4b MM |
7995 | in determining the exact location that caused a floating point trap. |
7996 | Depending on the requirements of an application, different levels of | |
7997 | precisions can be selected: | |
7998 | ||
7999 | @table @samp | |
8000 | @item p | |
8001 | Program precision. This option is the default and means a trap handler | |
8002 | can only identify which program caused a floating point exception. | |
8003 | ||
8004 | @item f | |
8005 | Function precision. The trap handler can determine the function that | |
8006 | caused a floating point exception. | |
8007 | ||
8008 | @item i | |
8009 | Instruction precision. The trap handler can determine the exact | |
8010 | instruction that caused a floating point exception. | |
8011 | @end table | |
8012 | ||
8013 | Other Alpha compilers provide the equivalent options called | |
630d3d5a | 8014 | @option{-scope_safe} and @option{-resumption_safe}. |
74291a4b MM |
8015 | |
8016 | @item -mieee-conformant | |
cd3bb277 | 8017 | @opindex mieee-conformant |
74291a4b | 8018 | This option marks the generated code as IEEE conformant. You must not |
630d3d5a JM |
8019 | use this option unless you also specify @option{-mtrap-precision=i} and either |
8020 | @option{-mfp-trap-mode=su} or @option{-mfp-trap-mode=sui}. Its only effect | |
74291a4b MM |
8021 | is to emit the line @samp{.eflag 48} in the function prologue of the |
8022 | generated assembly file. Under DEC Unix, this has the effect that | |
8023 | IEEE-conformant math library routines will be linked in. | |
8024 | ||
8025 | @item -mbuild-constants | |
cd3bb277 | 8026 | @opindex mbuild-constants |
0c2d1a2a | 8027 | Normally GCC examines a 32- or 64-bit integer constant to |
74291a4b MM |
8028 | see if it can construct it from smaller constants in two or three |
8029 | instructions. If it cannot, it will output the constant as a literal and | |
956d6950 | 8030 | generate code to load it from the data segment at runtime. |
74291a4b | 8031 | |
0c2d1a2a | 8032 | Use this option to require GCC to construct @emph{all} integer constants |
74291a4b MM |
8033 | using code, even if it takes more instructions (the maximum is six). |
8034 | ||
8035 | You would typically use this option to build a shared library dynamic | |
8036 | loader. Itself a shared library, it must relocate itself in memory | |
8037 | before it can find the variables and constants in its own data segment. | |
956d6950 JL |
8038 | |
8039 | @item -malpha-as | |
8040 | @itemx -mgas | |
cd3bb277 JM |
8041 | @opindex malpha-as |
8042 | @opindex mgas | |
956d6950 | 8043 | Select whether to generate code to be assembled by the vendor-supplied |
630d3d5a | 8044 | assembler (@option{-malpha-as}) or by the GNU assembler @option{-mgas}. |
956d6950 JL |
8045 | |
8046 | @item -mbwx | |
8047 | @itemx -mno-bwx | |
8048 | @itemx -mcix | |
8049 | @itemx -mno-cix | |
8050 | @itemx -mmax | |
8051 | @itemx -mno-max | |
cd3bb277 JM |
8052 | @opindex mbwx |
8053 | @opindex mno-bwx | |
8054 | @opindex mcix | |
8055 | @opindex mno-cix | |
8056 | @opindex mmax | |
8057 | @opindex mno-max | |
0c2d1a2a | 8058 | Indicate whether GCC should generate code to use the optional BWX, |
956d6950 | 8059 | CIX, and MAX instruction sets. The default is to use the instruction sets |
630d3d5a | 8060 | supported by the CPU type specified via @option{-mcpu=} option or that |
0c2d1a2a | 8061 | of the CPU on which GCC was built if none was specified. |
956d6950 | 8062 | |
956d6950 | 8063 | @item -mcpu=@var{cpu_type} |
cd3bb277 | 8064 | @opindex mcpu |
956d6950 JL |
8065 | Set the instruction set, register set, and instruction scheduling |
8066 | parameters for machine type @var{cpu_type}. You can specify either the | |
0c2d1a2a | 8067 | @samp{EV} style name or the corresponding chip number. GCC |
956d6950 JL |
8068 | supports scheduling parameters for the EV4 and EV5 family of processors |
8069 | and will choose the default values for the instruction set from | |
8070 | the processor you specify. If you do not specify a processor type, | |
0c2d1a2a | 8071 | GCC will default to the processor on which the compiler was built. |
956d6950 JL |
8072 | |
8073 | Supported values for @var{cpu_type} are | |
8074 | ||
8075 | @table @samp | |
8076 | @item ev4 | |
8077 | @itemx 21064 | |
8078 | Schedules as an EV4 and has no instruction set extensions. | |
8079 | ||
8080 | @item ev5 | |
8081 | @itemx 21164 | |
8082 | Schedules as an EV5 and has no instruction set extensions. | |
8083 | ||
8084 | @item ev56 | |
8085 | @itemx 21164a | |
8086 | Schedules as an EV5 and supports the BWX extension. | |
8087 | ||
8088 | @item pca56 | |
4f69985c | 8089 | @itemx 21164pc |
956d6950 JL |
8090 | @itemx 21164PC |
8091 | Schedules as an EV5 and supports the BWX and MAX extensions. | |
8092 | ||
8093 | @item ev6 | |
8094 | @itemx 21264 | |
8095 | Schedules as an EV5 (until Digital releases the scheduling parameters | |
8096 | for the EV6) and supports the BWX, CIX, and MAX extensions. | |
4f69985c RH |
8097 | @end table |
8098 | ||
8099 | @item -mmemory-latency=@var{time} | |
cd3bb277 | 8100 | @opindex mmemory-latency |
4f69985c RH |
8101 | Sets the latency the scheduler should assume for typical memory |
8102 | references as seen by the application. This number is highly | |
b192711e | 8103 | dependent on the memory access patterns used by the application |
4f69985c RH |
8104 | and the size of the external cache on the machine. |
8105 | ||
8106 | Valid options for @var{time} are | |
8107 | ||
8108 | @table @samp | |
8109 | @item @var{number} | |
8110 | A decimal number representing clock cycles. | |
8111 | ||
8112 | @item L1 | |
8113 | @itemx L2 | |
8114 | @itemx L3 | |
8115 | @itemx main | |
8116 | The compiler contains estimates of the number of clock cycles for | |
8117 | ``typical'' EV4 & EV5 hardware for the Level 1, 2 & 3 caches | |
8118 | (also called Dcache, Scache, and Bcache), as well as to main memory. | |
8119 | Note that L3 is only valid for EV5. | |
8120 | ||
956d6950 | 8121 | @end table |
74291a4b MM |
8122 | @end table |
8123 | ||
8124 | @node Clipper Options | |
8125 | @subsection Clipper Options | |
8126 | ||
8127 | These @samp{-m} options are defined for the Clipper implementations: | |
8128 | ||
2642624b | 8129 | @table @gcctabopt |
74291a4b | 8130 | @item -mc300 |
cd3bb277 | 8131 | @opindex mc300 |
767094dd | 8132 | Produce code for a C300 Clipper processor. This is the default. |
74291a4b | 8133 | |
62a1403d | 8134 | @item -mc400 |
cd3bb277 | 8135 | @opindex mc400 |
9c34dbbf ZW |
8136 | Produce code for a C400 Clipper processor, i.e.@: use floating point |
8137 | registers f8--f15. | |
74291a4b MM |
8138 | @end table |
8139 | ||
8140 | @node H8/300 Options | |
8141 | @subsection H8/300 Options | |
8142 | ||
8143 | These @samp{-m} options are defined for the H8/300 implementations: | |
8144 | ||
2642624b | 8145 | @table @gcctabopt |
74291a4b | 8146 | @item -mrelax |
cd3bb277 | 8147 | @opindex mrelax |
74291a4b | 8148 | Shorten some address references at link time, when possible; uses the |
630d3d5a | 8149 | linker option @option{-relax}. @xref{H8/300,, @code{ld} and the H8/300, |
74291a4b MM |
8150 | ld.info, Using ld}, for a fuller description. |
8151 | ||
8152 | @item -mh | |
cd3bb277 | 8153 | @opindex mh |
161d7b59 | 8154 | Generate code for the H8/300H@. |
74291a4b | 8155 | |
dcb9d1f0 | 8156 | @item -ms |
cd3bb277 | 8157 | @opindex ms |
161d7b59 | 8158 | Generate code for the H8/S@. |
dcb9d1f0 | 8159 | |
17f0f8fa | 8160 | @item -ms2600 |
cd3bb277 | 8161 | @opindex ms2600 |
695ac33f | 8162 | Generate code for the H8/S2600. This switch must be used with @option{-ms}. |
17f0f8fa | 8163 | |
74291a4b | 8164 | @item -mint32 |
cd3bb277 | 8165 | @opindex mint32 |
74291a4b MM |
8166 | Make @code{int} data 32 bits by default. |
8167 | ||
8168 | @item -malign-300 | |
cd3bb277 | 8169 | @opindex malign-300 |
2c54abce KH |
8170 | On the H8/300H and H8/S, use the same alignment rules as for the H8/300. |
8171 | The default for the H8/300H and H8/S is to align longs and floats on 4 | |
8172 | byte boundaries. | |
630d3d5a | 8173 | @option{-malign-300} causes them to be aligned on 2 byte boundaries. |
2c54abce | 8174 | This option has no effect on the H8/300. |
74291a4b MM |
8175 | @end table |
8176 | ||
8177 | @node SH Options | |
8178 | @subsection SH Options | |
8179 | ||
8180 | These @samp{-m} options are defined for the SH implementations: | |
8181 | ||
2642624b | 8182 | @table @gcctabopt |
74291a4b | 8183 | @item -m1 |
cd3bb277 | 8184 | @opindex m1 |
74291a4b MM |
8185 | Generate code for the SH1. |
8186 | ||
8187 | @item -m2 | |
cd3bb277 | 8188 | @opindex m2 |
74291a4b MM |
8189 | Generate code for the SH2. |
8190 | ||
8191 | @item -m3 | |
cd3bb277 | 8192 | @opindex m3 |
74291a4b MM |
8193 | Generate code for the SH3. |
8194 | ||
8195 | @item -m3e | |
cd3bb277 | 8196 | @opindex m3e |
74291a4b MM |
8197 | Generate code for the SH3e. |
8198 | ||
3cadd778 | 8199 | @item -m4-nofpu |
cd3bb277 | 8200 | @opindex m4-nofpu |
3cadd778 AO |
8201 | Generate code for the SH4 without a floating-point unit. |
8202 | ||
8203 | @item -m4-single-only | |
cd3bb277 | 8204 | @opindex m4-single-only |
3cadd778 | 8205 | Generate code for the SH4 with a floating-point unit that only |
c771326b | 8206 | supports single-precision arithmetic. |
3cadd778 AO |
8207 | |
8208 | @item -m4-single | |
cd3bb277 | 8209 | @opindex m4-single |
3cadd778 AO |
8210 | Generate code for the SH4 assuming the floating-point unit is in |
8211 | single-precision mode by default. | |
8212 | ||
8213 | @item -m4 | |
cd3bb277 | 8214 | @opindex m4 |
3cadd778 AO |
8215 | Generate code for the SH4. |
8216 | ||
74291a4b | 8217 | @item -mb |
cd3bb277 | 8218 | @opindex mb |
74291a4b MM |
8219 | Compile code for the processor in big endian mode. |
8220 | ||
8221 | @item -ml | |
cd3bb277 | 8222 | @opindex ml |
74291a4b MM |
8223 | Compile code for the processor in little endian mode. |
8224 | ||
3d5a0820 | 8225 | @item -mdalign |
cd3bb277 | 8226 | @opindex mdalign |
02f52e19 | 8227 | Align doubles at 64-bit boundaries. Note that this changes the calling |
3d5a0820 | 8228 | conventions, and thus some functions from the standard C library will |
695ac33f | 8229 | not work unless you recompile it first with @option{-mdalign}. |
3d5a0820 | 8230 | |
74291a4b | 8231 | @item -mrelax |
cd3bb277 | 8232 | @opindex mrelax |
74291a4b | 8233 | Shorten some address references at link time, when possible; uses the |
630d3d5a | 8234 | linker option @option{-relax}. |
3cadd778 AO |
8235 | |
8236 | @item -mbigtable | |
cd3bb277 | 8237 | @opindex mbigtable |
3cadd778 AO |
8238 | Use 32-bit offsets in @code{switch} tables. The default is to use |
8239 | 16-bit offsets. | |
8240 | ||
8241 | @item -mfmovd | |
cd3bb277 | 8242 | @opindex mfmovd |
3cadd778 AO |
8243 | Enable the use of the instruction @code{fmovd}. |
8244 | ||
8245 | @item -mhitachi | |
cd3bb277 | 8246 | @opindex mhitachi |
3cadd778 AO |
8247 | Comply with the calling conventions defined by Hitachi. |
8248 | ||
8249 | @item -mnomacsave | |
cd3bb277 | 8250 | @opindex mnomacsave |
3cadd778 | 8251 | Mark the @code{MAC} register as call-clobbered, even if |
bedc7537 | 8252 | @option{-mhitachi} is given. |
3cadd778 | 8253 | |
c474f76b AO |
8254 | @item -mieee |
8255 | @opindex mieee | |
8256 | Increase IEEE-compliance of floating-point code. | |
8257 | ||
3cadd778 | 8258 | @item -misize |
cd3bb277 | 8259 | @opindex misize |
3cadd778 AO |
8260 | Dump instruction size and location in the assembly code. |
8261 | ||
8262 | @item -mpadstruct | |
cd3bb277 | 8263 | @opindex mpadstruct |
3cadd778 | 8264 | This option is deprecated. It pads structures to multiple of 4 bytes, |
161d7b59 | 8265 | which is incompatible with the SH ABI@. |
3cadd778 AO |
8266 | |
8267 | @item -mspace | |
cd3bb277 | 8268 | @opindex mspace |
bedc7537 | 8269 | Optimize for space instead of speed. Implied by @option{-Os}. |
1a66cd67 AO |
8270 | |
8271 | @item -mprefergot | |
cd3bb277 | 8272 | @opindex mprefergot |
1a66cd67 AO |
8273 | When generating position-independent code, emit function calls using |
8274 | the Global Offset Table instead of the Procedure Linkage Table. | |
93ca1662 NY |
8275 | |
8276 | @item -musermode | |
cd3bb277 | 8277 | @opindex musermode |
93ca1662 NY |
8278 | Generate a library function call to invalidate instruction cache |
8279 | entries, after fixing up a trampoline. This library function call | |
8280 | doesn't assume it can write to the whole memory address space. This | |
8281 | is the default when the target is @code{sh-*-linux*}. | |
74291a4b MM |
8282 | @end table |
8283 | ||
8284 | @node System V Options | |
8285 | @subsection Options for System V | |
8286 | ||
8287 | These additional options are available on System V Release 4 for | |
8288 | compatibility with other compilers on those systems: | |
8289 | ||
2642624b | 8290 | @table @gcctabopt |
74291a4b | 8291 | @item -G |
cd3bb277 | 8292 | @opindex G |
74291a4b | 8293 | Create a shared object. |
630d3d5a | 8294 | It is recommended that @option{-symbolic} or @option{-shared} be used instead. |
74291a4b MM |
8295 | |
8296 | @item -Qy | |
cd3bb277 | 8297 | @opindex Qy |
74291a4b MM |
8298 | Identify the versions of each tool used by the compiler, in a |
8299 | @code{.ident} assembler directive in the output. | |
8300 | ||
8301 | @item -Qn | |
cd3bb277 | 8302 | @opindex Qn |
74291a4b MM |
8303 | Refrain from adding @code{.ident} directives to the output file (this is |
8304 | the default). | |
8305 | ||
aee96fe9 | 8306 | @item -YP,@var{dirs} |
cd3bb277 | 8307 | @opindex YP |
74291a4b | 8308 | Search the directories @var{dirs}, and no others, for libraries |
630d3d5a | 8309 | specified with @option{-l}. |
74291a4b | 8310 | |
aee96fe9 | 8311 | @item -Ym,@var{dir} |
cd3bb277 | 8312 | @opindex Ym |
bedc7537 | 8313 | Look in the directory @var{dir} to find the M4 preprocessor. |
74291a4b MM |
8314 | The assembler uses this option. |
8315 | @c This is supposed to go with a -Yd for predefined M4 macro files, but | |
8316 | @c the generic assembler that comes with Solaris takes just -Ym. | |
8317 | @end table | |
8318 | ||
282a61e6 MH |
8319 | @node TMS320C3x/C4x Options |
8320 | @subsection TMS320C3x/C4x Options | |
8321 | @cindex TMS320C3x/C4x Options | |
8322 | ||
8323 | These @samp{-m} options are defined for TMS320C3x/C4x implementations: | |
8324 | ||
2642624b | 8325 | @table @gcctabopt |
282a61e6 MH |
8326 | |
8327 | @item -mcpu=@var{cpu_type} | |
cd3bb277 | 8328 | @opindex mcpu |
282a61e6 MH |
8329 | Set the instruction set, register set, and instruction scheduling |
8330 | parameters for machine type @var{cpu_type}. Supported values for | |
8331 | @var{cpu_type} are @samp{c30}, @samp{c31}, @samp{c32}, @samp{c40}, and | |
8332 | @samp{c44}. The default is @samp{c40} to generate code for the | |
8333 | TMS320C40. | |
8334 | ||
8335 | @item -mbig-memory | |
8336 | @item -mbig | |
8337 | @itemx -msmall-memory | |
8338 | @itemx -msmall | |
cd3bb277 JM |
8339 | @opindex mbig-memory |
8340 | @opindex mbig | |
8341 | @opindex msmall-memory | |
8342 | @opindex msmall | |
282a61e6 MH |
8343 | Generates code for the big or small memory model. The small memory |
8344 | model assumed that all data fits into one 64K word page. At run-time | |
8345 | the data page (DP) register must be set to point to the 64K page | |
8346 | containing the .bss and .data program sections. The big memory model is | |
8347 | the default and requires reloading of the DP register for every direct | |
8348 | memory access. | |
8349 | ||
8350 | @item -mbk | |
8351 | @itemx -mno-bk | |
cd3bb277 JM |
8352 | @opindex mbk |
8353 | @opindex mno-bk | |
282a61e6 | 8354 | Allow (disallow) allocation of general integer operands into the block |
161d7b59 | 8355 | count register BK@. |
282a61e6 MH |
8356 | |
8357 | @item -mdb | |
8358 | @itemx -mno-db | |
cd3bb277 JM |
8359 | @opindex mdb |
8360 | @opindex mno-db | |
282a61e6 MH |
8361 | Enable (disable) generation of code using decrement and branch, |
8362 | DBcond(D), instructions. This is enabled by default for the C4x. To be | |
8363 | on the safe side, this is disabled for the C3x, since the maximum | |
aee96fe9 JM |
8364 | iteration count on the C3x is @math{2^23 + 1} (but who iterates loops more than |
8365 | @math{2^23} times on the C3x?). Note that GCC will try to reverse a loop so | |
282a61e6 MH |
8366 | that it can utilise the decrement and branch instruction, but will give |
8367 | up if there is more than one memory reference in the loop. Thus a loop | |
8368 | where the loop counter is decremented can generate slightly more | |
8369 | efficient code, in cases where the RPTB instruction cannot be utilised. | |
8370 | ||
8371 | @item -mdp-isr-reload | |
8372 | @itemx -mparanoid | |
cd3bb277 JM |
8373 | @opindex mdp-isr-reload |
8374 | @opindex mparanoid | |
282a61e6 MH |
8375 | Force the DP register to be saved on entry to an interrupt service |
8376 | routine (ISR), reloaded to point to the data section, and restored on | |
161d7b59 | 8377 | exit from the ISR@. This should not be required unless someone has |
282a61e6 MH |
8378 | violated the small memory model by modifying the DP register, say within |
8379 | an object library. | |
8380 | ||
8381 | @item -mmpyi | |
8382 | @itemx -mno-mpyi | |
cd3bb277 JM |
8383 | @opindex mmpyi |
8384 | @opindex mno-mpyi | |
282a61e6 MH |
8385 | For the C3x use the 24-bit MPYI instruction for integer multiplies |
8386 | instead of a library call to guarantee 32-bit results. Note that if one | |
8387 | of the operands is a constant, then the multiplication will be performed | |
695ac33f | 8388 | using shifts and adds. If the @option{-mmpyi} option is not specified for the C3x, |
282a61e6 MH |
8389 | then squaring operations are performed inline instead of a library call. |
8390 | ||
8391 | @item -mfast-fix | |
8392 | @itemx -mno-fast-fix | |
cd3bb277 JM |
8393 | @opindex mfast-fix |
8394 | @opindex mno-fast-fix | |
282a61e6 MH |
8395 | The C3x/C4x FIX instruction to convert a floating point value to an |
8396 | integer value chooses the nearest integer less than or equal to the | |
8397 | floating point value rather than to the nearest integer. Thus if the | |
8398 | floating point number is negative, the result will be incorrectly | |
8399 | truncated an additional code is necessary to detect and correct this | |
8400 | case. This option can be used to disable generation of the additional | |
8401 | code required to correct the result. | |
8402 | ||
8403 | @item -mrptb | |
8404 | @itemx -mno-rptb | |
cd3bb277 JM |
8405 | @opindex mrptb |
8406 | @opindex mno-rptb | |
282a61e6 MH |
8407 | Enable (disable) generation of repeat block sequences using the RPTB |
8408 | instruction for zero overhead looping. The RPTB construct is only used | |
8409 | for innermost loops that do not call functions or jump across the loop | |
8410 | boundaries. There is no advantage having nested RPTB loops due to the | |
8411 | overhead required to save and restore the RC, RS, and RE registers. | |
695ac33f | 8412 | This is enabled by default with @option{-O2}. |
282a61e6 MH |
8413 | |
8414 | @item -mrpts=@var{count} | |
8415 | @itemx -mno-rpts | |
cd3bb277 JM |
8416 | @opindex mrpts |
8417 | @opindex mno-rpts | |
282a61e6 | 8418 | Enable (disable) the use of the single instruction repeat instruction |
161d7b59 | 8419 | RPTS@. If a repeat block contains a single instruction, and the loop |
282a61e6 | 8420 | count can be guaranteed to be less than the value @var{count}, GCC will |
161d7b59 | 8421 | emit a RPTS instruction instead of a RPTB@. If no value is specified, |
282a61e6 MH |
8422 | then a RPTS will be emitted even if the loop count cannot be determined |
8423 | at compile time. Note that the repeated instruction following RPTS does | |
8424 | not have to be reloaded from memory each iteration, thus freeing up the | |
b192711e | 8425 | CPU buses for operands. However, since interrupts are blocked by this |
282a61e6 MH |
8426 | instruction, it is disabled by default. |
8427 | ||
8428 | @item -mloop-unsigned | |
8429 | @itemx -mno-loop-unsigned | |
cd3bb277 JM |
8430 | @opindex mloop-unsigned |
8431 | @opindex mno-loop-unsigned | |
282a61e6 | 8432 | The maximum iteration count when using RPTS and RPTB (and DB on the C40) |
aee96fe9 | 8433 | is @math{2^31 + 1} since these instructions test if the iteration count is |
282a61e6 | 8434 | negative to terminate the loop. If the iteration count is unsigned |
aee96fe9 | 8435 | there is a possibility than the @math{2^31 + 1} maximum iteration count may be |
282a61e6 MH |
8436 | exceeded. This switch allows an unsigned iteration count. |
8437 | ||
8438 | @item -mti | |
cd3bb277 | 8439 | @opindex mti |
282a61e6 MH |
8440 | Try to emit an assembler syntax that the TI assembler (asm30) is happy |
8441 | with. This also enforces compatibility with the API employed by the TI | |
8442 | C3x C compiler. For example, long doubles are passed as structures | |
8443 | rather than in floating point registers. | |
8444 | ||
8445 | @item -mregparm | |
8446 | @itemx -mmemparm | |
cd3bb277 JM |
8447 | @opindex mregparm |
8448 | @opindex mmemparm | |
282a61e6 MH |
8449 | Generate code that uses registers (stack) for passing arguments to functions. |
8450 | By default, arguments are passed in registers where possible rather | |
8451 | than by pushing arguments on to the stack. | |
8452 | ||
8453 | @item -mparallel-insns | |
8454 | @itemx -mno-parallel-insns | |
cd3bb277 JM |
8455 | @opindex mparallel-insns |
8456 | @opindex mno-parallel-insns | |
282a61e6 | 8457 | Allow the generation of parallel instructions. This is enabled by |
695ac33f | 8458 | default with @option{-O2}. |
282a61e6 MH |
8459 | |
8460 | @item -mparallel-mpy | |
8461 | @itemx -mno-parallel-mpy | |
cd3bb277 JM |
8462 | @opindex mparallel-mpy |
8463 | @opindex mno-parallel-mpy | |
282a61e6 | 8464 | Allow the generation of MPY||ADD and MPY||SUB parallel instructions, |
695ac33f | 8465 | provided @option{-mparallel-insns} is also specified. These instructions have |
282a61e6 MH |
8466 | tight register constraints which can pessimize the code generation |
8467 | of large functions. | |
8468 | ||
8469 | @end table | |
8470 | ||
f84271d9 JL |
8471 | @node V850 Options |
8472 | @subsection V850 Options | |
8473 | @cindex V850 Options | |
8474 | ||
8475 | These @samp{-m} options are defined for V850 implementations: | |
8476 | ||
2642624b | 8477 | @table @gcctabopt |
f84271d9 JL |
8478 | @item -mlong-calls |
8479 | @itemx -mno-long-calls | |
cd3bb277 JM |
8480 | @opindex mlong-calls |
8481 | @opindex mno-long-calls | |
f84271d9 JL |
8482 | Treat all calls as being far away (near). If calls are assumed to be |
8483 | far away, the compiler will always load the functions address up into a | |
8484 | register, and call indirect through the pointer. | |
8485 | ||
8486 | @item -mno-ep | |
bd762873 | 8487 | @itemx -mep |
cd3bb277 JM |
8488 | @opindex mno-ep |
8489 | @opindex mep | |
f84271d9 JL |
8490 | Do not optimize (do optimize) basic blocks that use the same index |
8491 | pointer 4 or more times to copy pointer into the @code{ep} register, and | |
630d3d5a | 8492 | use the shorter @code{sld} and @code{sst} instructions. The @option{-mep} |
f84271d9 JL |
8493 | option is on by default if you optimize. |
8494 | ||
8495 | @item -mno-prolog-function | |
8496 | @itemx -mprolog-function | |
cd3bb277 JM |
8497 | @opindex mno-prolog-function |
8498 | @opindex mprolog-function | |
f84271d9 JL |
8499 | Do not use (do use) external functions to save and restore registers at |
8500 | the prolog and epilog of a function. The external functions are slower, | |
8501 | but use less code space if more than one function saves the same number | |
630d3d5a | 8502 | of registers. The @option{-mprolog-function} option is on by default if |
f84271d9 JL |
8503 | you optimize. |
8504 | ||
8505 | @item -mspace | |
cd3bb277 | 8506 | @opindex mspace |
f84271d9 | 8507 | Try to make the code as small as possible. At present, this just turns |
630d3d5a | 8508 | on the @option{-mep} and @option{-mprolog-function} options. |
f84271d9 JL |
8509 | |
8510 | @item -mtda=@var{n} | |
cd3bb277 | 8511 | @opindex mtda |
f84271d9 JL |
8512 | Put static or global variables whose size is @var{n} bytes or less into |
8513 | the tiny data area that register @code{ep} points to. The tiny data | |
8514 | area can hold up to 256 bytes in total (128 bytes for byte references). | |
8515 | ||
8516 | @item -msda=@var{n} | |
cd3bb277 | 8517 | @opindex msda |
f84271d9 JL |
8518 | Put static or global variables whose size is @var{n} bytes or less into |
8519 | the small data area that register @code{gp} points to. The small data | |
8520 | area can hold up to 64 kilobytes. | |
8521 | ||
8522 | @item -mzda=@var{n} | |
cd3bb277 | 8523 | @opindex mzda |
f84271d9 JL |
8524 | Put static or global variables whose size is @var{n} bytes or less into |
8525 | the first 32 kilobytes of memory. | |
02f52e19 | 8526 | |
48f0be1b | 8527 | @item -mv850 |
cd3bb277 | 8528 | @opindex mv850 |
48f0be1b SC |
8529 | Specify that the target processor is the V850. |
8530 | ||
e9a25f70 | 8531 | @item -mbig-switch |
cd3bb277 | 8532 | @opindex mbig-switch |
e9a25f70 JL |
8533 | Generate code suitable for big switch tables. Use this option only if |
8534 | the assembler/linker complain about out of range branches within a switch | |
8535 | table. | |
f84271d9 JL |
8536 | @end table |
8537 | ||
56b2d7a7 JL |
8538 | @node ARC Options |
8539 | @subsection ARC Options | |
8540 | @cindex ARC Options | |
8541 | ||
8542 | These options are defined for ARC implementations: | |
8543 | ||
2642624b | 8544 | @table @gcctabopt |
56b2d7a7 | 8545 | @item -EL |
cd3bb277 | 8546 | @opindex EL |
56b2d7a7 JL |
8547 | Compile code for little endian mode. This is the default. |
8548 | ||
8549 | @item -EB | |
cd3bb277 | 8550 | @opindex EB |
56b2d7a7 JL |
8551 | Compile code for big endian mode. |
8552 | ||
8553 | @item -mmangle-cpu | |
cd3bb277 | 8554 | @opindex mmangle-cpu |
56b2d7a7 JL |
8555 | Prepend the name of the cpu to all public symbol names. |
8556 | In multiple-processor systems, there are many ARC variants with different | |
8557 | instruction and register set characteristics. This flag prevents code | |
8558 | compiled for one cpu to be linked with code compiled for another. | |
695ac33f | 8559 | No facility exists for handling variants that are ``almost identical''. |
56b2d7a7 JL |
8560 | This is an all or nothing option. |
8561 | ||
8562 | @item -mcpu=@var{cpu} | |
cd3bb277 | 8563 | @opindex mcpu |
56b2d7a7 JL |
8564 | Compile code for ARC variant @var{cpu}. |
8565 | Which variants are supported depend on the configuration. | |
630d3d5a | 8566 | All variants support @option{-mcpu=base}, this is the default. |
56b2d7a7 | 8567 | |
630d3d5a JM |
8568 | @item -mtext=@var{text-section} |
8569 | @itemx -mdata=@var{data-section} | |
8570 | @itemx -mrodata=@var{readonly-data-section} | |
cd3bb277 JM |
8571 | @opindex mtext |
8572 | @opindex mdata | |
8573 | @opindex mrodata | |
630d3d5a JM |
8574 | Put functions, data, and readonly data in @var{text-section}, |
8575 | @var{data-section}, and @var{readonly-data-section} respectively | |
56b2d7a7 | 8576 | by default. This can be overridden with the @code{section} attribute. |
0b433de6 | 8577 | @xref{Variable Attributes}. |
56b2d7a7 JL |
8578 | |
8579 | @end table | |
8580 | ||
83575957 ID |
8581 | @node NS32K Options |
8582 | @subsection NS32K Options | |
8583 | @cindex NS32K options | |
8584 | ||
8585 | These are the @samp{-m} options defined for the 32000 series. The default | |
8586 | values for these options depends on which style of 32000 was selected when | |
8587 | the compiler was configured; the defaults for the most common choices are | |
8588 | given below. | |
8589 | ||
2642624b | 8590 | @table @gcctabopt |
83575957 ID |
8591 | @item -m32032 |
8592 | @itemx -m32032 | |
cd3bb277 JM |
8593 | @opindex m32032 |
8594 | @opindex m32032 | |
83575957 ID |
8595 | Generate output for a 32032. This is the default |
8596 | when the compiler is configured for 32032 and 32016 based systems. | |
8597 | ||
8598 | @item -m32332 | |
8599 | @itemx -m32332 | |
cd3bb277 JM |
8600 | @opindex m32332 |
8601 | @opindex m32332 | |
83575957 ID |
8602 | Generate output for a 32332. This is the default |
8603 | when the compiler is configured for 32332-based systems. | |
8604 | ||
8605 | @item -m32532 | |
8606 | @itemx -m32532 | |
cd3bb277 JM |
8607 | @opindex m32532 |
8608 | @opindex m32532 | |
83575957 ID |
8609 | Generate output for a 32532. This is the default |
8610 | when the compiler is configured for 32532-based systems. | |
8611 | ||
8612 | @item -m32081 | |
cd3bb277 | 8613 | @opindex m32081 |
83575957 ID |
8614 | Generate output containing 32081 instructions for floating point. |
8615 | This is the default for all systems. | |
8616 | ||
8617 | @item -m32381 | |
cd3bb277 | 8618 | @opindex m32381 |
83575957 | 8619 | Generate output containing 32381 instructions for floating point. This |
767094dd JM |
8620 | also implies @option{-m32081}. The 32381 is only compatible with the 32332 |
8621 | and 32532 cpus. This is the default for the pc532-netbsd configuration. | |
83575957 ID |
8622 | |
8623 | @item -mmulti-add | |
cd3bb277 | 8624 | @opindex mmulti-add |
83575957 | 8625 | Try and generate multiply-add floating point instructions @code{polyF} |
767094dd JM |
8626 | and @code{dotF}. This option is only available if the @option{-m32381} |
8627 | option is in effect. Using these instructions requires changes to to | |
83575957 ID |
8628 | register allocation which generally has a negative impact on |
8629 | performance. This option should only be enabled when compiling code | |
8630 | particularly likely to make heavy use of multiply-add instructions. | |
8631 | ||
8632 | @item -mnomulti-add | |
cd3bb277 | 8633 | @opindex mnomulti-add |
83575957 | 8634 | Do not try and generate multiply-add floating point instructions |
767094dd | 8635 | @code{polyF} and @code{dotF}. This is the default on all platforms. |
83575957 ID |
8636 | |
8637 | @item -msoft-float | |
cd3bb277 | 8638 | @opindex msoft-float |
83575957 ID |
8639 | Generate output containing library calls for floating point. |
8640 | @strong{Warning:} the requisite libraries may not be available. | |
8641 | ||
8642 | @item -mnobitfield | |
cd3bb277 | 8643 | @opindex mnobitfield |
767094dd JM |
8644 | Do not use the bit-field instructions. On some machines it is faster to |
8645 | use shifting and masking operations. This is the default for the pc532. | |
83575957 ID |
8646 | |
8647 | @item -mbitfield | |
cd3bb277 | 8648 | @opindex mbitfield |
767094dd | 8649 | Do use the bit-field instructions. This is the default for all platforms |
83575957 ID |
8650 | except the pc532. |
8651 | ||
8652 | @item -mrtd | |
cd3bb277 | 8653 | @opindex mrtd |
83575957 ID |
8654 | Use a different function-calling convention, in which functions |
8655 | that take a fixed number of arguments return pop their | |
8656 | arguments on return with the @code{ret} instruction. | |
8657 | ||
8658 | This calling convention is incompatible with the one normally | |
8659 | used on Unix, so you cannot use it if you need to call libraries | |
8660 | compiled with the Unix compiler. | |
8661 | ||
8662 | Also, you must provide function prototypes for all functions that | |
8663 | take variable numbers of arguments (including @code{printf}); | |
8664 | otherwise incorrect code will be generated for calls to those | |
8665 | functions. | |
8666 | ||
8667 | In addition, seriously incorrect code will result if you call a | |
8668 | function with too many arguments. (Normally, extra arguments are | |
8669 | harmlessly ignored.) | |
8670 | ||
8671 | This option takes its name from the 680x0 @code{rtd} instruction. | |
8672 | ||
8673 | ||
8674 | @item -mregparam | |
cd3bb277 | 8675 | @opindex mregparam |
83575957 ID |
8676 | Use a different function-calling convention where the first two arguments |
8677 | are passed in registers. | |
8678 | ||
8679 | This calling convention is incompatible with the one normally | |
8680 | used on Unix, so you cannot use it if you need to call libraries | |
8681 | compiled with the Unix compiler. | |
8682 | ||
8683 | @item -mnoregparam | |
cd3bb277 | 8684 | @opindex mnoregparam |
767094dd | 8685 | Do not pass any arguments in registers. This is the default for all |
83575957 ID |
8686 | targets. |
8687 | ||
8688 | @item -msb | |
cd3bb277 | 8689 | @opindex msb |
83575957 | 8690 | It is OK to use the sb as an index register which is always loaded with |
767094dd | 8691 | zero. This is the default for the pc532-netbsd target. |
83575957 ID |
8692 | |
8693 | @item -mnosb | |
cd3bb277 | 8694 | @opindex mnosb |
83575957 | 8695 | The sb register is not available for use or has not been initialized to |
767094dd JM |
8696 | zero by the run time system. This is the default for all targets except |
8697 | the pc532-netbsd. It is also implied whenever @option{-mhimem} or | |
630d3d5a | 8698 | @option{-fpic} is set. |
83575957 ID |
8699 | |
8700 | @item -mhimem | |
cd3bb277 | 8701 | @opindex mhimem |
161d7b59 | 8702 | Many ns32000 series addressing modes use displacements of up to 512MB@. |
83575957 | 8703 | If an address is above 512MB then displacements from zero can not be used. |
161d7b59 | 8704 | This option causes code to be generated which can be loaded above 512MB@. |
83575957 ID |
8705 | This may be useful for operating systems or ROM code. |
8706 | ||
8707 | @item -mnohimem | |
cd3bb277 | 8708 | @opindex mnohimem |
83575957 ID |
8709 | Assume code will be loaded in the first 512MB of virtual address space. |
8710 | This is the default for all platforms. | |
8711 | ||
8712 | ||
8713 | @end table | |
8714 | ||
052a4b28 DC |
8715 | @node AVR Options |
8716 | @subsection AVR Options | |
8717 | @cindex AVR Options | |
8718 | ||
8719 | These options are defined for AVR implementations: | |
8720 | ||
2642624b | 8721 | @table @gcctabopt |
052a4b28 | 8722 | @item -mmcu=@var{mcu} |
cd3bb277 | 8723 | @opindex mmcu |
3a69a7d5 MM |
8724 | Specify ATMEL AVR instruction set or MCU type. |
8725 | ||
8726 | Instruction set avr1 is for the minimal AVR core, not supported by the C | |
8727 | compiler, only for assembler programs (MCU types: at90s1200, attiny10, | |
8728 | attiny11, attiny12, attiny15, attiny28). | |
8729 | ||
8730 | Instruction set avr2 (default) is for the classic AVR core with up to | |
8731 | 8K program memory space (MCU types: at90s2313, at90s2323, attiny22, | |
8732 | at90s2333, at90s2343, at90s4414, at90s4433, at90s4434, at90s8515, | |
8733 | at90c8534, at90s8535). | |
8734 | ||
8735 | Instruction set avr3 is for the classic AVR core with up to 128K program | |
8736 | memory space (MCU types: atmega103, atmega603). | |
8737 | ||
8738 | Instruction set avr4 is for the enhanced AVR core with up to 8K program | |
8739 | memory space (MCU types: atmega83, atmega85). | |
8740 | ||
8741 | Instruction set avr5 is for the enhanced AVR core with up to 128K program | |
8742 | memory space (MCU types: atmega161, atmega163, atmega32, at94k). | |
052a4b28 DC |
8743 | |
8744 | @item -msize | |
cd3bb277 | 8745 | @opindex msize |
3a69a7d5 | 8746 | Output instruction sizes to the asm file. |
052a4b28 DC |
8747 | |
8748 | @item -minit-stack=@var{N} | |
cd3bb277 | 8749 | @opindex minit-stack |
3a69a7d5 | 8750 | Specify the initial stack address, which may be a symbol or numeric value, |
aee96fe9 | 8751 | @samp{__stack} is the default. |
052a4b28 DC |
8752 | |
8753 | @item -mno-interrupts | |
cd3bb277 | 8754 | @opindex mno-interrupts |
052a4b28 DC |
8755 | Generated code is not compatible with hardware interrupts. |
8756 | Code size will be smaller. | |
8757 | ||
8758 | @item -mcall-prologues | |
cd3bb277 | 8759 | @opindex mcall-prologues |
052a4b28 | 8760 | Functions prologues/epilogues expanded as call to appropriate |
767094dd | 8761 | subroutines. Code size will be smaller. |
3a69a7d5 MM |
8762 | |
8763 | @item -mno-tablejump | |
cd3bb277 | 8764 | @opindex mno-tablejump |
3a69a7d5 MM |
8765 | Do not generate tablejump insns which sometimes increase code size. |
8766 | ||
8767 | @item -mtiny-stack | |
cd3bb277 | 8768 | @opindex mtiny-stack |
3a69a7d5 | 8769 | Change only the low 8 bits of the stack pointer. |
052a4b28 DC |
8770 | @end table |
8771 | ||
789a3090 NC |
8772 | @node MCore Options |
8773 | @subsection MCore Options | |
8774 | @cindex MCore options | |
8775 | ||
8776 | These are the @samp{-m} options defined for the Motorola M*Core | |
02f52e19 | 8777 | processors. |
789a3090 | 8778 | |
2642624b | 8779 | @table @gcctabopt |
789a3090 NC |
8780 | |
8781 | @item -mhardlit | |
8782 | @itemx -mhardlit | |
8783 | @itemx -mno-hardlit | |
cd3bb277 JM |
8784 | @opindex mhardlit |
8785 | @opindex mhardlit | |
8786 | @opindex mno-hardlit | |
789a3090 NC |
8787 | Inline constants into the code stream if it can be done in two |
8788 | instructions or less. | |
8789 | ||
8790 | @item -mdiv | |
8791 | @itemx -mdiv | |
8792 | @itemx -mno-div | |
cd3bb277 JM |
8793 | @opindex mdiv |
8794 | @opindex mdiv | |
8795 | @opindex mno-div | |
789a3090 NC |
8796 | Use the divide instruction. (Enabled by default). |
8797 | ||
8798 | @item -mrelax-immediate | |
8799 | @itemx -mrelax-immediate | |
8800 | @itemx -mno-relax-immediate | |
cd3bb277 JM |
8801 | @opindex mrelax-immediate |
8802 | @opindex mrelax-immediate | |
8803 | @opindex mno-relax-immediate | |
b192711e | 8804 | Allow arbitrary sized immediates in bit operations. |
789a3090 NC |
8805 | |
8806 | @item -mwide-bitfields | |
8807 | @itemx -mwide-bitfields | |
8808 | @itemx -mno-wide-bitfields | |
cd3bb277 JM |
8809 | @opindex mwide-bitfields |
8810 | @opindex mwide-bitfields | |
8811 | @opindex mno-wide-bitfields | |
c771326b | 8812 | Always treat bit-fields as int-sized. |
789a3090 NC |
8813 | |
8814 | @item -m4byte-functions | |
8815 | @itemx -m4byte-functions | |
8816 | @itemx -mno-4byte-functions | |
cd3bb277 JM |
8817 | @opindex m4byte-functions |
8818 | @opindex m4byte-functions | |
8819 | @opindex mno-4byte-functions | |
b192711e | 8820 | Force all functions to be aligned to a four byte boundary. |
789a3090 NC |
8821 | |
8822 | @item -mcallgraph-data | |
8823 | @itemx -mcallgraph-data | |
8824 | @itemx -mno-callgraph-data | |
cd3bb277 JM |
8825 | @opindex mcallgraph-data |
8826 | @opindex mcallgraph-data | |
8827 | @opindex mno-callgraph-data | |
789a3090 NC |
8828 | Emit callgraph information. |
8829 | ||
8830 | @item -mslow-bytes | |
8831 | @itemx -mslow-bytes | |
8832 | @itemx -mno-slow-bytes | |
cd3bb277 JM |
8833 | @opindex mslow-bytes |
8834 | @opindex mslow-bytes | |
8835 | @opindex mno-slow-bytes | |
789a3090 NC |
8836 | Prefer word access when reading byte quantities. |
8837 | ||
8838 | @item -mlittle-endian | |
8839 | @itemx -mlittle-endian | |
8840 | @itemx -mbig-endian | |
cd3bb277 JM |
8841 | @opindex mlittle-endian |
8842 | @opindex mlittle-endian | |
8843 | @opindex mbig-endian | |
b192711e | 8844 | Generate code for a little endian target. |
789a3090 NC |
8845 | |
8846 | @item -m210 | |
8847 | @itemx -m210 | |
8848 | @itemx -m340 | |
cd3bb277 JM |
8849 | @opindex m210 |
8850 | @opindex m210 | |
8851 | @opindex m340 | |
789a3090 | 8852 | Generate code for the 210 processor. |
789a3090 | 8853 | @end table |
83575957 | 8854 | |
df6194d4 JW |
8855 | @node IA-64 Options |
8856 | @subsection IA-64 Options | |
8857 | @cindex IA-64 Options | |
8858 | ||
8859 | These are the @samp{-m} options defined for the Intel IA-64 architecture. | |
8860 | ||
8861 | @table @gcctabopt | |
8862 | @item -mbig-endian | |
cd3bb277 | 8863 | @opindex mbig-endian |
161d7b59 | 8864 | Generate code for a big endian target. This is the default for HPUX@. |
df6194d4 JW |
8865 | |
8866 | @item -mlittle-endian | |
cd3bb277 | 8867 | @opindex mlittle-endian |
df6194d4 JW |
8868 | Generate code for a little endian target. This is the default for AIX5 |
8869 | and Linux. | |
8870 | ||
8871 | @item -mgnu-as | |
8872 | @itemx -mno-gnu-as | |
cd3bb277 JM |
8873 | @opindex mgnu-as |
8874 | @opindex mno-gnu-as | |
15d3a111 | 8875 | Generate (or don't) code for the GNU assembler. This is the default. |
630d3d5a | 8876 | @c Also, this is the default if the configure option @option{--with-gnu-as} |
15d3a111 | 8877 | @c is used. |
df6194d4 JW |
8878 | |
8879 | @item -mgnu-ld | |
8880 | @itemx -mno-gnu-ld | |
cd3bb277 JM |
8881 | @opindex mgnu-ld |
8882 | @opindex mno-gnu-ld | |
15d3a111 | 8883 | Generate (or don't) code for the GNU linker. This is the default. |
630d3d5a | 8884 | @c Also, this is the default if the configure option @option{--with-gnu-ld} |
15d3a111 | 8885 | @c is used. |
df6194d4 JW |
8886 | |
8887 | @item -mno-pic | |
cd3bb277 | 8888 | @opindex mno-pic |
15d3a111 | 8889 | Generate code that does not use a global pointer register. The result |
161d7b59 | 8890 | is not position independent code, and violates the IA-64 ABI@. |
df6194d4 JW |
8891 | |
8892 | @item -mvolatile-asm-stop | |
8893 | @itemx -mno-volatile-asm-stop | |
cd3bb277 JM |
8894 | @opindex mvolatile-asm-stop |
8895 | @opindex mno-volatile-asm-stop | |
15d3a111 JW |
8896 | Generate (or don't) a stop bit immediately before and after volatile asm |
8897 | statements. | |
df6194d4 JW |
8898 | |
8899 | @item -mb-step | |
cd3bb277 | 8900 | @opindex mb-step |
df6194d4 JW |
8901 | Generate code that works around Itanium B step errata. |
8902 | ||
8903 | @item -mregister-names | |
8904 | @itemx -mno-register-names | |
cd3bb277 JM |
8905 | @opindex mregister-names |
8906 | @opindex mno-register-names | |
15d3a111 JW |
8907 | Generate (or don't) @samp{in}, @samp{loc}, and @samp{out} register names for |
8908 | the stacked registers. This may make assembler output more readable. | |
df6194d4 JW |
8909 | |
8910 | @item -mno-sdata | |
8911 | @itemx -msdata | |
cd3bb277 JM |
8912 | @opindex mno-sdata |
8913 | @opindex msdata | |
15d3a111 JW |
8914 | Disable (or enable) optimizations that use the small data section. This may |
8915 | be useful for working around optimizer bugs. | |
df6194d4 JW |
8916 | |
8917 | @item -mconstant-gp | |
cd3bb277 | 8918 | @opindex mconstant-gp |
df6194d4 JW |
8919 | Generate code that uses a single constant global pointer value. This is |
8920 | useful when compiling kernel code. | |
8921 | ||
8922 | @item -mauto-pic | |
cd3bb277 | 8923 | @opindex mauto-pic |
630d3d5a | 8924 | Generate code that is self-relocatable. This implies @option{-mconstant-gp}. |
df6194d4 JW |
8925 | This is useful when compiling firmware code. |
8926 | ||
8927 | @item -minline-divide-min-latency | |
cd3bb277 | 8928 | @opindex minline-divide-min-latency |
df6194d4 JW |
8929 | Generate code for inline divides using the minimum latency algorithm. |
8930 | ||
8931 | @item -minline-divide-max-throughput | |
cd3bb277 | 8932 | @opindex minline-divide-max-throughput |
df6194d4 JW |
8933 | Generate code for inline divides using the maximum throughput algorithm. |
8934 | ||
8935 | @item -mno-dwarf2-asm | |
8936 | @itemx -mdwarf2-asm | |
cd3bb277 JM |
8937 | @opindex mno-dwarf2-asm |
8938 | @opindex mdwarf2-asm | |
15d3a111 JW |
8939 | Don't (or do) generate assembler code for the DWARF2 line number debugging |
8940 | info. This may be useful when not using the GNU assembler. | |
df6194d4 | 8941 | |
630d3d5a | 8942 | @item -mfixed-range=@var{register-range} |
cd3bb277 | 8943 | @opindex mfixed-range |
df6194d4 JW |
8944 | Generate code treating the given register range as fixed registers. |
8945 | A fixed register is one that the register allocator can not use. This is | |
8946 | useful when compiling kernel code. A register range is specified as | |
8947 | two registers separated by a dash. Multiple register ranges can be | |
8948 | specified separated by a comma. | |
8949 | @end table | |
8950 | ||
e8ad90e5 MM |
8951 | @node D30V Options |
8952 | @subsection D30V Options | |
8953 | @cindex D30V Options | |
8954 | ||
8955 | These @samp{-m} options are defined for D30V implementations: | |
8956 | ||
2642624b | 8957 | @table @gcctabopt |
e8ad90e5 | 8958 | @item -mextmem |
cd3bb277 | 8959 | @opindex mextmem |
e8ad90e5 MM |
8960 | Link the @samp{.text}, @samp{.data}, @samp{.bss}, @samp{.strings}, |
8961 | @samp{.rodata}, @samp{.rodata1}, @samp{.data1} sections into external | |
8962 | memory, which starts at location @code{0x80000000}. | |
8963 | ||
8964 | @item -mextmemory | |
cd3bb277 | 8965 | @opindex mextmemory |
630d3d5a | 8966 | Same as the @option{-mextmem} switch. |
e8ad90e5 MM |
8967 | |
8968 | @item -monchip | |
cd3bb277 | 8969 | @opindex monchip |
e8ad90e5 MM |
8970 | Link the @samp{.text} section into onchip text memory, which starts at |
8971 | location @code{0x0}. Also link @samp{.data}, @samp{.bss}, | |
8972 | @samp{.strings}, @samp{.rodata}, @samp{.rodata1}, @samp{.data1} sections | |
8973 | into onchip data memory, which starts at location @code{0x20000000}. | |
8974 | ||
8975 | @item -mno-asm-optimize | |
8976 | @itemx -masm-optimize | |
cd3bb277 JM |
8977 | @opindex mno-asm-optimize |
8978 | @opindex masm-optimize | |
630d3d5a JM |
8979 | Disable (enable) passing @option{-O} to the assembler when optimizing. |
8980 | The assembler uses the @option{-O} option to automatically parallelize | |
e8ad90e5 MM |
8981 | adjacent short instructions where possible. |
8982 | ||
8983 | @item -mbranch-cost=@var{n} | |
cd3bb277 | 8984 | @opindex mbranch-cost |
e8ad90e5 MM |
8985 | Increase the internal costs of branches to @var{n}. Higher costs means |
8986 | that the compiler will issue more instructions to avoid doing a branch. | |
8987 | The default is 2. | |
8988 | ||
8989 | @item -mcond-exec=@var{n} | |
cd3bb277 | 8990 | @opindex mcond-exec |
e8ad90e5 MM |
8991 | Specify the maximum number of conditionally executed instructions that |
8992 | replace a branch. The default is 4. | |
8993 | @end table | |
56b2d7a7 | 8994 | |
91abf72d HP |
8995 | @node S/390 and zSeries Options |
8996 | @subsection S/390 and zSeries Options | |
8997 | @cindex S/390 and zSeries Options | |
8998 | ||
8999 | These are the @samp{-m} options defined for the S/390 and zSeries architecture. | |
9000 | ||
9001 | @table @gcctabopt | |
9002 | @item -mhard-float | |
9003 | @itemx -msoft-float | |
9004 | @opindex mhard-float | |
9005 | @opindex msoft-float | |
9006 | Use (do not use) the hardware floating-point instructions and registers | |
9007 | for floating-point operations. When @option{-msoft-float} is specified, | |
9008 | functions in @file{libgcc.a} will be used to perform floating-point | |
9009 | operations. When @option{-mhard-float} is specified, the compiler | |
9010 | generates IEEE floating-point instructions. This is the default. | |
9011 | ||
9012 | @item -mbackchain | |
9013 | @itemx -mno-backchain | |
9014 | @opindex mbackchain | |
9015 | @opindex mno-backchain | |
9016 | Generate (or do not generate) code which maintains an explicit | |
9017 | backchain within the stack frame that points to the caller's frame. | |
9018 | This is currently needed to allow debugging. The default is to | |
9019 | generate the backchain. | |
9020 | ||
9021 | @item -msmall-exec | |
9022 | @itemx -mno-small-exec | |
9023 | @opindex msmall-exec | |
9024 | @opindex mno-small-exec | |
9025 | Generate (or do not generate) code using the @code{bras} instruction | |
9026 | to do subroutine calls. | |
9027 | This only works reliably if the total executable size does not | |
9028 | exceed 64k. The default is to use the @code{basr} instruction instead, | |
9029 | which does not have this limitation. | |
9030 | ||
9031 | @item -m64 | |
9032 | @itemx -m31 | |
9033 | @opindex m64 | |
9034 | @opindex m31 | |
9035 | When @option{-m31} is specified, generate code compliant to the | |
9036 | Linux for S/390 ABI@. When @option{-m64} is specified, generate | |
9037 | code compliant to the Linux for zSeries ABI@. This allows GCC in | |
9038 | particular to generate 64-bit instructions. For the @samp{s390} | |
9039 | targets, the default is @option{-m31}, while the @samp{s390x} | |
9040 | targets default to @option{-m64}. | |
9041 | ||
9042 | @item -mmvcle | |
9043 | @itemx -mno-mvcle | |
9044 | @opindex mmvcle | |
9045 | @opindex mno-mvcle | |
9046 | Generate (or do not generate) code using the @code{mvcle} instruction | |
9047 | to perform block moves. When @option{-mno-mvcle} is specifed, | |
9048 | use a @code{mvc} loop instead. This is the default. | |
9049 | ||
9050 | @item -mdebug | |
9051 | @itemx -mno-debug | |
9052 | @opindex mdebug | |
9053 | @opindex mno-debug | |
9054 | Print (or do not print) additional debug information when compiling. | |
9055 | The default is to not print debug information. | |
9056 | ||
9057 | @end table | |
9058 | ||
9059 | ||
74291a4b MM |
9060 | @node Code Gen Options |
9061 | @section Options for Code Generation Conventions | |
9062 | @cindex code generation conventions | |
9063 | @cindex options, code generation | |
9064 | @cindex run-time options | |
9065 | ||
9066 | These machine-independent options control the interface conventions | |
9067 | used in code generation. | |
9068 | ||
9069 | Most of them have both positive and negative forms; the negative form | |
630d3d5a | 9070 | of @option{-ffoo} would be @option{-fno-foo}. In the table below, only |
74291a4b MM |
9071 | one of the forms is listed---the one which is not the default. You |
9072 | can figure out the other form by either removing @samp{no-} or adding | |
9073 | it. | |
9074 | ||
2642624b | 9075 | @table @gcctabopt |
956d6950 | 9076 | @item -fexceptions |
cd3bb277 | 9077 | @opindex fexceptions |
767094dd | 9078 | Enable exception handling. Generates extra code needed to propagate |
f0523f02 | 9079 | exceptions. For some targets, this implies GCC will generate frame |
c5c76735 JL |
9080 | unwind information for all functions, which can produce significant data |
9081 | size overhead, although it does not affect execution. If you do not | |
f0523f02 | 9082 | specify this option, GCC will enable it by default for languages like |
90ecce3e | 9083 | C++ which normally require exception handling, and disable it for |
c5c76735 JL |
9084 | languages like C that do not normally require it. However, you may need |
9085 | to enable this option when compiling C code that needs to interoperate | |
9086 | properly with exception handlers written in C++. You may also wish to | |
9087 | disable this option if you are compiling older C++ programs that don't | |
9088 | use exception handling. | |
956d6950 | 9089 | |
6cfc0341 RH |
9090 | @item -fnon-call-exceptions |
9091 | @opindex fnon-call-exceptions | |
9092 | Generate code that allows trapping instructions to throw exceptions. | |
9093 | Note that this requires platform-specific runtime support that does | |
9094 | not exist everywhere. Moreover, it only allows @emph{trapping} | |
e979f9e8 | 9095 | instructions to throw exceptions, i.e.@: memory references or floating |
6cfc0341 RH |
9096 | point instructions. It does not allow exceptions to be thrown from |
9097 | arbitrary signal handlers such as @code{SIGALRM}. | |
9098 | ||
14a774a9 | 9099 | @item -funwind-tables |
cd3bb277 | 9100 | @opindex funwind-tables |
bedc7537 | 9101 | Similar to @option{-fexceptions}, except that it will just generate any needed |
14a774a9 RK |
9102 | static data, but will not affect the generated code in any other way. |
9103 | You will normally not enable this option; instead, a language processor | |
9104 | that needs this handling would enable it on your behalf. | |
9105 | ||
74291a4b | 9106 | @item -fpcc-struct-return |
cd3bb277 | 9107 | @opindex fpcc-struct-return |
74291a4b MM |
9108 | Return ``short'' @code{struct} and @code{union} values in memory like |
9109 | longer ones, rather than in registers. This convention is less | |
9110 | efficient, but it has the advantage of allowing intercallability between | |
0c2d1a2a | 9111 | GCC-compiled files and files compiled with other compilers. |
74291a4b MM |
9112 | |
9113 | The precise convention for returning structures in memory depends | |
9114 | on the target configuration macros. | |
9115 | ||
9116 | Short structures and unions are those whose size and alignment match | |
9117 | that of some integer type. | |
9118 | ||
9119 | @item -freg-struct-return | |
cd3bb277 | 9120 | @opindex freg-struct-return |
9c34dbbf ZW |
9121 | Return @code{struct} and @code{union} values in registers when possible. |
9122 | This is more efficient for small structures than | |
9123 | @option{-fpcc-struct-return}. | |
74291a4b | 9124 | |
9c34dbbf | 9125 | If you specify neither @option{-fpcc-struct-return} nor |
630d3d5a | 9126 | @option{-freg-struct-return}, GCC defaults to whichever convention is |
0c2d1a2a | 9127 | standard for the target. If there is no standard convention, GCC |
9c34dbbf ZW |
9128 | defaults to @option{-fpcc-struct-return}, except on targets where GCC is |
9129 | the principal compiler. In those cases, we can choose the standard, and | |
9130 | we chose the more efficient register return alternative. | |
74291a4b MM |
9131 | |
9132 | @item -fshort-enums | |
cd3bb277 | 9133 | @opindex fshort-enums |
74291a4b MM |
9134 | Allocate to an @code{enum} type only as many bytes as it needs for the |
9135 | declared range of possible values. Specifically, the @code{enum} type | |
9136 | will be equivalent to the smallest integer type which has enough room. | |
9137 | ||
9138 | @item -fshort-double | |
cd3bb277 | 9139 | @opindex fshort-double |
74291a4b MM |
9140 | Use the same size for @code{double} as for @code{float}. |
9141 | ||
9142 | @item -fshared-data | |
cd3bb277 | 9143 | @opindex fshared-data |
74291a4b MM |
9144 | Requests that the data and non-@code{const} variables of this |
9145 | compilation be shared data rather than private data. The distinction | |
9146 | makes sense only on certain operating systems, where shared data is | |
9147 | shared between processes running the same program, while private data | |
9148 | exists in one copy per process. | |
9149 | ||
9150 | @item -fno-common | |
cd3bb277 | 9151 | @opindex fno-common |
90ecce3e | 9152 | In C, allocate even uninitialized global variables in the data section of the |
74291a4b MM |
9153 | object file, rather than generating them as common blocks. This has the |
9154 | effect that if the same variable is declared (without @code{extern}) in | |
9155 | two different compilations, you will get an error when you link them. | |
9156 | The only reason this might be useful is if you wish to verify that the | |
9157 | program will work on other systems which always work this way. | |
9158 | ||
9159 | @item -fno-ident | |
cd3bb277 | 9160 | @opindex fno-ident |
74291a4b MM |
9161 | Ignore the @samp{#ident} directive. |
9162 | ||
9163 | @item -fno-gnu-linker | |
cd3bb277 | 9164 | @opindex fno-gnu-linker |
74291a4b MM |
9165 | Do not output global initializations (such as C++ constructors and |
9166 | destructors) in the form used by the GNU linker (on systems where the GNU | |
9167 | linker is the standard method of handling them). Use this option when | |
9168 | you want to use a non-GNU linker, which also requires using the | |
bedc7537 NC |
9169 | @command{collect2} program to make sure the system linker includes |
9170 | constructors and destructors. (@command{collect2} is included in the GCC | |
9171 | distribution.) For systems which @emph{must} use @command{collect2}, the | |
9172 | compiler driver @command{gcc} is configured to do this automatically. | |
74291a4b MM |
9173 | |
9174 | @item -finhibit-size-directive | |
cd3bb277 | 9175 | @opindex finhibit-size-directive |
74291a4b MM |
9176 | Don't output a @code{.size} assembler directive, or anything else that |
9177 | would cause trouble if the function is split in the middle, and the | |
9178 | two halves are placed at locations far apart in memory. This option is | |
9179 | used when compiling @file{crtstuff.c}; you should not need to use it | |
9180 | for anything else. | |
9181 | ||
9182 | @item -fverbose-asm | |
cd3bb277 | 9183 | @opindex fverbose-asm |
74291a4b MM |
9184 | Put extra commentary information in the generated assembly code to |
9185 | make it more readable. This option is generally only of use to those | |
9186 | who actually need to read the generated assembly code (perhaps while | |
9187 | debugging the compiler itself). | |
9188 | ||
630d3d5a | 9189 | @option{-fno-verbose-asm}, the default, causes the |
74291a4b MM |
9190 | extra information to be omitted and is useful when comparing two assembler |
9191 | files. | |
9192 | ||
9193 | @item -fvolatile | |
cd3bb277 | 9194 | @opindex fvolatile |
74291a4b MM |
9195 | Consider all memory references through pointers to be volatile. |
9196 | ||
9197 | @item -fvolatile-global | |
cd3bb277 | 9198 | @opindex fvolatile-global |
74291a4b | 9199 | Consider all memory references to extern and global data items to |
0c2d1a2a | 9200 | be volatile. GCC does not consider static data items to be volatile |
ab87f8c8 JL |
9201 | because of this switch. |
9202 | ||
9203 | @item -fvolatile-static | |
cd3bb277 | 9204 | @opindex fvolatile-static |
ab87f8c8 | 9205 | Consider all memory references to static data to be volatile. |
74291a4b MM |
9206 | |
9207 | @item -fpic | |
cd3bb277 | 9208 | @opindex fpic |
74291a4b MM |
9209 | @cindex global offset table |
9210 | @cindex PIC | |
9211 | Generate position-independent code (PIC) suitable for use in a shared | |
9212 | library, if supported for the target machine. Such code accesses all | |
161d7b59 | 9213 | constant addresses through a global offset table (GOT)@. The dynamic |
861bb6c1 | 9214 | loader resolves the GOT entries when the program starts (the dynamic |
0c2d1a2a | 9215 | loader is not part of GCC; it is part of the operating system). If |
861bb6c1 JL |
9216 | the GOT size for the linked executable exceeds a machine-specific |
9217 | maximum size, you get an error message from the linker indicating that | |
630d3d5a | 9218 | @option{-fpic} does not work; in that case, recompile with @option{-fPIC} |
861bb6c1 JL |
9219 | instead. (These maximums are 16k on the m88k, 8k on the Sparc, and 32k |
9220 | on the m68k and RS/6000. The 386 has no such limit.) | |
74291a4b MM |
9221 | |
9222 | Position-independent code requires special support, and therefore works | |
0c2d1a2a | 9223 | only on certain machines. For the 386, GCC supports PIC for System V |
74291a4b MM |
9224 | but not for the Sun 386i. Code generated for the IBM RS/6000 is always |
9225 | position-independent. | |
9226 | ||
74291a4b | 9227 | @item -fPIC |
cd3bb277 | 9228 | @opindex fPIC |
74291a4b MM |
9229 | If supported for the target machine, emit position-independent code, |
9230 | suitable for dynamic linking and avoiding any limit on the size of the | |
9231 | global offset table. This option makes a difference on the m68k, m88k, | |
9232 | and the Sparc. | |
9233 | ||
9234 | Position-independent code requires special support, and therefore works | |
9235 | only on certain machines. | |
9236 | ||
9237 | @item -ffixed-@var{reg} | |
cd3bb277 | 9238 | @opindex ffixed |
74291a4b MM |
9239 | Treat the register named @var{reg} as a fixed register; generated code |
9240 | should never refer to it (except perhaps as a stack pointer, frame | |
9241 | pointer or in some other fixed role). | |
9242 | ||
9243 | @var{reg} must be the name of a register. The register names accepted | |
9244 | are machine-specific and are defined in the @code{REGISTER_NAMES} | |
9245 | macro in the machine description macro file. | |
9246 | ||
9247 | This flag does not have a negative form, because it specifies a | |
9248 | three-way choice. | |
9249 | ||
9250 | @item -fcall-used-@var{reg} | |
cd3bb277 | 9251 | @opindex fcall-used |
956d6950 | 9252 | Treat the register named @var{reg} as an allocable register that is |
74291a4b MM |
9253 | clobbered by function calls. It may be allocated for temporaries or |
9254 | variables that do not live across a call. Functions compiled this way | |
9255 | will not save and restore the register @var{reg}. | |
9256 | ||
cb2fdc84 GRK |
9257 | It is an error to used this flag with the frame pointer or stack pointer. |
9258 | Use of this flag for other registers that have fixed pervasive roles in | |
9259 | the machine's execution model will produce disastrous results. | |
74291a4b MM |
9260 | |
9261 | This flag does not have a negative form, because it specifies a | |
9262 | three-way choice. | |
9263 | ||
9264 | @item -fcall-saved-@var{reg} | |
cd3bb277 | 9265 | @opindex fcall-saved |
956d6950 | 9266 | Treat the register named @var{reg} as an allocable register saved by |
74291a4b MM |
9267 | functions. It may be allocated even for temporaries or variables that |
9268 | live across a call. Functions compiled this way will save and restore | |
9269 | the register @var{reg} if they use it. | |
9270 | ||
cb2fdc84 GRK |
9271 | It is an error to used this flag with the frame pointer or stack pointer. |
9272 | Use of this flag for other registers that have fixed pervasive roles in | |
9273 | the machine's execution model will produce disastrous results. | |
74291a4b MM |
9274 | |
9275 | A different sort of disaster will result from the use of this flag for | |
9276 | a register in which function values may be returned. | |
9277 | ||
9278 | This flag does not have a negative form, because it specifies a | |
9279 | three-way choice. | |
9280 | ||
9281 | @item -fpack-struct | |
cd3bb277 | 9282 | @opindex fpack-struct |
74291a4b MM |
9283 | Pack all structure members together without holes. Usually you would |
9284 | not want to use this option, since it makes the code suboptimal, and | |
9285 | the offsets of structure members won't agree with system libraries. | |
9286 | ||
861bb6c1 | 9287 | @item -fcheck-memory-usage |
cd3bb277 | 9288 | @opindex fcheck-memory-usage |
0c2d1a2a | 9289 | Generate extra code to check each memory access. GCC will generate |
861bb6c1 | 9290 | code that is suitable for a detector of bad memory accesses such as |
7d384cc0 | 9291 | @file{Checker}. |
861bb6c1 | 9292 | |
d3111037 CB |
9293 | Normally, you should compile all, or none, of your code with this option. |
9294 | ||
9295 | If you do mix code compiled with and without this option, | |
9296 | you must ensure that all code that has side effects | |
9297 | and that is called by code compiled with this option | |
9298 | is, itself, compiled with this option. | |
9299 | If you do not, you might get erroneous messages from the detector. | |
9300 | ||
861bb6c1 | 9301 | If you use functions from a library that have side-effects (such as |
d3111037 | 9302 | @code{read}), you might not be able to recompile the library and |
861bb6c1 | 9303 | specify this option. In that case, you can enable the |
630d3d5a | 9304 | @option{-fprefix-function-name} option, which requests GCC to encapsulate |
861bb6c1 | 9305 | your code and make other functions look as if they were compiled with |
630d3d5a | 9306 | @option{-fcheck-memory-usage}. This is done by calling ``stubs'', |
861bb6c1 | 9307 | which are provided by the detector. If you cannot find or build |
d3111037 | 9308 | stubs for every function you call, you might have to specify |
630d3d5a | 9309 | @option{-fcheck-memory-usage} without @option{-fprefix-function-name}. |
861bb6c1 | 9310 | |
7d384cc0 | 9311 | If you specify this option, you can not use the @code{asm} or |
f0523f02 JM |
9312 | @code{__asm__} keywords in functions with memory checking enabled. GCC |
9313 | cannot understand what the @code{asm} statement may do, and therefore | |
c5c76735 | 9314 | cannot generate the appropriate code, so it will reject it. However, if |
ee457005 | 9315 | you specify the function attribute @code{no_check_memory_usage} |
f0523f02 | 9316 | (@pxref{Function Attributes}), GCC will disable memory checking within a |
c5c76735 JL |
9317 | function; you may use @code{asm} statements inside such functions. You |
9318 | may have an inline expansion of a non-checked function within a checked | |
f0523f02 | 9319 | function; in that case GCC will not generate checks for the inlined |
c5c76735 JL |
9320 | function's memory accesses. |
9321 | ||
9322 | If you move your @code{asm} statements to non-checked inline functions | |
9323 | and they do access memory, you can add calls to the support code in your | |
7d384cc0 KR |
9324 | inline function, to indicate any reads, writes, or copies being done. |
9325 | These calls would be similar to those done in the stubs described above. | |
9326 | ||
861bb6c1 | 9327 | @item -fprefix-function-name |
cd3bb277 | 9328 | @opindex fprefix-function-name |
0c2d1a2a JB |
9329 | Request GCC to add a prefix to the symbols generated for function names. |
9330 | GCC adds a prefix to the names of functions defined as well as | |
861bb6c1 | 9331 | functions called. Code compiled with this option and code compiled |
d3111037 | 9332 | without the option can't be linked together, unless stubs are used. |
861bb6c1 | 9333 | |
630d3d5a | 9334 | If you compile the following code with @option{-fprefix-function-name} |
861bb6c1 JL |
9335 | @example |
9336 | extern void bar (int); | |
9337 | void | |
9338 | foo (int a) | |
9339 | @{ | |
9340 | return bar (a + 5); | |
861bb6c1 JL |
9341 | @} |
9342 | @end example | |
9343 | ||
9344 | @noindent | |
0c2d1a2a | 9345 | GCC will compile the code as if it was written: |
861bb6c1 JL |
9346 | @example |
9347 | extern void prefix_bar (int); | |
9348 | void | |
9349 | prefix_foo (int a) | |
9350 | @{ | |
9351 | return prefix_bar (a + 5); | |
9352 | @} | |
9353 | @end example | |
630d3d5a | 9354 | This option is designed to be used with @option{-fcheck-memory-usage}. |
861bb6c1 | 9355 | |
07417085 | 9356 | @item -finstrument-functions |
cd3bb277 | 9357 | @opindex finstrument-functions |
07417085 KR |
9358 | Generate instrumentation calls for entry and exit to functions. Just |
9359 | after function entry and just before function exit, the following | |
9360 | profiling functions will be called with the address of the current | |
9361 | function and its call site. (On some platforms, | |
9362 | @code{__builtin_return_address} does not work beyond the current | |
9363 | function, so the call site information may not be available to the | |
9364 | profiling functions otherwise.) | |
9365 | ||
9366 | @example | |
310668e8 JM |
9367 | void __cyg_profile_func_enter (void *this_fn, |
9368 | void *call_site); | |
9369 | void __cyg_profile_func_exit (void *this_fn, | |
9370 | void *call_site); | |
07417085 KR |
9371 | @end example |
9372 | ||
9373 | The first argument is the address of the start of the current function, | |
9374 | which may be looked up exactly in the symbol table. | |
9375 | ||
9376 | This instrumentation is also done for functions expanded inline in other | |
9377 | functions. The profiling calls will indicate where, conceptually, the | |
9378 | inline function is entered and exited. This means that addressable | |
9379 | versions of such functions must be available. If all your uses of a | |
9380 | function are expanded inline, this may mean an additional expansion of | |
9381 | code size. If you use @samp{extern inline} in your C code, an | |
9382 | addressable version of such functions must be provided. (This is | |
9383 | normally the case anyways, but if you get lucky and the optimizer always | |
9384 | expands the functions inline, you might have gotten away without | |
9385 | providing static copies.) | |
9386 | ||
9387 | A function may be given the attribute @code{no_instrument_function}, in | |
9388 | which case this instrumentation will not be done. This can be used, for | |
9389 | example, for the profiling functions listed above, high-priority | |
9390 | interrupt routines, and any functions from which the profiling functions | |
9391 | cannot safely be called (perhaps signal handlers, if the profiling | |
9392 | routines generate output or allocate memory). | |
9393 | ||
861bb6c1 | 9394 | @item -fstack-check |
cd3bb277 | 9395 | @opindex fstack-check |
861bb6c1 JL |
9396 | Generate code to verify that you do not go beyond the boundary of the |
9397 | stack. You should specify this flag if you are running in an | |
9398 | environment with multiple threads, but only rarely need to specify it in | |
9399 | a single-threaded environment since stack overflow is automatically | |
9400 | detected on nearly all systems if there is only one stack. | |
9401 | ||
a157febd GK |
9402 | Note that this switch does not actually cause checking to be done; the |
9403 | operating system must do that. The switch causes generation of code | |
9404 | to ensure that the operating system sees the stack being extended. | |
9405 | ||
9406 | @item -fstack-limit-register=@var{reg} | |
9407 | @itemx -fstack-limit-symbol=@var{sym} | |
9408 | @itemx -fno-stack-limit | |
cd3bb277 JM |
9409 | @opindex fstack-limit-register |
9410 | @opindex fstack-limit-symbol | |
9411 | @opindex fno-stack-limit | |
a157febd GK |
9412 | Generate code to ensure that the stack does not grow beyond a certain value, |
9413 | either the value of a register or the address of a symbol. If the stack | |
9414 | would grow beyond the value, a signal is raised. For most targets, | |
9415 | the signal is raised before the stack overruns the boundary, so | |
9416 | it is possible to catch the signal without taking special precautions. | |
9417 | ||
9c34dbbf ZW |
9418 | For instance, if the stack starts at absolute address @samp{0x80000000} |
9419 | and grows downwards, you can use the flags | |
9420 | @option{-fstack-limit-symbol=__stack_limit} and | |
9421 | @option{-Wl,--defsym,__stack_limit=0x7ffe0000} to enforce a stack limit | |
9422 | of 128KB@. Note that this may only work with the GNU linker. | |
a157febd | 9423 | |
e5eb27e5 JL |
9424 | @cindex aliasing of parameters |
9425 | @cindex parameters, aliased | |
9426 | @item -fargument-alias | |
04afd9d6 JL |
9427 | @itemx -fargument-noalias |
9428 | @itemx -fargument-noalias-global | |
cd3bb277 JM |
9429 | @opindex fargument-alias |
9430 | @opindex fargument-noalias | |
9431 | @opindex fargument-noalias-global | |
e5eb27e5 JL |
9432 | Specify the possible relationships among parameters and between |
9433 | parameters and global data. | |
9434 | ||
630d3d5a | 9435 | @option{-fargument-alias} specifies that arguments (parameters) may |
9c34dbbf | 9436 | alias each other and may alias global storage.@* |
630d3d5a | 9437 | @option{-fargument-noalias} specifies that arguments do not alias |
9c34dbbf | 9438 | each other, but may alias global storage.@* |
630d3d5a | 9439 | @option{-fargument-noalias-global} specifies that arguments do not |
e5eb27e5 JL |
9440 | alias each other and do not alias global storage. |
9441 | ||
9442 | Each language will automatically use whatever option is required by | |
9443 | the language standard. You should not need to use these options yourself. | |
19283265 RH |
9444 | |
9445 | @item -fleading-underscore | |
cd3bb277 | 9446 | @opindex fleading-underscore |
695ac33f | 9447 | This option and its counterpart, @option{-fno-leading-underscore}, forcibly |
19283265 RH |
9448 | change the way C symbols are represented in the object file. One use |
9449 | is to help link with legacy assembly code. | |
9450 | ||
9451 | Be warned that you should know what you are doing when invoking this | |
9452 | option, and that not all targets provide complete support for it. | |
74291a4b MM |
9453 | @end table |
9454 | ||
ee457005 JM |
9455 | @c man end |
9456 | ||
74291a4b | 9457 | @node Environment Variables |
0c2d1a2a | 9458 | @section Environment Variables Affecting GCC |
74291a4b MM |
9459 | @cindex environment variables |
9460 | ||
ee457005 JM |
9461 | @c man begin ENVIRONMENT |
9462 | ||
0c2d1a2a JB |
9463 | This section describes several environment variables that affect how GCC |
9464 | operates. Some of them work by specifying directories or prefixes to use | |
767094dd | 9465 | when searching for various kinds of files. Some are used to specify other |
46103ab4 | 9466 | aspects of the compilation environment. |
74291a4b MM |
9467 | |
9468 | @ifclear INTERNALS | |
9469 | Note that you can also specify places to search using options such as | |
630d3d5a | 9470 | @option{-B}, @option{-I} and @option{-L} (@pxref{Directory Options}). These |
74291a4b | 9471 | take precedence over places specified using environment variables, which |
161d7b59 | 9472 | in turn take precedence over those specified by the configuration of GCC@. |
0c2d1a2a | 9473 | |
74291a4b MM |
9474 | @end ifclear |
9475 | @ifset INTERNALS | |
9476 | Note that you can also specify places to search using options such as | |
630d3d5a | 9477 | @option{-B}, @option{-I} and @option{-L} (@pxref{Directory Options}). These |
74291a4b | 9478 | take precedence over places specified using environment variables, which |
161d7b59 | 9479 | in turn take precedence over those specified by the configuration of GCC@. |
0c2d1a2a | 9480 | @xref{Driver}. |
74291a4b MM |
9481 | @end ifset |
9482 | ||
bedc7537 | 9483 | @table @env |
ab87f8c8 JL |
9484 | @item LANG |
9485 | @itemx LC_CTYPE | |
9486 | @c @itemx LC_COLLATE | |
9487 | @itemx LC_MESSAGES | |
9488 | @c @itemx LC_MONETARY | |
9489 | @c @itemx LC_NUMERIC | |
9490 | @c @itemx LC_TIME | |
9491 | @itemx LC_ALL | |
9492 | @findex LANG | |
9493 | @findex LC_CTYPE | |
9494 | @c @findex LC_COLLATE | |
9495 | @findex LC_MESSAGES | |
9496 | @c @findex LC_MONETARY | |
9497 | @c @findex LC_NUMERIC | |
9498 | @c @findex LC_TIME | |
9499 | @findex LC_ALL | |
9500 | @cindex locale | |
0c2d1a2a JB |
9501 | These environment variables control the way that GCC uses |
9502 | localization information that allow GCC to work with different | |
9503 | national conventions. GCC inspects the locale categories | |
bedc7537 | 9504 | @env{LC_CTYPE} and @env{LC_MESSAGES} if it has been configured to do |
ab87f8c8 JL |
9505 | so. These locale categories can be set to any value supported by your |
9506 | installation. A typical value is @samp{en_UK} for English in the United | |
9507 | Kingdom. | |
9508 | ||
bedc7537 | 9509 | The @env{LC_CTYPE} environment variable specifies character |
0c2d1a2a | 9510 | classification. GCC uses it to determine the character boundaries in |
ab87f8c8 JL |
9511 | a string; this is needed for some multibyte encodings that contain quote |
9512 | and escape characters that would otherwise be interpreted as a string | |
9513 | end or escape. | |
9514 | ||
bedc7537 | 9515 | The @env{LC_MESSAGES} environment variable specifies the language to |
ab87f8c8 JL |
9516 | use in diagnostic messages. |
9517 | ||
bedc7537 NC |
9518 | If the @env{LC_ALL} environment variable is set, it overrides the value |
9519 | of @env{LC_CTYPE} and @env{LC_MESSAGES}; otherwise, @env{LC_CTYPE} | |
9520 | and @env{LC_MESSAGES} default to the value of the @env{LANG} | |
0c2d1a2a | 9521 | environment variable. If none of these variables are set, GCC |
ab87f8c8 JL |
9522 | defaults to traditional C English behavior. |
9523 | ||
74291a4b MM |
9524 | @item TMPDIR |
9525 | @findex TMPDIR | |
bedc7537 | 9526 | If @env{TMPDIR} is set, it specifies the directory to use for temporary |
0c2d1a2a | 9527 | files. GCC uses temporary files to hold the output of one stage of |
74291a4b MM |
9528 | compilation which is to be used as input to the next stage: for example, |
9529 | the output of the preprocessor, which is the input to the compiler | |
9530 | proper. | |
9531 | ||
9532 | @item GCC_EXEC_PREFIX | |
9533 | @findex GCC_EXEC_PREFIX | |
bedc7537 | 9534 | If @env{GCC_EXEC_PREFIX} is set, it specifies a prefix to use in the |
74291a4b MM |
9535 | names of the subprograms executed by the compiler. No slash is added |
9536 | when this prefix is combined with the name of a subprogram, but you can | |
9537 | specify a prefix that ends with a slash if you wish. | |
9538 | ||
f0523f02 | 9539 | If @env{GCC_EXEC_PREFIX} is not set, GCC will attempt to figure out |
0deb20df TT |
9540 | an appropriate prefix to use based on the pathname it was invoked with. |
9541 | ||
0c2d1a2a | 9542 | If GCC cannot find the subprogram using the specified prefix, it |
74291a4b MM |
9543 | tries looking in the usual places for the subprogram. |
9544 | ||
bedc7537 | 9545 | The default value of @env{GCC_EXEC_PREFIX} is |
74291a4b MM |
9546 | @file{@var{prefix}/lib/gcc-lib/} where @var{prefix} is the value |
9547 | of @code{prefix} when you ran the @file{configure} script. | |
9548 | ||
630d3d5a | 9549 | Other prefixes specified with @option{-B} take precedence over this prefix. |
74291a4b MM |
9550 | |
9551 | This prefix is also used for finding files such as @file{crt0.o} that are | |
9552 | used for linking. | |
9553 | ||
9554 | In addition, the prefix is used in an unusual way in finding the | |
9555 | directories to search for header files. For each of the standard | |
9556 | directories whose name normally begins with @samp{/usr/local/lib/gcc-lib} | |
bedc7537 | 9557 | (more precisely, with the value of @env{GCC_INCLUDE_DIR}), GCC tries |
74291a4b | 9558 | replacing that beginning with the specified prefix to produce an |
630d3d5a | 9559 | alternate directory name. Thus, with @option{-Bfoo/}, GCC will search |
74291a4b MM |
9560 | @file{foo/bar} where it would normally search @file{/usr/local/lib/bar}. |
9561 | These alternate directories are searched first; the standard directories | |
9562 | come next. | |
9563 | ||
9564 | @item COMPILER_PATH | |
9565 | @findex COMPILER_PATH | |
bedc7537 NC |
9566 | The value of @env{COMPILER_PATH} is a colon-separated list of |
9567 | directories, much like @env{PATH}. GCC tries the directories thus | |
74291a4b | 9568 | specified when searching for subprograms, if it can't find the |
bedc7537 | 9569 | subprograms using @env{GCC_EXEC_PREFIX}. |
74291a4b MM |
9570 | |
9571 | @item LIBRARY_PATH | |
9572 | @findex LIBRARY_PATH | |
bedc7537 NC |
9573 | The value of @env{LIBRARY_PATH} is a colon-separated list of |
9574 | directories, much like @env{PATH}. When configured as a native compiler, | |
0c2d1a2a | 9575 | GCC tries the directories thus specified when searching for special |
bedc7537 | 9576 | linker files, if it can't find them using @env{GCC_EXEC_PREFIX}. Linking |
0c2d1a2a | 9577 | using GCC also uses these directories when searching for ordinary |
630d3d5a JM |
9578 | libraries for the @option{-l} option (but directories specified with |
9579 | @option{-L} come first). | |
74291a4b MM |
9580 | |
9581 | @item C_INCLUDE_PATH | |
9582 | @itemx CPLUS_INCLUDE_PATH | |
9583 | @itemx OBJC_INCLUDE_PATH | |
9584 | @findex C_INCLUDE_PATH | |
9585 | @findex CPLUS_INCLUDE_PATH | |
9586 | @findex OBJC_INCLUDE_PATH | |
9587 | @c @itemx OBJCPLUS_INCLUDE_PATH | |
9588 | These environment variables pertain to particular languages. Each | |
9589 | variable's value is a colon-separated list of directories, much like | |
bedc7537 | 9590 | @env{PATH}. When GCC searches for header files, it tries the |
74291a4b | 9591 | directories listed in the variable for the language you are using, after |
630d3d5a | 9592 | the directories specified with @option{-I} but before the standard header |
74291a4b MM |
9593 | file directories. |
9594 | ||
9595 | @item DEPENDENCIES_OUTPUT | |
9596 | @findex DEPENDENCIES_OUTPUT | |
9597 | @cindex dependencies for make as output | |
9598 | If this variable is set, its value specifies how to output dependencies | |
9599 | for Make based on the header files processed by the compiler. This | |
630d3d5a | 9600 | output looks much like the output from the @option{-M} option |
74291a4b MM |
9601 | (@pxref{Preprocessor Options}), but it goes to a separate file, and is |
9602 | in addition to the usual results of compilation. | |
9603 | ||
bedc7537 | 9604 | The value of @env{DEPENDENCIES_OUTPUT} can be just a file name, in |
74291a4b MM |
9605 | which case the Make rules are written to that file, guessing the target |
9606 | name from the source file name. Or the value can have the form | |
9607 | @samp{@var{file} @var{target}}, in which case the rules are written to | |
9608 | file @var{file} using @var{target} as the target name. | |
56f48ce9 DB |
9609 | |
9610 | @item LANG | |
9611 | @findex LANG | |
9612 | @cindex locale definition | |
767094dd | 9613 | This variable is used to pass locale information to the compiler. One way in |
56f48ce9 DB |
9614 | which this information is used is to determine the character set to be used |
9615 | when character literals, string literals and comments are parsed in C and C++. | |
9616 | When the compiler is configured to allow multibyte characters, | |
bedc7537 | 9617 | the following values for @env{LANG} are recognized: |
56f48ce9 | 9618 | |
2642624b | 9619 | @table @samp |
56f48ce9 DB |
9620 | @item C-JIS |
9621 | Recognize JIS characters. | |
9622 | @item C-SJIS | |
9623 | Recognize SJIS characters. | |
9624 | @item C-EUCJP | |
9625 | Recognize EUCJP characters. | |
9626 | @end table | |
9627 | ||
bedc7537 | 9628 | If @env{LANG} is not defined, or if it has some other value, then the |
56f48ce9 DB |
9629 | compiler will use mblen and mbtowc as defined by the default locale to |
9630 | recognize and translate multibyte characters. | |
74291a4b MM |
9631 | @end table |
9632 | ||
9d86bffc JM |
9633 | @c man end |
9634 | ||
74291a4b MM |
9635 | @node Running Protoize |
9636 | @section Running Protoize | |
9637 | ||
161d7b59 | 9638 | The program @code{protoize} is an optional part of GCC@. You can use |
c1030c7c | 9639 | it to add prototypes to a program, thus converting the program to ISO |
74291a4b MM |
9640 | C in one respect. The companion program @code{unprotoize} does the |
9641 | reverse: it removes argument types from any prototypes that are found. | |
9642 | ||
9643 | When you run these programs, you must specify a set of source files as | |
9644 | command line arguments. The conversion programs start out by compiling | |
9645 | these files to see what functions they define. The information gathered | |
9646 | about a file @var{foo} is saved in a file named @file{@var{foo}.X}. | |
9647 | ||
9648 | After scanning comes actual conversion. The specified files are all | |
9649 | eligible to be converted; any files they include (whether sources or | |
9650 | just headers) are eligible as well. | |
9651 | ||
9652 | But not all the eligible files are converted. By default, | |
9653 | @code{protoize} and @code{unprotoize} convert only source and header | |
9654 | files in the current directory. You can specify additional directories | |
630d3d5a | 9655 | whose files should be converted with the @option{-d @var{directory}} |
74291a4b | 9656 | option. You can also specify particular files to exclude with the |
630d3d5a | 9657 | @option{-x @var{file}} option. A file is converted if it is eligible, its |
74291a4b MM |
9658 | directory name matches one of the specified directory names, and its |
9659 | name within the directory has not been excluded. | |
9660 | ||
9661 | Basic conversion with @code{protoize} consists of rewriting most | |
9662 | function definitions and function declarations to specify the types of | |
9663 | the arguments. The only ones not rewritten are those for varargs | |
9664 | functions. | |
9665 | ||
9666 | @code{protoize} optionally inserts prototype declarations at the | |
9667 | beginning of the source file, to make them available for any calls that | |
9668 | precede the function's definition. Or it can insert prototype | |
9669 | declarations with block scope in the blocks where undeclared functions | |
9670 | are called. | |
9671 | ||
9672 | Basic conversion with @code{unprotoize} consists of rewriting most | |
9673 | function declarations to remove any argument types, and rewriting | |
c1030c7c | 9674 | function definitions to the old-style pre-ISO form. |
74291a4b MM |
9675 | |
9676 | Both conversion programs print a warning for any function declaration or | |
9677 | definition that they can't convert. You can suppress these warnings | |
630d3d5a | 9678 | with @option{-q}. |
74291a4b MM |
9679 | |
9680 | The output from @code{protoize} or @code{unprotoize} replaces the | |
9681 | original source file. The original file is renamed to a name ending | |
02f52e19 | 9682 | with @samp{.save} (for DOS, the saved filename ends in @samp{.sav} |
a7db8bbb MK |
9683 | without the original @samp{.c} suffix). If the @samp{.save} (@samp{.sav} |
9684 | for DOS) file already exists, then the source file is simply discarded. | |
74291a4b | 9685 | |
0c2d1a2a | 9686 | @code{protoize} and @code{unprotoize} both depend on GCC itself to |
74291a4b | 9687 | scan the program and collect information about the functions it uses. |
0c2d1a2a | 9688 | So neither of these programs will work until GCC is installed. |
74291a4b MM |
9689 | |
9690 | Here is a table of the options you can use with @code{protoize} and | |
9691 | @code{unprotoize}. Each option works with both programs unless | |
9692 | otherwise stated. | |
9693 | ||
9694 | @table @code | |
9695 | @item -B @var{directory} | |
9696 | Look for the file @file{SYSCALLS.c.X} in @var{directory}, instead of the | |
9697 | usual directory (normally @file{/usr/local/lib}). This file contains | |
9698 | prototype information about standard system functions. This option | |
9699 | applies only to @code{protoize}. | |
9700 | ||
9701 | @item -c @var{compilation-options} | |
9702 | Use @var{compilation-options} as the options when running @code{gcc} to | |
630d3d5a | 9703 | produce the @samp{.X} files. The special option @option{-aux-info} is |
74291a4b MM |
9704 | always passed in addition, to tell @code{gcc} to write a @samp{.X} file. |
9705 | ||
9706 | Note that the compilation options must be given as a single argument to | |
9707 | @code{protoize} or @code{unprotoize}. If you want to specify several | |
9708 | @code{gcc} options, you must quote the entire set of compilation options | |
9709 | to make them a single word in the shell. | |
9710 | ||
9711 | There are certain @code{gcc} arguments that you cannot use, because they | |
630d3d5a JM |
9712 | would produce the wrong kind of output. These include @option{-g}, |
9713 | @option{-O}, @option{-c}, @option{-S}, and @option{-o} If you include these in | |
74291a4b MM |
9714 | the @var{compilation-options}, they are ignored. |
9715 | ||
9716 | @item -C | |
a7db8bbb | 9717 | Rename files to end in @samp{.C} (@samp{.cc} for DOS-based file |
02f52e19 | 9718 | systems) instead of @samp{.c}. This is convenient if you are converting |
ee77eda5 | 9719 | a C program to C++. This option applies only to @code{protoize}. |
74291a4b MM |
9720 | |
9721 | @item -g | |
9722 | Add explicit global declarations. This means inserting explicit | |
9723 | declarations at the beginning of each source file for each function | |
9724 | that is called in the file and was not declared. These declarations | |
9725 | precede the first function definition that contains a call to an | |
9726 | undeclared function. This option applies only to @code{protoize}. | |
9727 | ||
9728 | @item -i @var{string} | |
9729 | Indent old-style parameter declarations with the string @var{string}. | |
9730 | This option applies only to @code{protoize}. | |
9731 | ||
9732 | @code{unprotoize} converts prototyped function definitions to old-style | |
9733 | function definitions, where the arguments are declared between the | |
9734 | argument list and the initial @samp{@{}. By default, @code{unprotoize} | |
9735 | uses five spaces as the indentation. If you want to indent with just | |
630d3d5a | 9736 | one space instead, use @option{-i " "}. |
74291a4b MM |
9737 | |
9738 | @item -k | |
9739 | Keep the @samp{.X} files. Normally, they are deleted after conversion | |
9740 | is finished. | |
9741 | ||
9742 | @item -l | |
630d3d5a | 9743 | Add explicit local declarations. @code{protoize} with @option{-l} inserts |
74291a4b MM |
9744 | a prototype declaration for each function in each block which calls the |
9745 | function without any declaration. This option applies only to | |
9746 | @code{protoize}. | |
9747 | ||
9748 | @item -n | |
9749 | Make no real changes. This mode just prints information about the conversions | |
630d3d5a | 9750 | that would have been done without @option{-n}. |
74291a4b MM |
9751 | |
9752 | @item -N | |
9753 | Make no @samp{.save} files. The original files are simply deleted. | |
9754 | Use this option with caution. | |
9755 | ||
9756 | @item -p @var{program} | |
9757 | Use the program @var{program} as the compiler. Normally, the name | |
9758 | @file{gcc} is used. | |
9759 | ||
9760 | @item -q | |
9761 | Work quietly. Most warnings are suppressed. | |
9762 | ||
9763 | @item -v | |
630d3d5a | 9764 | Print the version number, just like @option{-v} for @code{gcc}. |
74291a4b MM |
9765 | @end table |
9766 | ||
9767 | If you need special compiler options to compile one of your program's | |
9768 | source files, then you should generate that file's @samp{.X} file | |
9769 | specially, by running @code{gcc} on that source file with the | |
630d3d5a | 9770 | appropriate options and the option @option{-aux-info}. Then run |
74291a4b MM |
9771 | @code{protoize} on the entire set of files. @code{protoize} will use |
9772 | the existing @samp{.X} file because it is newer than the source file. | |
9773 | For example: | |
9774 | ||
9775 | @example | |
b1018de6 | 9776 | gcc -Dfoo=bar file1.c -aux-info file1.X |
74291a4b MM |
9777 | protoize *.c |
9778 | @end example | |
9779 | ||
9780 | @noindent | |
9781 | You need to include the special files along with the rest in the | |
9782 | @code{protoize} command, even though their @samp{.X} files already | |
9783 | exist, because otherwise they won't get converted. | |
9784 | ||
9785 | @xref{Protoize Caveats}, for more information on how to use | |
9786 | @code{protoize} successfully. |