]>
Commit | Line | Data |
---|---|---|
861bb6c1 | 1 | @c Copyright (C) 1988,89,92,93,94,95,96,1997 Free Software Foundation, Inc. |
74291a4b MM |
2 | @c This is part of the GCC manual. |
3 | @c For copying conditions, see the file gcc.texi. | |
4 | ||
5 | @node Invoking GCC | |
6 | @chapter GNU CC Command Options | |
7 | @cindex GNU CC command options | |
8 | @cindex command options | |
9 | @cindex options, GNU CC command | |
10 | ||
11 | When you invoke GNU CC, it normally does preprocessing, compilation, | |
12 | assembly and linking. The ``overall options'' allow you to stop this | |
13 | process at an intermediate stage. For example, the @samp{-c} option | |
14 | says not to run the linker. Then the output consists of object files | |
15 | output by the assembler. | |
16 | ||
17 | Other options are passed on to one stage of processing. Some options | |
18 | control the preprocessor and others the compiler itself. Yet other | |
19 | options control the assembler and linker; most of these are not | |
20 | documented here, since you rarely need to use any of them. | |
21 | ||
22 | @cindex C compilation options | |
23 | Most of the command line options that you can use with GNU CC are useful | |
24 | for C programs; when an option is only useful with another language | |
25 | (usually C++), the explanation says so explicitly. If the description | |
26 | for a particular option does not mention a source language, you can use | |
27 | that option with all supported languages. | |
28 | ||
29 | @cindex C++ compilation options | |
30 | @xref{Invoking G++,,Compiling C++ Programs}, for a summary of special | |
31 | options for compiling C++ programs. | |
32 | ||
33 | @cindex grouping options | |
34 | @cindex options, grouping | |
35 | The @code{gcc} program accepts options and file names as operands. Many | |
36 | options have multiletter names; therefore multiple single-letter options | |
37 | may @emph{not} be grouped: @samp{-dr} is very different from @w{@samp{-d | |
38 | -r}}. | |
39 | ||
40 | @cindex order of options | |
41 | @cindex options, order | |
42 | You can mix options and other arguments. For the most part, the order | |
43 | you use doesn't matter. Order does matter when you use several options | |
44 | of the same kind; for example, if you specify @samp{-L} more than once, | |
45 | the directories are searched in the order specified. | |
46 | ||
47 | Many options have long names starting with @samp{-f} or with | |
48 | @samp{-W}---for example, @samp{-fforce-mem}, | |
49 | @samp{-fstrength-reduce}, @samp{-Wformat} and so on. Most of | |
50 | these have both positive and negative forms; the negative form of | |
51 | @samp{-ffoo} would be @samp{-fno-foo}. This manual documents | |
52 | only one of these two forms, whichever one is not the default. | |
53 | ||
54 | @menu | |
55 | * Option Summary:: Brief list of all options, without explanations. | |
56 | * Overall Options:: Controlling the kind of output: | |
57 | an executable, object files, assembler files, | |
58 | or preprocessed source. | |
59 | * Invoking G++:: Compiling C++ programs. | |
60 | * C Dialect Options:: Controlling the variant of C language compiled. | |
61 | * C++ Dialect Options:: Variations on C++. | |
62 | * Warning Options:: How picky should the compiler be? | |
63 | * Debugging Options:: Symbol tables, measurements, and debugging dumps. | |
64 | * Optimize Options:: How much optimization? | |
65 | * Preprocessor Options:: Controlling header files and macro definitions. | |
66 | Also, getting dependency information for Make. | |
67 | * Assembler Options:: Passing options to the assembler. | |
68 | * Link Options:: Specifying libraries and so on. | |
69 | * Directory Options:: Where to find header files and libraries. | |
70 | Where to find the compiler executable files. | |
71 | * Target Options:: Running a cross-compiler, or an old version of GNU CC. | |
72 | * Submodel Options:: Specifying minor hardware or convention variations, | |
73 | such as 68010 vs 68020. | |
74 | * Code Gen Options:: Specifying conventions for function calls, data layout | |
75 | and register usage. | |
76 | * Environment Variables:: Env vars that affect GNU CC. | |
77 | * Running Protoize:: Automatically adding or removing function prototypes. | |
78 | @end menu | |
79 | ||
80 | @node Option Summary | |
81 | @section Option Summary | |
82 | ||
83 | Here is a summary of all the options, grouped by type. Explanations are | |
84 | in the following sections. | |
85 | ||
86 | @table @emph | |
87 | @item Overall Options | |
88 | @xref{Overall Options,,Options Controlling the Kind of Output}. | |
89 | @smallexample | |
90 | -c -S -E -o @var{file} -pipe -v -x @var{language} | |
91 | @end smallexample | |
92 | ||
93 | @item C Language Options | |
94 | @xref{C Dialect Options,,Options Controlling C Dialect}. | |
95 | @smallexample | |
861bb6c1 | 96 | -ansi -fallow-single-precision -fcond-mismatch -fno-asm |
8c81598d | 97 | -fno-builtin -ffreestanding -fhosted -fsigned-bitfields -fsigned-char |
74291a4b MM |
98 | -funsigned-bitfields -funsigned-char -fwritable-strings |
99 | -traditional -traditional-cpp -trigraphs | |
100 | @end smallexample | |
101 | ||
102 | @item C++ Language Options | |
103 | @xref{C++ Dialect Options,,Options Controlling C++ Dialect}. | |
104 | @smallexample | |
105 | -fall-virtual -fdollars-in-identifiers -felide-constructors | |
8c81598d JM |
106 | -fenum-int-equiv -fexternal-templates -ffor-scope -fno-for-scope |
107 | -fhandle-signatures -fmemoize-lookups -fname-mangling-version-@var{n} | |
108 | -fno-default-inline -fno-gnu-keywords -fnonnull-objects -fguiding-decls | |
109 | -foperator-names -fstrict-prototype -fthis-is-variable | |
110 | -ftemplate-depth-@var{n} -nostdinc++ -traditional +e@var{n} | |
74291a4b MM |
111 | @end smallexample |
112 | ||
113 | @item Warning Options | |
114 | @xref{Warning Options,,Options to Request or Suppress Warnings}. | |
115 | @smallexample | |
116 | -fsyntax-only -pedantic -pedantic-errors | |
117 | -w -W -Wall -Waggregate-return -Wbad-function-cast | |
8c81598d | 118 | -Wcast-align -Wcast-qual -Wchar-subscript -Wcomment |
74291a4b | 119 | -Wconversion -Werror -Wformat |
e9a25f70 JL |
120 | -Wid-clash-@var{len} -Wimplicit -Wimplicit-int |
121 | -Wimplicit-function-declarations -Wimport -Winline | |
861bb6c1 | 122 | -Wlarger-than-@var{len} -Wmain -Wmissing-declarations |
74291a4b | 123 | -Wmissing-prototypes -Wnested-externs |
d770d3b3 | 124 | -Wno-import -Wold-style-cast -Woverloaded-virtual -Wparentheses |
8c81598d JM |
125 | -Wpointer-arith -Wredundant-decls -Wreorder -Wreturn-type -Wshadow |
126 | -Wsign-compare -Wstrict-prototypes -Wswitch -Wsynth | |
74291a4b | 127 | -Wtemplate-debugging -Wtraditional -Wtrigraphs |
8c81598d | 128 | -Wundef -Wuninitialized -Wunused -Wwrite-strings |
74291a4b MM |
129 | @end smallexample |
130 | ||
131 | @item Debugging Options | |
132 | @xref{Debugging Options,,Options for Debugging Your Program or GCC}. | |
133 | @smallexample | |
134 | -a -ax -d@var{letters} -fpretend-float | |
861bb6c1 | 135 | -fprofile-arcs -ftest-coverage |
8c81598d | 136 | -g -g@var{level} -gcoff -gdwarf -gdwarf-1 -gdwarf-1+ -gdwarf-2 |
74291a4b MM |
137 | -ggdb -gstabs -gstabs+ -gxcoff -gxcoff+ |
138 | -p -pg -print-file-name=@var{library} -print-libgcc-file-name | |
139 | -print-prog-name=@var{program} -print-search-dirs -save-temps | |
140 | @end smallexample | |
141 | ||
142 | @item Optimization Options | |
143 | @xref{Optimize Options,,Options that Control Optimization}. | |
144 | @smallexample | |
861bb6c1 | 145 | -fbranch-probabilities |
74291a4b MM |
146 | -fcaller-saves -fcse-follow-jumps -fcse-skip-blocks |
147 | -fdelayed-branch -fexpensive-optimizations | |
148 | -ffast-math -ffloat-store -fforce-addr -fforce-mem | |
8c81598d JM |
149 | -ffunction-sections -finline-functions |
150 | -fkeep-inline-functions -fno-default-inline | |
74291a4b | 151 | -fno-defer-pop -fno-function-cse |
8c660648 | 152 | -fno-inline -fno-peephole -fomit-frame-pointer -fregmove |
6d6d0fa0 | 153 | -frerun-cse-after-loop -frerun-loop-opt -fschedule-insns |
74291a4b MM |
154 | -fschedule-insns2 -fstrength-reduce -fthread-jumps |
155 | -funroll-all-loops -funroll-loops | |
e5eb27e5 | 156 | -fmove-all-movables -freduce-all-givs |
74291a4b MM |
157 | -O -O0 -O1 -O2 -O3 |
158 | @end smallexample | |
159 | ||
160 | @item Preprocessor Options | |
161 | @xref{Preprocessor Options,,Options Controlling the Preprocessor}. | |
162 | @smallexample | |
163 | -A@var{question}(@var{answer}) -C -dD -dM -dN | |
164 | -D@var{macro}@r{[}=@var{defn}@r{]} -E -H | |
165 | -idirafter @var{dir} | |
166 | -include @var{file} -imacros @var{file} | |
167 | -iprefix @var{file} -iwithprefix @var{dir} | |
168 | -iwithprefixbefore @var{dir} -isystem @var{dir} | |
169 | -M -MD -MM -MMD -MG -nostdinc -P -trigraphs | |
170 | -undef -U@var{macro} -Wp,@var{option} | |
171 | @end smallexample | |
172 | ||
173 | @item Assembler Option | |
174 | @xref{Assembler Options,,Passing Options to the Assembler}. | |
175 | @smallexample | |
176 | -Wa,@var{option} | |
177 | @end smallexample | |
178 | ||
179 | @item Linker Options | |
180 | @xref{Link Options,,Options for Linking}. | |
181 | @smallexample | |
182 | @var{object-file-name} -l@var{library} | |
183 | -nostartfiles -nodefaultlibs -nostdlib | |
184 | -s -static -shared -symbolic | |
185 | -Wl,@var{option} -Xlinker @var{option} | |
186 | -u @var{symbol} | |
187 | @end smallexample | |
188 | ||
189 | @item Directory Options | |
190 | @xref{Directory Options,,Options for Directory Search}. | |
191 | @smallexample | |
8c81598d | 192 | -B@var{prefix} -I@var{dir} -I- -L@var{dir} -specs=@var{file} |
74291a4b MM |
193 | @end smallexample |
194 | ||
195 | @item Target Options | |
196 | @c I wrote this xref this way to avoid overfull hbox. -- rms | |
197 | @xref{Target Options}. | |
198 | @smallexample | |
199 | -b @var{machine} -V @var{version} | |
200 | @end smallexample | |
201 | ||
202 | @item Machine Dependent Options | |
203 | @xref{Submodel Options,,Hardware Models and Configurations}. | |
204 | @smallexample | |
205 | @emph{M680x0 Options} | |
8c81598d JM |
206 | -m68000 -m68020 -m68020-40 -m68020-60 -m68030 -m68040 |
207 | -m68060 -m5200 -m68881 -mbitfield -mc68000 -mc68020 -mfpa | |
861bb6c1 | 208 | -mnobitfield -mrtd -mshort -msoft-float -malign-int |
74291a4b MM |
209 | |
210 | @emph{VAX Options} | |
211 | -mg -mgnu -munix | |
212 | ||
213 | @emph{SPARC Options} | |
ded17aad DE |
214 | -mcpu=@var{cpu type} |
215 | -mtune=@var{cpu type} | |
216 | -mcmodel=@var{code model} | |
6d4312dd DE |
217 | -malign-jumps=@var{num} -malign-loops=@var{num} |
218 | -malign-functions=@var{num} | |
ded17aad | 219 | -m32 -m64 |
74291a4b | 220 | -mapp-regs -mbroken-saverestore -mcypress -mepilogue |
ded17aad DE |
221 | -mflat -mfpu -mhard-float -mhard-quad-float |
222 | -mimpure-text -mlive-g0 -mno-app-regs -mno-epilogue | |
74291a4b MM |
223 | -mno-flat -mno-fpu -mno-impure-text |
224 | -mno-stack-bias -mno-unaligned-doubles | |
225 | -msoft-float -msoft-quad-float -msparclite -mstack-bias | |
226 | -msupersparc -munaligned-doubles -mv8 | |
227 | ||
228 | @emph{Convex Options} | |
229 | -mc1 -mc2 -mc32 -mc34 -mc38 | |
230 | -margcount -mnoargcount | |
231 | -mlong32 -mlong64 | |
232 | -mvolatile-cache -mvolatile-nocache | |
233 | ||
234 | @emph{AMD29K Options} | |
235 | -m29000 -m29050 -mbw -mnbw -mdw -mndw | |
236 | -mlarge -mnormal -msmall | |
237 | -mkernel-registers -mno-reuse-arg-regs | |
238 | -mno-stack-check -mno-storem-bug | |
239 | -mreuse-arg-regs -msoft-float -mstack-check | |
240 | -mstorem-bug -muser-registers | |
241 | ||
242 | @emph{ARM Options} | |
8c81598d JM |
243 | -mapcs-frame -mapcs-26 -mapcs-32 |
244 | -mlittle-endian -mbig-endian -mwords-little-endian | |
245 | -mshort-load-bytes -mno-short-load-bytes | |
246 | -msoft-float -mhard-float | |
247 | -mbsd -mxopen -mno-symrename | |
74291a4b | 248 | |
6d6d0fa0 JL |
249 | @emph{MN10300 Options} |
250 | -mmult-bug | |
251 | -mno-mult-bug | |
252 | ||
861bb6c1 JL |
253 | @emph{M32R/D Options} |
254 | -mcode-model=@var{model type} -msdata=@var{sdata type} | |
255 | -G @var{num} | |
256 | ||
74291a4b MM |
257 | @emph{M88K Options} |
258 | -m88000 -m88100 -m88110 -mbig-pic | |
259 | -mcheck-zero-division -mhandle-large-shift | |
260 | -midentify-revision -mno-check-zero-division | |
261 | -mno-ocs-debug-info -mno-ocs-frame-position | |
262 | -mno-optimize-arg-area -mno-serialize-volatile | |
263 | -mno-underscores -mocs-debug-info | |
264 | -mocs-frame-position -moptimize-arg-area | |
265 | -mserialize-volatile -mshort-data-@var{num} -msvr3 | |
266 | -msvr4 -mtrap-large-shift -muse-div-instruction | |
267 | -mversion-03.00 -mwarn-passed-structs | |
268 | ||
269 | @emph{RS/6000 and PowerPC Options} | |
8c81598d JM |
270 | -mcpu=@var{cpu type} |
271 | -mtune=@var{cpu type} | |
74291a4b MM |
272 | -mpower -mno-power -mpower2 -mno-power2 |
273 | -mpowerpc -mno-powerpc | |
274 | -mpowerpc-gpopt -mno-powerpc-gpopt | |
275 | -mpowerpc-gfxopt -mno-powerpc-gfxopt | |
276 | -mnew-mnemonics -mno-new-mnemonics | |
277 | -mfull-toc -mminimal-toc -mno-fop-in-toc -mno-sum-in-toc | |
861bb6c1 | 278 | -mxl-call -mno-xl-call -mthreads -mpe |
74291a4b | 279 | -msoft-float -mhard-float -mmultiple -mno-multiple |
861bb6c1 JL |
280 | -mstring -mno-string -mupdate -mno-update |
281 | -mfused-madd -mno-fused-madd -mbit-align -mno-bit-align | |
74291a4b MM |
282 | -mstrict-align -mno-strict-align -mrelocatable |
283 | -mno-relocatable -mrelocatable-lib -mno-relocatable-lib | |
284 | -mtoc -mno-toc -mtraceback -mno-traceback | |
285 | -mlittle -mlittle-endian -mbig -mbig-endian | |
286 | -mcall-aix -mcall-sysv -mprototype -mno-prototype | |
e9a25f70 JL |
287 | -msim -mmvme -mads -myellowknife -memb |
288 | -msdata -msdata=@var{opt} -G @var{num} | |
74291a4b MM |
289 | |
290 | @emph{RT Options} | |
291 | -mcall-lib-mul -mfp-arg-in-fpregs -mfp-arg-in-gregs | |
292 | -mfull-fp-blocks -mhc-struct-return -min-line-mul | |
293 | -mminimum-fp-blocks -mnohc-struct-return | |
294 | ||
295 | @emph{MIPS Options} | |
8c81598d | 296 | -mabicalls -mcpu=@var{cpu type} -membedded-data |
74291a4b | 297 | -membedded-pic -mfp32 -mfp64 -mgas -mgp32 -mgp64 |
8c81598d JM |
298 | -mgpopt -mhalf-pic -mhard-float -mint64 -mips1 |
299 | -mips2 -mips3 -mlong64 -mlong-calls -mmemcpy | |
74291a4b MM |
300 | -mmips-as -mmips-tfile -mno-abicalls |
301 | -mno-embedded-data -mno-embedded-pic | |
302 | -mno-gpopt -mno-long-calls | |
303 | -mno-memcpy -mno-mips-tfile -mno-rnames -mno-stats | |
8c81598d JM |
304 | -mrnames -msoft-float |
305 | -m4650 -msingle-float -mmad | |
74291a4b MM |
306 | -mstats -EL -EB -G @var{num} -nocpp |
307 | ||
308 | @emph{i386 Options} | |
8c81598d | 309 | -m486 -m386 -mieee-fp -mno-fancy-math-387 |
74291a4b | 310 | -mno-fp-ret-in-387 -msoft-float -msvr3-shlib |
8c81598d JM |
311 | -mno-wide-multiply -mrtd -malign-double |
312 | -mreg-alloc=@var{list} -mregparm=@var{num} | |
313 | -malign-jumps=@var{num} -malign-loops=@var{num} | |
74291a4b MM |
314 | -malign-functions=@var{num} |
315 | ||
316 | @emph{HPPA Options} | |
8c81598d JM |
317 | -mbig-switch -mdisable-fpregs -mdisable-indexing -mfast-indirect-calls |
318 | -mgas -mjump-in-delay -mlong-load-store -mno-big-switch -mno-disable-fpregs | |
319 | -mno-disable-indexing -mno-fast-indirect-calls -mno-gas | |
74291a4b MM |
320 | -mno-jump-in-delay |
321 | -mno-long-load-store | |
e9a25f70 JL |
322 | -mno-portable-runtime -mno-soft-float -mno-space -mno-space-regs |
323 | -msoft-float | |
74291a4b | 324 | -mpa-risc-1-0 -mpa-risc-1-1 -mportable-runtime |
8c81598d | 325 | -mschedule=@var{list} -mspace -mspace-regs |
74291a4b MM |
326 | |
327 | @emph{Intel 960 Options} | |
328 | -m@var{cpu type} -masm-compat -mclean-linkage | |
329 | -mcode-align -mcomplex-addr -mleaf-procedures | |
330 | -mic-compat -mic2.0-compat -mic3.0-compat | |
331 | -mintel-asm -mno-clean-linkage -mno-code-align | |
332 | -mno-complex-addr -mno-leaf-procedures | |
333 | -mno-old-align -mno-strict-align -mno-tail-call | |
334 | -mnumerics -mold-align -msoft-float -mstrict-align | |
335 | -mtail-call | |
336 | ||
337 | @emph{DEC Alpha Options} | |
338 | -mfp-regs -mno-fp-regs | |
8c81598d JM |
339 | -mno-soft-float -msoft-float |
340 | -mieee -mieee-with-inexact -mieee-conformant | |
341 | -mfp-trap-mode -mfp-rounding-mode -mtrap-precision | |
74291a4b MM |
342 | -mbuild-constants |
343 | ||
344 | @emph{Clipper Options} | |
8c81598d | 345 | -mc300 -mc400 |
74291a4b MM |
346 | |
347 | @emph{H8/300 Options} | |
dcb9d1f0 | 348 | -mrelax -mh -ms -mint32 -malign-300 |
74291a4b MM |
349 | |
350 | @emph{SH Options} | |
351 | -m1 -m2 -m3 -m3e -mb -ml -mrelax | |
352 | ||
353 | @emph{System V Options} | |
354 | -Qy -Qn -YP,@var{paths} -Ym,@var{dir} | |
74291a4b | 355 | |
f84271d9 JL |
356 | @emph{V850 Options} |
357 | -mlong-calls -mno-long-calls -mep -mno-ep | |
358 | -mprolog-function -mno-prolog-function -mspace | |
359 | -mtda=@var{n} -msda=@var{n} -mzda=@var{n} | |
e9a25f70 | 360 | -mv850 -mbig-switch |
f84271d9 JL |
361 | @end smallexample |
362 | ||
74291a4b MM |
363 | @item Code Generation Options |
364 | @xref{Code Gen Options,,Options for Code Generation Conventions}. | |
365 | @smallexample | |
366 | -fcall-saved-@var{reg} -fcall-used-@var{reg} | |
367 | -ffixed-@var{reg} -finhibit-size-directive | |
861bb6c1 | 368 | -fcheck-memory-usage -fprefix-function-name |
74291a4b MM |
369 | -fno-common -fno-ident -fno-gnu-linker |
370 | -fpcc-struct-return -fpic -fPIC | |
371 | -freg-struct-return -fshared-data -fshort-enums | |
372 | -fshort-double -fvolatile -fvolatile-global | |
861bb6c1 | 373 | -fverbose-asm -fpack-struct -fstack-check +e0 +e1 |
e5eb27e5 JL |
374 | -fargument-alias -fargument-noalias |
375 | -fargument-noalias-global | |
74291a4b MM |
376 | @end smallexample |
377 | @end table | |
378 | ||
379 | @menu | |
380 | * Overall Options:: Controlling the kind of output: | |
381 | an executable, object files, assembler files, | |
382 | or preprocessed source. | |
383 | * C Dialect Options:: Controlling the variant of C language compiled. | |
384 | * C++ Dialect Options:: Variations on C++. | |
385 | * Warning Options:: How picky should the compiler be? | |
386 | * Debugging Options:: Symbol tables, measurements, and debugging dumps. | |
387 | * Optimize Options:: How much optimization? | |
388 | * Preprocessor Options:: Controlling header files and macro definitions. | |
389 | Also, getting dependency information for Make. | |
390 | * Assembler Options:: Passing options to the assembler. | |
391 | * Link Options:: Specifying libraries and so on. | |
392 | * Directory Options:: Where to find header files and libraries. | |
393 | Where to find the compiler executable files. | |
394 | * Target Options:: Running a cross-compiler, or an old version of GNU CC. | |
395 | @end menu | |
396 | ||
397 | @node Overall Options | |
398 | @section Options Controlling the Kind of Output | |
399 | ||
400 | Compilation can involve up to four stages: preprocessing, compilation | |
401 | proper, assembly and linking, always in that order. The first three | |
402 | stages apply to an individual source file, and end by producing an | |
403 | object file; linking combines all the object files (those newly | |
404 | compiled, and those specified as input) into an executable file. | |
405 | ||
406 | @cindex file name suffix | |
407 | For any given input file, the file name suffix determines what kind of | |
408 | compilation is done: | |
409 | ||
410 | @table @code | |
411 | @item @var{file}.c | |
412 | C source code which must be preprocessed. | |
413 | ||
414 | @item @var{file}.i | |
415 | C source code which should not be preprocessed. | |
416 | ||
417 | @item @var{file}.ii | |
418 | C++ source code which should not be preprocessed. | |
419 | ||
420 | @item @var{file}.m | |
421 | Objective-C source code. Note that you must link with the library | |
422 | @file{libobjc.a} to make an Objective-C program work. | |
423 | ||
424 | @item @var{file}.h | |
425 | C header file (not to be compiled or linked). | |
426 | ||
427 | @item @var{file}.cc | |
428 | @itemx @var{file}.cxx | |
429 | @itemx @var{file}.cpp | |
430 | @itemx @var{file}.C | |
431 | C++ source code which must be preprocessed. Note that in @samp{.cxx}, | |
432 | the last two letters must both be literally @samp{x}. Likewise, | |
433 | @samp{.C} refers to a literal capital C. | |
434 | ||
435 | @item @var{file}.s | |
436 | Assembler code. | |
437 | ||
438 | @item @var{file}.S | |
439 | Assembler code which must be preprocessed. | |
440 | ||
441 | @item @var{other} | |
442 | An object file to be fed straight into linking. | |
443 | Any file name with no recognized suffix is treated this way. | |
444 | @end table | |
445 | ||
446 | You can specify the input language explicitly with the @samp{-x} option: | |
447 | ||
448 | @table @code | |
449 | @item -x @var{language} | |
450 | Specify explicitly the @var{language} for the following input files | |
451 | (rather than letting the compiler choose a default based on the file | |
452 | name suffix). This option applies to all following input files until | |
453 | the next @samp{-x} option. Possible values for @var{language} are: | |
454 | @example | |
455 | c objective-c c++ | |
456 | c-header cpp-output c++-cpp-output | |
457 | assembler assembler-with-cpp | |
458 | @end example | |
459 | ||
460 | @item -x none | |
461 | Turn off any specification of a language, so that subsequent files are | |
462 | handled according to their file name suffixes (as they are if @samp{-x} | |
463 | has not been used at all). | |
464 | @end table | |
465 | ||
466 | If you only want some of the stages of compilation, you can use | |
467 | @samp{-x} (or filename suffixes) to tell @code{gcc} where to start, and | |
468 | one of the options @samp{-c}, @samp{-S}, or @samp{-E} to say where | |
469 | @code{gcc} is to stop. Note that some combinations (for example, | |
470 | @samp{-x cpp-output -E} instruct @code{gcc} to do nothing at all. | |
471 | ||
472 | @table @code | |
473 | @item -c | |
474 | Compile or assemble the source files, but do not link. The linking | |
475 | stage simply is not done. The ultimate output is in the form of an | |
476 | object file for each source file. | |
477 | ||
478 | By default, the object file name for a source file is made by replacing | |
479 | the suffix @samp{.c}, @samp{.i}, @samp{.s}, etc., with @samp{.o}. | |
480 | ||
481 | Unrecognized input files, not requiring compilation or assembly, are | |
482 | ignored. | |
483 | ||
484 | @item -S | |
485 | Stop after the stage of compilation proper; do not assemble. The output | |
486 | is in the form of an assembler code file for each non-assembler input | |
487 | file specified. | |
488 | ||
489 | By default, the assembler file name for a source file is made by | |
490 | replacing the suffix @samp{.c}, @samp{.i}, etc., with @samp{.s}. | |
491 | ||
492 | Input files that don't require compilation are ignored. | |
493 | ||
494 | @item -E | |
495 | Stop after the preprocessing stage; do not run the compiler proper. The | |
496 | output is in the form of preprocessed source code, which is sent to the | |
497 | standard output. | |
498 | ||
499 | Input files which don't require preprocessing are ignored. | |
500 | ||
501 | @cindex output file option | |
502 | @item -o @var{file} | |
503 | Place output in file @var{file}. This applies regardless to whatever | |
504 | sort of output is being produced, whether it be an executable file, | |
505 | an object file, an assembler file or preprocessed C code. | |
506 | ||
507 | Since only one output file can be specified, it does not make sense to | |
508 | use @samp{-o} when compiling more than one input file, unless you are | |
509 | producing an executable file as output. | |
510 | ||
511 | If @samp{-o} is not specified, the default is to put an executable file | |
512 | in @file{a.out}, the object file for @file{@var{source}.@var{suffix}} in | |
513 | @file{@var{source}.o}, its assembler file in @file{@var{source}.s}, and | |
514 | all preprocessed C source on standard output.@refill | |
515 | ||
516 | @item -v | |
517 | Print (on standard error output) the commands executed to run the stages | |
518 | of compilation. Also print the version number of the compiler driver | |
519 | program and of the preprocessor and the compiler proper. | |
520 | ||
521 | @item -pipe | |
522 | Use pipes rather than temporary files for communication between the | |
523 | various stages of compilation. This fails to work on some systems where | |
524 | the assembler is unable to read from a pipe; but the GNU assembler has | |
525 | no trouble. | |
526 | @end table | |
527 | ||
528 | @node Invoking G++ | |
529 | @section Compiling C++ Programs | |
530 | ||
531 | @cindex suffixes for C++ source | |
532 | @cindex C++ source file suffixes | |
533 | C++ source files conventionally use one of the suffixes @samp{.C}, | |
534 | @samp{.cc}, @samp{cpp}, or @samp{.cxx}; preprocessed C++ files use the | |
535 | suffix @samp{.ii}. GNU CC recognizes files with these names and | |
536 | compiles them as C++ programs even if you call the compiler the same way | |
537 | as for compiling C programs (usually with the name @code{gcc}). | |
538 | ||
539 | @findex g++ | |
540 | @findex c++ | |
541 | However, C++ programs often require class libraries as well as a | |
542 | compiler that understands the C++ language---and under some | |
543 | circumstances, you might want to compile programs from standard input, | |
544 | or otherwise without a suffix that flags them as C++ programs. | |
545 | @code{g++} is a program that calls GNU CC with the default language | |
546 | set to C++, and automatically specifies linking against the GNU class | |
547 | library libg++. | |
548 | @cindex @code{g++ 1.@var{xx}} | |
549 | @cindex @code{g++}, separate compiler | |
550 | @cindex @code{g++} older version | |
551 | @footnote{Prior to release 2 of the compiler, | |
552 | there was a separate @code{g++} compiler. That version was based on GNU | |
553 | CC, but not integrated with it. Versions of @code{g++} with a | |
554 | @samp{1.@var{xx}} version number---for example, @code{g++} version 1.37 | |
555 | or 1.42---are much less reliable than the versions integrated with GCC | |
556 | 2. Moreover, combining G++ @samp{1.@var{xx}} with a version 2 GCC will | |
557 | simply not work.} On many systems, the script @code{g++} is also | |
558 | installed with the name @code{c++}. | |
559 | ||
560 | @cindex invoking @code{g++} | |
561 | When you compile C++ programs, you may specify many of the same | |
562 | command-line options that you use for compiling programs in any | |
563 | language; or command-line options meaningful for C and related | |
564 | languages; or options that are meaningful only for C++ programs. | |
565 | @xref{C Dialect Options,,Options Controlling C Dialect}, for | |
566 | explanations of options for languages related to C. | |
567 | @xref{C++ Dialect Options,,Options Controlling C++ Dialect}, for | |
568 | explanations of options that are meaningful only for C++ programs. | |
569 | ||
570 | @node C Dialect Options | |
571 | @section Options Controlling C Dialect | |
572 | @cindex dialect options | |
573 | @cindex language dialect options | |
574 | @cindex options, dialect | |
575 | ||
576 | The following options control the dialect of C (or languages derived | |
577 | from C, such as C++ and Objective C) that the compiler accepts: | |
578 | ||
579 | @table @code | |
580 | @cindex ANSI support | |
581 | @item -ansi | |
582 | Support all ANSI standard C programs. | |
583 | ||
584 | This turns off certain features of GNU C that are incompatible with ANSI | |
585 | C, such as the @code{asm}, @code{inline} and @code{typeof} keywords, and | |
586 | predefined macros such as @code{unix} and @code{vax} that identify the | |
587 | type of system you are using. It also enables the undesirable and | |
861bb6c1 JL |
588 | rarely used ANSI trigraph feature, and it disables recognition of C++ |
589 | style @samp{//} comments. | |
74291a4b MM |
590 | |
591 | The alternate keywords @code{__asm__}, @code{__extension__}, | |
592 | @code{__inline__} and @code{__typeof__} continue to work despite | |
593 | @samp{-ansi}. You would not want to use them in an ANSI C program, of | |
594 | course, but it is useful to put them in header files that might be included | |
595 | in compilations done with @samp{-ansi}. Alternate predefined macros | |
596 | such as @code{__unix__} and @code{__vax__} are also available, with or | |
597 | without @samp{-ansi}. | |
598 | ||
599 | The @samp{-ansi} option does not cause non-ANSI programs to be | |
600 | rejected gratuitously. For that, @samp{-pedantic} is required in | |
601 | addition to @samp{-ansi}. @xref{Warning Options}. | |
602 | ||
603 | The macro @code{__STRICT_ANSI__} is predefined when the @samp{-ansi} | |
604 | option is used. Some header files may notice this macro and refrain | |
605 | from declaring certain functions or defining certain macros that the | |
606 | ANSI standard doesn't call for; this is to avoid interfering with any | |
607 | programs that might use these names for other things. | |
608 | ||
609 | The functions @code{alloca}, @code{abort}, @code{exit}, and | |
610 | @code{_exit} are not builtin functions when @samp{-ansi} is used. | |
611 | ||
612 | @item -fno-asm | |
613 | Do not recognize @code{asm}, @code{inline} or @code{typeof} as a | |
614 | keyword, so that code can use these words as identifiers. You can use | |
615 | the keywords @code{__asm__}, @code{__inline__} and @code{__typeof__} | |
616 | instead. @samp{-ansi} implies @samp{-fno-asm}. | |
617 | ||
618 | In C++, this switch only affects the @code{typeof} keyword, since | |
619 | @code{asm} and @code{inline} are standard keywords. You may want to | |
620 | use the @samp{-fno-gnu-keywords} flag instead, as it also disables the | |
621 | other, C++-specific, extension keywords such as @code{headof}. | |
622 | ||
623 | @item -fno-builtin | |
624 | @cindex builtin functions | |
625 | @findex abort | |
626 | @findex abs | |
627 | @findex alloca | |
628 | @findex cos | |
629 | @findex exit | |
630 | @findex fabs | |
631 | @findex ffs | |
632 | @findex labs | |
633 | @findex memcmp | |
634 | @findex memcpy | |
635 | @findex sin | |
636 | @findex sqrt | |
637 | @findex strcmp | |
638 | @findex strcpy | |
639 | @findex strlen | |
640 | Don't recognize builtin functions that do not begin with two leading | |
641 | underscores. Currently, the functions affected include @code{abort}, | |
642 | @code{abs}, @code{alloca}, @code{cos}, @code{exit}, @code{fabs}, | |
643 | @code{ffs}, @code{labs}, @code{memcmp}, @code{memcpy}, @code{sin}, | |
644 | @code{sqrt}, @code{strcmp}, @code{strcpy}, and @code{strlen}. | |
645 | ||
646 | GCC normally generates special code to handle certain builtin functions | |
647 | more efficiently; for instance, calls to @code{alloca} may become single | |
648 | instructions that adjust the stack directly, and calls to @code{memcpy} | |
649 | may become inline copy loops. The resulting code is often both smaller | |
650 | and faster, but since the function calls no longer appear as such, you | |
651 | cannot set a breakpoint on those calls, nor can you change the behavior | |
652 | of the functions by linking with a different library. | |
653 | ||
654 | The @samp{-ansi} option prevents @code{alloca} and @code{ffs} from being | |
655 | builtin functions, since these functions do not have an ANSI standard | |
656 | meaning. | |
657 | ||
861bb6c1 JL |
658 | @item -fhosted |
659 | @cindex hosted environment | |
660 | ||
661 | Assert that compilation takes place in a hosted environment. This implies | |
662 | @samp{-fbuiltin}. A hosted environment is one in which the | |
663 | entire standard library is available, and in which @code{main} has a return | |
664 | type of @code{int}. Examples are nearly everything except a kernel. | |
665 | This is equivalent to @samp{-fno-freestanding}. | |
666 | ||
667 | @item -ffreestanding | |
668 | @cindex hosted environment | |
669 | ||
670 | Assert that compilation takes place in a freestanding environment. This | |
671 | implies @samp{-fno-builtin}. A freestanding environment | |
672 | is one in which the standard library may not exist, and program startup may | |
673 | not necessarily be at @code{main}. The most obvious example is an OS kernel. | |
674 | This is equivalent to @samp{-fno-hosted}. | |
675 | ||
74291a4b MM |
676 | @item -trigraphs |
677 | Support ANSI C trigraphs. You don't want to know about this | |
678 | brain-damage. The @samp{-ansi} option implies @samp{-trigraphs}. | |
679 | ||
680 | @cindex traditional C language | |
681 | @cindex C language, traditional | |
682 | @item -traditional | |
683 | Attempt to support some aspects of traditional C compilers. | |
684 | Specifically: | |
685 | ||
686 | @itemize @bullet | |
687 | @item | |
688 | All @code{extern} declarations take effect globally even if they | |
689 | are written inside of a function definition. This includes implicit | |
690 | declarations of functions. | |
691 | ||
692 | @item | |
693 | The newer keywords @code{typeof}, @code{inline}, @code{signed}, @code{const} | |
694 | and @code{volatile} are not recognized. (You can still use the | |
695 | alternative keywords such as @code{__typeof__}, @code{__inline__}, and | |
696 | so on.) | |
697 | ||
698 | @item | |
699 | Comparisons between pointers and integers are always allowed. | |
700 | ||
701 | @item | |
702 | Integer types @code{unsigned short} and @code{unsigned char} promote | |
703 | to @code{unsigned int}. | |
704 | ||
705 | @item | |
706 | Out-of-range floating point literals are not an error. | |
707 | ||
708 | @item | |
709 | Certain constructs which ANSI regards as a single invalid preprocessing | |
710 | number, such as @samp{0xe-0xd}, are treated as expressions instead. | |
711 | ||
712 | @item | |
713 | String ``constants'' are not necessarily constant; they are stored in | |
714 | writable space, and identical looking constants are allocated | |
715 | separately. (This is the same as the effect of | |
716 | @samp{-fwritable-strings}.) | |
717 | ||
718 | @cindex @code{longjmp} and automatic variables | |
719 | @item | |
720 | All automatic variables not declared @code{register} are preserved by | |
721 | @code{longjmp}. Ordinarily, GNU C follows ANSI C: automatic variables | |
722 | not declared @code{volatile} may be clobbered. | |
723 | ||
724 | @item | |
725 | @kindex \x | |
726 | @kindex \a | |
727 | @cindex escape sequences, traditional | |
728 | The character escape sequences @samp{\x} and @samp{\a} evaluate as the | |
729 | literal characters @samp{x} and @samp{a} respectively. Without | |
730 | @w{@samp{-traditional}}, @samp{\x} is a prefix for the hexadecimal | |
731 | representation of a character, and @samp{\a} produces a bell. | |
732 | ||
733 | @item | |
734 | In C++ programs, assignment to @code{this} is permitted with | |
735 | @samp{-traditional}. (The option @samp{-fthis-is-variable} also has | |
736 | this effect.) | |
737 | @end itemize | |
738 | ||
739 | You may wish to use @samp{-fno-builtin} as well as @samp{-traditional} | |
740 | if your program uses names that are normally GNU C builtin functions for | |
741 | other purposes of its own. | |
742 | ||
743 | You cannot use @samp{-traditional} if you include any header files that | |
744 | rely on ANSI C features. Some vendors are starting to ship systems with | |
745 | ANSI C header files and you cannot use @samp{-traditional} on such | |
746 | systems to compile files that include any system headers. | |
747 | ||
748 | The @samp{-traditional} option also enables the @samp{-traditional-cpp} | |
749 | option, which is described next. | |
750 | ||
751 | @item -traditional-cpp | |
752 | Attempt to support some aspects of traditional C preprocessors. | |
753 | Specifically: | |
754 | ||
755 | @itemize @bullet | |
756 | @item | |
757 | Comments convert to nothing at all, rather than to a space. This allows | |
758 | traditional token concatenation. | |
759 | ||
760 | @item | |
761 | In a preprocessing directive, the @samp{#} symbol must appear as the first | |
762 | character of a line. | |
763 | ||
764 | @item | |
765 | Macro arguments are recognized within string constants in a macro | |
766 | definition (and their values are stringified, though without additional | |
767 | quote marks, when they appear in such a context). The preprocessor | |
768 | always considers a string constant to end at a newline. | |
769 | ||
770 | @item | |
771 | @cindex detecting @w{@samp{-traditional}} | |
772 | The predefined macro @code{__STDC__} is not defined when you use | |
773 | @samp{-traditional}, but @code{__GNUC__} is (since the GNU extensions | |
774 | which @code{__GNUC__} indicates are not affected by | |
775 | @samp{-traditional}). If you need to write header files that work | |
776 | differently depending on whether @samp{-traditional} is in use, by | |
777 | testing both of these predefined macros you can distinguish four | |
778 | situations: GNU C, traditional GNU C, other ANSI C compilers, and other | |
779 | old C compilers. The predefined macro @code{__STDC_VERSION__} is also | |
780 | not defined when you use @samp{-traditional}. @xref{Standard | |
781 | Predefined,,Standard Predefined Macros,cpp.info,The C Preprocessor}, | |
782 | for more discussion of these and other predefined macros. | |
783 | ||
784 | @item | |
785 | @cindex string constants vs newline | |
786 | @cindex newline vs string constants | |
787 | The preprocessor considers a string constant to end at a newline (unless | |
788 | the newline is escaped with @samp{\}). (Without @w{@samp{-traditional}}, | |
789 | string constants can contain the newline character as typed.) | |
790 | @end itemize | |
791 | ||
792 | @item -fcond-mismatch | |
793 | Allow conditional expressions with mismatched types in the second and | |
794 | third arguments. The value of such an expression is void. | |
795 | ||
796 | @item -funsigned-char | |
797 | Let the type @code{char} be unsigned, like @code{unsigned char}. | |
798 | ||
799 | Each kind of machine has a default for what @code{char} should | |
800 | be. It is either like @code{unsigned char} by default or like | |
801 | @code{signed char} by default. | |
802 | ||
803 | Ideally, a portable program should always use @code{signed char} or | |
804 | @code{unsigned char} when it depends on the signedness of an object. | |
805 | But many programs have been written to use plain @code{char} and | |
806 | expect it to be signed, or expect it to be unsigned, depending on the | |
807 | machines they were written for. This option, and its inverse, let you | |
808 | make such a program work with the opposite default. | |
809 | ||
810 | The type @code{char} is always a distinct type from each of | |
811 | @code{signed char} or @code{unsigned char}, even though its behavior | |
812 | is always just like one of those two. | |
813 | ||
814 | @item -fsigned-char | |
815 | Let the type @code{char} be signed, like @code{signed char}. | |
816 | ||
817 | Note that this is equivalent to @samp{-fno-unsigned-char}, which is | |
818 | the negative form of @samp{-funsigned-char}. Likewise, the option | |
819 | @samp{-fno-signed-char} is equivalent to @samp{-funsigned-char}. | |
820 | ||
821 | You may wish to use @samp{-fno-builtin} as well as @samp{-traditional} | |
822 | if your program uses names that are normally GNU C builtin functions for | |
823 | other purposes of its own. | |
824 | ||
825 | You cannot use @samp{-traditional} if you include any header files that | |
826 | rely on ANSI C features. Some vendors are starting to ship systems with | |
827 | ANSI C header files and you cannot use @samp{-traditional} on such | |
828 | systems to compile files that include any system headers. | |
829 | ||
830 | @item -fsigned-bitfields | |
831 | @itemx -funsigned-bitfields | |
832 | @itemx -fno-signed-bitfields | |
833 | @itemx -fno-unsigned-bitfields | |
834 | These options control whether a bitfield is signed or unsigned, when the | |
835 | declaration does not use either @code{signed} or @code{unsigned}. By | |
836 | default, such a bitfield is signed, because this is consistent: the | |
837 | basic integer types such as @code{int} are signed types. | |
838 | ||
839 | However, when @samp{-traditional} is used, bitfields are all unsigned | |
840 | no matter what. | |
841 | ||
842 | @item -fwritable-strings | |
843 | Store string constants in the writable data segment and don't uniquize | |
844 | them. This is for compatibility with old programs which assume they can | |
845 | write into string constants. The option @samp{-traditional} also has | |
846 | this effect. | |
847 | ||
848 | Writing into string constants is a very bad idea; ``constants'' should | |
849 | be constant. | |
850 | ||
851 | @item -fallow-single-precision | |
852 | Do not promote single precision math operations to double precision, | |
853 | even when compiling with @samp{-traditional}. | |
854 | ||
855 | Traditional K&R C promotes all floating point operations to double | |
856 | precision, regardless of the sizes of the operands. On the | |
857 | architecture for which you are compiling, single precision may be faster | |
858 | than double precision. If you must use @samp{-traditional}, but want | |
859 | to use single precision operations when the operands are single | |
860 | precision, use this option. This option has no effect when compiling | |
861 | with ANSI or GNU C conventions (the default). | |
862 | ||
863 | @end table | |
864 | ||
865 | @node C++ Dialect Options | |
866 | @section Options Controlling C++ Dialect | |
867 | ||
868 | @cindex compiler options, C++ | |
869 | @cindex C++ options, command line | |
870 | @cindex options, C++ | |
871 | This section describes the command-line options that are only meaningful | |
872 | for C++ programs; but you can also use most of the GNU compiler options | |
873 | regardless of what language your program is in. For example, you | |
874 | might compile a file @code{firstClass.C} like this: | |
875 | ||
876 | @example | |
877 | g++ -g -felide-constructors -O -c firstClass.C | |
878 | @end example | |
879 | ||
880 | @noindent | |
881 | In this example, only @samp{-felide-constructors} is an option meant | |
882 | only for C++ programs; you can use the other options with any | |
883 | language supported by GNU CC. | |
884 | ||
885 | Here is a list of options that are @emph{only} for compiling C++ programs: | |
886 | ||
887 | @table @code | |
888 | @item -fno-access-control | |
889 | Turn off all access checking. This switch is mainly useful for working | |
890 | around bugs in the access control code. | |
891 | ||
892 | @item -fall-virtual | |
893 | Treat all possible member functions as virtual, implicitly. | |
894 | All member functions (except for constructor functions and @code{new} or | |
895 | @code{delete} member operators) are treated as virtual functions of the | |
896 | class where they appear. | |
897 | ||
898 | This does not mean that all calls to these member functions will be made | |
899 | through the internal table of virtual functions. Under some | |
900 | circumstances, the compiler can determine that a call to a given virtual | |
901 | function can be made directly; in these cases the calls are direct in | |
902 | any case. | |
903 | ||
904 | @item -fcheck-new | |
905 | Check that the pointer returned by @code{operator new} is non-null | |
906 | before attempting to modify the storage allocated. The current Working | |
907 | Paper requires that @code{operator new} never return a null pointer, so | |
908 | this check is normally unnecessary. | |
909 | ||
910 | @item -fconserve-space | |
911 | Put uninitialized or runtime-initialized global variables into the | |
912 | common segment, as C does. This saves space in the executable at the | |
913 | cost of not diagnosing duplicate definitions. If you compile with this | |
914 | flag and your program mysteriously crashes after @code{main()} has | |
915 | completed, you may have an object that is being destroyed twice because | |
916 | two definitions were merged. | |
917 | ||
918 | @item -fdollars-in-identifiers | |
919 | Accept @samp{$} in identifiers. You can also explicitly prohibit use of | |
eb795509 RK |
920 | @samp{$} with the option @samp{-fno-dollars-in-identifiers}. (GNU C allows |
921 | @samp{$} by default on most target systems, but there are a few exceptions.) | |
74291a4b MM |
922 | Traditional C allowed the character @samp{$} to form part of |
923 | identifiers. However, ANSI C and C++ forbid @samp{$} in identifiers. | |
924 | ||
925 | @item -fenum-int-equiv | |
926 | Anachronistically permit implicit conversion of @code{int} to | |
927 | enumeration types. Current C++ allows conversion of @code{enum} to | |
928 | @code{int}, but not the other way around. | |
929 | ||
930 | @item -fexternal-templates | |
931 | Cause template instantiations to obey @samp{#pragma interface} and | |
932 | @samp{implementation}; template instances are emitted or not according | |
933 | to the location of the template definition. @xref{Template | |
934 | Instantiation}, for more information. | |
935 | ||
37f6b6bf MM |
936 | This option is deprecated. |
937 | ||
74291a4b MM |
938 | @item -falt-external-templates |
939 | Similar to -fexternal-templates, but template instances are emitted or | |
940 | not according to the place where they are first instantiated. | |
941 | @xref{Template Instantiation}, for more information. | |
942 | ||
37f6b6bf MM |
943 | This option is deprecated. |
944 | ||
74291a4b | 945 | @item -ffor-scope |
8c81598d | 946 | @itemx -fno-for-scope |
74291a4b MM |
947 | If -ffor-scope is specified, the scope of variables declared in |
948 | a @i{for-init-statement} is limited to the @samp{for} loop itself, | |
949 | as specified by the draft C++ standard. | |
950 | If -fno-for-scope is specified, the scope of variables declared in | |
951 | a @i{for-init-statement} extends to the end of the enclosing scope, | |
952 | as was the case in old versions of gcc, and other (traditional) | |
953 | implementations of C++. | |
954 | ||
955 | The default if neither flag is given to follow the standard, | |
956 | but to allow and give a warning for old-style code that would | |
957 | otherwise be invalid, or have different behavior. | |
958 | ||
959 | @item -fno-gnu-keywords | |
960 | Do not recognize @code{classof}, @code{headof}, @code{signature}, | |
961 | @code{sigof} or @code{typeof} as a keyword, so that code can use these | |
962 | words as identifiers. You can use the keywords @code{__classof__}, | |
963 | @code{__headof__}, @code{__signature__}, @code{__sigof__}, and | |
964 | @code{__typeof__} instead. @samp{-ansi} implies | |
965 | @samp{-fno-gnu-keywords}. | |
966 | ||
37f6b6bf MM |
967 | @item -fguiding-decls |
968 | Treat a function declaration with the same type as a potential function | |
969 | template instantiation as though it declares that instantiation, not a | |
970 | normal function. If a definition is given for the function later in the | |
971 | translation unit (or another translation unit if the target supports | |
972 | weak symbols), that definition will be used; otherwise the template will | |
973 | be instantiated. This behavior reflects the C++ language prior to | |
974 | September 1996, when guiding declarations were removed. | |
975 | ||
976 | This option implies @samp{-fname-mangling-version-0}, and will not work | |
977 | with other name mangling versions. | |
978 | ||
74291a4b MM |
979 | @item -fno-implicit-templates |
980 | Never emit code for templates which are instantiated implicitly (i.e. by | |
981 | use); only emit code for explicit instantiations. @xref{Template | |
982 | Instantiation}, for more information. | |
983 | ||
984 | @item -fhandle-signatures | |
985 | Recognize the @code{signature} and @code{sigof} keywords for specifying | |
986 | abstract types. The default (@samp{-fno-handle-signatures}) is not to | |
987 | recognize them. @xref{C++ Signatures, Type Abstraction using | |
988 | Signatures}. | |
989 | ||
990 | @item -fhuge-objects | |
991 | Support virtual function calls for objects that exceed the size | |
992 | representable by a @samp{short int}. Users should not use this flag by | |
993 | default; if you need to use it, the compiler will tell you so. If you | |
994 | compile any of your code with this flag, you must compile @emph{all} of | |
995 | your code with this flag (including libg++, if you use it). | |
996 | ||
997 | This flag is not useful when compiling with -fvtable-thunks. | |
998 | ||
999 | @item -fno-implement-inlines | |
1000 | To save space, do not emit out-of-line copies of inline functions | |
1001 | controlled by @samp{#pragma implementation}. This will cause linker | |
1002 | errors if these functions are not inlined everywhere they are called. | |
1003 | ||
1004 | @item -fmemoize-lookups | |
1005 | @itemx -fsave-memoized | |
1006 | Use heuristics to compile faster. These heuristics are not enabled by | |
1007 | default, since they are only effective for certain input files. Other | |
1008 | input files compile more slowly. | |
1009 | ||
1010 | The first time the compiler must build a call to a member function (or | |
1011 | reference to a data member), it must (1) determine whether the class | |
1012 | implements member functions of that name; (2) resolve which member | |
1013 | function to call (which involves figuring out what sorts of type | |
1014 | conversions need to be made); and (3) check the visibility of the member | |
1015 | function to the caller. All of this adds up to slower compilation. | |
1016 | Normally, the second time a call is made to that member function (or | |
1017 | reference to that data member), it must go through the same lengthy | |
1018 | process again. This means that code like this: | |
1019 | ||
1020 | @smallexample | |
1021 | cout << "This " << p << " has " << n << " legs.\n"; | |
1022 | @end smallexample | |
1023 | ||
1024 | @noindent | |
1025 | makes six passes through all three steps. By using a software cache, a | |
1026 | ``hit'' significantly reduces this cost. Unfortunately, using the cache | |
1027 | introduces another layer of mechanisms which must be implemented, and so | |
1028 | incurs its own overhead. @samp{-fmemoize-lookups} enables the software | |
1029 | cache. | |
1030 | ||
1031 | Because access privileges (visibility) to members and member functions | |
1032 | may differ from one function context to the next, G++ may need to flush | |
1033 | the cache. With the @samp{-fmemoize-lookups} flag, the cache is flushed | |
1034 | after every function that is compiled. The @samp{-fsave-memoized} flag | |
1035 | enables the same software cache, but when the compiler determines that | |
1036 | the context of the last function compiled would yield the same access | |
1037 | privileges of the next function to compile, it preserves the cache. | |
1038 | This is most helpful when defining many member functions for the same | |
1039 | class: with the exception of member functions which are friends of other | |
1040 | classes, each member function has exactly the same access privileges as | |
1041 | every other, and the cache need not be flushed. | |
1042 | ||
1043 | The code that implements these flags has rotted; you should probably | |
1044 | avoid using them. | |
1045 | ||
1046 | @item -fstrict-prototype | |
1047 | Within an @samp{extern "C"} linkage specification, treat a function | |
1048 | declaration with no arguments, such as @samp{int foo ();}, as declaring | |
1049 | the function to take no arguments. Normally, such a declaration means | |
1050 | that the function @code{foo} can take any combination of arguments, as | |
1051 | in C. @samp{-pedantic} implies @samp{-fstrict-prototype} unless | |
1052 | overridden with @samp{-fno-strict-prototype}. | |
1053 | ||
1054 | This flag no longer affects declarations with C++ linkage. | |
1055 | ||
37f6b6bf MM |
1056 | @item -fname-mangling-version-@var{n} |
1057 | Control the way in which names are mangled. Version 0 is compatible | |
1058 | with versions of g++ before 2.8. Version 1 is the default. Version 1 | |
1059 | will allow correct mangling of function templates. For example, | |
1060 | version 0 mangling does not mangle foo<int, double> and foo<int, char> | |
1061 | given this declaration: | |
1062 | ||
1063 | @example | |
1064 | template <class T, class U> void foo(T t); | |
1065 | @end example | |
1066 | ||
74291a4b MM |
1067 | @item -fno-nonnull-objects |
1068 | Don't assume that a reference is initialized to refer to a valid object. | |
1069 | Although the current C++ Working Paper prohibits null references, some | |
1070 | old code may rely on them, and you can use @samp{-fno-nonnull-objects} | |
1071 | to turn on checking. | |
1072 | ||
1073 | At the moment, the compiler only does this checking for conversions to | |
1074 | virtual base classes. | |
1075 | ||
1076 | @item -foperator-names | |
1077 | Recognize the operator name keywords @code{and}, @code{bitand}, | |
1078 | @code{bitor}, @code{compl}, @code{not}, @code{or} and @code{xor} as | |
1079 | synonyms for the symbols they refer to. @samp{-ansi} implies | |
1080 | @samp{-foperator-names}. | |
1081 | ||
8c81598d JM |
1082 | @item -frepo |
1083 | Enable automatic template instantiation. This option also implies | |
1084 | @samp{-fno-implicit-templates}. @xref{Template Instantiation}, for more | |
1085 | information. | |
1086 | ||
74291a4b MM |
1087 | @item -fthis-is-variable |
1088 | Permit assignment to @code{this}. The incorporation of user-defined | |
1089 | free store management into C++ has made assignment to @samp{this} an | |
1090 | anachronism. Therefore, by default it is invalid to assign to | |
1091 | @code{this} within a class member function; that is, GNU C++ treats | |
1092 | @samp{this} in a member function of class @code{X} as a non-lvalue of | |
1093 | type @samp{X *}. However, for backwards compatibility, you can make it | |
1094 | valid with @samp{-fthis-is-variable}. | |
1095 | ||
1096 | @item -fvtable-thunks | |
1097 | Use @samp{thunks} to implement the virtual function dispatch table | |
1098 | (@samp{vtable}). The traditional (cfront-style) approach to | |
1099 | implementing vtables was to store a pointer to the function and two | |
1100 | offsets for adjusting the @samp{this} pointer at the call site. Newer | |
1101 | implementations store a single pointer to a @samp{thunk} function which | |
1102 | does any necessary adjustment and then calls the target function. | |
1103 | ||
1104 | This option also enables a heuristic for controlling emission of | |
1105 | vtables; if a class has any non-inline virtual functions, the vtable | |
1106 | will be emitted in the translation unit containing the first one of | |
1107 | those. | |
1108 | ||
861bb6c1 JL |
1109 | @item -ftemplate-depth-@var{n} |
1110 | Set the maximum instantiation depth for template classes to @var{n}. | |
1111 | A limit on the template instantiation depth is needed to detect | |
1112 | endless recursions during template class instantiation. ANSI/ISO C++ | |
1113 | conforming programs must not rely on a maximum depth greater than 17. | |
1114 | ||
74291a4b MM |
1115 | @item -nostdinc++ |
1116 | Do not search for header files in the standard directories specific to | |
1117 | C++, but do still search the other standard directories. (This option | |
1118 | is used when building libg++.) | |
1119 | ||
1120 | @item -traditional | |
1121 | For C++ programs (in addition to the effects that apply to both C and | |
1122 | C++), this has the same effect as @samp{-fthis-is-variable}. | |
1123 | @xref{C Dialect Options,, Options Controlling C Dialect}. | |
1124 | @end table | |
1125 | ||
1126 | In addition, these optimization, warning, and code generation options | |
1127 | have meanings only for C++ programs: | |
1128 | ||
1129 | @table @code | |
1130 | @item -fno-default-inline | |
1131 | Do not assume @samp{inline} for functions defined inside a class scope. | |
1132 | @xref{Optimize Options,,Options That Control Optimization}. | |
1133 | ||
d770d3b3 JM |
1134 | @item -Wold-style-cast |
1135 | @itemx -Woverloaded-virtual | |
74291a4b MM |
1136 | @itemx -Wtemplate-debugging |
1137 | Warnings that apply only to C++ programs. @xref{Warning | |
1138 | Options,,Options to Request or Suppress Warnings}. | |
1139 | ||
861bb6c1 JL |
1140 | @item -Weffc++ |
1141 | Warn about violation of some style rules from Effective C++ by Scott Myers. | |
1142 | ||
74291a4b MM |
1143 | @item +e@var{n} |
1144 | Control how virtual function definitions are used, in a fashion | |
1145 | compatible with @code{cfront} 1.x. @xref{Code Gen Options,,Options for | |
1146 | Code Generation Conventions}. | |
1147 | @end table | |
1148 | ||
1149 | @node Warning Options | |
1150 | @section Options to Request or Suppress Warnings | |
1151 | @cindex options to control warnings | |
1152 | @cindex warning messages | |
1153 | @cindex messages, warning | |
1154 | @cindex suppressing warnings | |
1155 | ||
1156 | Warnings are diagnostic messages that report constructions which | |
1157 | are not inherently erroneous but which are risky or suggest there | |
1158 | may have been an error. | |
1159 | ||
1160 | You can request many specific warnings with options beginning @samp{-W}, | |
1161 | for example @samp{-Wimplicit} to request warnings on implicit | |
1162 | declarations. Each of these specific warning options also has a | |
1163 | negative form beginning @samp{-Wno-} to turn off warnings; | |
1164 | for example, @samp{-Wno-implicit}. This manual lists only one of the | |
1165 | two forms, whichever is not the default. | |
1166 | ||
1167 | These options control the amount and kinds of warnings produced by GNU | |
1168 | CC: | |
1169 | ||
1170 | @table @code | |
1171 | @cindex syntax checking | |
1172 | @item -fsyntax-only | |
1173 | Check the code for syntax errors, but don't do anything beyond that. | |
1174 | ||
1175 | @item -pedantic | |
1176 | Issue all the warnings demanded by strict ANSI standard C; reject | |
1177 | all programs that use forbidden extensions. | |
1178 | ||
1179 | Valid ANSI standard C programs should compile properly with or without | |
1180 | this option (though a rare few will require @samp{-ansi}). However, | |
1181 | without this option, certain GNU extensions and traditional C features | |
1182 | are supported as well. With this option, they are rejected. | |
1183 | ||
1184 | @samp{-pedantic} does not cause warning messages for use of the | |
1185 | alternate keywords whose names begin and end with @samp{__}. Pedantic | |
1186 | warnings are also disabled in the expression that follows | |
1187 | @code{__extension__}. However, only system header files should use | |
1188 | these escape routes; application programs should avoid them. | |
1189 | @xref{Alternate Keywords}. | |
1190 | ||
1191 | This option is not intended to be @i{useful}; it exists only to satisfy | |
1192 | pedants who would otherwise claim that GNU CC fails to support the ANSI | |
1193 | standard. | |
1194 | ||
1195 | Some users try to use @samp{-pedantic} to check programs for strict ANSI | |
1196 | C conformance. They soon find that it does not do quite what they want: | |
1197 | it finds some non-ANSI practices, but not all---only those for which | |
1198 | ANSI C @emph{requires} a diagnostic. | |
1199 | ||
1200 | A feature to report any failure to conform to ANSI C might be useful in | |
1201 | some instances, but would require considerable additional work and would | |
1202 | be quite different from @samp{-pedantic}. We recommend, rather, that | |
1203 | users take advantage of the extensions of GNU C and disregard the | |
1204 | limitations of other compilers. Aside from certain supercomputers and | |
1205 | obsolete small machines, there is less and less reason ever to use any | |
1206 | other C compiler other than for bootstrapping GNU CC. | |
1207 | ||
1208 | @item -pedantic-errors | |
1209 | Like @samp{-pedantic}, except that errors are produced rather than | |
1210 | warnings. | |
1211 | ||
1212 | @item -w | |
1213 | Inhibit all warning messages. | |
1214 | ||
1215 | @item -Wno-import | |
1216 | Inhibit warning messages about the use of @samp{#import}. | |
1217 | ||
1218 | @item -Wchar-subscripts | |
1219 | Warn if an array subscript has type @code{char}. This is a common cause | |
1220 | of error, as programmers often forget that this type is signed on some | |
1221 | machines. | |
1222 | ||
1223 | @item -Wcomment | |
1224 | Warn whenever a comment-start sequence @samp{/*} appears in a @samp{/*} | |
1225 | comment, or whenever a Backslash-Newline appears in a @samp{//} comment. | |
1226 | ||
1227 | @item -Wformat | |
1228 | Check calls to @code{printf} and @code{scanf}, etc., to make sure that | |
1229 | the arguments supplied have types appropriate to the format string | |
1230 | specified. | |
1231 | ||
e9a25f70 JL |
1232 | @item -Wimplicit-int |
1233 | Warn when a declaration does not specify a type. | |
1234 | ||
1235 | @item -Wimplicit-function-declarations | |
1236 | Warn whenever a function is used before being declared. | |
1237 | ||
74291a4b | 1238 | @item -Wimplicit |
e9a25f70 | 1239 | Same as @samp{-Wimplicit-int} @samp{-Wimplicit-function-declaration}. |
861bb6c1 JL |
1240 | |
1241 | @item -Wmain | |
1242 | Warn if the type of @samp{main} is suspicious. @samp{main} should be a | |
1243 | function with external linkage, returning int, taking either zero | |
1244 | arguments, two, or three arguments of appropriate types. | |
1245 | ||
74291a4b MM |
1246 | @item -Wparentheses |
1247 | Warn if parentheses are omitted in certain contexts, such | |
1248 | as when there is an assignment in a context where a truth value | |
1249 | is expected, or when operators are nested whose precedence people | |
1250 | often get confused about. | |
1251 | ||
e9a25f70 JL |
1252 | Also warn about constructions where there may be confusion to which |
1253 | @code{if} statement an @code{else} branch belongs. Here is an example of | |
1254 | such a case: | |
1255 | ||
1256 | @smallexample | |
1257 | @{ | |
1258 | if (a) | |
1259 | if (b) | |
1260 | foo (); | |
1261 | else | |
1262 | bar (); | |
1263 | @} | |
1264 | @end smallexample | |
1265 | ||
1266 | In C, every @code{else} branch belongs to the innermost possible @code{if} | |
1267 | statement, which in this example is @code{if (b)}. This is often not | |
1268 | what the programmer expected, as illustrated in the above example by | |
1269 | indentation the programmer chose. When there is the potential for this | |
1270 | confusion, GNU C will issue a warning when this flag is specified. | |
1271 | To eliminate the warning, add explicit braces around the innermost | |
1272 | @code{if} statement so there is no way the @code{else} could belong to | |
1273 | the enclosing @code{if}. The resulting code would look like this: | |
1274 | ||
1275 | @smallexample | |
1276 | @{ | |
1277 | if (a) | |
1278 | @{ | |
1279 | if (b) | |
1280 | foo (); | |
1281 | else | |
1282 | bar (); | |
1283 | @} | |
1284 | @} | |
1285 | @end smallexample | |
1286 | ||
74291a4b MM |
1287 | @item -Wreturn-type |
1288 | Warn whenever a function is defined with a return-type that defaults | |
1289 | to @code{int}. Also warn about any @code{return} statement with no | |
1290 | return-value in a function whose return-type is not @code{void}. | |
1291 | ||
1292 | @item -Wswitch | |
1293 | Warn whenever a @code{switch} statement has an index of enumeral type | |
1294 | and lacks a @code{case} for one or more of the named codes of that | |
1295 | enumeration. (The presence of a @code{default} label prevents this | |
1296 | warning.) @code{case} labels outside the enumeration range also | |
1297 | provoke warnings when this option is used. | |
1298 | ||
1299 | @item -Wtrigraphs | |
1300 | Warn if any trigraphs are encountered (assuming they are enabled). | |
1301 | ||
1302 | @item -Wunused | |
1303 | Warn whenever a variable is unused aside from its declaration, | |
1304 | whenever a function is declared static but never defined, whenever a | |
1305 | label is declared but not used, and whenever a statement computes a | |
1306 | result that is explicitly not used. | |
1307 | ||
1308 | To suppress this warning for an expression, simply cast it to void. For | |
1309 | unused variables and parameters, use the @samp{unused} attribute | |
1310 | (@pxref{Variable Attributes}). | |
1311 | ||
1312 | @item -Wuninitialized | |
1313 | An automatic variable is used without first being initialized. | |
1314 | ||
1315 | These warnings are possible only in optimizing compilation, | |
1316 | because they require data flow information that is computed only | |
1317 | when optimizing. If you don't specify @samp{-O}, you simply won't | |
1318 | get these warnings. | |
1319 | ||
1320 | These warnings occur only for variables that are candidates for | |
1321 | register allocation. Therefore, they do not occur for a variable that | |
1322 | is declared @code{volatile}, or whose address is taken, or whose size | |
1323 | is other than 1, 2, 4 or 8 bytes. Also, they do not occur for | |
1324 | structures, unions or arrays, even when they are in registers. | |
1325 | ||
1326 | Note that there may be no warning about a variable that is used only | |
1327 | to compute a value that itself is never used, because such | |
1328 | computations may be deleted by data flow analysis before the warnings | |
1329 | are printed. | |
1330 | ||
1331 | These warnings are made optional because GNU CC is not smart | |
1332 | enough to see all the reasons why the code might be correct | |
1333 | despite appearing to have an error. Here is one example of how | |
1334 | this can happen: | |
1335 | ||
1336 | @smallexample | |
1337 | @{ | |
1338 | int x; | |
1339 | switch (y) | |
1340 | @{ | |
1341 | case 1: x = 1; | |
1342 | break; | |
1343 | case 2: x = 4; | |
1344 | break; | |
1345 | case 3: x = 5; | |
1346 | @} | |
1347 | foo (x); | |
1348 | @} | |
1349 | @end smallexample | |
1350 | ||
1351 | @noindent | |
1352 | If the value of @code{y} is always 1, 2 or 3, then @code{x} is | |
1353 | always initialized, but GNU CC doesn't know this. Here is | |
1354 | another common case: | |
1355 | ||
1356 | @smallexample | |
1357 | @{ | |
1358 | int save_y; | |
1359 | if (change_y) save_y = y, y = new_y; | |
1360 | @dots{} | |
1361 | if (change_y) y = save_y; | |
1362 | @} | |
1363 | @end smallexample | |
1364 | ||
1365 | @noindent | |
1366 | This has no bug because @code{save_y} is used only if it is set. | |
1367 | ||
1368 | Some spurious warnings can be avoided if you declare all the functions | |
1369 | you use that never return as @code{noreturn}. @xref{Function | |
1370 | Attributes}. | |
1371 | ||
1372 | @item -Wreorder (C++ only) | |
1373 | @cindex reordering, warning | |
1374 | @cindex warning for reordering of member initializers | |
1375 | Warn when the order of member initializers given in the code does not | |
1376 | match the order in which they must be executed. For instance: | |
1377 | ||
1378 | @smallexample | |
1379 | struct A @{ | |
1380 | int i; | |
1381 | int j; | |
1382 | A(): j (0), i (1) @{ @} | |
1383 | @}; | |
1384 | @end smallexample | |
1385 | ||
1386 | Here the compiler will warn that the member initializers for @samp{i} | |
1387 | and @samp{j} will be rearranged to match the declaration order of the | |
1388 | members. | |
1389 | ||
74291a4b MM |
1390 | @item -Wtemplate-debugging |
1391 | @cindex template debugging | |
1392 | When using templates in a C++ program, warn if debugging is not yet | |
1393 | fully available (C++ only). | |
1394 | ||
1395 | @item -Wall | |
1396 | All of the above @samp{-W} options combined. This enables all the | |
1397 | warnings about constructions that some users consider questionable, and | |
1398 | that are easy to avoid (or modify to prevent the warning), even in | |
1399 | conjunction with macros. | |
1400 | @end table | |
1401 | ||
1402 | The following @samp{-W@dots{}} options are not implied by @samp{-Wall}. | |
1403 | Some of them warn about constructions that users generally do not | |
1404 | consider questionable, but which occasionally you might wish to check | |
1405 | for; others warn about constructions that are necessary or hard to avoid | |
1406 | in some cases, and there is no simple way to modify the code to suppress | |
1407 | the warning. | |
1408 | ||
1409 | @table @code | |
1410 | @item -W | |
1411 | Print extra warning messages for these events: | |
1412 | ||
1413 | @itemize @bullet | |
1414 | @cindex @code{longjmp} warnings | |
1415 | @item | |
1416 | A nonvolatile automatic variable might be changed by a call to | |
1417 | @code{longjmp}. These warnings as well are possible only in | |
1418 | optimizing compilation. | |
1419 | ||
1420 | The compiler sees only the calls to @code{setjmp}. It cannot know | |
1421 | where @code{longjmp} will be called; in fact, a signal handler could | |
1422 | call it at any point in the code. As a result, you may get a warning | |
1423 | even when there is in fact no problem because @code{longjmp} cannot | |
1424 | in fact be called at the place which would cause a problem. | |
1425 | ||
1426 | @item | |
1427 | A function can return either with or without a value. (Falling | |
1428 | off the end of the function body is considered returning without | |
1429 | a value.) For example, this function would evoke such a | |
1430 | warning: | |
1431 | ||
1432 | @smallexample | |
1433 | @group | |
1434 | foo (a) | |
1435 | @{ | |
1436 | if (a > 0) | |
1437 | return a; | |
1438 | @} | |
1439 | @end group | |
1440 | @end smallexample | |
1441 | ||
1442 | @item | |
1443 | An expression-statement or the left-hand side of a comma expression | |
1444 | contains no side effects. | |
1445 | To suppress the warning, cast the unused expression to void. | |
1446 | For example, an expression such as @samp{x[i,j]} will cause a warning, | |
1447 | but @samp{x[(void)i,j]} will not. | |
1448 | ||
1449 | @item | |
1450 | An unsigned value is compared against zero with @samp{<} or @samp{<=}. | |
1451 | ||
1452 | @item | |
1453 | A comparison like @samp{x<=y<=z} appears; this is equivalent to | |
1454 | @samp{(x<=y ? 1 : 0) <= z}, which is a different interpretation from | |
1455 | that of ordinary mathematical notation. | |
1456 | ||
1457 | @item | |
1458 | Storage-class specifiers like @code{static} are not the first things in | |
1459 | a declaration. According to the C Standard, this usage is obsolescent. | |
1460 | ||
1461 | @item | |
1462 | If @samp{-Wall} or @samp{-Wunused} is also specified, warn about unused | |
1463 | arguments. | |
1464 | ||
e9a25f70 JL |
1465 | @item |
1466 | A comparison between signed and unsigned values could produce an | |
1467 | incorrect result when the signed value is converted to unsigned. | |
1468 | (But do not warn if @samp{-Wno-sign-compare} is also specified.) | |
1469 | ||
74291a4b MM |
1470 | @item |
1471 | An aggregate has a partly bracketed initializer. | |
1472 | For example, the following code would evoke such a warning, | |
1473 | because braces are missing around the initializer for @code{x.h}: | |
1474 | ||
1475 | @smallexample | |
1476 | struct s @{ int f, g; @}; | |
1477 | struct t @{ struct s h; int i; @}; | |
1478 | struct t x = @{ 1, 2, 3 @}; | |
1479 | @end smallexample | |
1480 | @end itemize | |
1481 | ||
1482 | @item -Wtraditional | |
1483 | Warn about certain constructs that behave differently in traditional and | |
1484 | ANSI C. | |
1485 | ||
1486 | @itemize @bullet | |
1487 | @item | |
1488 | Macro arguments occurring within string constants in the macro body. | |
1489 | These would substitute the argument in traditional C, but are part of | |
1490 | the constant in ANSI C. | |
1491 | ||
1492 | @item | |
1493 | A function declared external in one block and then used after the end of | |
1494 | the block. | |
1495 | ||
1496 | @item | |
1497 | A @code{switch} statement has an operand of type @code{long}. | |
1498 | @end itemize | |
1499 | ||
861bb6c1 JL |
1500 | @item -Wundef |
1501 | Warn if an undefined identifier is evaluated in an @samp{#if} directive. | |
1502 | ||
74291a4b MM |
1503 | @item -Wshadow |
1504 | Warn whenever a local variable shadows another local variable. | |
1505 | ||
1506 | @item -Wid-clash-@var{len} | |
1507 | Warn whenever two distinct identifiers match in the first @var{len} | |
1508 | characters. This may help you prepare a program that will compile | |
1509 | with certain obsolete, brain-damaged compilers. | |
1510 | ||
1511 | @item -Wlarger-than-@var{len} | |
1512 | Warn whenever an object of larger than @var{len} bytes is defined. | |
1513 | ||
1514 | @item -Wpointer-arith | |
1515 | Warn about anything that depends on the ``size of'' a function type or | |
1516 | of @code{void}. GNU C assigns these types a size of 1, for | |
1517 | convenience in calculations with @code{void *} pointers and pointers | |
1518 | to functions. | |
1519 | ||
1520 | @item -Wbad-function-cast | |
1521 | Warn whenever a function call is cast to a non-matching type. | |
1522 | For example, warn if @code{int malloc()} is cast to @code{anything *}. | |
1523 | ||
1524 | @item -Wcast-qual | |
1525 | Warn whenever a pointer is cast so as to remove a type qualifier from | |
1526 | the target type. For example, warn if a @code{const char *} is cast | |
1527 | to an ordinary @code{char *}. | |
1528 | ||
1529 | @item -Wcast-align | |
1530 | Warn whenever a pointer is cast such that the required alignment of the | |
1531 | target is increased. For example, warn if a @code{char *} is cast to | |
1532 | an @code{int *} on machines where integers can only be accessed at | |
1533 | two- or four-byte boundaries. | |
1534 | ||
1535 | @item -Wwrite-strings | |
1536 | Give string constants the type @code{const char[@var{length}]} so that | |
1537 | copying the address of one into a non-@code{const} @code{char *} | |
1538 | pointer will get a warning. These warnings will help you find at | |
1539 | compile time code that can try to write into a string constant, but | |
1540 | only if you have been very careful about using @code{const} in | |
1541 | declarations and prototypes. Otherwise, it will just be a nuisance; | |
1542 | this is why we did not make @samp{-Wall} request these warnings. | |
1543 | ||
1544 | @item -Wconversion | |
1545 | Warn if a prototype causes a type conversion that is different from what | |
1546 | would happen to the same argument in the absence of a prototype. This | |
1547 | includes conversions of fixed point to floating and vice versa, and | |
1548 | conversions changing the width or signedness of a fixed point argument | |
1549 | except when the same as the default promotion. | |
1550 | ||
1551 | Also, warn if a negative integer constant expression is implicitly | |
1552 | converted to an unsigned type. For example, warn about the assignment | |
1553 | @code{x = -1} if @code{x} is unsigned. But do not warn about explicit | |
1554 | casts like @code{(unsigned) -1}. | |
1555 | ||
e9a25f70 JL |
1556 | @item -Wsign-compare |
1557 | @cindex warning for comparison of signed and unsigned values | |
1558 | @cindex comparison of signed and unsigned values, warning | |
1559 | @cindex signed and unsigned values, comparison warning | |
1560 | Warn when a comparison between signed and unsigned values could produce | |
1561 | an incorrect result when the signed value is converted to unsigned. | |
1562 | This warning is also enabled by @samp{-W}; to get the other warnings | |
1563 | of @samp{-W} without this warning, use @samp{-W -Wno-sign-compare}. | |
1564 | ||
74291a4b MM |
1565 | @item -Waggregate-return |
1566 | Warn if any functions that return structures or unions are defined or | |
1567 | called. (In languages where you can return an array, this also elicits | |
1568 | a warning.) | |
1569 | ||
1570 | @item -Wstrict-prototypes | |
1571 | Warn if a function is declared or defined without specifying the | |
1572 | argument types. (An old-style function definition is permitted without | |
1573 | a warning if preceded by a declaration which specifies the argument | |
1574 | types.) | |
1575 | ||
1576 | @item -Wmissing-prototypes | |
1577 | Warn if a global function is defined without a previous prototype | |
1578 | declaration. This warning is issued even if the definition itself | |
1579 | provides a prototype. The aim is to detect global functions that fail | |
1580 | to be declared in header files. | |
1581 | ||
1582 | @item -Wmissing-declarations | |
1583 | Warn if a global function is defined without a previous declaration. | |
1584 | Do so even if the definition itself provides a prototype. | |
1585 | Use this option to detect global functions that are not declared in | |
1586 | header files. | |
1587 | ||
1588 | @item -Wredundant-decls | |
1589 | Warn if anything is declared more than once in the same scope, even in | |
1590 | cases where multiple declaration is valid and changes nothing. | |
1591 | ||
1592 | @item -Wnested-externs | |
1593 | Warn if an @code{extern} declaration is encountered within an function. | |
1594 | ||
1595 | @item -Winline | |
1596 | Warn if a function can not be inlined, and either it was declared as inline, | |
1597 | or else the @samp{-finline-functions} option was given. | |
1598 | ||
d770d3b3 JM |
1599 | @item -Wold-style-cast |
1600 | Warn if an old-style (C-style) cast is used within a program. | |
1601 | ||
74291a4b MM |
1602 | @item -Woverloaded-virtual |
1603 | @cindex overloaded virtual fn, warning | |
1604 | @cindex warning for overloaded virtual fn | |
1605 | Warn when a derived class function declaration may be an error in | |
1606 | defining a virtual function (C++ only). In a derived class, the | |
1607 | definitions of virtual functions must match the type signature of a | |
1608 | virtual function declared in the base class. With this option, the | |
1609 | compiler warns when you define a function with the same name as a | |
1610 | virtual function, but with a type signature that does not match any | |
1611 | declarations from the base class. | |
1612 | ||
1613 | @item -Wsynth (C++ only) | |
1614 | @cindex warning for synthesized methods | |
1615 | @cindex synthesized methods, warning | |
1616 | Warn when g++'s synthesis behavior does not match that of cfront. For | |
1617 | instance: | |
1618 | ||
1619 | @smallexample | |
1620 | struct A @{ | |
1621 | operator int (); | |
1622 | A& operator = (int); | |
1623 | @}; | |
1624 | ||
1625 | main () | |
1626 | @{ | |
1627 | A a,b; | |
1628 | a = b; | |
1629 | @} | |
1630 | @end smallexample | |
1631 | ||
1632 | In this example, g++ will synthesize a default @samp{A& operator = | |
1633 | (const A&);}, while cfront will use the user-defined @samp{operator =}. | |
1634 | ||
1635 | @item -Werror | |
1636 | Make all warnings into errors. | |
1637 | @end table | |
1638 | ||
1639 | @node Debugging Options | |
1640 | @section Options for Debugging Your Program or GNU CC | |
1641 | @cindex options, debugging | |
1642 | @cindex debugging information options | |
1643 | ||
1644 | GNU CC has various special options that are used for debugging | |
1645 | either your program or GCC: | |
1646 | ||
1647 | @table @code | |
1648 | @item -g | |
1649 | Produce debugging information in the operating system's native format | |
1650 | (stabs, COFF, XCOFF, or DWARF). GDB can work with this debugging | |
1651 | information. | |
1652 | ||
1653 | On most systems that use stabs format, @samp{-g} enables use of extra | |
1654 | debugging information that only GDB can use; this extra information | |
1655 | makes debugging work better in GDB but will probably make other debuggers | |
1656 | crash or | |
1657 | refuse to read the program. If you want to control for certain whether | |
1658 | to generate the extra information, use @samp{-gstabs+}, @samp{-gstabs}, | |
861bb6c1 | 1659 | @samp{-gxcoff+}, @samp{-gxcoff}, @samp{-gdwarf-1+}, or @samp{-gdwarf-1} |
74291a4b MM |
1660 | (see below). |
1661 | ||
1662 | Unlike most other C compilers, GNU CC allows you to use @samp{-g} with | |
1663 | @samp{-O}. The shortcuts taken by optimized code may occasionally | |
1664 | produce surprising results: some variables you declared may not exist | |
1665 | at all; flow of control may briefly move where you did not expect it; | |
1666 | some statements may not be executed because they compute constant | |
1667 | results or their values were already at hand; some statements may | |
1668 | execute in different places because they were moved out of loops. | |
1669 | ||
1670 | Nevertheless it proves possible to debug optimized output. This makes | |
1671 | it reasonable to use the optimizer for programs that might have bugs. | |
1672 | ||
1673 | The following options are useful when GNU CC is generated with the | |
1674 | capability for more than one debugging format. | |
1675 | ||
1676 | @item -ggdb | |
861bb6c1 JL |
1677 | Produce debugging information for use by GDB. This means to use the |
1678 | most expressive format available (DWARF 2, stabs, or the native format | |
1679 | if neither of those are supported), including GDB extensions if at all | |
1680 | possible. | |
74291a4b MM |
1681 | |
1682 | @item -gstabs | |
1683 | Produce debugging information in stabs format (if that is supported), | |
1684 | without GDB extensions. This is the format used by DBX on most BSD | |
1685 | systems. On MIPS, Alpha and System V Release 4 systems this option | |
1686 | produces stabs debugging output which is not understood by DBX or SDB. | |
1687 | On System V Release 4 systems this option requires the GNU assembler. | |
1688 | ||
1689 | @item -gstabs+ | |
1690 | Produce debugging information in stabs format (if that is supported), | |
1691 | using GNU extensions understood only by the GNU debugger (GDB). The | |
1692 | use of these extensions is likely to make other debuggers crash or | |
1693 | refuse to read the program. | |
1694 | ||
1695 | @item -gcoff | |
1696 | Produce debugging information in COFF format (if that is supported). | |
1697 | This is the format used by SDB on most System V systems prior to | |
1698 | System V Release 4. | |
1699 | ||
1700 | @item -gxcoff | |
1701 | Produce debugging information in XCOFF format (if that is supported). | |
1702 | This is the format used by the DBX debugger on IBM RS/6000 systems. | |
1703 | ||
1704 | @item -gxcoff+ | |
1705 | Produce debugging information in XCOFF format (if that is supported), | |
1706 | using GNU extensions understood only by the GNU debugger (GDB). The | |
1707 | use of these extensions is likely to make other debuggers crash or | |
1708 | refuse to read the program, and may cause assemblers other than the GNU | |
1709 | assembler (GAS) to fail with an error. | |
1710 | ||
1711 | @item -gdwarf | |
861bb6c1 JL |
1712 | Produce debugging information in DWARF version 1 format (if that is |
1713 | supported). This is the format used by SDB on most System V Release 4 | |
1714 | systems. | |
74291a4b MM |
1715 | |
1716 | @item -gdwarf+ | |
861bb6c1 JL |
1717 | Produce debugging information in DWARF version 1 format (if that is |
1718 | supported), using GNU extensions understood only by the GNU debugger | |
1719 | (GDB). The use of these extensions is likely to make other debuggers | |
1720 | crash or refuse to read the program. | |
1721 | ||
1722 | @item -gdwarf-2 | |
1723 | Produce debugging information in DWARF version 2 format (if that is | |
1724 | supported). This is the format used by DBX on IRIX 6. | |
74291a4b MM |
1725 | |
1726 | @item -g@var{level} | |
1727 | @itemx -ggdb@var{level} | |
1728 | @itemx -gstabs@var{level} | |
1729 | @itemx -gcoff@var{level} | |
1730 | @itemx -gxcoff@var{level} | |
1731 | @itemx -gdwarf@var{level} | |
861bb6c1 | 1732 | @itemx -gdwarf-2@var{level} |
74291a4b MM |
1733 | Request debugging information and also use @var{level} to specify how |
1734 | much information. The default level is 2. | |
1735 | ||
1736 | Level 1 produces minimal information, enough for making backtraces in | |
1737 | parts of the program that you don't plan to debug. This includes | |
1738 | descriptions of functions and external variables, but no information | |
1739 | about local variables and no line numbers. | |
1740 | ||
1741 | Level 3 includes extra information, such as all the macro definitions | |
1742 | present in the program. Some debuggers support macro expansion when | |
1743 | you use @samp{-g3}. | |
1744 | ||
1745 | @cindex @code{prof} | |
1746 | @item -p | |
1747 | Generate extra code to write profile information suitable for the | |
1748 | analysis program @code{prof}. You must use this option when compiling | |
1749 | the source files you want data about, and you must also use it when | |
1750 | linking. | |
1751 | ||
1752 | @cindex @code{gprof} | |
1753 | @item -pg | |
1754 | Generate extra code to write profile information suitable for the | |
1755 | analysis program @code{gprof}. You must use this option when compiling | |
1756 | the source files you want data about, and you must also use it when | |
1757 | linking. | |
1758 | ||
1759 | @cindex @code{tcov} | |
1760 | @item -a | |
1761 | Generate extra code to write profile information for basic blocks, which will | |
1762 | record the number of times each basic block is executed, the basic block start | |
1763 | address, and the function name containing the basic block. If @samp{-g} is | |
1764 | used, the line number and filename of the start of the basic block will also be | |
1765 | recorded. If not overridden by the machine description, the default action is | |
1766 | to append to the text file @file{bb.out}. | |
1767 | ||
1768 | This data could be analyzed by a program like @code{tcov}. Note, | |
1769 | however, that the format of the data is not what @code{tcov} expects. | |
1770 | Eventually GNU @code{gprof} should be extended to process this data. | |
1771 | ||
1772 | @item -ax | |
1773 | Generate extra code to profile basic blocks. Your executable will | |
1774 | produce output that is a superset of that produced when @samp{-a} is | |
1775 | used. Additional output is the source and target address of the basic | |
1776 | blocks where a jump takes place, the number of times a jump is executed, | |
1777 | and (optionally) the complete sequence of basic blocks being executed. | |
1778 | The output is appended to file @file{bb.out}. | |
1779 | ||
1780 | You can examine different profiling aspects without recompilation. Your | |
1781 | execuable will read a list of function names from file @file{bb.in}. | |
1782 | Profiling starts when a function on the list is entered and stops when | |
1783 | that invocation is exited. To exclude a function from profiling, prefix | |
1784 | its name with `-'. If a function name is not unique, you can | |
1785 | disambiguate it by writing it in the form | |
1786 | @samp{/path/filename.d:functionname}. Your executable will write the | |
1787 | available paths and filenames in file @file{bb.out}. | |
1788 | ||
1789 | Several function names have a special meaning: | |
1790 | @table @code | |
1791 | @item __bb_jumps__ | |
1792 | Write source, target and frequency of jumps to file @file{bb.out}. | |
1793 | @item __bb_hidecall__ | |
1794 | Exclude function calls from frequency count. | |
1795 | @item __bb_showret__ | |
1796 | Include function returns in frequency count. | |
1797 | @item __bb_trace__ | |
1798 | Write the sequence of basic blocks executed to file @file{bbtrace.gz}. | |
1799 | The file will be compressed using the program @samp{gzip}, which must | |
1800 | exist in your @code{PATH}. On systems without the @samp{popen} | |
1801 | function, the file will be named @file{bbtrace} and will not be | |
1802 | compressed. @strong{Profiling for even a few seconds on these systems | |
1803 | will produce a very large file.} Note: @code{__bb_hidecall__} and | |
1804 | @code{__bb_showret__} will not affect the sequence written to | |
1805 | @file{bbtrace.gz}. | |
1806 | @end table | |
1807 | ||
1808 | Here's a short example using different profiling parameters | |
1809 | in file @file{bb.in}. Assume function @code{foo} consists of basic blocks | |
1810 | 1 and 2 and is called twice from block 3 of function @code{main}. After | |
1811 | the calls, block 3 transfers control to block 4 of @code{main}. | |
1812 | ||
1813 | With @code{__bb_trace__} and @code{main} contained in file @file{bb.in}, | |
1814 | the following sequence of blocks is written to file @file{bbtrace.gz}: | |
1815 | 0 3 1 2 1 2 4. The return from block 2 to block 3 is not shown, because | |
1816 | the return is to a point inside the block and not to the top. The | |
1817 | block address 0 always indicates, that control is transferred | |
1818 | to the trace from somewhere outside the observed functions. With | |
1819 | @samp{-foo} added to @file{bb.in}, the blocks of function | |
1820 | @code{foo} are removed from the trace, so only 0 3 4 remains. | |
1821 | ||
1822 | With @code{__bb_jumps__} and @code{main} contained in file @file{bb.in}, | |
1823 | jump frequencies will be written to file @file{bb.out}. The | |
1824 | frequencies are obtained by constructing a trace of blocks | |
1825 | and incrementing a counter for every neighbouring pair of blocks | |
1826 | in the trace. The trace 0 3 1 2 1 2 4 displays the following | |
1827 | frequencies: | |
1828 | ||
1829 | @example | |
1830 | Jump from block 0x0 to block 0x3 executed 1 time(s) | |
1831 | Jump from block 0x3 to block 0x1 executed 1 time(s) | |
1832 | Jump from block 0x1 to block 0x2 executed 2 time(s) | |
1833 | Jump from block 0x2 to block 0x1 executed 1 time(s) | |
1834 | Jump from block 0x2 to block 0x4 executed 1 time(s) | |
1835 | @end example | |
1836 | ||
1837 | With @code{__bb_hidecall__}, control transfer due to call instructions | |
1838 | is removed from the trace, that is the trace is cut into three parts: 0 | |
1839 | 3 4, 0 1 2 and 0 1 2. With @code{__bb_showret__}, control transfer due | |
1840 | to return instructions is added to the trace. The trace becomes: 0 3 1 | |
1841 | 2 3 1 2 3 4. Note, that this trace is not the same, as the sequence | |
1842 | written to @file{bbtrace.gz}. It is solely used for counting jump | |
1843 | frequencies. | |
1844 | ||
861bb6c1 JL |
1845 | @item -fprofile-arcs |
1846 | Instrument @dfn{arcs} during compilation. For each function of your | |
1847 | program, GNU CC creates a program flow graph, then finds a spanning tree | |
1848 | for the graph. Only arcs that are not on the spanning tree have to be | |
1849 | instrumented: the compiler adds code to count the number of times that these | |
1850 | arcs are executed. When an arc is the only exit or only entrance to a | |
1851 | block, the instrumentation code can be added to the block; otherwise, a | |
1852 | new basic block must be created to hold the instrumentation code. | |
1853 | ||
1854 | Since not every arc in the program must be instrumented, programs | |
1855 | compiled with this option run faster than programs compiled with | |
1856 | @samp{-a}, which adds instrumentation code to every basic block in the | |
1857 | program. The tradeoff: since @code{gcov} does not have | |
1858 | execution counts for all branches, it must start with the execution | |
1859 | counts for the instrumented branches, and then iterate over the program | |
1860 | flow graph until the entire graph has been solved. Hence, @code{gcov} | |
1861 | runs a little more slowly than a program which uses information from | |
1862 | @samp{-a}. | |
1863 | ||
1864 | @samp{-fprofile-arcs} also makes it possible to estimate branch | |
1865 | probabilities, and to calculate basic block execution counts. In | |
1866 | general, basic block execution counts do not give enough information to | |
1867 | estimate all branch probabilities. When the compiled program exits, it | |
1868 | saves the arc execution counts to a file called | |
1869 | @file{@var{sourcename}.da}. Use the compiler option | |
1870 | @samp{-fbranch-probabilities} (@pxref{Optimize Options,,Options that | |
1871 | Control Optimization}) when recompiling, to optimize using estimated | |
1872 | branch probabilities. | |
1873 | ||
1874 | @need 2000 | |
1875 | @item -ftest-coverage | |
1876 | Create data files for the @code{gcov} code-coverage utility | |
1877 | (@pxref{Gcov,, @code{gcov}: a GNU CC Test Coverage Program}). | |
1878 | The data file names begin with the name of your source file: | |
1879 | ||
1880 | @table @code | |
1881 | @item @var{sourcename}.bb | |
1882 | A mapping from basic blocks to line numbers, which @code{gcov} uses to | |
1883 | associate basic block execution counts with line numbers. | |
1884 | ||
1885 | @item @var{sourcename}.bbg | |
1886 | A list of all arcs in the program flow graph. This allows @code{gcov} | |
1887 | to reconstruct the program flow graph, so that it can compute all basic | |
1888 | block and arc execution counts from the information in the | |
1889 | @code{@var{sourcename}.da} file (this last file is the output from | |
1890 | @samp{-fprofile-arcs}). | |
1891 | @end table | |
1892 | ||
74291a4b MM |
1893 | @item -d@var{letters} |
1894 | Says to make debugging dumps during compilation at times specified by | |
1895 | @var{letters}. This is used for debugging the compiler. The file names | |
1896 | for most of the dumps are made by appending a word to the source file | |
1897 | name (e.g. @file{foo.c.rtl} or @file{foo.c.jump}). Here are the | |
1898 | possible letters for use in @var{letters}, and their meanings: | |
1899 | ||
1900 | @table @samp | |
1901 | @item M | |
1902 | Dump all macro definitions, at the end of preprocessing, and write no | |
1903 | output. | |
1904 | @item N | |
1905 | Dump all macro names, at the end of preprocessing. | |
1906 | @item D | |
1907 | Dump all macro definitions, at the end of preprocessing, in addition to | |
1908 | normal output. | |
1909 | @item y | |
1910 | Dump debugging information during parsing, to standard error. | |
1911 | @item r | |
1912 | Dump after RTL generation, to @file{@var{file}.rtl}. | |
1913 | @item x | |
1914 | Just generate RTL for a function instead of compiling it. Usually used | |
1915 | with @samp{r}. | |
1916 | @item j | |
1917 | Dump after first jump optimization, to @file{@var{file}.jump}. | |
1918 | @item s | |
1919 | Dump after CSE (including the jump optimization that sometimes | |
1920 | follows CSE), to @file{@var{file}.cse}. | |
1921 | @item L | |
1922 | Dump after loop optimization, to @file{@var{file}.loop}. | |
1923 | @item t | |
1924 | Dump after the second CSE pass (including the jump optimization that | |
1925 | sometimes follows CSE), to @file{@var{file}.cse2}. | |
1926 | @item f | |
1927 | Dump after flow analysis, to @file{@var{file}.flow}. | |
1928 | @item c | |
1929 | Dump after instruction combination, to the file | |
1930 | @file{@var{file}.combine}. | |
1931 | @item S | |
1932 | Dump after the first instruction scheduling pass, to | |
1933 | @file{@var{file}.sched}. | |
1934 | @item l | |
1935 | Dump after local register allocation, to | |
1936 | @file{@var{file}.lreg}. | |
1937 | @item g | |
1938 | Dump after global register allocation, to | |
1939 | @file{@var{file}.greg}. | |
1940 | @item R | |
1941 | Dump after the second instruction scheduling pass, to | |
1942 | @file{@var{file}.sched2}. | |
1943 | @item J | |
1944 | Dump after last jump optimization, to @file{@var{file}.jump2}. | |
1945 | @item d | |
1946 | Dump after delayed branch scheduling, to @file{@var{file}.dbr}. | |
1947 | @item k | |
1948 | Dump after conversion from registers to stack, to @file{@var{file}.stack}. | |
1949 | @item a | |
1950 | Produce all the dumps listed above. | |
1951 | @item m | |
1952 | Print statistics on memory usage, at the end of the run, to | |
1953 | standard error. | |
1954 | @item p | |
1955 | Annotate the assembler output with a comment indicating which | |
1956 | pattern and alternative was used. | |
1957 | @item A | |
1958 | Annotate the assembler output with miscellaneous debugging information. | |
1959 | @end table | |
1960 | ||
1961 | @item -fpretend-float | |
1962 | When running a cross-compiler, pretend that the target machine uses the | |
1963 | same floating point format as the host machine. This causes incorrect | |
1964 | output of the actual floating constants, but the actual instruction | |
1965 | sequence will probably be the same as GNU CC would make when running on | |
1966 | the target machine. | |
1967 | ||
1968 | @item -save-temps | |
1969 | Store the usual ``temporary'' intermediate files permanently; place them | |
1970 | in the current directory and name them based on the source file. Thus, | |
1971 | compiling @file{foo.c} with @samp{-c -save-temps} would produce files | |
1972 | @file{foo.i} and @file{foo.s}, as well as @file{foo.o}. | |
1973 | ||
1974 | @item -print-file-name=@var{library} | |
1975 | Print the full absolute name of the library file @var{library} that | |
1976 | would be used when linking---and don't do anything else. With this | |
1977 | option, GNU CC does not compile or link anything; it just prints the | |
1978 | file name. | |
1979 | ||
1980 | @item -print-prog-name=@var{program} | |
1981 | Like @samp{-print-file-name}, but searches for a program such as @samp{cpp}. | |
1982 | ||
1983 | @item -print-libgcc-file-name | |
1984 | Same as @samp{-print-file-name=libgcc.a}. | |
1985 | ||
1986 | This is useful when you use @samp{-nostdlib} or @samp{-nodefaultlibs} | |
1987 | but you do want to link with @file{libgcc.a}. You can do | |
1988 | ||
1989 | @example | |
1990 | gcc -nostdlib @var{files}@dots{} `gcc -print-libgcc-file-name` | |
1991 | @end example | |
1992 | ||
1993 | @item -print-search-dirs | |
1994 | Print the name of the configured installation directory and a list of | |
1995 | program and library directories gcc will search---and don't do anything else. | |
1996 | ||
1997 | This is useful when gcc prints the error message | |
1998 | @samp{installation problem, cannot exec cpp: No such file or directory}. | |
1999 | To resolve this you either need to put @file{cpp} and the other compiler | |
2000 | components where gcc expects to find them, or you can set the environment | |
2001 | variable @code{GCC_EXEC_PREFIX} to the directory where you installed them. | |
2002 | Don't forget the trailing '/'. | |
2003 | @xref{Environment Variables}. | |
2004 | @end table | |
2005 | ||
2006 | @node Optimize Options | |
2007 | @section Options That Control Optimization | |
2008 | @cindex optimize options | |
2009 | @cindex options, optimization | |
2010 | ||
2011 | These options control various sorts of optimizations: | |
2012 | ||
2013 | @table @code | |
2014 | @item -O | |
2015 | @itemx -O1 | |
2016 | Optimize. Optimizing compilation takes somewhat more time, and a lot | |
2017 | more memory for a large function. | |
2018 | ||
2019 | Without @samp{-O}, the compiler's goal is to reduce the cost of | |
2020 | compilation and to make debugging produce the expected results. | |
2021 | Statements are independent: if you stop the program with a breakpoint | |
2022 | between statements, you can then assign a new value to any variable or | |
2023 | change the program counter to any other statement in the function and | |
2024 | get exactly the results you would expect from the source code. | |
2025 | ||
2026 | Without @samp{-O}, the compiler only allocates variables declared | |
2027 | @code{register} in registers. The resulting compiled code is a little | |
2028 | worse than produced by PCC without @samp{-O}. | |
2029 | ||
2030 | With @samp{-O}, the compiler tries to reduce code size and execution | |
2031 | time. | |
2032 | ||
2033 | When you specify @samp{-O}, the compiler turns on @samp{-fthread-jumps} | |
2034 | and @samp{-fdefer-pop} on all machines. The compiler turns on | |
2035 | @samp{-fdelayed-branch} on machines that have delay slots, and | |
2036 | @samp{-fomit-frame-pointer} on machines that can support debugging even | |
2037 | without a frame pointer. On some machines the compiler also turns | |
2038 | on other flags.@refill | |
2039 | ||
2040 | @item -O2 | |
2041 | Optimize even more. GNU CC performs nearly all supported optimizations | |
2042 | that do not involve a space-speed tradeoff. The compiler does not | |
2043 | perform loop unrolling or function inlining when you specify @samp{-O2}. | |
2044 | As compared to @samp{-O}, this option increases both compilation time | |
2045 | and the performance of the generated code. | |
2046 | ||
2047 | @samp{-O2} turns on all optional optimizations except for loop unrolling | |
2048 | and function inlining. It also turns on the @samp{-fforce-mem} option | |
2049 | on all machines and frame pointer elimination on machines where doing so | |
2050 | does not interfere with debugging. | |
2051 | ||
2052 | @item -O3 | |
2053 | Optimize yet more. @samp{-O3} turns on all optimizations specified by | |
2054 | @samp{-O2} and also turns on the @samp{inline-functions} option. | |
2055 | ||
2056 | @item -O0 | |
2057 | Do not optimize. | |
2058 | ||
2059 | If you use multiple @samp{-O} options, with or without level numbers, | |
2060 | the last such option is the one that is effective. | |
2061 | @end table | |
2062 | ||
2063 | Options of the form @samp{-f@var{flag}} specify machine-independent | |
2064 | flags. Most flags have both positive and negative forms; the negative | |
2065 | form of @samp{-ffoo} would be @samp{-fno-foo}. In the table below, | |
2066 | only one of the forms is listed---the one which is not the default. | |
2067 | You can figure out the other form by either removing @samp{no-} or | |
2068 | adding it. | |
2069 | ||
2070 | @table @code | |
2071 | @item -ffloat-store | |
2072 | Do not store floating point variables in registers, and inhibit other | |
2073 | options that might change whether a floating point value is taken from a | |
2074 | register or memory. | |
2075 | ||
2076 | @cindex floating point precision | |
2077 | This option prevents undesirable excess precision on machines such as | |
2078 | the 68000 where the floating registers (of the 68881) keep more | |
2079 | precision than a @code{double} is supposed to have. Similarly for the | |
2080 | x86 architecture. For most programs, the excess precision does only | |
2081 | good, but a few programs rely on the precise definition of IEEE floating | |
2082 | point. Use @samp{-ffloat-store} for such programs. | |
2083 | ||
2084 | @item -fno-default-inline | |
2085 | Do not make member functions inline by default merely because they are | |
2086 | defined inside the class scope (C++ only). Otherwise, when you specify | |
2087 | @w{@samp{-O}}, member functions defined inside class scope are compiled | |
2088 | inline by default; i.e., you don't need to add @samp{inline} in front of | |
2089 | the member function name. | |
2090 | ||
2091 | @item -fno-defer-pop | |
2092 | Always pop the arguments to each function call as soon as that function | |
2093 | returns. For machines which must pop arguments after a function call, | |
2094 | the compiler normally lets arguments accumulate on the stack for several | |
2095 | function calls and pops them all at once. | |
2096 | ||
2097 | @item -fforce-mem | |
2098 | Force memory operands to be copied into registers before doing | |
2099 | arithmetic on them. This produces better code by making all memory | |
2100 | references potential common subexpressions. When they are not common | |
2101 | subexpressions, instruction combination should eliminate the separate | |
2102 | register-load. The @samp{-O2} option turns on this option. | |
2103 | ||
2104 | @item -fforce-addr | |
2105 | Force memory address constants to be copied into registers before | |
2106 | doing arithmetic on them. This may produce better code just as | |
2107 | @samp{-fforce-mem} may. | |
2108 | ||
2109 | @item -fomit-frame-pointer | |
2110 | Don't keep the frame pointer in a register for functions that | |
2111 | don't need one. This avoids the instructions to save, set up and | |
2112 | restore frame pointers; it also makes an extra register available | |
2113 | in many functions. @strong{It also makes debugging impossible on | |
2114 | some machines.} | |
2115 | ||
2116 | @ifset INTERNALS | |
2117 | On some machines, such as the Vax, this flag has no effect, because | |
2118 | the standard calling sequence automatically handles the frame pointer | |
2119 | and nothing is saved by pretending it doesn't exist. The | |
2120 | machine-description macro @code{FRAME_POINTER_REQUIRED} controls | |
2121 | whether a target machine supports this flag. @xref{Registers}.@refill | |
2122 | @end ifset | |
2123 | @ifclear INTERNALS | |
2124 | On some machines, such as the Vax, this flag has no effect, because | |
2125 | the standard calling sequence automatically handles the frame pointer | |
2126 | and nothing is saved by pretending it doesn't exist. The | |
2127 | machine-description macro @code{FRAME_POINTER_REQUIRED} controls | |
2128 | whether a target machine supports this flag. @xref{Registers,,Register | |
2129 | Usage, gcc.info, Using and Porting GCC}.@refill | |
2130 | @end ifclear | |
2131 | ||
2132 | @item -fno-inline | |
2133 | Don't pay attention to the @code{inline} keyword. Normally this option | |
2134 | is used to keep the compiler from expanding any functions inline. | |
2135 | Note that if you are not optimizing, no functions can be expanded inline. | |
2136 | ||
2137 | @item -finline-functions | |
2138 | Integrate all simple functions into their callers. The compiler | |
2139 | heuristically decides which functions are simple enough to be worth | |
2140 | integrating in this way. | |
2141 | ||
2142 | If all calls to a given function are integrated, and the function is | |
2143 | declared @code{static}, then the function is normally not output as | |
2144 | assembler code in its own right. | |
2145 | ||
2146 | @item -fkeep-inline-functions | |
2147 | Even if all calls to a given function are integrated, and the function | |
2148 | is declared @code{static}, nevertheless output a separate run-time | |
2149 | callable version of the function. This switch does not affect | |
2150 | @code{extern inline} functions. | |
2151 | ||
2152 | @item -fkeep-static-consts | |
2153 | Emit variables declared @code{static const} when optimization isn't turned | |
2154 | on, even if the variables aren't referenced. | |
2155 | ||
2156 | GNU CC enables this option by default. If you want to force the compiler to | |
2157 | check if the variable was referenced, regardless of whether or not | |
2158 | optimization is turned on, use the @samp{-fno-keep-static-consts} option. | |
2159 | ||
2160 | @item -fno-function-cse | |
2161 | Do not put function addresses in registers; make each instruction that | |
2162 | calls a constant function contain the function's address explicitly. | |
2163 | ||
2164 | This option results in less efficient code, but some strange hacks | |
2165 | that alter the assembler output may be confused by the optimizations | |
2166 | performed when this option is not used. | |
2167 | ||
2168 | @item -ffast-math | |
2169 | This option allows GCC to violate some ANSI or IEEE rules and/or | |
2170 | specifications in the interest of optimizing code for speed. For | |
2171 | example, it allows the compiler to assume arguments to the @code{sqrt} | |
2172 | function are non-negative numbers and that no floating-point values | |
2173 | are NaNs. | |
2174 | ||
2175 | This option should never be turned on by any @samp{-O} option since | |
2176 | it can result in incorrect output for programs which depend on | |
2177 | an exact implementation of IEEE or ANSI rules/specifications for | |
2178 | math functions. | |
2179 | @end table | |
2180 | ||
2181 | @c following causes underfulls.. they don't look great, but we deal. | |
2182 | @c --mew 26jan93 | |
2183 | The following options control specific optimizations. The @samp{-O2} | |
2184 | option turns on all of these optimizations except @samp{-funroll-loops} | |
2185 | and @samp{-funroll-all-loops}. On most machines, the @samp{-O} option | |
2186 | turns on the @samp{-fthread-jumps} and @samp{-fdelayed-branch} options, | |
2187 | but specific machines may handle it differently. | |
2188 | ||
2189 | You can use the following flags in the rare cases when ``fine-tuning'' | |
2190 | of optimizations to be performed is desired. | |
2191 | ||
2192 | @table @code | |
2193 | @item -fstrength-reduce | |
2194 | Perform the optimizations of loop strength reduction and | |
2195 | elimination of iteration variables. | |
2196 | ||
2197 | @item -fthread-jumps | |
2198 | Perform optimizations where we check to see if a jump branches to a | |
2199 | location where another comparison subsumed by the first is found. If | |
2200 | so, the first branch is redirected to either the destination of the | |
2201 | second branch or a point immediately following it, depending on whether | |
2202 | the condition is known to be true or false. | |
2203 | ||
2204 | @item -fcse-follow-jumps | |
2205 | In common subexpression elimination, scan through jump instructions | |
2206 | when the target of the jump is not reached by any other path. For | |
2207 | example, when CSE encounters an @code{if} statement with an | |
2208 | @code{else} clause, CSE will follow the jump when the condition | |
2209 | tested is false. | |
2210 | ||
2211 | @item -fcse-skip-blocks | |
2212 | This is similar to @samp{-fcse-follow-jumps}, but causes CSE to | |
2213 | follow jumps which conditionally skip over blocks. When CSE | |
2214 | encounters a simple @code{if} statement with no else clause, | |
2215 | @samp{-fcse-skip-blocks} causes CSE to follow the jump around the | |
2216 | body of the @code{if}. | |
2217 | ||
2218 | @item -frerun-cse-after-loop | |
2219 | Re-run common subexpression elimination after loop optimizations has been | |
2220 | performed. | |
2221 | ||
6d6d0fa0 JL |
2222 | @item -frerun-loop-opt |
2223 | Run the loop optimizer twice. | |
2224 | ||
74291a4b MM |
2225 | @item -fexpensive-optimizations |
2226 | Perform a number of minor optimizations that are relatively expensive. | |
2227 | ||
2228 | @item -fdelayed-branch | |
2229 | If supported for the target machine, attempt to reorder instructions | |
2230 | to exploit instruction slots available after delayed branch | |
2231 | instructions. | |
2232 | ||
2233 | @item -fschedule-insns | |
2234 | If supported for the target machine, attempt to reorder instructions to | |
2235 | eliminate execution stalls due to required data being unavailable. This | |
2236 | helps machines that have slow floating point or memory load instructions | |
2237 | by allowing other instructions to be issued until the result of the load | |
2238 | or floating point instruction is required. | |
2239 | ||
2240 | @item -fschedule-insns2 | |
2241 | Similar to @samp{-fschedule-insns}, but requests an additional pass of | |
2242 | instruction scheduling after register allocation has been done. This is | |
2243 | especially useful on machines with a relatively small number of | |
2244 | registers and where memory load instructions take more than one cycle. | |
2245 | ||
2246 | @item -ffunction-sections | |
2247 | Place each function into its own section in the output file if the | |
2248 | target supports arbitrary sections. The function's name determines | |
2249 | the section's name in the output file. | |
2250 | ||
2251 | Use this option on systems where the linker can perform optimizations | |
2252 | to improve locality of reference in the instruction space. HPPA | |
2253 | processors running HP-UX and Sparc processors running Solaris 2 have | |
2254 | linkers with such optimizations. Other systems using the ELF object format | |
2255 | as well as AIX may have these optimizations in the future. | |
2256 | ||
2257 | Only use this option when there are significant benefits from doing | |
2258 | so. When you specify this option, the assembler and linker will | |
2259 | create larger object and executable files and will also be slower. | |
2260 | You will not be able to use @code{gprof} on all systems if you | |
2261 | specify this option and you may have problems with debugging if | |
2262 | you specify both this option and @samp{-g}. | |
2263 | ||
2264 | @item -fcaller-saves | |
2265 | Enable values to be allocated in registers that will be clobbered by | |
2266 | function calls, by emitting extra instructions to save and restore the | |
2267 | registers around such calls. Such allocation is done only when it | |
2268 | seems to result in better code than would otherwise be produced. | |
2269 | ||
2270 | This option is enabled by default on certain machines, usually those | |
2271 | which have no call-preserved registers to use instead. | |
2272 | ||
2273 | @item -funroll-loops | |
2274 | Perform the optimization of loop unrolling. This is only done for loops | |
2275 | whose number of iterations can be determined at compile time or run time. | |
2276 | @samp{-funroll-loop} implies both @samp{-fstrength-reduce} and | |
2277 | @samp{-frerun-cse-after-loop}. | |
2278 | ||
2279 | @item -funroll-all-loops | |
2280 | Perform the optimization of loop unrolling. This is done for all loops | |
2281 | and usually makes programs run more slowly. @samp{-funroll-all-loops} | |
2282 | implies @samp{-fstrength-reduce} as well as @samp{-frerun-cse-after-loop}. | |
2283 | ||
e5eb27e5 JL |
2284 | @item -fmove-all-movables |
2285 | Forces all invariant computations in loops to be moved | |
2286 | outside the loop. | |
2287 | ||
2288 | @item -freduce-all-givs | |
2289 | Forces all general-induction variables in loops to be | |
2290 | strength-reduced. | |
2291 | ||
2292 | @emph{Note:} When compiling programs written in Fortran, | |
2293 | @samp{-fmove-all-moveables} and @samp{-freduce-all-givs} are enabled | |
2294 | by default when you use the optimizer. | |
2295 | ||
2296 | These options may generate better or worse code; results are highly | |
2297 | dependent on the structure of loops within the source code. | |
2298 | ||
2299 | These two options are intended to be removed someday, once | |
2300 | they have helped determine the efficacy of various | |
2301 | approaches to improving loop optimizations. | |
2302 | ||
ec83e9d3 | 2303 | Please let us (@code{egcs@@cygnus.com} and @code{fortran@@gnu.ai.mit.edu}) |
e5eb27e5 JL |
2304 | know how use of these options affects |
2305 | the performance of your production code. | |
2306 | We're very interested in code that runs @emph{slower} | |
2307 | when these options are @emph{enabled}. | |
2308 | ||
74291a4b MM |
2309 | @item -fno-peephole |
2310 | Disable any machine-specific peephole optimizations. | |
861bb6c1 JL |
2311 | |
2312 | @item -fbranch-probabilities | |
2313 | After running a program compiled with @samp{-fprofile-arcs} | |
2314 | (@pxref{Debugging Options,, Options for Debugging Your Program or | |
2315 | @code{gcc}}), you can compile it a second time using | |
2316 | @samp{-fbranch-probabilities}, to improve optimizations based on | |
2317 | guessing the path a branch might take. | |
2318 | ||
2319 | @ifset INTERNALS | |
2320 | With @samp{-fbranch-probabilities}, GNU CC puts a @samp{REG_EXEC_COUNT} | |
2321 | note on the first instruction of each basic block, and a | |
2322 | @samp{REG_BR_PROB} note on each @samp{JUMP_INSN} and @samp{CALL_INSN}. | |
2323 | These can be used to improve optimization. Currently, they are only | |
2324 | used in one place: in @file{reorg.c}, instead of guessing which path a | |
2325 | branch is mostly to take, the @samp{REG_BR_PROB} values are used to | |
2326 | exactly determine which path is taken more often. | |
2327 | @end ifset | |
8c660648 JL |
2328 | |
2329 | @item -fregmove | |
2330 | Some machines only support 2 operands per instruction. On such | |
2331 | machines, GNU CC might have to do extra copies. The @samp{-fregmove} | |
2332 | option overrides the default for the machine to do the copy before | |
2333 | register allocation. | |
74291a4b MM |
2334 | @end table |
2335 | ||
2336 | @node Preprocessor Options | |
2337 | @section Options Controlling the Preprocessor | |
2338 | @cindex preprocessor options | |
2339 | @cindex options, preprocessor | |
2340 | ||
2341 | These options control the C preprocessor, which is run on each C source | |
2342 | file before actual compilation. | |
2343 | ||
2344 | If you use the @samp{-E} option, nothing is done except preprocessing. | |
2345 | Some of these options make sense only together with @samp{-E} because | |
2346 | they cause the preprocessor output to be unsuitable for actual | |
2347 | compilation. | |
2348 | ||
2349 | @table @code | |
2350 | @item -include @var{file} | |
2351 | Process @var{file} as input before processing the regular input file. | |
2352 | In effect, the contents of @var{file} are compiled first. Any @samp{-D} | |
2353 | and @samp{-U} options on the command line are always processed before | |
2354 | @samp{-include @var{file}}, regardless of the order in which they are | |
2355 | written. All the @samp{-include} and @samp{-imacros} options are | |
2356 | processed in the order in which they are written. | |
2357 | ||
2358 | @item -imacros @var{file} | |
2359 | Process @var{file} as input, discarding the resulting output, before | |
2360 | processing the regular input file. Because the output generated from | |
2361 | @var{file} is discarded, the only effect of @samp{-imacros @var{file}} | |
2362 | is to make the macros defined in @var{file} available for use in the | |
2363 | main input. | |
2364 | ||
2365 | Any @samp{-D} and @samp{-U} options on the command line are always | |
2366 | processed before @samp{-imacros @var{file}}, regardless of the order in | |
2367 | which they are written. All the @samp{-include} and @samp{-imacros} | |
2368 | options are processed in the order in which they are written. | |
2369 | ||
2370 | @item -idirafter @var{dir} | |
2371 | @cindex second include path | |
2372 | Add the directory @var{dir} to the second include path. The directories | |
2373 | on the second include path are searched when a header file is not found | |
2374 | in any of the directories in the main include path (the one that | |
2375 | @samp{-I} adds to). | |
2376 | ||
2377 | @item -iprefix @var{prefix} | |
2378 | Specify @var{prefix} as the prefix for subsequent @samp{-iwithprefix} | |
2379 | options. | |
2380 | ||
2381 | @item -iwithprefix @var{dir} | |
2382 | Add a directory to the second include path. The directory's name is | |
2383 | made by concatenating @var{prefix} and @var{dir}, where @var{prefix} was | |
2384 | specified previously with @samp{-iprefix}. If you have not specified a | |
2385 | prefix yet, the directory containing the installed passes of the | |
2386 | compiler is used as the default. | |
2387 | ||
2388 | @item -iwithprefixbefore @var{dir} | |
2389 | Add a directory to the main include path. The directory's name is made | |
2390 | by concatenating @var{prefix} and @var{dir}, as in the case of | |
2391 | @samp{-iwithprefix}. | |
2392 | ||
2393 | @item -isystem @var{dir} | |
2394 | Add a directory to the beginning of the second include path, marking it | |
2395 | as a system directory, so that it gets the same special treatment as | |
2396 | is applied to the standard system directories. | |
2397 | ||
2398 | @item -nostdinc | |
2399 | Do not search the standard system directories for header files. Only | |
2400 | the directories you have specified with @samp{-I} options (and the | |
2401 | current directory, if appropriate) are searched. @xref{Directory | |
2402 | Options}, for information on @samp{-I}. | |
2403 | ||
2404 | By using both @samp{-nostdinc} and @samp{-I-}, you can limit the include-file | |
2405 | search path to only those directories you specify explicitly. | |
2406 | ||
2407 | @item -undef | |
2408 | Do not predefine any nonstandard macros. (Including architecture flags). | |
2409 | ||
2410 | @item -E | |
2411 | Run only the C preprocessor. Preprocess all the C source files | |
2412 | specified and output the results to standard output or to the | |
2413 | specified output file. | |
2414 | ||
2415 | @item -C | |
2416 | Tell the preprocessor not to discard comments. Used with the | |
2417 | @samp{-E} option. | |
2418 | ||
2419 | @item -P | |
2420 | Tell the preprocessor not to generate @samp{#line} directives. | |
2421 | Used with the @samp{-E} option. | |
2422 | ||
2423 | @cindex make | |
2424 | @cindex dependencies, make | |
2425 | @item -M | |
2426 | Tell the preprocessor to output a rule suitable for @code{make} | |
2427 | describing the dependencies of each object file. For each source file, | |
2428 | the preprocessor outputs one @code{make}-rule whose target is the object | |
2429 | file name for that source file and whose dependencies are all the | |
2430 | @code{#include} header files it uses. This rule may be a single line or | |
2431 | may be continued with @samp{\}-newline if it is long. The list of rules | |
2432 | is printed on standard output instead of the preprocessed C program. | |
2433 | ||
2434 | @samp{-M} implies @samp{-E}. | |
2435 | ||
2436 | Another way to specify output of a @code{make} rule is by setting | |
2437 | the environment variable @code{DEPENDENCIES_OUTPUT} (@pxref{Environment | |
2438 | Variables}). | |
2439 | ||
2440 | @item -MM | |
2441 | Like @samp{-M} but the output mentions only the user header files | |
2442 | included with @samp{#include "@var{file}"}. System header files | |
2443 | included with @samp{#include <@var{file}>} are omitted. | |
2444 | ||
2445 | @item -MD | |
2446 | Like @samp{-M} but the dependency information is written to a file made by | |
2447 | replacing ".c" with ".d" at the end of the input file names. | |
2448 | This is in addition to compiling the file as specified---@samp{-MD} does | |
2449 | not inhibit ordinary compilation the way @samp{-M} does. | |
2450 | ||
2451 | In Mach, you can use the utility @code{md} to merge multiple dependency | |
2452 | files into a single dependency file suitable for using with the @samp{make} | |
2453 | command. | |
2454 | ||
2455 | @item -MMD | |
2456 | Like @samp{-MD} except mention only user header files, not system | |
2457 | header files. | |
2458 | ||
2459 | @item -MG | |
2460 | Treat missing header files as generated files and assume they live in the | |
2461 | same directory as the source file. If you specify @samp{-MG}, you | |
2462 | must also specify either @samp{-M} or @samp{-MM}. @samp{-MG} is not | |
2463 | supported with @samp{-MD} or @samp{-MMD}. | |
2464 | ||
2465 | @item -H | |
2466 | Print the name of each header file used, in addition to other normal | |
2467 | activities. | |
2468 | ||
2469 | @item -A@var{question}(@var{answer}) | |
2470 | Assert the answer @var{answer} for @var{question}, in case it is tested | |
2471 | with a preprocessing conditional such as @samp{#if | |
2472 | #@var{question}(@var{answer})}. @samp{-A-} disables the standard | |
2473 | assertions that normally describe the target machine. | |
2474 | ||
2475 | @item -D@var{macro} | |
2476 | Define macro @var{macro} with the string @samp{1} as its definition. | |
2477 | ||
2478 | @item -D@var{macro}=@var{defn} | |
2479 | Define macro @var{macro} as @var{defn}. All instances of @samp{-D} on | |
2480 | the command line are processed before any @samp{-U} options. | |
2481 | ||
2482 | @item -U@var{macro} | |
2483 | Undefine macro @var{macro}. @samp{-U} options are evaluated after all | |
2484 | @samp{-D} options, but before any @samp{-include} and @samp{-imacros} | |
2485 | options. | |
2486 | ||
2487 | @item -dM | |
2488 | Tell the preprocessor to output only a list of the macro definitions | |
2489 | that are in effect at the end of preprocessing. Used with the @samp{-E} | |
2490 | option. | |
2491 | ||
2492 | @item -dD | |
2493 | Tell the preprocessing to pass all macro definitions into the output, in | |
2494 | their proper sequence in the rest of the output. | |
2495 | ||
2496 | @item -dN | |
2497 | Like @samp{-dD} except that the macro arguments and contents are omitted. | |
2498 | Only @samp{#define @var{name}} is included in the output. | |
2499 | ||
2500 | @item -trigraphs | |
2501 | Support ANSI C trigraphs. The @samp{-ansi} option also has this effect. | |
2502 | ||
2503 | @item -Wp,@var{option} | |
2504 | Pass @var{option} as an option to the preprocessor. If @var{option} | |
2505 | contains commas, it is split into multiple options at the commas. | |
2506 | @end table | |
2507 | ||
2508 | @node Assembler Options | |
2509 | @section Passing Options to the Assembler | |
2510 | ||
2511 | @c prevent bad page break with this line | |
2512 | You can pass options to the assembler. | |
2513 | ||
2514 | @table @code | |
2515 | @item -Wa,@var{option} | |
2516 | Pass @var{option} as an option to the assembler. If @var{option} | |
2517 | contains commas, it is split into multiple options at the commas. | |
2518 | @end table | |
2519 | ||
2520 | @node Link Options | |
2521 | @section Options for Linking | |
2522 | @cindex link options | |
2523 | @cindex options, linking | |
2524 | ||
2525 | These options come into play when the compiler links object files into | |
2526 | an executable output file. They are meaningless if the compiler is | |
2527 | not doing a link step. | |
2528 | ||
2529 | @table @code | |
2530 | @cindex file names | |
2531 | @item @var{object-file-name} | |
2532 | A file name that does not end in a special recognized suffix is | |
2533 | considered to name an object file or library. (Object files are | |
2534 | distinguished from libraries by the linker according to the file | |
2535 | contents.) If linking is done, these object files are used as input | |
2536 | to the linker. | |
2537 | ||
2538 | @item -c | |
2539 | @itemx -S | |
2540 | @itemx -E | |
2541 | If any of these options is used, then the linker is not run, and | |
2542 | object file names should not be used as arguments. @xref{Overall | |
2543 | Options}. | |
2544 | ||
2545 | @cindex Libraries | |
2546 | @item -l@var{library} | |
2547 | Search the library named @var{library} when linking. | |
2548 | ||
2549 | It makes a difference where in the command you write this option; the | |
2550 | linker searches processes libraries and object files in the order they | |
2551 | are specified. Thus, @samp{foo.o -lz bar.o} searches library @samp{z} | |
2552 | after file @file{foo.o} but before @file{bar.o}. If @file{bar.o} refers | |
2553 | to functions in @samp{z}, those functions may not be loaded. | |
2554 | ||
2555 | The linker searches a standard list of directories for the library, | |
2556 | which is actually a file named @file{lib@var{library}.a}. The linker | |
2557 | then uses this file as if it had been specified precisely by name. | |
2558 | ||
2559 | The directories searched include several standard system directories | |
2560 | plus any that you specify with @samp{-L}. | |
2561 | ||
2562 | Normally the files found this way are library files---archive files | |
2563 | whose members are object files. The linker handles an archive file by | |
2564 | scanning through it for members which define symbols that have so far | |
2565 | been referenced but not defined. But if the file that is found is an | |
2566 | ordinary object file, it is linked in the usual fashion. The only | |
2567 | difference between using an @samp{-l} option and specifying a file name | |
2568 | is that @samp{-l} surrounds @var{library} with @samp{lib} and @samp{.a} | |
2569 | and searches several directories. | |
2570 | ||
2571 | @item -lobjc | |
2572 | You need this special case of the @samp{-l} option in order to | |
2573 | link an Objective C program. | |
2574 | ||
2575 | @item -nostartfiles | |
2576 | Do not use the standard system startup files when linking. | |
2577 | The standard system libraries are used normally, unless @code{-nostdlib} | |
2578 | or @code{-nodefaultlibs} is used. | |
2579 | ||
2580 | @item -nodefaultlibs | |
2581 | Do not use the standard system libraries when linking. | |
2582 | Only the libraries you specify will be passed to the linker. | |
2583 | The standard startup files are used normally, unless @code{-nostartfiles} | |
2584 | is used. | |
2585 | ||
2586 | @item -nostdlib | |
2587 | Do not use the standard system startup files or libraries when linking. | |
2588 | No startup files and only the libraries you specify will be passed to | |
2589 | the linker. | |
2590 | ||
2591 | @cindex @code{-lgcc}, use with @code{-nostdlib} | |
2592 | @cindex @code{-nostdlib} and unresolved references | |
2593 | @cindex unresolved references and @code{-nostdlib} | |
2594 | @cindex @code{-lgcc}, use with @code{-nodefaultlibs} | |
2595 | @cindex @code{-nodefaultlibs} and unresolved references | |
2596 | @cindex unresolved references and @code{-nodefaultlibs} | |
2597 | One of the standard libraries bypassed by @samp{-nostdlib} and | |
2598 | @samp{-nodefaultlibs} is @file{libgcc.a}, a library of internal subroutines | |
2599 | that GNU CC uses to overcome shortcomings of particular machines, or special | |
2600 | needs for some languages. | |
2601 | @ifset INTERNALS | |
2602 | (@xref{Interface,,Interfacing to GNU CC Output}, for more discussion of | |
2603 | @file{libgcc.a}.) | |
2604 | @end ifset | |
2605 | @ifclear INTERNALS | |
2606 | (@xref{Interface,,Interfacing to GNU CC Output,gcc.info,Porting GNU CC}, | |
2607 | for more discussion of @file{libgcc.a}.) | |
2608 | @end ifclear | |
2609 | In most cases, you need @file{libgcc.a} even when you want to avoid | |
2610 | other standard libraries. In other words, when you specify @samp{-nostdlib} | |
2611 | or @samp{-nodefaultlibs} you should usually specify @samp{-lgcc} as well. | |
2612 | This ensures that you have no unresolved references to internal GNU CC | |
2613 | library subroutines. (For example, @samp{__main}, used to ensure C++ | |
2614 | constructors will be called; @pxref{Collect2,,@code{collect2}}.) | |
2615 | ||
2616 | @item -s | |
2617 | Remove all symbol table and relocation information from the executable. | |
2618 | ||
2619 | @item -static | |
2620 | On systems that support dynamic linking, this prevents linking with the shared | |
2621 | libraries. On other systems, this option has no effect. | |
2622 | ||
2623 | @item -shared | |
2624 | Produce a shared object which can then be linked with other objects to | |
2625 | form an executable. Not all systems support this option. You must | |
2626 | also specify @samp{-fpic} or @samp{-fPIC} on some systems when | |
2627 | you specify this option. | |
2628 | ||
2629 | @item -symbolic | |
2630 | Bind references to global symbols when building a shared object. Warn | |
2631 | about any unresolved references (unless overridden by the link editor | |
2632 | option @samp{-Xlinker -z -Xlinker defs}). Only a few systems support | |
2633 | this option. | |
2634 | ||
2635 | @item -Xlinker @var{option} | |
2636 | Pass @var{option} as an option to the linker. You can use this to | |
2637 | supply system-specific linker options which GNU CC does not know how to | |
2638 | recognize. | |
2639 | ||
2640 | If you want to pass an option that takes an argument, you must use | |
2641 | @samp{-Xlinker} twice, once for the option and once for the argument. | |
2642 | For example, to pass @samp{-assert definitions}, you must write | |
2643 | @samp{-Xlinker -assert -Xlinker definitions}. It does not work to write | |
2644 | @samp{-Xlinker "-assert definitions"}, because this passes the entire | |
2645 | string as a single argument, which is not what the linker expects. | |
2646 | ||
2647 | @item -Wl,@var{option} | |
2648 | Pass @var{option} as an option to the linker. If @var{option} contains | |
2649 | commas, it is split into multiple options at the commas. | |
2650 | ||
2651 | @item -u @var{symbol} | |
2652 | Pretend the symbol @var{symbol} is undefined, to force linking of | |
2653 | library modules to define it. You can use @samp{-u} multiple times with | |
2654 | different symbols to force loading of additional library modules. | |
2655 | @end table | |
2656 | ||
2657 | @node Directory Options | |
2658 | @section Options for Directory Search | |
2659 | @cindex directory options | |
2660 | @cindex options, directory search | |
2661 | @cindex search path | |
2662 | ||
2663 | These options specify directories to search for header files, for | |
2664 | libraries and for parts of the compiler: | |
2665 | ||
2666 | @table @code | |
2667 | @item -I@var{dir} | |
861bb6c1 JL |
2668 | Add the directory @var{dir} to the head of the list of directories to be |
2669 | searched for header files. This can be used to override a system header | |
2670 | file, substituting your own version, since these directories are | |
74291a4b MM |
2671 | searched before the system header file directories. If you use more |
2672 | than one @samp{-I} option, the directories are scanned in left-to-right | |
2673 | order; the standard system directories come after. | |
2674 | ||
2675 | @item -I- | |
2676 | Any directories you specify with @samp{-I} options before the @samp{-I-} | |
2677 | option are searched only for the case of @samp{#include "@var{file}"}; | |
2678 | they are not searched for @samp{#include <@var{file}>}. | |
2679 | ||
2680 | If additional directories are specified with @samp{-I} options after | |
2681 | the @samp{-I-}, these directories are searched for all @samp{#include} | |
2682 | directives. (Ordinarily @emph{all} @samp{-I} directories are used | |
2683 | this way.) | |
2684 | ||
2685 | In addition, the @samp{-I-} option inhibits the use of the current | |
2686 | directory (where the current input file came from) as the first search | |
2687 | directory for @samp{#include "@var{file}"}. There is no way to | |
2688 | override this effect of @samp{-I-}. With @samp{-I.} you can specify | |
2689 | searching the directory which was current when the compiler was | |
2690 | invoked. That is not exactly the same as what the preprocessor does | |
2691 | by default, but it is often satisfactory. | |
2692 | ||
2693 | @samp{-I-} does not inhibit the use of the standard system directories | |
2694 | for header files. Thus, @samp{-I-} and @samp{-nostdinc} are | |
2695 | independent. | |
2696 | ||
2697 | @item -L@var{dir} | |
2698 | Add directory @var{dir} to the list of directories to be searched | |
2699 | for @samp{-l}. | |
2700 | ||
2701 | @item -B@var{prefix} | |
2702 | This option specifies where to find the executables, libraries, | |
2703 | include files, and data files of the compiler itself. | |
2704 | ||
2705 | The compiler driver program runs one or more of the subprograms | |
2706 | @file{cpp}, @file{cc1}, @file{as} and @file{ld}. It tries | |
2707 | @var{prefix} as a prefix for each program it tries to run, both with and | |
2708 | without @samp{@var{machine}/@var{version}/} (@pxref{Target Options}). | |
2709 | ||
2710 | For each subprogram to be run, the compiler driver first tries the | |
2711 | @samp{-B} prefix, if any. If that name is not found, or if @samp{-B} | |
2712 | was not specified, the driver tries two standard prefixes, which are | |
2713 | @file{/usr/lib/gcc/} and @file{/usr/local/lib/gcc-lib/}. If neither of | |
2714 | those results in a file name that is found, the unmodified program | |
2715 | name is searched for using the directories specified in your | |
2716 | @samp{PATH} environment variable. | |
2717 | ||
2718 | @samp{-B} prefixes that effectively specify directory names also apply | |
2719 | to libraries in the linker, because the compiler translates these | |
2720 | options into @samp{-L} options for the linker. They also apply to | |
2721 | includes files in the preprocessor, because the compiler translates these | |
2722 | options into @samp{-isystem} options for the preprocessor. In this case, | |
2723 | the compiler appends @samp{include} to the prefix. | |
2724 | ||
2725 | The run-time support file @file{libgcc.a} can also be searched for using | |
2726 | the @samp{-B} prefix, if needed. If it is not found there, the two | |
2727 | standard prefixes above are tried, and that is all. The file is left | |
2728 | out of the link if it is not found by those means. | |
2729 | ||
2730 | Another way to specify a prefix much like the @samp{-B} prefix is to use | |
2731 | the environment variable @code{GCC_EXEC_PREFIX}. @xref{Environment | |
2732 | Variables}. | |
861bb6c1 JL |
2733 | |
2734 | @item -specs=@var{file} | |
2735 | Process @var{file} after the compiler reads in the standard @file{specs} | |
2736 | file, in order to override the defaults that the @file{gcc} driver | |
2737 | program uses when determining what switches to pass to @file{cc1}, | |
2738 | @file{cc1plus}, @file{as}, @file{ld}, etc. More than one | |
2739 | @samp{-specs=}@var{file} can be specified on the command line, and they | |
2740 | are processed in order, from left to right. | |
74291a4b MM |
2741 | @end table |
2742 | ||
2743 | @node Target Options | |
2744 | @section Specifying Target Machine and Compiler Version | |
2745 | @cindex target options | |
2746 | @cindex cross compiling | |
2747 | @cindex specifying machine version | |
2748 | @cindex specifying compiler version and target machine | |
2749 | @cindex compiler version, specifying | |
2750 | @cindex target machine, specifying | |
2751 | ||
2752 | By default, GNU CC compiles code for the same type of machine that you | |
2753 | are using. However, it can also be installed as a cross-compiler, to | |
2754 | compile for some other type of machine. In fact, several different | |
2755 | configurations of GNU CC, for different target machines, can be | |
2756 | installed side by side. Then you specify which one to use with the | |
2757 | @samp{-b} option. | |
2758 | ||
2759 | In addition, older and newer versions of GNU CC can be installed side | |
2760 | by side. One of them (probably the newest) will be the default, but | |
2761 | you may sometimes wish to use another. | |
2762 | ||
2763 | @table @code | |
2764 | @item -b @var{machine} | |
2765 | The argument @var{machine} specifies the target machine for compilation. | |
2766 | This is useful when you have installed GNU CC as a cross-compiler. | |
2767 | ||
2768 | The value to use for @var{machine} is the same as was specified as the | |
2769 | machine type when configuring GNU CC as a cross-compiler. For | |
2770 | example, if a cross-compiler was configured with @samp{configure | |
2771 | i386v}, meaning to compile for an 80386 running System V, then you | |
2772 | would specify @samp{-b i386v} to run that cross compiler. | |
2773 | ||
2774 | When you do not specify @samp{-b}, it normally means to compile for | |
2775 | the same type of machine that you are using. | |
2776 | ||
2777 | @item -V @var{version} | |
2778 | The argument @var{version} specifies which version of GNU CC to run. | |
2779 | This is useful when multiple versions are installed. For example, | |
2780 | @var{version} might be @samp{2.0}, meaning to run GNU CC version 2.0. | |
2781 | ||
2782 | The default version, when you do not specify @samp{-V}, is the last | |
2783 | version of GNU CC that you installed. | |
2784 | @end table | |
2785 | ||
2786 | The @samp{-b} and @samp{-V} options actually work by controlling part of | |
2787 | the file name used for the executable files and libraries used for | |
2788 | compilation. A given version of GNU CC, for a given target machine, is | |
2789 | normally kept in the directory @file{/usr/local/lib/gcc-lib/@var{machine}/@var{version}}.@refill | |
2790 | ||
2791 | Thus, sites can customize the effect of @samp{-b} or @samp{-V} either by | |
2792 | changing the names of these directories or adding alternate names (or | |
2793 | symbolic links). If in directory @file{/usr/local/lib/gcc-lib/} the | |
2794 | file @file{80386} is a link to the file @file{i386v}, then @samp{-b | |
2795 | 80386} becomes an alias for @samp{-b i386v}. | |
2796 | ||
2797 | In one respect, the @samp{-b} or @samp{-V} do not completely change | |
2798 | to a different compiler: the top-level driver program @code{gcc} | |
2799 | that you originally invoked continues to run and invoke the other | |
2800 | executables (preprocessor, compiler per se, assembler and linker) | |
2801 | that do the real work. However, since no real work is done in the | |
2802 | driver program, it usually does not matter that the driver program | |
2803 | in use is not the one for the specified target and version. | |
2804 | ||
2805 | The only way that the driver program depends on the target machine is | |
2806 | in the parsing and handling of special machine-specific options. | |
2807 | However, this is controlled by a file which is found, along with the | |
2808 | other executables, in the directory for the specified version and | |
2809 | target machine. As a result, a single installed driver program adapts | |
2810 | to any specified target machine and compiler version. | |
2811 | ||
2812 | The driver program executable does control one significant thing, | |
2813 | however: the default version and target machine. Therefore, you can | |
2814 | install different instances of the driver program, compiled for | |
2815 | different targets or versions, under different names. | |
2816 | ||
2817 | For example, if the driver for version 2.0 is installed as @code{ogcc} | |
2818 | and that for version 2.1 is installed as @code{gcc}, then the command | |
2819 | @code{gcc} will use version 2.1 by default, while @code{ogcc} will use | |
2820 | 2.0 by default. However, you can choose either version with either | |
2821 | command with the @samp{-V} option. | |
2822 | ||
2823 | @node Submodel Options | |
2824 | @section Hardware Models and Configurations | |
2825 | @cindex submodel options | |
2826 | @cindex specifying hardware config | |
2827 | @cindex hardware models and configurations, specifying | |
2828 | @cindex machine dependent options | |
2829 | ||
2830 | Earlier we discussed the standard option @samp{-b} which chooses among | |
2831 | different installed compilers for completely different target | |
2832 | machines, such as Vax vs. 68000 vs. 80386. | |
2833 | ||
2834 | In addition, each of these target machine types can have its own | |
2835 | special options, starting with @samp{-m}, to choose among various | |
2836 | hardware models or configurations---for example, 68010 vs 68020, | |
2837 | floating coprocessor or none. A single installed version of the | |
2838 | compiler can compile for any model or configuration, according to the | |
2839 | options specified. | |
2840 | ||
2841 | Some configurations of the compiler also support additional special | |
2842 | options, usually for compatibility with other compilers on the same | |
2843 | platform. | |
2844 | ||
2845 | @ifset INTERNALS | |
2846 | These options are defined by the macro @code{TARGET_SWITCHES} in the | |
2847 | machine description. The default for the options is also defined by | |
2848 | that macro, which enables you to change the defaults. | |
2849 | @end ifset | |
2850 | ||
2851 | @menu | |
2852 | * M680x0 Options:: | |
2853 | * VAX Options:: | |
2854 | * SPARC Options:: | |
2855 | * Convex Options:: | |
2856 | * AMD29K Options:: | |
2857 | * ARM Options:: | |
6d6d0fa0 | 2858 | * MN10300 Options:: |
861bb6c1 | 2859 | * M32R/D Options:: |
74291a4b MM |
2860 | * M88K Options:: |
2861 | * RS/6000 and PowerPC Options:: | |
2862 | * RT Options:: | |
2863 | * MIPS Options:: | |
2864 | * i386 Options:: | |
2865 | * HPPA Options:: | |
2866 | * Intel 960 Options:: | |
2867 | * DEC Alpha Options:: | |
2868 | * Clipper Options:: | |
2869 | * H8/300 Options:: | |
2870 | * SH Options:: | |
2871 | * System V Options:: | |
f84271d9 | 2872 | * V850 Options:: |
74291a4b MM |
2873 | @end menu |
2874 | ||
2875 | @node M680x0 Options | |
2876 | @subsection M680x0 Options | |
2877 | @cindex M680x0 options | |
2878 | ||
2879 | These are the @samp{-m} options defined for the 68000 series. The default | |
2880 | values for these options depends on which style of 68000 was selected when | |
2881 | the compiler was configured; the defaults for the most common choices are | |
2882 | given below. | |
2883 | ||
2884 | @table @code | |
2885 | @item -m68000 | |
2886 | @itemx -mc68000 | |
2887 | Generate output for a 68000. This is the default | |
2888 | when the compiler is configured for 68000-based systems. | |
2889 | ||
2890 | @item -m68020 | |
2891 | @itemx -mc68020 | |
2892 | Generate output for a 68020. This is the default | |
2893 | when the compiler is configured for 68020-based systems. | |
2894 | ||
2895 | @item -m68881 | |
2896 | Generate output containing 68881 instructions for floating point. | |
2897 | This is the default for most 68020 systems unless @samp{-nfp} was | |
2898 | specified when the compiler was configured. | |
2899 | ||
2900 | @item -m68030 | |
2901 | Generate output for a 68030. This is the default when the compiler is | |
2902 | configured for 68030-based systems. | |
2903 | ||
2904 | @item -m68040 | |
2905 | Generate output for a 68040. This is the default when the compiler is | |
2906 | configured for 68040-based systems. | |
2907 | ||
2908 | This option inhibits the use of 68881/68882 instructions that have to be | |
2909 | emulated by software on the 68040. If your 68040 does not have code to | |
2910 | emulate those instructions, use @samp{-m68040}. | |
2911 | ||
2912 | @item -m68060 | |
2913 | Generate output for a 68060. This is the default when the compiler is | |
2914 | configured for 68060-based systems. | |
2915 | ||
2916 | This option inhibits the use of 68020 and 68881/68882 instructions that | |
2917 | have to be emulated by software on the 68060. If your 68060 does not | |
2918 | have code to emulate those instructions, use @samp{-m68060}. | |
2919 | ||
2920 | @item -m5200 | |
2921 | Generate output for a 520X "coldfire" family cpu. This is the default | |
2922 | when the compiler is configured for 520X-based systems. | |
2923 | ||
2924 | ||
2925 | @item -m68020-40 | |
2926 | Generate output for a 68040, without using any of the new instructions. | |
2927 | This results in code which can run relatively efficiently on either a | |
2928 | 68020/68881 or a 68030 or a 68040. The generated code does use the | |
2929 | 68881 instructions that are emulated on the 68040. | |
2930 | ||
861bb6c1 JL |
2931 | @item -m68020-60 |
2932 | Generate output for a 68060, without using any of the new instructions. | |
2933 | This results in code which can run relatively efficiently on either a | |
2934 | 68020/68881 or a 68030 or a 68040. The generated code does use the | |
2935 | 68881 instructions that are emulated on the 68060. | |
2936 | ||
74291a4b MM |
2937 | @item -mfpa |
2938 | Generate output containing Sun FPA instructions for floating point. | |
2939 | ||
2940 | @item -msoft-float | |
2941 | Generate output containing library calls for floating point. | |
2942 | @strong{Warning:} the requisite libraries are not available for all m68k | |
2943 | targets. Normally the facilities of the machine's usual C compiler are | |
2944 | used, but this can't be done directly in cross-compilation. You must | |
2945 | make your own arrangements to provide suitable library functions for | |
2946 | cross-compilation. The embedded targets @samp{m68k-*-aout} and | |
2947 | @samp{m68k-*-coff} do provide software floating point support. | |
2948 | ||
2949 | @item -mshort | |
2950 | Consider type @code{int} to be 16 bits wide, like @code{short int}. | |
2951 | ||
2952 | @item -mnobitfield | |
2953 | Do not use the bit-field instructions. The @samp{-m68000} option | |
2954 | implies @w{@samp{-mnobitfield}}. | |
2955 | ||
2956 | @item -mbitfield | |
2957 | Do use the bit-field instructions. The @samp{-m68020} option implies | |
2958 | @samp{-mbitfield}. This is the default if you use a configuration | |
2959 | designed for a 68020. | |
2960 | ||
2961 | @item -mrtd | |
2962 | Use a different function-calling convention, in which functions | |
2963 | that take a fixed number of arguments return with the @code{rtd} | |
2964 | instruction, which pops their arguments while returning. This | |
2965 | saves one instruction in the caller since there is no need to pop | |
2966 | the arguments there. | |
2967 | ||
2968 | This calling convention is incompatible with the one normally | |
2969 | used on Unix, so you cannot use it if you need to call libraries | |
2970 | compiled with the Unix compiler. | |
2971 | ||
2972 | Also, you must provide function prototypes for all functions that | |
2973 | take variable numbers of arguments (including @code{printf}); | |
2974 | otherwise incorrect code will be generated for calls to those | |
2975 | functions. | |
2976 | ||
2977 | In addition, seriously incorrect code will result if you call a | |
2978 | function with too many arguments. (Normally, extra arguments are | |
2979 | harmlessly ignored.) | |
2980 | ||
2981 | The @code{rtd} instruction is supported by the 68010, 68020, 68030, | |
2982 | 68040, and 68060 processors, but not by the 68000 or 5200. | |
861bb6c1 JL |
2983 | |
2984 | @item -malign-int | |
2985 | @itemx -mno-align-int | |
2986 | Control whether GNU CC aligns @code{int}, @code{long}, @code{long long}, | |
2987 | @code{float}, @code{double}, and @code{long double} variables on a 32-bit | |
2988 | boundary (@samp{-malign-int}) or a 16-bit boundary (@samp{-mno-align-int}). | |
2989 | Aligning variables on 32-bit boundaries produces code that runs somewhat | |
2990 | faster on processors with 32-bit busses at the expense of more memory. | |
2991 | ||
2992 | @strong{Warning:} if you use the @samp{-malign-int} switch, GNU CC will | |
2993 | align structures containing the above types differently than | |
2994 | most published application binary interface specifications for the m68k. | |
2995 | ||
74291a4b MM |
2996 | @end table |
2997 | ||
2998 | @node VAX Options | |
2999 | @subsection VAX Options | |
3000 | @cindex VAX options | |
3001 | ||
3002 | These @samp{-m} options are defined for the Vax: | |
3003 | ||
3004 | @table @code | |
3005 | @item -munix | |
3006 | Do not output certain jump instructions (@code{aobleq} and so on) | |
3007 | that the Unix assembler for the Vax cannot handle across long | |
3008 | ranges. | |
3009 | ||
3010 | @item -mgnu | |
3011 | Do output those jump instructions, on the assumption that you | |
3012 | will assemble with the GNU assembler. | |
3013 | ||
3014 | @item -mg | |
3015 | Output code for g-format floating point numbers instead of d-format. | |
3016 | @end table | |
3017 | ||
3018 | @node SPARC Options | |
3019 | @subsection SPARC Options | |
3020 | @cindex SPARC options | |
3021 | ||
3022 | These @samp{-m} switches are supported on the SPARC: | |
3023 | ||
3024 | @table @code | |
3025 | @item -mno-app-regs | |
3026 | @itemx -mapp-regs | |
3027 | Specify @samp{-mapp-regs} to generate output using the global registers | |
3028 | 2 through 4, which the SPARC SVR4 ABI reserves for applications. This | |
3029 | is the default. | |
3030 | ||
3031 | To be fully SVR4 ABI compliant at the cost of some performance loss, | |
3032 | specify @samp{-mno-app-regs}. You should compile libraries and system | |
3033 | software with this option. | |
3034 | ||
3035 | @item -mfpu | |
3036 | @itemx -mhard-float | |
3037 | Generate output containing floating point instructions. This is the | |
3038 | default. | |
3039 | ||
3040 | @item -mno-fpu | |
3041 | @itemx -msoft-float | |
3042 | Generate output containing library calls for floating point. | |
3043 | @strong{Warning:} the requisite libraries are not available for all SPARC | |
3044 | targets. Normally the facilities of the machine's usual C compiler are | |
3045 | used, but this cannot be done directly in cross-compilation. You must make | |
3046 | your own arrangements to provide suitable library functions for | |
3047 | cross-compilation. The embedded targets @samp{sparc-*-aout} and | |
3048 | @samp{sparclite-*-*} do provide software floating point support. | |
3049 | ||
3050 | @samp{-msoft-float} changes the calling convention in the output file; | |
3051 | therefore, it is only useful if you compile @emph{all} of a program with | |
3052 | this option. In particular, you need to compile @file{libgcc.a}, the | |
3053 | library that comes with GNU CC, with @samp{-msoft-float} in order for | |
3054 | this to work. | |
3055 | ||
3056 | @item -mhard-quad-float | |
3057 | Generate output containing quad-word (long double) floating point | |
3058 | instructions. | |
3059 | ||
3060 | @item -msoft-quad-float | |
3061 | Generate output containing library calls for quad-word (long double) | |
3062 | floating point instructions. The functions called are those specified | |
3063 | in the SPARC ABI. This is the default. | |
3064 | ||
3065 | As of this writing, there are no sparc implementations that have hardware | |
3066 | support for the quad-word floating point instructions. They all invoke | |
3067 | a trap handler for one of these instructions, and then the trap handler | |
3068 | emulates the effect of the instruction. Because of the trap handler overhead, | |
3069 | this is much slower than calling the ABI library routines. Thus the | |
3070 | @samp{-msoft-quad-float} option is the default. | |
3071 | ||
3072 | @item -mno-epilogue | |
3073 | @itemx -mepilogue | |
3074 | With @samp{-mepilogue} (the default), the compiler always emits code for | |
3075 | function exit at the end of each function. Any function exit in | |
3076 | the middle of the function (such as a return statement in C) will | |
3077 | generate a jump to the exit code at the end of the function. | |
3078 | ||
3079 | With @samp{-mno-epilogue}, the compiler tries to emit exit code inline | |
3080 | at every function exit. | |
3081 | ||
3082 | @item -mno-flat | |
3083 | @itemx -mflat | |
3084 | With @samp{-mflat}, the compiler does not generate save/restore instructions | |
3085 | and will use a "flat" or single register window calling convention. | |
3086 | This model uses %i7 as the frame pointer and is compatible with the normal | |
3087 | register window model. Code from either may be intermixed. | |
3088 | The local registers and the input registers (0-5) are still treated as | |
3089 | "call saved" registers and will be saved on the stack as necessary. | |
3090 | ||
3091 | With @samp{-mno-flat} (the default), the compiler emits save/restore | |
3092 | instructions (except for leaf functions) and is the normal mode of operation. | |
3093 | ||
3094 | @item -mno-unaligned-doubles | |
3095 | @itemx -munaligned-doubles | |
3096 | Assume that doubles have 8 byte alignment. This is the default. | |
3097 | ||
3098 | With @samp{-munaligned-doubles}, GNU CC assumes that doubles have 8 byte | |
3099 | alignment only if they are contained in another type, or if they have an | |
3100 | absolute address. Otherwise, it assumes they have 4 byte alignment. | |
3101 | Specifying this option avoids some rare compatibility problems with code | |
3102 | generated by other compilers. It is not the default because it results | |
3103 | in a performance loss, especially for floating point code. | |
3104 | ||
3105 | @item -mv8 | |
3106 | @itemx -msparclite | |
3107 | These two options select variations on the SPARC architecture. | |
3108 | ||
3109 | By default (unless specifically configured for the Fujitsu SPARClite), | |
3110 | GCC generates code for the v7 variant of the SPARC architecture. | |
3111 | ||
3112 | @samp{-mv8} will give you SPARC v8 code. The only difference from v7 | |
3113 | code is that the compiler emits the integer multiply and integer | |
3114 | divide instructions which exist in SPARC v8 but not in SPARC v7. | |
3115 | ||
3116 | @samp{-msparclite} will give you SPARClite code. This adds the integer | |
3117 | multiply, integer divide step and scan (@code{ffs}) instructions which | |
3118 | exist in SPARClite but not in SPARC v7. | |
3119 | ||
3120 | These options are deprecated and will be deleted in GNU CC 2.9. | |
3121 | They have been replaced with @samp{-mcpu=xxx}. | |
3122 | ||
3123 | @item -mcypress | |
3124 | @itemx -msupersparc | |
3125 | These two options select the processor for which the code is optimised. | |
3126 | ||
3127 | With @samp{-mcypress} (the default), the compiler optimizes code for the | |
3128 | Cypress CY7C602 chip, as used in the SparcStation/SparcServer 3xx series. | |
3129 | This is also appropriate for the older SparcStation 1, 2, IPX etc. | |
3130 | ||
3131 | With @samp{-msupersparc} the compiler optimizes code for the SuperSparc cpu, as | |
3132 | used in the SparcStation 10, 1000 and 2000 series. This flag also enables use | |
3133 | of the full SPARC v8 instruction set. | |
3134 | ||
3135 | These options are deprecated and will be deleted in GNU CC 2.9. | |
3136 | They have been replaced with @samp{-mcpu=xxx}. | |
3137 | ||
3138 | @item -mcpu=@var{cpu_type} | |
c0498f43 DE |
3139 | Set the instruction set, register set, and instruction scheduling parameters |
3140 | for machine type @var{cpu_type}. Supported values for @var{cpu_type} are | |
3141 | @samp{v7}, @samp{cypress}, @samp{v8}, @samp{supersparc}, @samp{sparclite}, | |
3142 | @samp{f930}, @samp{f934}, @samp{sparclet}, @samp{tsc701}, @samp{v9}, and | |
3143 | @samp{ultrasparc}. | |
3144 | ||
3145 | Default instruction scheduling parameters are used for values that select | |
3146 | an architecture and not an implementation. These are @samp{v7}, @samp{v8}, | |
3147 | @samp{sparclite}, @samp{sparclet}, @samp{v9}. | |
3148 | ||
3149 | Here is a list of each supported architecture and their supported | |
3150 | implementations. | |
3151 | ||
3152 | @smallexample | |
3153 | v7: cypress | |
3154 | v8: supersparc | |
3155 | sparclite: f930, f934 | |
3156 | sparclet: tsc701 | |
3157 | v9: ultrasparc | |
3158 | @end smallexample | |
74291a4b MM |
3159 | |
3160 | @item -mtune=@var{cpu_type} | |
3161 | Set the instruction scheduling parameters for machine type | |
c0498f43 DE |
3162 | @var{cpu_type}, but do not set the instruction set or register set that the |
3163 | option @samp{-mcpu=}@var{cpu_type} would. | |
3164 | ||
3165 | The same values for @samp{-mcpu=}@var{cpu_type} are used for | |
3166 | @samp{-mtune=}@var{cpu_type}, though the only useful values are those that | |
3167 | select a particular cpu implementation: @samp{cypress}, @samp{supersparc}, | |
3168 | @samp{f930}, @samp{f934}, @samp{tsc701}, @samp{ultrasparc}. | |
74291a4b | 3169 | |
6d4312dd DE |
3170 | @item -malign-loops=@var{num} |
3171 | Align loops to a 2 raised to a @var{num} byte boundary. If | |
3172 | @samp{-malign-loops} is not specified, the default is 2. | |
3173 | ||
3174 | @item -malign-jumps=@var{num} | |
3175 | Align instructions that are only jumped to to a 2 raised to a @var{num} | |
3176 | byte boundary. If @samp{-malign-jumps} is not specified, the default is 2. | |
3177 | ||
3178 | @item -malign-functions=@var{num} | |
3179 | Align the start of functions to a 2 raised to @var{num} byte boundary. | |
3180 | If @samp{-malign-functions} is not specified, the default is 2 if compiling | |
3181 | for 32 bit sparc, and 5 if compiling for 64 bit sparc. | |
3182 | ||
74291a4b MM |
3183 | @end table |
3184 | ||
3185 | These @samp{-m} switches are supported in addition to the above | |
3186 | on the SPARCLET processor. | |
3187 | ||
3188 | @table @code | |
3189 | @item -mlittle-endian | |
3190 | Generate code for a processor running in little-endian mode. | |
3191 | ||
3192 | @item -mlive-g0 | |
3193 | Treat register @code{%g0} as a normal register. | |
3194 | GCC will continue to clobber it as necessary but will not assume | |
3195 | it always reads as 0. | |
3196 | ||
3197 | @item -mbroken-saverestore | |
3198 | Generate code that does not use non-trivial forms of the @code{save} and | |
3199 | @code{restore} instructions. Early versions of the SPARCLET processor do | |
3200 | not correctly handle @code{save} and @code{restore} instructions used with | |
3201 | arguments. They correctly handle them used without arguments. A @code{save} | |
3202 | instruction used without arguments increments the current window pointer | |
3203 | but does not allocate a new stack frame. It is assumed that the window | |
3204 | overflow trap handler will properly handle this case as will interrupt | |
3205 | handlers. | |
3206 | @end table | |
3207 | ||
3208 | These @samp{-m} switches are supported in addition to the above | |
3209 | on SPARC V9 processors in 64 bit environments. | |
3210 | ||
3211 | @table @code | |
3212 | @item -mlittle-endian | |
3213 | Generate code for a processor running in little-endian mode. | |
3214 | ||
ded17aad DE |
3215 | @item -m32 |
3216 | @itemx -m64 | |
3217 | Generate code for a 32 bit or 64 bit environment. | |
3218 | The 32 bit environment sets int, long and pointer to 32 bits. | |
3219 | The 64 bit environment sets int to 32 bits and long and pointer | |
3220 | to 64 bits. | |
3221 | ||
3222 | @item -mcmodel=medlow | |
3223 | Generate code for the Medium/Low code model: the program must be linked | |
3224 | in the low 32 bits of the address space. Pointers are 64 bits. | |
3225 | Programs can be statically or dynamically linked. | |
3226 | ||
3227 | @item -mcmodel=medmid | |
3228 | Generate code for the Medium/Middle code model: the program must be linked | |
3229 | in the low 44 bits of the address space, the text segment must be less than | |
3230 | 2G bytes, and data segment must be within 2G of the text segment. | |
3231 | Pointers are 64 bits. | |
3232 | ||
3233 | @item -mcmodel=medany | |
3234 | Generate code for the Medium/Anywhere code model: the program may be linked | |
3235 | anywhere in the address space, the text segment must be less than | |
3236 | 2G bytes, and data segment must be within 2G of the text segment. | |
3237 | Pointers are 64 bits. | |
3238 | ||
3239 | @item -mcmodel=embmedany | |
3240 | Generate code for the Medium/Anywhere code model for embedded systems: | |
3241 | assume a 32 bit text and a 32 bit data segment, both starting anywhere | |
3242 | (determined at link time). Register %g4 points to the base of the | |
3243 | data segment. Pointers still 64 bits. | |
3244 | Programs are statically linked, PIC is not supported. | |
74291a4b MM |
3245 | |
3246 | @item -mstack-bias | |
3247 | @itemx -mno-stack-bias | |
3248 | With @samp{-mstack-bias}, GNU CC assumes that the stack pointer, and | |
3249 | frame pointer if present, are offset by -2047 which must be added back | |
3250 | when making stack frame references. | |
3251 | Otherwise, assume no such offset is present. | |
3252 | @end table | |
3253 | ||
3254 | @node Convex Options | |
3255 | @subsection Convex Options | |
3256 | @cindex Convex options | |
3257 | ||
3258 | These @samp{-m} options are defined for Convex: | |
3259 | ||
3260 | @table @code | |
3261 | @item -mc1 | |
3262 | Generate output for C1. The code will run on any Convex machine. | |
3263 | The preprocessor symbol @code{__convex__c1__} is defined. | |
3264 | ||
3265 | @item -mc2 | |
3266 | Generate output for C2. Uses instructions not available on C1. | |
3267 | Scheduling and other optimizations are chosen for max performance on C2. | |
3268 | The preprocessor symbol @code{__convex_c2__} is defined. | |
3269 | ||
3270 | @item -mc32 | |
3271 | Generate output for C32xx. Uses instructions not available on C1. | |
3272 | Scheduling and other optimizations are chosen for max performance on C32. | |
3273 | The preprocessor symbol @code{__convex_c32__} is defined. | |
3274 | ||
3275 | @item -mc34 | |
3276 | Generate output for C34xx. Uses instructions not available on C1. | |
3277 | Scheduling and other optimizations are chosen for max performance on C34. | |
3278 | The preprocessor symbol @code{__convex_c34__} is defined. | |
3279 | ||
3280 | @item -mc38 | |
3281 | Generate output for C38xx. Uses instructions not available on C1. | |
3282 | Scheduling and other optimizations are chosen for max performance on C38. | |
3283 | The preprocessor symbol @code{__convex_c38__} is defined. | |
3284 | ||
3285 | @item -margcount | |
3286 | Generate code which puts an argument count in the word preceding each | |
3287 | argument list. This is compatible with regular CC, and a few programs | |
3288 | may need the argument count word. GDB and other source-level debuggers | |
3289 | do not need it; this info is in the symbol table. | |
3290 | ||
3291 | @item -mnoargcount | |
3292 | Omit the argument count word. This is the default. | |
3293 | ||
3294 | @item -mvolatile-cache | |
3295 | Allow volatile references to be cached. This is the default. | |
3296 | ||
3297 | @item -mvolatile-nocache | |
3298 | Volatile references bypass the data cache, going all the way to memory. | |
3299 | This is only needed for multi-processor code that does not use standard | |
3300 | synchronization instructions. Making non-volatile references to volatile | |
3301 | locations will not necessarily work. | |
3302 | ||
3303 | @item -mlong32 | |
3304 | Type long is 32 bits, the same as type int. This is the default. | |
3305 | ||
3306 | @item -mlong64 | |
3307 | Type long is 64 bits, the same as type long long. This option is useless, | |
3308 | because no library support exists for it. | |
3309 | @end table | |
3310 | ||
3311 | @node AMD29K Options | |
3312 | @subsection AMD29K Options | |
3313 | @cindex AMD29K options | |
3314 | ||
3315 | These @samp{-m} options are defined for the AMD Am29000: | |
3316 | ||
3317 | @table @code | |
3318 | @item -mdw | |
3319 | @kindex -mdw | |
3320 | @cindex DW bit (29k) | |
3321 | Generate code that assumes the @code{DW} bit is set, i.e., that byte and | |
3322 | halfword operations are directly supported by the hardware. This is the | |
3323 | default. | |
3324 | ||
3325 | @item -mndw | |
3326 | @kindex -mndw | |
3327 | Generate code that assumes the @code{DW} bit is not set. | |
3328 | ||
3329 | @item -mbw | |
3330 | @kindex -mbw | |
3331 | @cindex byte writes (29k) | |
3332 | Generate code that assumes the system supports byte and halfword write | |
3333 | operations. This is the default. | |
3334 | ||
3335 | @item -mnbw | |
3336 | @kindex -mnbw | |
3337 | Generate code that assumes the systems does not support byte and | |
3338 | halfword write operations. @samp{-mnbw} implies @samp{-mndw}. | |
3339 | ||
3340 | @item -msmall | |
3341 | @kindex -msmall | |
3342 | @cindex memory model (29k) | |
3343 | Use a small memory model that assumes that all function addresses are | |
3344 | either within a single 256 KB segment or at an absolute address of less | |
3345 | than 256k. This allows the @code{call} instruction to be used instead | |
3346 | of a @code{const}, @code{consth}, @code{calli} sequence. | |
3347 | ||
3348 | @item -mnormal | |
3349 | @kindex -mnormal | |
3350 | Use the normal memory model: Generate @code{call} instructions only when | |
3351 | calling functions in the same file and @code{calli} instructions | |
3352 | otherwise. This works if each file occupies less than 256 KB but allows | |
3353 | the entire executable to be larger than 256 KB. This is the default. | |
3354 | ||
3355 | @item -mlarge | |
3356 | Always use @code{calli} instructions. Specify this option if you expect | |
3357 | a single file to compile into more than 256 KB of code. | |
3358 | ||
3359 | @item -m29050 | |
3360 | @kindex -m29050 | |
3361 | @cindex processor selection (29k) | |
3362 | Generate code for the Am29050. | |
3363 | ||
3364 | @item -m29000 | |
3365 | @kindex -m29000 | |
3366 | Generate code for the Am29000. This is the default. | |
3367 | ||
3368 | @item -mkernel-registers | |
3369 | @kindex -mkernel-registers | |
3370 | @cindex kernel and user registers (29k) | |
3371 | Generate references to registers @code{gr64-gr95} instead of to | |
3372 | registers @code{gr96-gr127}. This option can be used when compiling | |
3373 | kernel code that wants a set of global registers disjoint from that used | |
3374 | by user-mode code. | |
3375 | ||
3376 | Note that when this option is used, register names in @samp{-f} flags | |
3377 | must use the normal, user-mode, names. | |
3378 | ||
3379 | @item -muser-registers | |
3380 | @kindex -muser-registers | |
3381 | Use the normal set of global registers, @code{gr96-gr127}. This is the | |
3382 | default. | |
3383 | ||
3384 | @item -mstack-check | |
3385 | @itemx -mno-stack-check | |
3386 | @kindex -mstack-check | |
3387 | @cindex stack checks (29k) | |
3388 | Insert (or do not insert) a call to @code{__msp_check} after each stack | |
3389 | adjustment. This is often used for kernel code. | |
3390 | ||
3391 | @item -mstorem-bug | |
3392 | @itemx -mno-storem-bug | |
3393 | @kindex -mstorem-bug | |
3394 | @cindex storem bug (29k) | |
3395 | @samp{-mstorem-bug} handles 29k processors which cannot handle the | |
3396 | separation of a mtsrim insn and a storem instruction (most 29000 chips | |
3397 | to date, but not the 29050). | |
3398 | ||
3399 | @item -mno-reuse-arg-regs | |
3400 | @itemx -mreuse-arg-regs | |
3401 | @kindex -mreuse-arg-regs | |
3402 | @samp{-mno-reuse-arg-regs} tells the compiler to only use incoming argument | |
3403 | registers for copying out arguments. This helps detect calling a function | |
3404 | with fewer arguments than it was declared with. | |
3405 | ||
861bb6c1 JL |
3406 | @item -mno-impure-text |
3407 | @itemx -mimpure-text | |
3408 | @kindex -mimpure-text | |
3409 | @samp{-mimpure-text}, used in addition to @samp{-shared}, tells the compiler to | |
3410 | not pass @samp{-assert pure-text} to the linker when linking a shared object. | |
3411 | ||
74291a4b MM |
3412 | @item -msoft-float |
3413 | @kindex -msoft-float | |
3414 | Generate output containing library calls for floating point. | |
3415 | @strong{Warning:} the requisite libraries are not part of GNU CC. | |
3416 | Normally the facilities of the machine's usual C compiler are used, but | |
3417 | this can't be done directly in cross-compilation. You must make your | |
3418 | own arrangements to provide suitable library functions for | |
3419 | cross-compilation. | |
3420 | @end table | |
3421 | ||
3422 | @node ARM Options | |
3423 | @subsection ARM Options | |
3424 | @cindex ARM options | |
3425 | ||
3426 | These @samp{-m} options are defined for Advanced RISC Machines (ARM) | |
3427 | architectures: | |
3428 | ||
3429 | @table @code | |
3430 | @item -mapcs-frame | |
3431 | @kindex -mapcs-frame | |
3432 | Generate a stack frame that is compliant with the ARM Procedure Call | |
3433 | Standard for all functions, even if this is not strictly necessary for | |
3434 | correct execution of the code. | |
3435 | ||
3436 | @item -mapcs-26 | |
3437 | @kindex -mapcs-26 | |
3438 | Generate code for a processor running with a 26-bit program counter, | |
3439 | and conforming to the function calling standards for the APCS 26-bit | |
3440 | option. This option replaces the @samp{-m2} and @samp{-m3} options | |
3441 | of previous releases of the compiler. | |
3442 | ||
3443 | @item -mapcs-32 | |
3444 | @kindex -mapcs-32 | |
3445 | Generate code for a processor running with a 32-bit program counter, | |
3446 | and conforming to the function calling standards for the APCS 32-bit | |
3447 | option. This option replaces the @samp{-m6} option of previous releases | |
3448 | of the compiler. | |
3449 | ||
3450 | @item -mhard-float | |
3451 | Generate output containing floating point instructions. This is the | |
3452 | default. | |
3453 | ||
3454 | @item -msoft-float | |
3455 | Generate output containing library calls for floating point. | |
3456 | @strong{Warning:} the requisite libraries are not available for all ARM | |
3457 | targets. Normally the facilities of the machine's usual C compiler are | |
3458 | used, but this cannot be done directly in cross-compilation. You must make | |
3459 | your own arrangements to provide suitable library functions for | |
3460 | cross-compilation. | |
3461 | ||
3462 | @samp{-msoft-float} changes the calling convention in the output file; | |
3463 | therefore, it is only useful if you compile @emph{all} of a program with | |
3464 | this option. In particular, you need to compile @file{libgcc.a}, the | |
3465 | library that comes with GNU CC, with @samp{-msoft-float} in order for | |
3466 | this to work. | |
3467 | ||
3468 | @item -mlittle-endian | |
3469 | Generate code for a processor running in little-endian mode. This is | |
3470 | the default for all standard configurations. | |
3471 | ||
3472 | @item -mbig-endian | |
3473 | Generate code for a processor running in big-endian mode; the default is | |
3474 | to compile code for a little-endian processor. | |
3475 | ||
3476 | @item -mwords-little-endian | |
3477 | This option only applies when generating code for big-endian processors. | |
3478 | Generate code for a little-endian word order but a big-endian byte | |
3479 | order. That is, a byte order of the form @samp{32107654}. Note: this | |
3480 | option should only be used if you require compatibility with code for | |
3481 | big-endian ARM processors generated by versions of the compiler prior to | |
3482 | 2.8. | |
3483 | ||
3484 | @item -mshort-load-bytes | |
3485 | @kindex -mshort-load-bytes | |
3486 | Do not try to load half-words (eg @samp{short}s) by loading a word from | |
3487 | an unaligned address. For some targets the MMU is configured to trap | |
3488 | unaligned loads; use this option to generate code that is safe in these | |
3489 | environments. | |
3490 | ||
3491 | @item -mno-short-load-bytes | |
3492 | @kindex -mno-short-load-bytes | |
3493 | Use unaligned word loads to load half-words (eg @samp{short}s). This | |
3494 | option produces more efficient code, but the MMU is sometimes configured | |
3495 | to trap these instructions. | |
3496 | ||
3497 | @item -mbsd | |
3498 | @kindex -mbsd | |
3499 | This option only applies to RISC iX. Emulate the native BSD-mode | |
3500 | compiler. This is the default if @samp{-ansi} is not specified. | |
3501 | ||
3502 | @item -mxopen | |
3503 | @kindex -mxopen | |
3504 | This option only applies to RISC iX. Emulate the native X/Open-mode | |
3505 | compiler. | |
3506 | ||
3507 | @item -mno-symrename | |
3508 | @kindex -mno-symrename | |
3509 | This option only applies to RISC iX. Do not run the assembler | |
3510 | post-processor, @samp{symrename}, after code has been assembled. | |
3511 | Normally it is necessary to modify some of the standard symbols in | |
3512 | preparation for linking with the RISC iX C library; this option | |
3513 | suppresses this pass. The post-processor is never run when the | |
3514 | compiler is built for cross-compilation. | |
3515 | @end table | |
3516 | ||
6d6d0fa0 JL |
3517 | @node MN10300 Options |
3518 | @subsection MN10300 Options | |
3519 | @cindex MN10300 options | |
3520 | These @samp{-m} options are defined for Matsushita MN10300 architectures: | |
3521 | ||
3522 | @table @code | |
3523 | @item -mmult-bug | |
3524 | Generate code to avoid bugs in the multiply instructions for the MN10300 | |
3525 | processors. This is the default. | |
3526 | ||
3527 | @item -mno-mult-bug | |
3528 | Do not generate code to avoid bugs in the multiply instructions for the | |
3529 | MN10300 processors. | |
3530 | @end table | |
3531 | ||
861bb6c1 JL |
3532 | @node M32R/D Options |
3533 | @subsection M32R/D Options | |
3534 | @cindex M32R/D options | |
3535 | ||
3536 | These @samp{-m} options are defined for Mitsubishi M32R/D architectures: | |
3537 | ||
3538 | @table @code | |
3539 | @item -mcode-model=small | |
3540 | Assume all objects live in the lower 16MB of memory (so that their addresses | |
3541 | can be loaded with the @code{ld24} instruction), and assume all subroutines | |
3542 | are reachable with the @code{bl} instruction. | |
3543 | This is the default. | |
3544 | ||
3545 | The addressability of a particular object can be set with the | |
3546 | @code{model} attribute. | |
3547 | ||
3548 | @item -mcode-model=medium | |
3549 | Assume objects may be anywhere in the 32 bit address space (the compiler | |
3550 | will generate @code{seth/add3} instructions to load their addresses), and | |
3551 | assume all subroutines are reachable with the @code{bl} instruction. | |
3552 | ||
3553 | @item -mcode-model=large | |
3554 | Assume objects may be anywhere in the 32 bit address space (the compiler | |
3555 | will generate @code{seth/add3} instructions to load their addresses), and | |
3556 | assume subroutines may not be reachable with the @code{bl} instruction | |
3557 | (the compiler will generate the much slower @code{seth/add3/jl} | |
3558 | instruction sequence). | |
3559 | ||
3560 | @item -msdata=none | |
3561 | Disable use of the small data area. Variables will be put into | |
3562 | one of @samp{.data}, @samp{bss}, or @samp{.rodata} (unless the | |
3563 | @code{section} attribute has been specified). | |
3564 | This is the default. | |
3565 | ||
3566 | The small data area consists of sections @samp{.sdata} and @samp{.sbss}. | |
3567 | Objects may be explicitly put in the small data area with the | |
3568 | @code{section} attribute using one of these sections. | |
3569 | ||
3570 | @item -msdata=sdata | |
3571 | Put small global and static data in the small data area, but do not | |
3572 | generate special code to reference them. | |
3573 | ||
3574 | @item -msdata=use | |
3575 | Put small global and static data in the small data area, and generate | |
3576 | special instructions to reference them. | |
3577 | ||
3578 | @item -G @var{num} | |
3579 | @cindex smaller data references | |
3580 | Put global and static objects less than or equal to @var{num} bytes | |
3581 | into the small data or bss sections instead of the normal data or bss | |
3582 | sections. The default value of @var{num} is 8. | |
3583 | The @samp{-msdata} option must be set to one of @samp{sdata} or @samp{use} | |
3584 | for this option to have any effect. | |
3585 | ||
3586 | All modules should be compiled with the same @samp{-G @var{num}} value. | |
3587 | Compiling with different values of @var{num} may or may not work; if it | |
3588 | doesn't the linker will give an error message - incorrect code will not be | |
3589 | generated. | |
3590 | ||
3591 | @end table | |
3592 | ||
74291a4b MM |
3593 | @node M88K Options |
3594 | @subsection M88K Options | |
3595 | @cindex M88k options | |
3596 | ||
3597 | These @samp{-m} options are defined for Motorola 88k architectures: | |
3598 | ||
3599 | @table @code | |
3600 | @item -m88000 | |
3601 | @kindex -m88000 | |
3602 | Generate code that works well on both the m88100 and the | |
3603 | m88110. | |
3604 | ||
3605 | @item -m88100 | |
3606 | @kindex -m88100 | |
3607 | Generate code that works best for the m88100, but that also | |
3608 | runs on the m88110. | |
3609 | ||
3610 | @item -m88110 | |
3611 | @kindex -m88110 | |
3612 | Generate code that works best for the m88110, and may not run | |
3613 | on the m88100. | |
3614 | ||
3615 | @item -mbig-pic | |
3616 | @kindex -mbig-pic | |
3617 | Obsolete option to be removed from the next revision. | |
3618 | Use @samp{-fPIC}. | |
3619 | ||
3620 | @item -midentify-revision | |
3621 | @kindex -midentify-revision | |
3622 | @kindex ident | |
3623 | @cindex identifying source, compiler (88k) | |
3624 | Include an @code{ident} directive in the assembler output recording the | |
3625 | source file name, compiler name and version, timestamp, and compilation | |
3626 | flags used. | |
3627 | ||
3628 | @item -mno-underscores | |
3629 | @kindex -mno-underscores | |
3630 | @cindex underscores, avoiding (88k) | |
3631 | In assembler output, emit symbol names without adding an underscore | |
3632 | character at the beginning of each name. The default is to use an | |
3633 | underscore as prefix on each name. | |
3634 | ||
3635 | @item -mocs-debug-info | |
3636 | @itemx -mno-ocs-debug-info | |
3637 | @kindex -mocs-debug-info | |
3638 | @kindex -mno-ocs-debug-info | |
3639 | @cindex OCS (88k) | |
3640 | @cindex debugging, 88k OCS | |
3641 | Include (or omit) additional debugging information (about registers used | |
3642 | in each stack frame) as specified in the 88open Object Compatibility | |
3643 | Standard, ``OCS''. This extra information allows debugging of code that | |
3644 | has had the frame pointer eliminated. The default for DG/UX, SVr4, and | |
3645 | Delta 88 SVr3.2 is to include this information; other 88k configurations | |
3646 | omit this information by default. | |
3647 | ||
3648 | @item -mocs-frame-position | |
3649 | @kindex -mocs-frame-position | |
3650 | @cindex register positions in frame (88k) | |
3651 | When emitting COFF debugging information for automatic variables and | |
3652 | parameters stored on the stack, use the offset from the canonical frame | |
3653 | address, which is the stack pointer (register 31) on entry to the | |
3654 | function. The DG/UX, SVr4, Delta88 SVr3.2, and BCS configurations use | |
3655 | @samp{-mocs-frame-position}; other 88k configurations have the default | |
3656 | @samp{-mno-ocs-frame-position}. | |
3657 | ||
3658 | @item -mno-ocs-frame-position | |
3659 | @kindex -mno-ocs-frame-position | |
3660 | @cindex register positions in frame (88k) | |
3661 | When emitting COFF debugging information for automatic variables and | |
3662 | parameters stored on the stack, use the offset from the frame pointer | |
3663 | register (register 30). When this option is in effect, the frame | |
3664 | pointer is not eliminated when debugging information is selected by the | |
3665 | -g switch. | |
3666 | ||
3667 | @item -moptimize-arg-area | |
3668 | @itemx -mno-optimize-arg-area | |
3669 | @kindex -moptimize-arg-area | |
3670 | @kindex -mno-optimize-arg-area | |
3671 | @cindex arguments in frame (88k) | |
3672 | Control how function arguments are stored in stack frames. | |
3673 | @samp{-moptimize-arg-area} saves space by optimizing them, but this | |
3674 | conflicts with the 88open specifications. The opposite alternative, | |
3675 | @samp{-mno-optimize-arg-area}, agrees with 88open standards. By default | |
3676 | GNU CC does not optimize the argument area. | |
3677 | ||
3678 | @item -mshort-data-@var{num} | |
3679 | @kindex -mshort-data-@var{num} | |
3680 | @cindex smaller data references (88k) | |
3681 | @cindex r0-relative references (88k) | |
3682 | Generate smaller data references by making them relative to @code{r0}, | |
3683 | which allows loading a value using a single instruction (rather than the | |
3684 | usual two). You control which data references are affected by | |
3685 | specifying @var{num} with this option. For example, if you specify | |
3686 | @samp{-mshort-data-512}, then the data references affected are those | |
3687 | involving displacements of less than 512 bytes. | |
3688 | @samp{-mshort-data-@var{num}} is not effective for @var{num} greater | |
3689 | than 64k. | |
3690 | ||
3691 | @item -mserialize-volatile | |
3692 | @kindex -mserialize-volatile | |
3693 | @itemx -mno-serialize-volatile | |
3694 | @kindex -mno-serialize-volatile | |
3695 | @cindex sequential consistency on 88k | |
3696 | Do, or don't, generate code to guarantee sequential consistency | |
3697 | of volatile memory references. By default, consistency is | |
3698 | guaranteed. | |
3699 | ||
3700 | The order of memory references made by the MC88110 processor does | |
3701 | not always match the order of the instructions requesting those | |
3702 | references. In particular, a load instruction may execute before | |
3703 | a preceding store instruction. Such reordering violates | |
3704 | sequential consistency of volatile memory references, when there | |
3705 | are multiple processors. When consistency must be guaranteed, | |
3706 | GNU C generates special instructions, as needed, to force | |
3707 | execution in the proper order. | |
3708 | ||
3709 | The MC88100 processor does not reorder memory references and so | |
3710 | always provides sequential consistency. However, by default, GNU | |
3711 | C generates the special instructions to guarantee consistency | |
3712 | even when you use @samp{-m88100}, so that the code may be run on an | |
3713 | MC88110 processor. If you intend to run your code only on the | |
3714 | MC88100 processor, you may use @samp{-mno-serialize-volatile}. | |
3715 | ||
3716 | The extra code generated to guarantee consistency may affect the | |
3717 | performance of your application. If you know that you can safely | |
3718 | forgo this guarantee, you may use @samp{-mno-serialize-volatile}. | |
3719 | ||
3720 | @item -msvr4 | |
3721 | @itemx -msvr3 | |
3722 | @kindex -msvr4 | |
3723 | @kindex -msvr3 | |
3724 | @cindex assembler syntax, 88k | |
3725 | @cindex SVr4 | |
3726 | Turn on (@samp{-msvr4}) or off (@samp{-msvr3}) compiler extensions | |
3727 | related to System V release 4 (SVr4). This controls the following: | |
3728 | ||
3729 | @enumerate | |
3730 | @item | |
3731 | Which variant of the assembler syntax to emit. | |
3732 | @item | |
3733 | @samp{-msvr4} makes the C preprocessor recognize @samp{#pragma weak} | |
3734 | that is used on System V release 4. | |
3735 | @item | |
3736 | @samp{-msvr4} makes GNU CC issue additional declaration directives used in | |
3737 | SVr4. | |
3738 | @end enumerate | |
3739 | ||
3740 | @samp{-msvr4} is the default for the m88k-motorola-sysv4 and | |
3741 | m88k-dg-dgux m88k configurations. @samp{-msvr3} is the default for all | |
3742 | other m88k configurations. | |
3743 | ||
3744 | @item -mversion-03.00 | |
3745 | @kindex -mversion-03.00 | |
3746 | This option is obsolete, and is ignored. | |
3747 | @c ??? which asm syntax better for GAS? option there too? | |
3748 | ||
3749 | @item -mno-check-zero-division | |
3750 | @itemx -mcheck-zero-division | |
3751 | @kindex -mno-check-zero-division | |
3752 | @kindex -mcheck-zero-division | |
3753 | @cindex zero division on 88k | |
3754 | Do, or don't, generate code to guarantee that integer division by | |
3755 | zero will be detected. By default, detection is guaranteed. | |
3756 | ||
3757 | Some models of the MC88100 processor fail to trap upon integer | |
3758 | division by zero under certain conditions. By default, when | |
3759 | compiling code that might be run on such a processor, GNU C | |
3760 | generates code that explicitly checks for zero-valued divisors | |
3761 | and traps with exception number 503 when one is detected. Use of | |
3762 | mno-check-zero-division suppresses such checking for code | |
3763 | generated to run on an MC88100 processor. | |
3764 | ||
3765 | GNU C assumes that the MC88110 processor correctly detects all | |
3766 | instances of integer division by zero. When @samp{-m88110} is | |
3767 | specified, both @samp{-mcheck-zero-division} and | |
3768 | @samp{-mno-check-zero-division} are ignored, and no explicit checks for | |
3769 | zero-valued divisors are generated. | |
3770 | ||
3771 | @item -muse-div-instruction | |
3772 | @kindex -muse-div-instruction | |
3773 | @cindex divide instruction, 88k | |
3774 | Use the div instruction for signed integer division on the | |
3775 | MC88100 processor. By default, the div instruction is not used. | |
3776 | ||
3777 | On the MC88100 processor the signed integer division instruction | |
3778 | div) traps to the operating system on a negative operand. The | |
3779 | operating system transparently completes the operation, but at a | |
3780 | large cost in execution time. By default, when compiling code | |
3781 | that might be run on an MC88100 processor, GNU C emulates signed | |
3782 | integer division using the unsigned integer division instruction | |
3783 | divu), thereby avoiding the large penalty of a trap to the | |
3784 | operating system. Such emulation has its own, smaller, execution | |
3785 | cost in both time and space. To the extent that your code's | |
3786 | important signed integer division operations are performed on two | |
3787 | nonnegative operands, it may be desirable to use the div | |
3788 | instruction directly. | |
3789 | ||
3790 | On the MC88110 processor the div instruction (also known as the | |
3791 | divs instruction) processes negative operands without trapping to | |
3792 | the operating system. When @samp{-m88110} is specified, | |
3793 | @samp{-muse-div-instruction} is ignored, and the div instruction is used | |
3794 | for signed integer division. | |
3795 | ||
3796 | Note that the result of dividing INT_MIN by -1 is undefined. In | |
3797 | particular, the behavior of such a division with and without | |
3798 | @samp{-muse-div-instruction} may differ. | |
3799 | ||
3800 | @item -mtrap-large-shift | |
3801 | @itemx -mhandle-large-shift | |
3802 | @kindex -mtrap-large-shift | |
3803 | @kindex -mhandle-large-shift | |
3804 | @cindex bit shift overflow (88k) | |
3805 | @cindex large bit shifts (88k) | |
3806 | Include code to detect bit-shifts of more than 31 bits; respectively, | |
3807 | trap such shifts or emit code to handle them properly. By default GNU CC | |
3808 | makes no special provision for large bit shifts. | |
3809 | ||
3810 | @item -mwarn-passed-structs | |
3811 | @kindex -mwarn-passed-structs | |
3812 | @cindex structure passing (88k) | |
3813 | Warn when a function passes a struct as an argument or result. | |
3814 | Structure-passing conventions have changed during the evolution of the C | |
3815 | language, and are often the source of portability problems. By default, | |
3816 | GNU CC issues no such warning. | |
3817 | @end table | |
3818 | ||
3819 | @node RS/6000 and PowerPC Options | |
3820 | @subsection IBM RS/6000 and PowerPC Options | |
3821 | @cindex RS/6000 and PowerPC Options | |
3822 | @cindex IBM RS/6000 and PowerPC Options | |
3823 | ||
3824 | These @samp{-m} options are defined for the IBM RS/6000 and PowerPC: | |
3825 | @table @code | |
3826 | @item -mpower | |
3827 | @itemx -mno-power | |
3828 | @itemx -mpower2 | |
3829 | @itemx -mno-power2 | |
3830 | @itemx -mpowerpc | |
3831 | @itemx -mno-powerpc | |
3832 | @itemx -mpowerpc-gpopt | |
3833 | @itemx -mno-powerpc-gpopt | |
3834 | @itemx -mpowerpc-gfxopt | |
3835 | @itemx -mno-powerpc-gfxopt | |
3836 | @kindex -mpower | |
3837 | @kindex -mpower2 | |
3838 | @kindex -mpowerpc | |
3839 | @kindex -mpowerpc-gpopt | |
3840 | @kindex -mpowerpc-gfxopt | |
3841 | GNU CC supports two related instruction set architectures for the | |
3842 | RS/6000 and PowerPC. The @dfn{POWER} instruction set are those | |
3843 | instructions supported by the @samp{rios} chip set used in the original | |
3844 | RS/6000 systems and the @dfn{PowerPC} instruction set is the | |
3845 | architecture of the Motorola MPC5xx, MPC6xx, MPC8xx microprocessors, and | |
861bb6c1 | 3846 | the IBM 4xx microprocessors. |
74291a4b MM |
3847 | |
3848 | Neither architecture is a subset of the other. However there is a | |
3849 | large common subset of instructions supported by both. An MQ | |
3850 | register is included in processors supporting the POWER architecture. | |
3851 | ||
3852 | You use these options to specify which instructions are available on the | |
3853 | processor you are using. The default value of these options is | |
3854 | determined when configuring GNU CC. Specifying the | |
3855 | @samp{-mcpu=@var{cpu_type}} overrides the specification of these | |
3856 | options. We recommend you use the @samp{-mcpu=@var{cpu_type}} option | |
3857 | rather than the options listed above. | |
3858 | ||
3859 | The @samp{-mpower} option allows GNU CC to generate instructions that | |
3860 | are found only in the POWER architecture and to use the MQ register. | |
3861 | Specifying @samp{-mpower2} implies @samp{-power} and also allows GNU CC | |
3862 | to generate instructions that are present in the POWER2 architecture but | |
3863 | not the original POWER architecture. | |
3864 | ||
3865 | The @samp{-mpowerpc} option allows GNU CC to generate instructions that | |
3866 | are found only in the 32-bit subset of the PowerPC architecture. | |
3867 | Specifying @samp{-mpowerpc-gpopt} implies @samp{-mpowerpc} and also allows | |
3868 | GNU CC to use the optional PowerPC architecture instructions in the | |
3869 | General Purpose group, including floating-point square root. Specifying | |
3870 | @samp{-mpowerpc-gfxopt} implies @samp{-mpowerpc} and also allows GNU CC to | |
3871 | use the optional PowerPC architecture instructions in the Graphics | |
3872 | group, including floating-point select. | |
3873 | ||
3874 | If you specify both @samp{-mno-power} and @samp{-mno-powerpc}, GNU CC | |
3875 | will use only the instructions in the common subset of both | |
3876 | architectures plus some special AIX common-mode calls, and will not use | |
3877 | the MQ register. Specifying both @samp{-mpower} and @samp{-mpowerpc} | |
3878 | permits GNU CC to use any instruction from either architecture and to | |
3879 | allow use of the MQ register; specify this for the Motorola MPC601. | |
3880 | ||
3881 | @item -mnew-mnemonics | |
3882 | @itemx -mold-mnemonics | |
3883 | @kindex -mnew-mnemonics | |
3884 | @kindex -mold-mnemonics | |
3885 | Select which mnemonics to use in the generated assembler code. | |
3886 | @samp{-mnew-mnemonics} requests output that uses the assembler mnemonics | |
3887 | defined for the PowerPC architecture, while @samp{-mold-mnemonics} | |
3888 | requests the assembler mnemonics defined for the POWER architecture. | |
3889 | Instructions defined in only one architecture have only one mnemonic; | |
3890 | GNU CC uses that mnemonic irrespective of which of these options is | |
3891 | specified. | |
3892 | ||
3893 | PowerPC assemblers support both the old and new mnemonics, as will later | |
3894 | POWER assemblers. Current POWER assemblers only support the old | |
3895 | mnemonics. Specify @samp{-mnew-mnemonics} if you have an assembler that | |
3896 | supports them, otherwise specify @samp{-mold-mnemonics}. | |
3897 | ||
3898 | The default value of these options depends on how GNU CC was configured. | |
3899 | Specifying @samp{-mcpu=@var{cpu_type}} sometimes overrides the value of | |
3900 | these option. Unless you are building a cross-compiler, you should | |
3901 | normally not specify either @samp{-mnew-mnemonics} or | |
3902 | @samp{-mold-mnemonics}, but should instead accept the default. | |
3903 | ||
3904 | @item -mcpu=@var{cpu_type} | |
3905 | Set architecture type, register usage, choice of mnemonics, and | |
3906 | instruction scheduling parameters for machine type @var{cpu_type}. | |
3907 | Supported values for @var{cpu_type} are @samp{rs6000}, @samp{rios1}, | |
3908 | @samp{rios2}, @samp{rsc}, @samp{601}, @samp{602}, @samp{603}, | |
861bb6c1 JL |
3909 | @samp{603e}, @samp{604}, @samp{604e}, @samp{620}, @samp{power}, |
3910 | @samp{power2}, @samp{powerpc}, @samp{403}, @samp{505}, @samp{801}, | |
3911 | @samp{821}, @samp{823}, and @samp{860} and @samp{common}. | |
3912 | @samp{-mcpu=power}, @samp{-mcpu=power2}, and @samp{-mcpu=powerpc} | |
3913 | specify generic POWER, POWER2 and pure PowerPC (i.e., not MPC601) | |
3914 | architecture machine types, with an appropriate, generic processor model | |
3915 | assumed for scheduling purposes.@refill | |
74291a4b MM |
3916 | |
3917 | @c overfull hbox here --bob 22 jul96 | |
3918 | @c original text between ignore ... end ignore | |
3919 | @ignore | |
861bb6c1 JL |
3920 | Specifying any of the @samp{-mcpu=rios1}, @samp{-mcpu=rios2}, |
3921 | @samp{-mcpu=rsc}, @samp{-mcpu=power}, or @samp{-mcpu=power2} options | |
3922 | enables the @samp{-mpower} option and disables the @samp{-mpowerpc} | |
3923 | option; @samp{-mcpu=601} enables both the @samp{-mpower} and | |
3924 | @samp{-mpowerpc} options; all of @samp{-mcpu=602}, @samp{-mcpu=603}, | |
3925 | @samp{-mcpu=603e}, @samp{-mcpu=604}, @samp{-mcpu=604e}, | |
3926 | @samp{-mcpu=620}, @samp{-mcpu=403}, @samp{-mcpu=505}, @samp{-mcpu=801}, | |
3927 | @samp{-mcpu=821}, @samp{-mcpu=823}, @samp{-mcpu=860} and | |
3928 | @samp{-mcpu=powerpc} enable the @samp{-mpowerpc} option and disable the | |
3929 | @samp{-mpower} option; @samp{-mcpu=common} disables both the | |
3930 | @samp{-mpower} and @samp{-mpowerpc} options.@refill | |
74291a4b MM |
3931 | @end ignore |
3932 | @c changed paragraph | |
3933 | Specifying any of the following options: | |
3934 | @samp{-mcpu=rios1}, @samp{-mcpu=rios2}, @samp{-mcpu=rsc}, | |
3935 | @samp{-mcpu=power}, or @samp{-mcpu=power2} | |
3936 | enables the @samp{-mpower} option and disables the @samp{-mpowerpc} option; | |
3937 | @samp{-mcpu=601} enables both the @samp{-mpower} and @samp{-mpowerpc} options. | |
3938 | All of @samp{-mcpu=602}, @samp{-mcpu=603}, @samp{-mcpu=603e}, | |
3939 | @samp{-mcpu=604}, @samp{-mcpu=620}, | |
3940 | enable the @samp{-mpowerpc} option and disable the @samp{-mpower} option. | |
3941 | Exactly similarly, all of @samp{-mcpu=403}, | |
3942 | @samp{-mcpu=505}, @samp{-mcpu=821}, @samp{-mcpu=860} and @samp{-mcpu=powerpc} | |
3943 | enable the @samp{-mpowerpc} option and disable the @samp{-mpower} option. | |
3944 | @samp{-mcpu=common} disables both the | |
3945 | @samp{-mpower} and @samp{-mpowerpc} options.@refill | |
3946 | @c end changes to prevent overfull hboxes | |
3947 | ||
3948 | AIX versions 4 or greater selects @samp{-mcpu=common} by default, so | |
3949 | that code will operate on all members of the RS/6000 and PowerPC | |
3950 | families. In that case, GNU CC will use only the instructions in the | |
3951 | common subset of both architectures plus some special AIX common-mode | |
3952 | calls, and will not use the MQ register. GNU CC assumes a generic | |
3953 | processor model for scheduling purposes. | |
3954 | ||
3955 | Specifying any of the options @samp{-mcpu=rios1}, @samp{-mcpu=rios2}, | |
3956 | @samp{-mcpu=rsc}, @samp{-mcpu=power}, or @samp{-mcpu=power2} also | |
3957 | disables the @samp{new-mnemonics} option. Specifying @samp{-mcpu=601}, | |
3958 | @samp{-mcpu=602}, @samp{-mcpu=603}, @samp{-mcpu=603e}, @samp{-mcpu=604}, | |
3959 | @samp{620}, @samp{403}, or @samp{-mcpu=powerpc} also enables the | |
3960 | @samp{new-mnemonics} option.@refill | |
3961 | ||
3962 | Specifying @samp{-mcpu=403}, @samp{-mcpu=821}, or @samp{-mcpu=860} also | |
3963 | enables the @samp{-msoft-float} option. | |
3964 | ||
3965 | @item -mtune=@var{cpu_type} | |
3966 | Set the instruction scheduling parameters for machine type | |
3967 | @var{cpu_type}, but do not set the architecture type, register usage, | |
3968 | choice of mnemonics like @samp{-mcpu=}@var{cpu_type} would. The same | |
3969 | values for @var{cpu_type} are used for @samp{-mtune=}@var{cpu_type} as | |
3970 | for @samp{-mcpu=}@var{cpu_type}. The @samp{-mtune=}@var{cpu_type} | |
3971 | option overrides the @samp{-mcpu=}@var{cpu_type} option in terms of | |
3972 | instruction scheduling parameters. | |
3973 | ||
3974 | @item -mfull-toc | |
3975 | @itemx -mno-fp-in-toc | |
3976 | @itemx -mno-sum-in-toc | |
3977 | @itemx -mminimal-toc | |
3978 | Modify generation of the TOC (Table Of Contents), which is created for | |
3979 | every executable file. The @samp{-mfull-toc} option is selected by | |
3980 | default. In that case, GNU CC will allocate at least one TOC entry for | |
3981 | each unique non-automatic variable reference in your program. GNU CC | |
3982 | will also place floating-point constants in the TOC. However, only | |
3983 | 16,384 entries are available in the TOC. | |
3984 | ||
3985 | If you receive a linker error message that saying you have overflowed | |
3986 | the available TOC space, you can reduce the amount of TOC space used | |
3987 | with the @samp{-mno-fp-in-toc} and @samp{-mno-sum-in-toc} options. | |
3988 | @samp{-mno-fp-in-toc} prevents GNU CC from putting floating-point | |
3989 | constants in the TOC and @samp{-mno-sum-in-toc} forces GNU CC to | |
3990 | generate code to calculate the sum of an address and a constant at | |
3991 | run-time instead of putting that sum into the TOC. You may specify one | |
3992 | or both of these options. Each causes GNU CC to produce very slightly | |
3993 | slower and larger code at the expense of conserving TOC space. | |
3994 | ||
3995 | If you still run out of space in the TOC even when you specify both of | |
3996 | these options, specify @samp{-mminimal-toc} instead. This option causes | |
3997 | GNU CC to make only one TOC entry for every file. When you specify this | |
3998 | option, GNU CC will produce code that is slower and larger but which | |
3999 | uses extremely little TOC space. You may wish to use this option | |
4000 | only on files that contain less frequently executed code. @refill | |
4001 | ||
4002 | @item -mxl-call | |
4003 | @itemx -mno-xl-call | |
4004 | On AIX, pass floating-point arguments to prototyped functions beyond the | |
4005 | register save area (RSA) on the stack in addition to argument FPRs. The | |
4006 | AIX calling convention was extended but not initially documented to | |
4007 | handle an obscure K&R C case of calling a function that takes the | |
4008 | address of its arguments with fewer arguments than declared. AIX XL | |
4009 | compilers assume that floating point arguments which do not fit in the | |
4010 | RSA are on the stack when they compile a subroutine without | |
4011 | optimization. Because always storing floating-point arguments on the | |
4012 | stack is inefficient and rarely needed, this option is not enabled by | |
4013 | default and only is necessary when calling subroutines compiled by AIX | |
4014 | XL compilers without optimization. | |
4015 | ||
861bb6c1 JL |
4016 | @item -mthreads |
4017 | Support @dfn{AIX Threads}. Link an application written to use | |
4018 | @dfn{pthreads} with special libraries and startup code to enable the | |
4019 | application to run. | |
4020 | ||
4021 | @item -mpe | |
4022 | Support @dfn{IBM RS/6000 SP} @dfn{Parallel Environment} (PE). Link an | |
4023 | application written to use message passing with special startup code to | |
4024 | enable the application to run. The system must have PE installed in the | |
4025 | standard location (@file{/usr/lpp/ppe.poe/}), or the @file{specs} file | |
4026 | must be overridden with the @samp{-specs=} option to specify the | |
4027 | appropriate directory location. The Parallel Environment does not | |
4028 | support threads, so the @samp{-mpe} option and the @samp{-mthreads} | |
4029 | option are incompatible. | |
4030 | ||
74291a4b MM |
4031 | @item -msoft-float |
4032 | @itemx -mhard-float | |
4033 | Generate code that does not use (uses) the floating-point register set. | |
4034 | Software floating point emulation is provided if you use the | |
4035 | @samp{-msoft-float} option, and pass the option to GNU CC when linking. | |
4036 | ||
4037 | @item -mmultiple | |
4038 | @itemx -mno-multiple | |
4039 | Generate code that uses (does not use) the load multiple word | |
4040 | instructions and the store multiple word instructions. These | |
4041 | instructions are generated by default on POWER systems, and not | |
4042 | generated on PowerPC systems. Do not use @samp{-mmultiple} on little | |
4043 | endian PowerPC systems, since those instructions do not work when the | |
4044 | processor is in little endian mode. | |
4045 | ||
4046 | @item -mstring | |
4047 | @itemx -mno-string | |
4048 | Generate code that uses (does not use) the load string instructions and the | |
4049 | store string word instructions to save multiple registers and do small block | |
861bb6c1 | 4050 | moves. These instructions are generated by default on POWER systems, and not |
74291a4b MM |
4051 | generated on PowerPC systems. Do not use @samp{-mstring} on little endian |
4052 | PowerPC systems, since those instructions do not work when the processor is in | |
4053 | little endian mode. | |
4054 | ||
861bb6c1 JL |
4055 | @item -mupdate |
4056 | @itemx -mno-update | |
4057 | Generate code that uses (does not use) the load or store instructions | |
4058 | that update the base register to the address of the calculated memory | |
4059 | location. These instructions are generated by default. If you use | |
4060 | @samp{-mno-update}, there is a small window between the time that the | |
4061 | stack pointer is updated and the address of the previous frame is | |
4062 | stored, which means code that walks the stack frame across interrupts or | |
4063 | signals may get corrupted data. | |
4064 | ||
4065 | @item -mfused-madd | |
4066 | @itemx -mno-fused-madd | |
4067 | Generate code that uses (does not use) the floating point multiply and | |
4068 | accumulate instructions. These instructions are generated by default if | |
4069 | hardware floating is used. | |
4070 | ||
74291a4b MM |
4071 | @item -mno-bit-align |
4072 | @itemx -mbit-align | |
4073 | On System V.4 and embedded PowerPC systems do not (do) force structures | |
4074 | and unions that contain bit fields to be aligned to the base type of the | |
4075 | bit field. | |
4076 | ||
4077 | For example, by default a structure containing nothing but 8 | |
4078 | @code{unsigned} bitfields of length 1 would be aligned to a 4 byte | |
4079 | boundary and have a size of 4 bytes. By using @samp{-mno-bit-align}, | |
4080 | the structure would be aligned to a 1 byte boundary and be one byte in | |
4081 | size. | |
4082 | ||
4083 | @item -mno-strict-align | |
4084 | @itemx -mstrict-align | |
4085 | On System V.4 and embedded PowerPC systems do not (do) assume that | |
4086 | unaligned memory references will be handled by the system. | |
4087 | ||
4088 | @item -mrelocatable | |
4089 | @itemx -mno-relocatable | |
4090 | On embedded PowerPC systems generate code that allows (does not allow) | |
4091 | the program to be relocated to a different address at runtime. If you | |
4092 | use @samp{-mrelocatable} on any module, all objects linked together must | |
4093 | be compiled with @samp{-mrelocatable} or @samp{-mrelocatable-lib}. | |
4094 | ||
4095 | @item -mrelocatable-lib | |
4096 | @itemx -mno-relocatable-lib | |
4097 | On embedded PowerPC systems generate code that allows (does not allow) | |
4098 | the program to be relocated to a different address at runtime. Modules | |
4099 | compiled with @samp{-mreloctable-lib} can be linked with either modules | |
4100 | compiled without @samp{-mrelocatable} and @samp{-mrelocatable-lib} or | |
4101 | with modules compiled with the @samp{-mrelocatable} options. | |
4102 | ||
4103 | @item -mno-toc | |
4104 | @itemx -mtoc | |
4105 | On System V.4 and embedded PowerPC systems do not (do) assume that | |
4106 | register 2 contains a pointer to a global area pointing to the addresses | |
4107 | used in the program. | |
4108 | ||
4109 | @item -mno-traceback | |
4110 | @itemx -mtraceback | |
4111 | On embedded PowerPC systems do not (do) generate a traceback tag before | |
4112 | the start of the function. This tag can be used by the debugger to | |
4113 | identify where the start of a function is. | |
4114 | ||
4115 | @item -mlittle | |
4116 | @itemx -mlittle-endian | |
4117 | On System V.4 and embedded PowerPC systems compile code for the | |
4118 | processor in little endian mode. The @samp{-mlittle-endian} option is | |
4119 | the same as @samp{-mlittle}. | |
4120 | ||
4121 | @item -mbig | |
4122 | @itemx -mbig-endian | |
4123 | On System V.4 and embedded PowerPC systems compile code for the | |
4124 | processor in big endian mode. The @samp{-mbig-endian} option is | |
4125 | the same as @samp{-mbig}. | |
4126 | ||
4127 | @item -mcall-sysv | |
4128 | On System V.4 and embedded PowerPC systems compile code using calling | |
4129 | conventions that adheres to the March 1995 draft of the System V | |
4130 | Application Binary Interface, PowerPC processor supplement. This is the | |
4131 | default unless you configured GCC using @samp{powerpc-*-eabiaix}. | |
4132 | ||
4133 | @item -mcall-sysv-eabi | |
4134 | Specify both @samp{-mcall-sysv} and @samp{-meabi} options. | |
4135 | ||
4136 | @item -mcall-sysv-noeabi | |
4137 | Specify both @samp{-mcall-sysv} and @samp{-mno-eabi} options. | |
4138 | ||
4139 | @item -mcall-aix | |
4140 | On System V.4 and embedded PowerPC systems compile code using calling | |
4141 | conventions that are similar to those used on AIX. This is the | |
4142 | default if you configured GCC using @samp{powerpc-*-eabiaix}. | |
4143 | ||
4144 | @item -mcall-solaris | |
4145 | On System V.4 and embedded PowerPC systems compile code for the Solaris | |
4146 | operating system. | |
4147 | ||
4148 | @item -mcall-linux | |
861bb6c1 JL |
4149 | On System V.4 and embedded PowerPC systems compile code for the |
4150 | Linux-based GNU system. | |
74291a4b MM |
4151 | |
4152 | @item -mprototype | |
e9a25f70 | 4153 | @itemx -mno-prototype |
74291a4b MM |
4154 | On System V.4 and embedded PowerPC systems assume that all calls to |
4155 | variable argument functions are properly prototyped. Otherwise, the | |
4156 | compiler must insert an instruction before every non prototyped call to | |
4157 | set or clear bit 6 of the condition code register (@var{CR}) to | |
4158 | indicate whether floating point values were passed in the floating point | |
4159 | registers in case the function takes a variable arguments. With | |
4160 | @samp{-mprototype}, only calls to prototyped variable argument functions | |
4161 | will set or clear the bit. | |
4162 | ||
4163 | @item -msim | |
4164 | On embedded PowerPC systems, assume that the startup module is called | |
4165 | @file{sim-crt0.o} and that the standard C libraries are @file{libsim.a} and | |
4166 | @file{libc.a}. This is the default for @samp{powerpc-*-eabisim}. | |
4167 | configurations. | |
4168 | ||
4169 | @item -mmvme | |
4170 | On embedded PowerPC systems, assume that the startup module is called | |
e9a25f70 JL |
4171 | @file{crt0.o} and the standard C libraries are @file{libmvme.a} and |
4172 | @file{libc.a}. | |
4173 | ||
4174 | @item -mads | |
4175 | On embedded PowerPC systems, assume that the startup module is called | |
4176 | @file{crt0.o} and the standard C libraries are @file{libads.a} and | |
4177 | @file{libc.a}. | |
4178 | ||
4179 | @item -myellowknife | |
4180 | On embedded PowerPC systems, assume that the startup module is called | |
4181 | @file{crt0.o} and the standard C libraries are @file{libyk.a} and | |
74291a4b MM |
4182 | @file{libc.a}. |
4183 | ||
4184 | @item -memb | |
4185 | On embedded PowerPC systems, set the @var{PPC_EMB} bit in the ELF flags | |
4186 | header to indicate that @samp{eabi} extended relocations are used. | |
4187 | ||
4188 | @item -meabi | |
4189 | @itemx -mno-eabi | |
4190 | On System V.4 and embedded PowerPC systems do (do not) adhere to the | |
4191 | Embedded Applications Binary Interface (eabi) which is a set of | |
4192 | modifications to the System V.4 specifications. Selecting @code{-meabi} | |
4193 | means that the stack is aligned to an 8 byte boundary, a function | |
4194 | @code{__eabi} is called to from @code{main} to set up the eabi | |
4195 | environment, and the @samp{-msdata} option can use both @code{r2} and | |
4196 | @code{r13} to point to two separate small data areas. Selecting | |
4197 | @code{-mno-eabi} means that the stack is aligned to a 16 byte boundary, | |
4198 | do not call an initialization function from @code{main}, and the | |
4199 | @samp{-msdata} option will only use @code{r13} to point to a single | |
4200 | small data area. The @samp{-meabi} option is on by default if you | |
4201 | configured GCC using one of the @samp{powerpc*-*-eabi*} options. | |
4202 | ||
4203 | @item -msdata=eabi | |
4204 | On System V.4 and embedded PowerPC systems, put small initialized | |
4205 | @code{const} global and static data in the @samp{.sdata2} section, which | |
4206 | is pointed to by register @code{r2}. Put small initialized | |
4207 | non-@code{const} global and static data in the @samp{.sdata} section, | |
4208 | which is pointed to by register @code{r13}. Put small uninitialized | |
4209 | global and static data in the @samp{.sbss} section, which is adjacent to | |
4210 | the @samp{.sdata} section. The @samp{-msdata=eabi} option is | |
4211 | incompatible with the @samp{-mrelocatable} option. The | |
4212 | @samp{-msdata=eabi} option also sets the @samp{-memb} option. | |
4213 | ||
4214 | @item -msdata=sysv | |
4215 | On System V.4 and embedded PowerPC systems, put small global and static | |
4216 | data in the @samp{.sdata} section, which is pointed to by register | |
4217 | @code{r13}. Put small uninitialized global and static data in the | |
4218 | @samp{.sbss} section, which is adjacent to the @samp{.sdata} section. | |
4219 | The @samp{-msdata=sysv} option is incompatible with the | |
4220 | @samp{-mrelocatable} option. | |
4221 | ||
4222 | @item -msdata=default | |
4223 | @itemx -msdata | |
4224 | On System V.4 and embedded PowerPC systems, if @samp{-meabi} is used, | |
4225 | compile code the same as @samp{-msdata=eabi}, otherwise compile code the | |
4226 | same as @samp{-msdata=sysv}. | |
4227 | ||
4228 | @item -msdata-data | |
4229 | On System V.4 and embedded PowerPC systems, put small global and static | |
4230 | data in the @samp{.sdata} section. Put small uninitialized global and | |
4231 | static data in the @samp{.sbss} section. Do not use register @code{r13} | |
4232 | to address small data however. This is the default behavior unless | |
4233 | other @samp{-msdata} options are used. | |
4234 | ||
4235 | @item -msdata=none | |
4236 | @itemx -mno-sdata | |
4237 | On embedded PowerPC systems, put all initialized global and static data | |
4238 | in the @samp{.data} section, and all uninitialized data in the | |
4239 | @samp{.bss} section. | |
4240 | ||
4241 | @item -G @var{num} | |
4242 | @cindex smaller data references (PowerPC) | |
4243 | @cindex .sdata/.sdata2 references (PowerPC) | |
4244 | On embbeded PowerPC systems, put global and static items less than or | |
4245 | equal to @var{num} bytes into the small data or bss sections instead of | |
4246 | the normal data or bss section. By default, @var{num} is 8. The | |
4247 | @samp{-G @var{num}} switch is also passed to the linker. | |
4248 | All modules should be compiled with the same @samp{-G @var{num}} value. | |
4249 | ||
4250 | @item -mregnames | |
4251 | @itemx -mno-regnames | |
4252 | On System V.4 and embedded PowerPC systems do (do not) emit register | |
4253 | names in the assembly language output using symbolic forms. | |
4254 | @end table | |
4255 | @node RT Options | |
4256 | @subsection IBM RT Options | |
4257 | @cindex RT options | |
4258 | @cindex IBM RT options | |
4259 | ||
4260 | These @samp{-m} options are defined for the IBM RT PC: | |
4261 | ||
4262 | @table @code | |
4263 | @item -min-line-mul | |
4264 | Use an in-line code sequence for integer multiplies. This is the | |
4265 | default. | |
4266 | ||
4267 | @item -mcall-lib-mul | |
4268 | Call @code{lmul$$} for integer multiples. | |
4269 | ||
4270 | @item -mfull-fp-blocks | |
4271 | Generate full-size floating point data blocks, including the minimum | |
4272 | amount of scratch space recommended by IBM. This is the default. | |
4273 | ||
4274 | @item -mminimum-fp-blocks | |
4275 | Do not include extra scratch space in floating point data blocks. This | |
4276 | results in smaller code, but slower execution, since scratch space must | |
4277 | be allocated dynamically. | |
4278 | ||
4279 | @cindex @file{varargs.h} and RT PC | |
4280 | @cindex @file{stdarg.h} and RT PC | |
4281 | @item -mfp-arg-in-fpregs | |
4282 | Use a calling sequence incompatible with the IBM calling convention in | |
4283 | which floating point arguments are passed in floating point registers. | |
4284 | Note that @code{varargs.h} and @code{stdargs.h} will not work with | |
4285 | floating point operands if this option is specified. | |
4286 | ||
4287 | @item -mfp-arg-in-gregs | |
4288 | Use the normal calling convention for floating point arguments. This is | |
4289 | the default. | |
4290 | ||
4291 | @item -mhc-struct-return | |
4292 | Return structures of more than one word in memory, rather than in a | |
4293 | register. This provides compatibility with the MetaWare HighC (hc) | |
4294 | compiler. Use the option @samp{-fpcc-struct-return} for compatibility | |
4295 | with the Portable C Compiler (pcc). | |
4296 | ||
4297 | @item -mnohc-struct-return | |
4298 | Return some structures of more than one word in registers, when | |
4299 | convenient. This is the default. For compatibility with the | |
4300 | IBM-supplied compilers, use the option @samp{-fpcc-struct-return} or the | |
4301 | option @samp{-mhc-struct-return}. | |
4302 | @end table | |
4303 | ||
4304 | @node MIPS Options | |
4305 | @subsection MIPS Options | |
4306 | @cindex MIPS options | |
4307 | ||
4308 | These @samp{-m} options are defined for the MIPS family of computers: | |
4309 | ||
4310 | @table @code | |
4311 | @item -mcpu=@var{cpu type} | |
4312 | Assume the defaults for the machine type @var{cpu type} when scheduling | |
4313 | instructions. The choices for @var{cpu type} are @samp{r2000}, @samp{r3000}, | |
4314 | @samp{r4000}, @samp{r4400}, @samp{r4600}, and @samp{r6000}. While picking a | |
4315 | specific @var{cpu type} will schedule things appropriately for that | |
4316 | particular chip, the compiler will not generate any code that does not | |
4317 | meet level 1 of the MIPS ISA (instruction set architecture) without | |
4318 | the @samp{-mips2} or @samp{-mips3} switches being used. | |
4319 | ||
4320 | @item -mips1 | |
4321 | Issue instructions from level 1 of the MIPS ISA. This is the default. | |
4322 | @samp{r3000} is the default @var{cpu type} at this ISA level. | |
4323 | ||
4324 | @item -mips2 | |
4325 | Issue instructions from level 2 of the MIPS ISA (branch likely, square | |
4326 | root instructions). @samp{r6000} is the default @var{cpu type} at this | |
4327 | ISA level. | |
4328 | ||
4329 | @item -mips3 | |
4330 | Issue instructions from level 3 of the MIPS ISA (64 bit instructions). | |
4331 | @samp{r4000} is the default @var{cpu type} at this ISA level. | |
4332 | This option does not change the sizes of any of the C data types. | |
4333 | ||
4334 | @item -mfp32 | |
4335 | Assume that 32 32-bit floating point registers are available. This is | |
4336 | the default. | |
4337 | ||
4338 | @item -mfp64 | |
4339 | Assume that 32 64-bit floating point registers are available. This is | |
4340 | the default when the @samp{-mips3} option is used. | |
4341 | ||
4342 | @item -mgp32 | |
4343 | Assume that 32 32-bit general purpose registers are available. This is | |
4344 | the default. | |
4345 | ||
4346 | @item -mgp64 | |
4347 | Assume that 32 64-bit general purpose registers are available. This is | |
4348 | the default when the @samp{-mips3} option is used. | |
4349 | ||
4350 | @item -mint64 | |
4351 | Types long, int, and pointer are 64 bits. This works only if @samp{-mips3} | |
4352 | is also specified. | |
4353 | ||
4354 | @item -mlong64 | |
4355 | Types long and pointer are 64 bits, and type int is 32 bits. | |
4356 | This works only if @samp{-mips3} is also specified. | |
4357 | ||
4358 | @item -mmips-as | |
4359 | Generate code for the MIPS assembler, and invoke @file{mips-tfile} to | |
4360 | add normal debug information. This is the default for all | |
4361 | platforms except for the OSF/1 reference platform, using the OSF/rose | |
4362 | object format. If the either of the @samp{-gstabs} or @samp{-gstabs+} | |
4363 | switches are used, the @file{mips-tfile} program will encapsulate the | |
4364 | stabs within MIPS ECOFF. | |
4365 | ||
4366 | @item -mgas | |
4367 | Generate code for the GNU assembler. This is the default on the OSF/1 | |
861bb6c1 JL |
4368 | reference platform, using the OSF/rose object format. Also, this is |
4369 | the default if the configure option @samp{--with-gnu-as} is used. | |
4370 | ||
4371 | @item -msplit-addresses | |
4372 | @itemx -mno-split-addresses | |
4373 | Generate code to load the high and low parts of address constants separately. | |
4374 | This allows @code{gcc} to optimize away redundant loads of the high order | |
4375 | bits of addresses. This optimization requires GNU as and GNU ld. | |
4376 | This optimization is enabled by default for some embedded targets where | |
4377 | GNU as and GNU ld are standard. | |
74291a4b MM |
4378 | |
4379 | @item -mrnames | |
4380 | @itemx -mno-rnames | |
4381 | The @samp{-mrnames} switch says to output code using the MIPS software | |
4382 | names for the registers, instead of the hardware names (ie, @var{a0} | |
4383 | instead of @var{$4}). The only known assembler that supports this option | |
4384 | is the Algorithmics assembler. | |
4385 | ||
4386 | @item -mgpopt | |
4387 | @itemx -mno-gpopt | |
4388 | The @samp{-mgpopt} switch says to write all of the data declarations | |
4389 | before the instructions in the text section, this allows the MIPS | |
4390 | assembler to generate one word memory references instead of using two | |
4391 | words for short global or static data items. This is on by default if | |
4392 | optimization is selected. | |
4393 | ||
4394 | @item -mstats | |
4395 | @itemx -mno-stats | |
4396 | For each non-inline function processed, the @samp{-mstats} switch | |
4397 | causes the compiler to emit one line to the standard error file to | |
4398 | print statistics about the program (number of registers saved, stack | |
4399 | size, etc.). | |
4400 | ||
4401 | @item -mmemcpy | |
4402 | @itemx -mno-memcpy | |
4403 | The @samp{-mmemcpy} switch makes all block moves call the appropriate | |
4404 | string function (@samp{memcpy} or @samp{bcopy}) instead of possibly | |
4405 | generating inline code. | |
4406 | ||
4407 | @item -mmips-tfile | |
4408 | @itemx -mno-mips-tfile | |
4409 | The @samp{-mno-mips-tfile} switch causes the compiler not | |
4410 | postprocess the object file with the @file{mips-tfile} program, | |
4411 | after the MIPS assembler has generated it to add debug support. If | |
4412 | @file{mips-tfile} is not run, then no local variables will be | |
4413 | available to the debugger. In addition, @file{stage2} and | |
4414 | @file{stage3} objects will have the temporary file names passed to the | |
4415 | assembler embedded in the object file, which means the objects will | |
4416 | not compare the same. The @samp{-mno-mips-tfile} switch should only | |
4417 | be used when there are bugs in the @file{mips-tfile} program that | |
4418 | prevents compilation. | |
4419 | ||
4420 | @item -msoft-float | |
4421 | Generate output containing library calls for floating point. | |
4422 | @strong{Warning:} the requisite libraries are not part of GNU CC. | |
4423 | Normally the facilities of the machine's usual C compiler are used, but | |
4424 | this can't be done directly in cross-compilation. You must make your | |
4425 | own arrangements to provide suitable library functions for | |
4426 | cross-compilation. | |
4427 | ||
4428 | @item -mhard-float | |
4429 | Generate output containing floating point instructions. This is the | |
4430 | default if you use the unmodified sources. | |
4431 | ||
4432 | @item -mabicalls | |
4433 | @itemx -mno-abicalls | |
4434 | Emit (or do not emit) the pseudo operations @samp{.abicalls}, | |
4435 | @samp{.cpload}, and @samp{.cprestore} that some System V.4 ports use for | |
4436 | position independent code. | |
4437 | ||
4438 | @item -mlong-calls | |
4439 | @itemx -mno-long-calls | |
4440 | Do all calls with the @samp{JALR} instruction, which requires | |
4441 | loading up a function's address into a register before the call. | |
4442 | You need to use this switch, if you call outside of the current | |
4443 | 512 megabyte segment to functions that are not through pointers. | |
4444 | ||
4445 | @item -mhalf-pic | |
4446 | @itemx -mno-half-pic | |
4447 | Put pointers to extern references into the data section and load them | |
4448 | up, rather than put the references in the text section. | |
4449 | ||
4450 | @item -membedded-pic | |
4451 | @itemx -mno-embedded-pic | |
4452 | Generate PIC code suitable for some embedded systems. All calls are made | |
4453 | using PC relative address, and all data is addressed using the $gp register. | |
4454 | This requires GNU as and GNU ld which do most of the work. | |
4455 | ||
4456 | @item -membedded-data | |
4457 | @itemx -mno-embedded-data | |
4458 | Allocate variables to the read-only data section first if possible, then | |
4459 | next in the small data section if possible, otherwise in data. This gives | |
4460 | slightly slower code than the default, but reduces the amount of RAM required | |
4461 | when executing, and thus may be preferred for some embedded systems. | |
4462 | ||
4463 | @item -msingle-float | |
4464 | @itemx -mdouble-float | |
4465 | The @samp{-msingle-float} switch tells gcc to assume that the floating | |
4466 | point coprocessor only supports single precision operations, as on the | |
4467 | @samp{r4650} chip. The @samp{-mdouble-float} switch permits gcc to use | |
4468 | double precision operations. This is the default. | |
4469 | ||
4470 | @item -mmad | |
4471 | @itemx -mno-mad | |
4472 | Permit use of the @samp{mad}, @samp{madu} and @samp{mul} instructions, | |
4473 | as on the @samp{r4650} chip. | |
4474 | ||
4475 | @item -m4650 | |
4476 | Turns on @samp{-msingle-float}, @samp{-mmad}, and, at least for now, | |
4477 | @samp{-mcpu=r4650}. | |
4478 | ||
4479 | @item -EL | |
4480 | Compile code for the processor in little endian mode. | |
4481 | The requisite libraries are assumed to exist. | |
4482 | ||
4483 | @item -EB | |
4484 | Compile code for the processor in big endian mode. | |
4485 | The requisite libraries are assumed to exist. | |
4486 | ||
4487 | @item -G @var{num} | |
4488 | @cindex smaller data references (MIPS) | |
4489 | @cindex gp-relative references (MIPS) | |
4490 | Put global and static items less than or equal to @var{num} bytes into | |
4491 | the small data or bss sections instead of the normal data or bss | |
4492 | section. This allows the assembler to emit one word memory reference | |
4493 | instructions based on the global pointer (@var{gp} or @var{$28}), | |
4494 | instead of the normal two words used. By default, @var{num} is 8 when | |
4495 | the MIPS assembler is used, and 0 when the GNU assembler is used. The | |
4496 | @samp{-G @var{num}} switch is also passed to the assembler and linker. | |
4497 | All modules should be compiled with the same @samp{-G @var{num}} | |
4498 | value. | |
4499 | ||
4500 | @item -nocpp | |
4501 | Tell the MIPS assembler to not run it's preprocessor over user | |
4502 | assembler files (with a @samp{.s} suffix) when assembling them. | |
4503 | @end table | |
4504 | ||
4505 | @ifset INTERNALS | |
4506 | These options are defined by the macro | |
4507 | @code{TARGET_SWITCHES} in the machine description. The default for the | |
4508 | options is also defined by that macro, which enables you to change the | |
4509 | defaults. | |
4510 | @end ifset | |
4511 | ||
4512 | @node i386 Options | |
4513 | @subsection Intel 386 Options | |
4514 | @cindex i386 Options | |
4515 | @cindex Intel 386 Options | |
4516 | ||
4517 | These @samp{-m} options are defined for the i386 family of computers: | |
4518 | ||
4519 | @table @code | |
4520 | @item -m486 | |
4521 | @itemx -m386 | |
4522 | Control whether or not code is optimized for a 486 instead of an | |
4523 | 386. Code generated for an 486 will run on a 386 and vice versa. | |
4524 | ||
4525 | @item -mieee-fp | |
4526 | @itemx -mno-ieee-fp | |
4527 | Control whether or not the compiler uses IEEE floating point | |
4528 | comparisons. These handle correctly the case where the result of a | |
4529 | comparison is unordered. | |
4530 | ||
4531 | @item -msoft-float | |
4532 | Generate output containing library calls for floating point. | |
4533 | @strong{Warning:} the requisite libraries are not part of GNU CC. | |
4534 | Normally the facilities of the machine's usual C compiler are used, but | |
4535 | this can't be done directly in cross-compilation. You must make your | |
4536 | own arrangements to provide suitable library functions for | |
4537 | cross-compilation. | |
4538 | ||
4539 | On machines where a function returns floating point results in the 80387 | |
4540 | register stack, some floating point opcodes may be emitted even if | |
4541 | @samp{-msoft-float} is used. | |
4542 | ||
4543 | @item -mno-fp-ret-in-387 | |
4544 | Do not use the FPU registers for return values of functions. | |
4545 | ||
4546 | The usual calling convention has functions return values of types | |
4547 | @code{float} and @code{double} in an FPU register, even if there | |
4548 | is no FPU. The idea is that the operating system should emulate | |
4549 | an FPU. | |
4550 | ||
4551 | The option @samp{-mno-fp-ret-in-387} causes such values to be returned | |
4552 | in ordinary CPU registers instead. | |
4553 | ||
4554 | @item -mno-fancy-math-387 | |
4555 | Some 387 emulators do not support the @code{sin}, @code{cos} and | |
4556 | @code{sqrt} instructions for the 387. Specify this option to avoid | |
4557 | generating those instructions. This option is the default on FreeBSD. | |
4558 | As of revision 2.6.1, these instructions are not generated unless you | |
4559 | also use the @samp{-ffast-math} switch. | |
4560 | ||
4561 | @item -malign-double | |
4562 | @itemx -mno-align-double | |
4563 | Control whether GNU CC aligns @code{double}, @code{long double}, and | |
4564 | @code{long long} variables on a two word boundary or a one word | |
4565 | boundary. Aligning @code{double} variables on a two word boundary will | |
4566 | produce code that runs somewhat faster on a @samp{Pentium} at the | |
4567 | expense of more memory. | |
4568 | ||
4569 | @strong{Warning:} if you use the @samp{-malign-double} switch, | |
4570 | structures containing the above types will be aligned differently than | |
4571 | the published application binary interface specifications for the 386. | |
4572 | ||
4573 | @item -msvr3-shlib | |
4574 | @itemx -mno-svr3-shlib | |
4575 | Control whether GNU CC places uninitialized locals into @code{bss} or | |
4576 | @code{data}. @samp{-msvr3-shlib} places these locals into @code{bss}. | |
4577 | These options are meaningful only on System V Release 3. | |
4578 | ||
4579 | @item -mno-wide-multiply | |
4580 | @itemx -mwide-multiply | |
4581 | Control whether GNU CC uses the @code{mul} and @code{imul} that produce | |
4582 | 64 bit results in @code{eax:edx} from 32 bit operands to do @code{long | |
4583 | long} multiplies and 32-bit division by constants. | |
4584 | ||
4585 | @item -mrtd | |
4586 | Use a different function-calling convention, in which functions that | |
4587 | take a fixed number of arguments return with the @code{ret} @var{num} | |
4588 | instruction, which pops their arguments while returning. This saves one | |
4589 | instruction in the caller since there is no need to pop the arguments | |
4590 | there. | |
4591 | ||
4592 | You can specify that an individual function is called with this calling | |
4593 | sequence with the function attribute @samp{stdcall}. You can also | |
4594 | override the @samp{-mrtd} option by using the function attribute | |
4595 | @samp{cdecl}. @xref{Function Attributes} | |
4596 | ||
4597 | @strong{Warning:} this calling convention is incompatible with the one | |
4598 | normally used on Unix, so you cannot use it if you need to call | |
4599 | libraries compiled with the Unix compiler. | |
4600 | ||
4601 | Also, you must provide function prototypes for all functions that | |
4602 | take variable numbers of arguments (including @code{printf}); | |
4603 | otherwise incorrect code will be generated for calls to those | |
4604 | functions. | |
4605 | ||
4606 | In addition, seriously incorrect code will result if you call a | |
4607 | function with too many arguments. (Normally, extra arguments are | |
4608 | harmlessly ignored.) | |
4609 | ||
4610 | @item -mreg-alloc=@var{regs} | |
4611 | Control the default allocation order of integer registers. The | |
4612 | string @var{regs} is a series of letters specifying a register. The | |
4613 | supported letters are: @code{a} allocate EAX; @code{b} allocate EBX; | |
4614 | @code{c} allocate ECX; @code{d} allocate EDX; @code{S} allocate ESI; | |
4615 | @code{D} allocate EDI; @code{B} allocate EBP. | |
4616 | ||
4617 | @item -mregparm=@var{num} | |
4618 | Control how many registers are used to pass integer arguments. By | |
4619 | default, no registers are used to pass arguments, and at most 3 | |
4620 | registers can be used. You can control this behavior for a specific | |
4621 | function by using the function attribute @samp{regparm}. @xref{Function Attributes} | |
4622 | ||
4623 | @strong{Warning:} if you use this switch, and | |
4624 | @var{num} is nonzero, then you must build all modules with the same | |
4625 | value, including any libraries. This includes the system libraries and | |
4626 | startup modules. | |
4627 | ||
4628 | @item -malign-loops=@var{num} | |
4629 | Align loops to a 2 raised to a @var{num} byte boundary. If | |
4630 | @samp{-malign-loops} is not specified, the default is 2. | |
4631 | ||
4632 | @item -malign-jumps=@var{num} | |
4633 | Align instructions that are only jumped to to a 2 raised to a @var{num} | |
4634 | byte boundary. If @samp{-malign-jumps} is not specified, the default is | |
4635 | 2 if optimizing for a 386, and 4 if optimizing for a 486. | |
4636 | ||
4637 | @item -malign-functions=@var{num} | |
4638 | Align the start of functions to a 2 raised to @var{num} byte boundary. | |
6d4312dd | 4639 | If @samp{-malign-functions} is not specified, the default is 2 if optimizing |
74291a4b MM |
4640 | for a 386, and 4 if optimizing for a 486. |
4641 | @end table | |
4642 | ||
4643 | @node HPPA Options | |
4644 | @subsection HPPA Options | |
4645 | @cindex HPPA Options | |
4646 | ||
4647 | These @samp{-m} options are defined for the HPPA family of computers: | |
4648 | ||
4649 | @table @code | |
4650 | @item -mpa-risc-1-0 | |
4651 | Generate code for a PA 1.0 processor. | |
4652 | ||
4653 | @item -mpa-risc-1-1 | |
4654 | Generate code for a PA 1.1 processor. | |
4655 | ||
861bb6c1 JL |
4656 | @item -mbig-switch |
4657 | Generate code suitable for big switch tables. Use this option only if | |
4658 | the assembler/linker complain about out of range branches within a switch | |
4659 | table. | |
4660 | ||
74291a4b MM |
4661 | @item -mjump-in-delay |
4662 | Fill delay slots of function calls with unconditional jump instructions | |
4663 | by modifying the return pointer for the function call to be the target | |
4664 | of the conditional jump. | |
4665 | ||
4666 | @item -mdisable-fpregs | |
4667 | Prevent floating point registers from being used in any manner. This is | |
4668 | necessary for compiling kernels which perform lazy context switching of | |
4669 | floating point registers. If you use this option and attempt to perform | |
4670 | floating point operations, the compiler will abort. | |
4671 | ||
4672 | @item -mdisable-indexing | |
4673 | Prevent the compiler from using indexing address modes. This avoids some | |
4674 | rather obscure problems when compiling MIG generated code under MACH. | |
4675 | ||
4676 | @item -mno-space-regs | |
4677 | Generate code that assumes the target has no space registers. This allows | |
4678 | GCC to generate faster indirect calls and use unscaled index address modes. | |
4679 | ||
4680 | Such code is suitable for level 0 PA systems and kernels. | |
4681 | ||
4682 | @item -mfast-indirect-calls | |
4683 | Generate code that assumes calls never cross space boundaries. This | |
4684 | allows GCC to emit code which performs faster indirect calls. | |
4685 | ||
4686 | This option will not work in the presense of shared libraries or nested | |
4687 | functions. | |
4688 | ||
4689 | @item -mspace | |
4690 | Optimize for space rather than execution time. Currently this only | |
4691 | enables out of line function prologues and epilogues. This option is | |
4692 | incompatable with PIC code generation and profiling. | |
4693 | ||
4694 | @item -mlong-load-store | |
4695 | Generate 3-instruction load and store sequences as sometimes required by | |
4696 | the HP-UX 10 linker. This is equivalent to the @samp{+k} option to | |
4697 | the HP compilers. | |
4698 | ||
4699 | @item -mportable-runtime | |
4700 | Use the portable calling conventions proposed by HP for ELF systems. | |
4701 | ||
4702 | @item -mgas | |
4703 | Enable the use of assembler directives only GAS understands. | |
4704 | ||
4705 | @item -mschedule=@var{cpu type} | |
4706 | Schedule code according to the constraints for the machine type | |
4707 | @var{cpu type}. The choices for @var{cpu type} are @samp{700} for | |
4708 | 7@var{n}0 machines, @samp{7100} for 7@var{n}5 machines, and @samp{7100} | |
4709 | for 7@var{n}2 machines. @samp{7100} is the default for @var{cpu type}. | |
4710 | ||
4711 | Note the @samp{7100LC} scheduling information is incomplete and using | |
4712 | @samp{7100LC} often leads to bad schedules. For now it's probably best | |
4713 | to use @samp{7100} instead of @samp{7100LC} for the 7@var{n}2 machines. | |
4714 | ||
4715 | @item -mlinker-opt | |
4716 | Enable the optimization pass in the HPUX linker. Note this makes symbolic | |
4717 | debugging impossible. It also triggers a bug in the HPUX 8 and HPUX 9 linkers | |
4718 | in which they give bogus error messages when linking some programs. | |
4719 | ||
4720 | @item -msoft-float | |
4721 | Generate output containing library calls for floating point. | |
4722 | @strong{Warning:} the requisite libraries are not available for all HPPA | |
4723 | targets. Normally the facilities of the machine's usual C compiler are | |
4724 | used, but this cannot be done directly in cross-compilation. You must make | |
4725 | your own arrangements to provide suitable library functions for | |
4726 | cross-compilation. The embedded target @samp{hppa1.1-*-pro} | |
4727 | does provide software floating point support. | |
4728 | ||
4729 | @samp{-msoft-float} changes the calling convention in the output file; | |
4730 | therefore, it is only useful if you compile @emph{all} of a program with | |
4731 | this option. In particular, you need to compile @file{libgcc.a}, the | |
4732 | library that comes with GNU CC, with @samp{-msoft-float} in order for | |
4733 | this to work. | |
4734 | @end table | |
4735 | ||
4736 | @node Intel 960 Options | |
4737 | @subsection Intel 960 Options | |
4738 | ||
4739 | These @samp{-m} options are defined for the Intel 960 implementations: | |
4740 | ||
4741 | @table @code | |
4742 | @item -m@var{cpu type} | |
4743 | Assume the defaults for the machine type @var{cpu type} for some of | |
4744 | the other options, including instruction scheduling, floating point | |
4745 | support, and addressing modes. The choices for @var{cpu type} are | |
4746 | @samp{ka}, @samp{kb}, @samp{mc}, @samp{ca}, @samp{cf}, | |
4747 | @samp{sa}, and @samp{sb}. | |
4748 | The default is | |
4749 | @samp{kb}. | |
4750 | ||
4751 | @item -mnumerics | |
4752 | @itemx -msoft-float | |
4753 | The @samp{-mnumerics} option indicates that the processor does support | |
4754 | floating-point instructions. The @samp{-msoft-float} option indicates | |
4755 | that floating-point support should not be assumed. | |
4756 | ||
4757 | @item -mleaf-procedures | |
4758 | @itemx -mno-leaf-procedures | |
4759 | Do (or do not) attempt to alter leaf procedures to be callable with the | |
4760 | @code{bal} instruction as well as @code{call}. This will result in more | |
4761 | efficient code for explicit calls when the @code{bal} instruction can be | |
4762 | substituted by the assembler or linker, but less efficient code in other | |
4763 | cases, such as calls via function pointers, or using a linker that doesn't | |
4764 | support this optimization. | |
4765 | ||
4766 | @item -mtail-call | |
4767 | @itemx -mno-tail-call | |
4768 | Do (or do not) make additional attempts (beyond those of the | |
4769 | machine-independent portions of the compiler) to optimize tail-recursive | |
4770 | calls into branches. You may not want to do this because the detection of | |
4771 | cases where this is not valid is not totally complete. The default is | |
4772 | @samp{-mno-tail-call}. | |
4773 | ||
4774 | @item -mcomplex-addr | |
4775 | @itemx -mno-complex-addr | |
4776 | Assume (or do not assume) that the use of a complex addressing mode is a | |
4777 | win on this implementation of the i960. Complex addressing modes may not | |
4778 | be worthwhile on the K-series, but they definitely are on the C-series. | |
4779 | The default is currently @samp{-mcomplex-addr} for all processors except | |
4780 | the CB and CC. | |
4781 | ||
4782 | @item -mcode-align | |
4783 | @itemx -mno-code-align | |
4784 | Align code to 8-byte boundaries for faster fetching (or don't bother). | |
4785 | Currently turned on by default for C-series implementations only. | |
4786 | ||
4787 | @ignore | |
4788 | @item -mclean-linkage | |
4789 | @itemx -mno-clean-linkage | |
4790 | These options are not fully implemented. | |
4791 | @end ignore | |
4792 | ||
4793 | @item -mic-compat | |
4794 | @itemx -mic2.0-compat | |
4795 | @itemx -mic3.0-compat | |
4796 | Enable compatibility with iC960 v2.0 or v3.0. | |
4797 | ||
4798 | @item -masm-compat | |
4799 | @itemx -mintel-asm | |
4800 | Enable compatibility with the iC960 assembler. | |
4801 | ||
4802 | @item -mstrict-align | |
4803 | @itemx -mno-strict-align | |
4804 | Do not permit (do permit) unaligned accesses. | |
4805 | ||
4806 | @item -mold-align | |
4807 | Enable structure-alignment compatibility with Intel's gcc release version | |
861bb6c1 | 4808 | 1.3 (based on gcc 1.37). This option implies @samp{-mstrict-align}. |
74291a4b MM |
4809 | @end table |
4810 | ||
4811 | @node DEC Alpha Options | |
4812 | @subsection DEC Alpha Options | |
4813 | ||
4814 | These @samp{-m} options are defined for the DEC Alpha implementations: | |
4815 | ||
4816 | @table @code | |
4817 | @item -mno-soft-float | |
4818 | @itemx -msoft-float | |
4819 | Use (do not use) the hardware floating-point instructions for | |
4820 | floating-point operations. When @code{-msoft-float} is specified, | |
4821 | functions in @file{libgcc1.c} will be used to perform floating-point | |
4822 | operations. Unless they are replaced by routines that emulate the | |
4823 | floating-point operations, or compiled in such a way as to call such | |
4824 | emulations routines, these routines will issue floating-point | |
4825 | operations. If you are compiling for an Alpha without floating-point | |
4826 | operations, you must ensure that the library is built so as not to call | |
4827 | them. | |
4828 | ||
4829 | Note that Alpha implementations without floating-point operations are | |
4830 | required to have floating-point registers. | |
4831 | ||
4832 | @item -mfp-reg | |
4833 | @itemx -mno-fp-regs | |
4834 | Generate code that uses (does not use) the floating-point register set. | |
4835 | @code{-mno-fp-regs} implies @code{-msoft-float}. If the floating-point | |
4836 | register set is not used, floating point operands are passed in integer | |
4837 | registers as if they were integers and floating-point results are passed | |
4838 | in $0 instead of $f0. This is a non-standard calling sequence, so any | |
4839 | function with a floating-point argument or return value called by code | |
4840 | compiled with @code{-mno-fp-regs} must also be compiled with that | |
4841 | option. | |
4842 | ||
4843 | A typical use of this option is building a kernel that does not use, | |
4844 | and hence need not save and restore, any floating-point registers. | |
4845 | ||
4846 | @item -mieee | |
4847 | The Alpha architecture implements floating-point hardware optimized for | |
4848 | maximum performance. It is mostly compliant with the IEEE floating | |
4849 | point standard. However, for full compliance, software assistance is | |
4850 | required. This option generates code fully IEEE compliant code | |
4851 | @emph{except} that the @var{inexact flag} is not maintained (see below). | |
4852 | If this option is turned on, the CPP macro @code{_IEEE_FP} is defined | |
4853 | during compilation. The option is a shorthand for: @samp{-D_IEEE_FP | |
4854 | -mfp-trap-mode=su -mtrap-precision=i -mieee-conformant}. The resulting | |
4855 | code is less efficient but is able to correctly support denormalized | |
4856 | numbers and exceptional IEEE values such as not-a-number and plus/minus | |
4857 | infinity. Other Alpha compilers call this option | |
4858 | @code{-ieee_with_no_inexact}. | |
4859 | ||
4860 | @item -mieee-with-inexact | |
4861 | @c overfull hbox here --bob 22 jul96 | |
4862 | @c original text between ignore ... end ignore | |
4863 | @ignore | |
4864 | This is like @samp{-mieee} except the generated code also maintains the | |
4865 | IEEE @var{inexact flag}. Turning on this option causes the generated | |
4866 | code to implement fully-compliant IEEE math. The option is a shorthand | |
4867 | for @samp{-D_IEEE_FP -D_IEEE_FP_INEXACT} plus @samp{-mieee-conformant}, | |
4868 | @samp{-mfp-trap-mode=sui}, and @samp{-mtrap-precision=i}. On some Alpha | |
4869 | implementations the resulting code may execute significantly slower than | |
4870 | the code generated by default. Since there is very little code that | |
4871 | depends on the @var{inexact flag}, you should normally not specify this | |
4872 | option. Other Alpha compilers call this option | |
4873 | @samp{-ieee_with_inexact}. | |
4874 | @end ignore | |
4875 | @c changed paragraph | |
4876 | This is like @samp{-mieee} except the generated code also maintains the | |
4877 | IEEE @var{inexact flag}. Turning on this option causes the generated | |
4878 | code to implement fully-compliant IEEE math. The option is a shorthand | |
4879 | for @samp{-D_IEEE_FP -D_IEEE_FP_INEXACT} plus the three following: | |
4880 | @samp{-mieee-conformant}, | |
4881 | @samp{-mfp-trap-mode=sui}, | |
4882 | and @samp{-mtrap-precision=i}. | |
4883 | On some Alpha implementations the resulting code may execute | |
4884 | significantly slower than the code generated by default. Since there | |
4885 | is very little code that depends on the @var{inexact flag}, you should | |
4886 | normally not specify this option. Other Alpha compilers call this | |
4887 | option @samp{-ieee_with_inexact}. | |
4888 | @c end changes to prevent overfull hboxes | |
4889 | ||
4890 | @item -mfp-trap-mode=@var{trap mode} | |
4891 | This option controls what floating-point related traps are enabled. | |
4892 | Other Alpha compilers call this option @samp{-fptm }@var{trap mode}. | |
4893 | The trap mode can be set to one of four values: | |
4894 | ||
4895 | @table @samp | |
4896 | @item n | |
4897 | This is the default (normal) setting. The only traps that are enabled | |
4898 | are the ones that cannot be disabled in software (e.g., division by zero | |
4899 | trap). | |
4900 | ||
4901 | @item u | |
4902 | In addition to the traps enabled by @samp{n}, underflow traps are enabled | |
4903 | as well. | |
4904 | ||
4905 | @item su | |
4906 | Like @samp{su}, but the instructions are marked to be safe for software | |
4907 | completion (see Alpha architecture manual for details). | |
4908 | ||
4909 | @item sui | |
4910 | Like @samp{su}, but inexact traps are enabled as well. | |
4911 | @end table | |
4912 | ||
4913 | @item -mfp-rounding-mode=@var{rounding mode} | |
4914 | Selects the IEEE rounding mode. Other Alpha compilers call this option | |
4915 | @samp{-fprm }@var{rounding mode}. The @var{rounding mode} can be one | |
4916 | of: | |
4917 | ||
4918 | @table @samp | |
4919 | @item n | |
4920 | Normal IEEE rounding mode. Floating point numbers are rounded towards | |
4921 | the nearest machine number or towards the even machine number in case | |
4922 | of a tie. | |
4923 | ||
4924 | @item m | |
4925 | Round towards minus infinity. | |
4926 | ||
4927 | @item c | |
4928 | Chopped rounding mode. Floating point numbers are rounded towards zero. | |
4929 | ||
4930 | @item d | |
4931 | Dynamic rounding mode. A field in the floating point control register | |
4932 | (@var{fpcr}, see Alpha architecture reference manual) controls the | |
4933 | rounding mode in effect. The C library initializes this register for | |
4934 | rounding towards plus infinity. Thus, unless your program modifies the | |
4935 | @var{fpcr}, @samp{d} corresponds to round towards plus infinity.@end table | |
4936 | ||
4937 | @item -mtrap-precision=@var{trap precision} | |
4938 | In the Alpha architecture, floating point traps are imprecise. This | |
4939 | means without software assistance it is impossible to recover from a | |
4940 | floating trap and program execution normally needs to be terminated. | |
4941 | GNU CC can generate code that can assist operating system trap handlers | |
4942 | in determining the exact location that caused a floating point trap. | |
4943 | Depending on the requirements of an application, different levels of | |
4944 | precisions can be selected: | |
4945 | ||
4946 | @table @samp | |
4947 | @item p | |
4948 | Program precision. This option is the default and means a trap handler | |
4949 | can only identify which program caused a floating point exception. | |
4950 | ||
4951 | @item f | |
4952 | Function precision. The trap handler can determine the function that | |
4953 | caused a floating point exception. | |
4954 | ||
4955 | @item i | |
4956 | Instruction precision. The trap handler can determine the exact | |
4957 | instruction that caused a floating point exception. | |
4958 | @end table | |
4959 | ||
4960 | Other Alpha compilers provide the equivalent options called | |
4961 | @samp{-scope_safe} and @samp{-resumption_safe}. | |
4962 | ||
4963 | @item -mieee-conformant | |
4964 | This option marks the generated code as IEEE conformant. You must not | |
4965 | use this option unless you also specify @samp{-mtrap-precision=i} and either | |
4966 | @samp{-mfp-trap-mode=su} or @samp{-mfp-trap-mode=sui}. Its only effect | |
4967 | is to emit the line @samp{.eflag 48} in the function prologue of the | |
4968 | generated assembly file. Under DEC Unix, this has the effect that | |
4969 | IEEE-conformant math library routines will be linked in. | |
4970 | ||
4971 | @item -mbuild-constants | |
4972 | Normally GNU CC examines a 32- or 64-bit integer constant to | |
4973 | see if it can construct it from smaller constants in two or three | |
4974 | instructions. If it cannot, it will output the constant as a literal and | |
4975 | generate code to load it from the data segement at runtime. | |
4976 | ||
4977 | Use this option to require GNU CC to construct @emph{all} integer constants | |
4978 | using code, even if it takes more instructions (the maximum is six). | |
4979 | ||
4980 | You would typically use this option to build a shared library dynamic | |
4981 | loader. Itself a shared library, it must relocate itself in memory | |
4982 | before it can find the variables and constants in its own data segment. | |
4983 | @end table | |
4984 | ||
4985 | @node Clipper Options | |
4986 | @subsection Clipper Options | |
4987 | ||
4988 | These @samp{-m} options are defined for the Clipper implementations: | |
4989 | ||
4990 | @table @code | |
4991 | @item -mc300 | |
4992 | Produce code for a C300 Clipper processor. This is the default. | |
4993 | ||
4994 | @itemx -mc400 | |
4995 | Produce code for a C400 Clipper processor i.e. use floating point | |
4996 | registers f8..f15. | |
4997 | @end table | |
4998 | ||
4999 | @node H8/300 Options | |
5000 | @subsection H8/300 Options | |
5001 | ||
5002 | These @samp{-m} options are defined for the H8/300 implementations: | |
5003 | ||
5004 | @table @code | |
5005 | @item -mrelax | |
5006 | Shorten some address references at link time, when possible; uses the | |
5007 | linker option @samp{-relax}. @xref{H8/300,, @code{ld} and the H8/300, | |
5008 | ld.info, Using ld}, for a fuller description. | |
5009 | ||
5010 | @item -mh | |
5011 | Generate code for the H8/300H. | |
5012 | ||
dcb9d1f0 JL |
5013 | @item -ms |
5014 | Generate code for the H8/S. | |
5015 | ||
74291a4b MM |
5016 | @item -mint32 |
5017 | Make @code{int} data 32 bits by default. | |
5018 | ||
5019 | @item -malign-300 | |
5020 | On the h8/300h, use the same alignment rules as for the h8/300. | |
5021 | The default for the h8/300h is to align longs and floats on 4 byte boundaries. | |
5022 | @samp{-malign-300} causes them to be aligned on 2 byte boundaries. | |
5023 | This option has no effect on the h8/300. | |
5024 | @end table | |
5025 | ||
5026 | @node SH Options | |
5027 | @subsection SH Options | |
5028 | ||
5029 | These @samp{-m} options are defined for the SH implementations: | |
5030 | ||
5031 | @table @code | |
5032 | @item -m1 | |
5033 | Generate code for the SH1. | |
5034 | ||
5035 | @item -m2 | |
5036 | Generate code for the SH2. | |
5037 | ||
5038 | @item -m3 | |
5039 | Generate code for the SH3. | |
5040 | ||
5041 | @item -m3e | |
5042 | Generate code for the SH3e. | |
5043 | ||
5044 | @item -mb | |
5045 | Compile code for the processor in big endian mode. | |
5046 | ||
5047 | @item -ml | |
5048 | Compile code for the processor in little endian mode. | |
5049 | ||
5050 | @item -mrelax | |
5051 | Shorten some address references at link time, when possible; uses the | |
5052 | linker option @samp{-relax}. | |
5053 | @end table | |
5054 | ||
5055 | @node System V Options | |
5056 | @subsection Options for System V | |
5057 | ||
5058 | These additional options are available on System V Release 4 for | |
5059 | compatibility with other compilers on those systems: | |
5060 | ||
5061 | @table @code | |
5062 | @item -G | |
5063 | Create a shared object. | |
5064 | It is recommended that @samp{-symbolic} or @samp{-shared} be used instead. | |
5065 | ||
5066 | @item -Qy | |
5067 | Identify the versions of each tool used by the compiler, in a | |
5068 | @code{.ident} assembler directive in the output. | |
5069 | ||
5070 | @item -Qn | |
5071 | Refrain from adding @code{.ident} directives to the output file (this is | |
5072 | the default). | |
5073 | ||
5074 | @item -YP,@var{dirs} | |
5075 | Search the directories @var{dirs}, and no others, for libraries | |
5076 | specified with @samp{-l}. | |
5077 | ||
5078 | @item -Ym,@var{dir} | |
5079 | Look in the directory @var{dir} to find the M4 preprocessor. | |
5080 | The assembler uses this option. | |
5081 | @c This is supposed to go with a -Yd for predefined M4 macro files, but | |
5082 | @c the generic assembler that comes with Solaris takes just -Ym. | |
5083 | @end table | |
5084 | ||
f84271d9 JL |
5085 | @node V850 Options |
5086 | @subsection V850 Options | |
5087 | @cindex V850 Options | |
5088 | ||
5089 | These @samp{-m} options are defined for V850 implementations: | |
5090 | ||
5091 | @table @code | |
5092 | @item -mlong-calls | |
5093 | @itemx -mno-long-calls | |
5094 | Treat all calls as being far away (near). If calls are assumed to be | |
5095 | far away, the compiler will always load the functions address up into a | |
5096 | register, and call indirect through the pointer. | |
5097 | ||
5098 | @item -mno-ep | |
5099 | @item -mep | |
5100 | Do not optimize (do optimize) basic blocks that use the same index | |
5101 | pointer 4 or more times to copy pointer into the @code{ep} register, and | |
5102 | use the shorter @code{sld} and @code{sst} instructions. The @samp{-mep} | |
5103 | option is on by default if you optimize. | |
5104 | ||
5105 | @item -mno-prolog-function | |
5106 | @itemx -mprolog-function | |
5107 | Do not use (do use) external functions to save and restore registers at | |
5108 | the prolog and epilog of a function. The external functions are slower, | |
5109 | but use less code space if more than one function saves the same number | |
5110 | of registers. The @samp{-mprolog-function} option is on by default if | |
5111 | you optimize. | |
5112 | ||
5113 | @item -mspace | |
5114 | Try to make the code as small as possible. At present, this just turns | |
5115 | on the @samp{-mep} and @samp{-mprolog-function} options. | |
5116 | ||
5117 | @item -mtda=@var{n} | |
5118 | Put static or global variables whose size is @var{n} bytes or less into | |
5119 | the tiny data area that register @code{ep} points to. The tiny data | |
5120 | area can hold up to 256 bytes in total (128 bytes for byte references). | |
5121 | ||
5122 | @item -msda=@var{n} | |
5123 | Put static or global variables whose size is @var{n} bytes or less into | |
5124 | the small data area that register @code{gp} points to. The small data | |
5125 | area can hold up to 64 kilobytes. | |
5126 | ||
5127 | @item -mzda=@var{n} | |
5128 | Put static or global variables whose size is @var{n} bytes or less into | |
5129 | the first 32 kilobytes of memory. | |
e9a25f70 | 5130 | |
48f0be1b SC |
5131 | @item -mv850 |
5132 | Specify that the target processor is the V850. | |
5133 | ||
e9a25f70 JL |
5134 | @item -mbig-switch |
5135 | Generate code suitable for big switch tables. Use this option only if | |
5136 | the assembler/linker complain about out of range branches within a switch | |
5137 | table. | |
f84271d9 JL |
5138 | @end table |
5139 | ||
74291a4b MM |
5140 | @node Code Gen Options |
5141 | @section Options for Code Generation Conventions | |
5142 | @cindex code generation conventions | |
5143 | @cindex options, code generation | |
5144 | @cindex run-time options | |
5145 | ||
5146 | These machine-independent options control the interface conventions | |
5147 | used in code generation. | |
5148 | ||
5149 | Most of them have both positive and negative forms; the negative form | |
5150 | of @samp{-ffoo} would be @samp{-fno-foo}. In the table below, only | |
5151 | one of the forms is listed---the one which is not the default. You | |
5152 | can figure out the other form by either removing @samp{no-} or adding | |
5153 | it. | |
5154 | ||
5155 | @table @code | |
5156 | @item -fpcc-struct-return | |
5157 | Return ``short'' @code{struct} and @code{union} values in memory like | |
5158 | longer ones, rather than in registers. This convention is less | |
5159 | efficient, but it has the advantage of allowing intercallability between | |
5160 | GNU CC-compiled files and files compiled with other compilers. | |
5161 | ||
5162 | The precise convention for returning structures in memory depends | |
5163 | on the target configuration macros. | |
5164 | ||
5165 | Short structures and unions are those whose size and alignment match | |
5166 | that of some integer type. | |
5167 | ||
5168 | @item -freg-struct-return | |
5169 | Use the convention that @code{struct} and @code{union} values are | |
5170 | returned in registers when possible. This is more efficient for small | |
5171 | structures than @samp{-fpcc-struct-return}. | |
5172 | ||
5173 | If you specify neither @samp{-fpcc-struct-return} nor its contrary | |
5174 | @samp{-freg-struct-return}, GNU CC defaults to whichever convention is | |
5175 | standard for the target. If there is no standard convention, GNU CC | |
5176 | defaults to @samp{-fpcc-struct-return}, except on targets where GNU CC | |
5177 | is the principal compiler. In those cases, we can choose the standard, | |
5178 | and we chose the more efficient register return alternative. | |
5179 | ||
5180 | @item -fshort-enums | |
5181 | Allocate to an @code{enum} type only as many bytes as it needs for the | |
5182 | declared range of possible values. Specifically, the @code{enum} type | |
5183 | will be equivalent to the smallest integer type which has enough room. | |
5184 | ||
5185 | @item -fshort-double | |
5186 | Use the same size for @code{double} as for @code{float}. | |
5187 | ||
5188 | @item -fshared-data | |
5189 | Requests that the data and non-@code{const} variables of this | |
5190 | compilation be shared data rather than private data. The distinction | |
5191 | makes sense only on certain operating systems, where shared data is | |
5192 | shared between processes running the same program, while private data | |
5193 | exists in one copy per process. | |
5194 | ||
5195 | @item -fno-common | |
5196 | Allocate even uninitialized global variables in the bss section of the | |
5197 | object file, rather than generating them as common blocks. This has the | |
5198 | effect that if the same variable is declared (without @code{extern}) in | |
5199 | two different compilations, you will get an error when you link them. | |
5200 | The only reason this might be useful is if you wish to verify that the | |
5201 | program will work on other systems which always work this way. | |
5202 | ||
5203 | @item -fno-ident | |
5204 | Ignore the @samp{#ident} directive. | |
5205 | ||
5206 | @item -fno-gnu-linker | |
5207 | Do not output global initializations (such as C++ constructors and | |
5208 | destructors) in the form used by the GNU linker (on systems where the GNU | |
5209 | linker is the standard method of handling them). Use this option when | |
5210 | you want to use a non-GNU linker, which also requires using the | |
5211 | @code{collect2} program to make sure the system linker includes | |
5212 | constructors and destructors. (@code{collect2} is included in the GNU CC | |
5213 | distribution.) For systems which @emph{must} use @code{collect2}, the | |
5214 | compiler driver @code{gcc} is configured to do this automatically. | |
5215 | ||
5216 | @item -finhibit-size-directive | |
5217 | Don't output a @code{.size} assembler directive, or anything else that | |
5218 | would cause trouble if the function is split in the middle, and the | |
5219 | two halves are placed at locations far apart in memory. This option is | |
5220 | used when compiling @file{crtstuff.c}; you should not need to use it | |
5221 | for anything else. | |
5222 | ||
5223 | @item -fverbose-asm | |
5224 | Put extra commentary information in the generated assembly code to | |
5225 | make it more readable. This option is generally only of use to those | |
5226 | who actually need to read the generated assembly code (perhaps while | |
5227 | debugging the compiler itself). | |
5228 | ||
5229 | @samp{-fverbose-asm} is the default. @samp{-fno-verbose-asm} causes the | |
5230 | extra information to be omitted and is useful when comparing two assembler | |
5231 | files. | |
5232 | ||
5233 | @item -fvolatile | |
5234 | Consider all memory references through pointers to be volatile. | |
5235 | ||
5236 | @item -fvolatile-global | |
5237 | Consider all memory references to extern and global data items to | |
5238 | be volatile. | |
5239 | ||
5240 | @item -fpic | |
5241 | @cindex global offset table | |
5242 | @cindex PIC | |
5243 | Generate position-independent code (PIC) suitable for use in a shared | |
5244 | library, if supported for the target machine. Such code accesses all | |
861bb6c1 JL |
5245 | constant addresses through a global offset table (GOT). The dynamic |
5246 | loader resolves the GOT entries when the program starts (the dynamic | |
5247 | loader is not part of GNU CC; it is part of the operating system). If | |
5248 | the GOT size for the linked executable exceeds a machine-specific | |
5249 | maximum size, you get an error message from the linker indicating that | |
5250 | @samp{-fpic} does not work; in that case, recompile with @samp{-fPIC} | |
5251 | instead. (These maximums are 16k on the m88k, 8k on the Sparc, and 32k | |
5252 | on the m68k and RS/6000. The 386 has no such limit.) | |
74291a4b MM |
5253 | |
5254 | Position-independent code requires special support, and therefore works | |
5255 | only on certain machines. For the 386, GNU CC supports PIC for System V | |
5256 | but not for the Sun 386i. Code generated for the IBM RS/6000 is always | |
5257 | position-independent. | |
5258 | ||
74291a4b MM |
5259 | @item -fPIC |
5260 | If supported for the target machine, emit position-independent code, | |
5261 | suitable for dynamic linking and avoiding any limit on the size of the | |
5262 | global offset table. This option makes a difference on the m68k, m88k, | |
5263 | and the Sparc. | |
5264 | ||
5265 | Position-independent code requires special support, and therefore works | |
5266 | only on certain machines. | |
5267 | ||
5268 | @item -ffixed-@var{reg} | |
5269 | Treat the register named @var{reg} as a fixed register; generated code | |
5270 | should never refer to it (except perhaps as a stack pointer, frame | |
5271 | pointer or in some other fixed role). | |
5272 | ||
5273 | @var{reg} must be the name of a register. The register names accepted | |
5274 | are machine-specific and are defined in the @code{REGISTER_NAMES} | |
5275 | macro in the machine description macro file. | |
5276 | ||
5277 | This flag does not have a negative form, because it specifies a | |
5278 | three-way choice. | |
5279 | ||
5280 | @item -fcall-used-@var{reg} | |
5281 | Treat the register named @var{reg} as an allocatable register that is | |
5282 | clobbered by function calls. It may be allocated for temporaries or | |
5283 | variables that do not live across a call. Functions compiled this way | |
5284 | will not save and restore the register @var{reg}. | |
5285 | ||
5286 | Use of this flag for a register that has a fixed pervasive role in the | |
5287 | machine's execution model, such as the stack pointer or frame pointer, | |
5288 | will produce disastrous results. | |
5289 | ||
5290 | This flag does not have a negative form, because it specifies a | |
5291 | three-way choice. | |
5292 | ||
5293 | @item -fcall-saved-@var{reg} | |
5294 | Treat the register named @var{reg} as an allocatable register saved by | |
5295 | functions. It may be allocated even for temporaries or variables that | |
5296 | live across a call. Functions compiled this way will save and restore | |
5297 | the register @var{reg} if they use it. | |
5298 | ||
5299 | Use of this flag for a register that has a fixed pervasive role in the | |
5300 | machine's execution model, such as the stack pointer or frame pointer, | |
5301 | will produce disastrous results. | |
5302 | ||
5303 | A different sort of disaster will result from the use of this flag for | |
5304 | a register in which function values may be returned. | |
5305 | ||
5306 | This flag does not have a negative form, because it specifies a | |
5307 | three-way choice. | |
5308 | ||
5309 | @item -fpack-struct | |
5310 | Pack all structure members together without holes. Usually you would | |
5311 | not want to use this option, since it makes the code suboptimal, and | |
5312 | the offsets of structure members won't agree with system libraries. | |
5313 | ||
861bb6c1 JL |
5314 | @item -fcheck-memory-usage |
5315 | Generate extra code to check each memory access. GNU CC will generate | |
5316 | code that is suitable for a detector of bad memory accesses such as | |
5317 | @file{Checker}. If you specify this option, you can not use the | |
5318 | @code{asm} or @code{__asm__} keywords. | |
5319 | ||
5320 | You must also specify this option when you compile functions you call that | |
5321 | have side effects. If you do not, you may get erronous messages from | |
5322 | the detector. Normally, you should compile all your code with this option. | |
5323 | If you use functions from a library that have side-effects (such as | |
5324 | @code{read}), you may not be able to recompile the library and | |
5325 | specify this option. In that case, you can enable the | |
5326 | @samp{-fprefix-function-name} option, which requests GNU CC to encapsulate | |
5327 | your code and make other functions look as if they were compiled with | |
5328 | @samp{-fcheck-memory-usage}. This is done by calling ``stubs'', | |
5329 | which are provided by the detector. If you cannot find or build | |
5330 | stubs for every function you call, you may have to specify | |
5331 | @samp{-fcheck-memory-usage} without @samp{-fprefix-function-name}. | |
5332 | ||
5333 | @item -fprefix-function-name | |
5334 | Request GNU CC to add a prefix to the symbols generated for function names. | |
5335 | GNU CC adds a prefix to the names of functions defined as well as | |
5336 | functions called. Code compiled with this option and code compiled | |
5337 | without the option can't be linked together, unless or stubs are used. | |
5338 | ||
5339 | If you compile the following code with @samp{-fprefix-function-name} | |
5340 | @example | |
5341 | extern void bar (int); | |
5342 | void | |
5343 | foo (int a) | |
5344 | @{ | |
5345 | return bar (a + 5); | |
5346 | ||
5347 | @} | |
5348 | @end example | |
5349 | ||
5350 | @noindent | |
5351 | GNU CC will compile the code as if it was written: | |
5352 | @example | |
5353 | extern void prefix_bar (int); | |
5354 | void | |
5355 | prefix_foo (int a) | |
5356 | @{ | |
5357 | return prefix_bar (a + 5); | |
5358 | @} | |
5359 | @end example | |
5360 | This option is designed to be used with @samp{-fcheck-memory-usage}. | |
5361 | ||
5362 | @item -fstack-check | |
5363 | Generate code to verify that you do not go beyond the boundary of the | |
5364 | stack. You should specify this flag if you are running in an | |
5365 | environment with multiple threads, but only rarely need to specify it in | |
5366 | a single-threaded environment since stack overflow is automatically | |
5367 | detected on nearly all systems if there is only one stack. | |
5368 | ||
74291a4b MM |
5369 | @item +e0 |
5370 | @itemx +e1 | |
5371 | Control whether virtual function definitions in classes are used to | |
5372 | generate code, or only to define interfaces for their callers. (C++ | |
5373 | only). | |
5374 | ||
5375 | These options are provided for compatibility with @code{cfront} 1.x | |
5376 | usage; the recommended alternative GNU C++ usage is in flux. @xref{C++ | |
5377 | Interface,,Declarations and Definitions in One Header}. | |
5378 | ||
5379 | With @samp{+e0}, virtual function definitions in classes are declared | |
5380 | @code{extern}; the declaration is used only as an interface | |
5381 | specification, not to generate code for the virtual functions (in this | |
5382 | compilation). | |
5383 | ||
5384 | With @samp{+e1}, G++ actually generates the code implementing virtual | |
5385 | functions defined in the code, and makes them publicly visible. | |
e5eb27e5 JL |
5386 | |
5387 | @cindex aliasing of parameters | |
5388 | @cindex parameters, aliased | |
5389 | @item -fargument-alias | |
5390 | @item -fargument-noalias | |
5391 | @item -fargument-noalias-global | |
5392 | Specify the possible relationships among parameters and between | |
5393 | parameters and global data. | |
5394 | ||
5395 | @samp{-fargument-alias} specifies that arguments (parameters) may | |
5396 | alias each other and may alias global storage. | |
5397 | @samp{-fargument-noalias} specifies that arguments do not alias | |
5398 | each other, but may alias global storage. | |
5399 | @samp{-fargument-noalias-global} specifies that arguments do not | |
5400 | alias each other and do not alias global storage. | |
5401 | ||
5402 | Each language will automatically use whatever option is required by | |
5403 | the language standard. You should not need to use these options yourself. | |
74291a4b MM |
5404 | @end table |
5405 | ||
5406 | @node Environment Variables | |
5407 | @section Environment Variables Affecting GNU CC | |
5408 | @cindex environment variables | |
5409 | ||
5410 | This section describes several environment variables that affect how GNU | |
5411 | CC operates. They work by specifying directories or prefixes to use | |
5412 | when searching for various kinds of files. | |
5413 | ||
5414 | @ifclear INTERNALS | |
5415 | Note that you can also specify places to search using options such as | |
5416 | @samp{-B}, @samp{-I} and @samp{-L} (@pxref{Directory Options}). These | |
5417 | take precedence over places specified using environment variables, which | |
5418 | in turn take precedence over those specified by the configuration of GNU | |
5419 | CC. | |
5420 | @end ifclear | |
5421 | @ifset INTERNALS | |
5422 | Note that you can also specify places to search using options such as | |
5423 | @samp{-B}, @samp{-I} and @samp{-L} (@pxref{Directory Options}). These | |
5424 | take precedence over places specified using environment variables, which | |
5425 | in turn take precedence over those specified by the configuration of GNU | |
5426 | CC. @xref{Driver}. | |
5427 | @end ifset | |
5428 | ||
5429 | @table @code | |
5430 | @item TMPDIR | |
5431 | @findex TMPDIR | |
5432 | If @code{TMPDIR} is set, it specifies the directory to use for temporary | |
5433 | files. GNU CC uses temporary files to hold the output of one stage of | |
5434 | compilation which is to be used as input to the next stage: for example, | |
5435 | the output of the preprocessor, which is the input to the compiler | |
5436 | proper. | |
5437 | ||
5438 | @item GCC_EXEC_PREFIX | |
5439 | @findex GCC_EXEC_PREFIX | |
5440 | If @code{GCC_EXEC_PREFIX} is set, it specifies a prefix to use in the | |
5441 | names of the subprograms executed by the compiler. No slash is added | |
5442 | when this prefix is combined with the name of a subprogram, but you can | |
5443 | specify a prefix that ends with a slash if you wish. | |
5444 | ||
5445 | If GNU CC cannot find the subprogram using the specified prefix, it | |
5446 | tries looking in the usual places for the subprogram. | |
5447 | ||
5448 | The default value of @code{GCC_EXEC_PREFIX} is | |
5449 | @file{@var{prefix}/lib/gcc-lib/} where @var{prefix} is the value | |
5450 | of @code{prefix} when you ran the @file{configure} script. | |
5451 | ||
5452 | Other prefixes specified with @samp{-B} take precedence over this prefix. | |
5453 | ||
5454 | This prefix is also used for finding files such as @file{crt0.o} that are | |
5455 | used for linking. | |
5456 | ||
5457 | In addition, the prefix is used in an unusual way in finding the | |
5458 | directories to search for header files. For each of the standard | |
5459 | directories whose name normally begins with @samp{/usr/local/lib/gcc-lib} | |
5460 | (more precisely, with the value of @code{GCC_INCLUDE_DIR}), GNU CC tries | |
5461 | replacing that beginning with the specified prefix to produce an | |
5462 | alternate directory name. Thus, with @samp{-Bfoo/}, GNU CC will search | |
5463 | @file{foo/bar} where it would normally search @file{/usr/local/lib/bar}. | |
5464 | These alternate directories are searched first; the standard directories | |
5465 | come next. | |
5466 | ||
5467 | @item COMPILER_PATH | |
5468 | @findex COMPILER_PATH | |
5469 | The value of @code{COMPILER_PATH} is a colon-separated list of | |
5470 | directories, much like @code{PATH}. GNU CC tries the directories thus | |
5471 | specified when searching for subprograms, if it can't find the | |
5472 | subprograms using @code{GCC_EXEC_PREFIX}. | |
5473 | ||
5474 | @item LIBRARY_PATH | |
5475 | @findex LIBRARY_PATH | |
5476 | The value of @code{LIBRARY_PATH} is a colon-separated list of | |
5477 | directories, much like @code{PATH}. When configured as a native compiler, | |
5478 | GNU CC tries the directories thus specified when searching for special | |
5479 | linker files, if it can't find them using @code{GCC_EXEC_PREFIX}. Linking | |
5480 | using GNU CC also uses these directories when searching for ordinary | |
5481 | libraries for the @samp{-l} option (but directories specified with | |
5482 | @samp{-L} come first). | |
5483 | ||
5484 | @item C_INCLUDE_PATH | |
5485 | @itemx CPLUS_INCLUDE_PATH | |
5486 | @itemx OBJC_INCLUDE_PATH | |
5487 | @findex C_INCLUDE_PATH | |
5488 | @findex CPLUS_INCLUDE_PATH | |
5489 | @findex OBJC_INCLUDE_PATH | |
5490 | @c @itemx OBJCPLUS_INCLUDE_PATH | |
5491 | These environment variables pertain to particular languages. Each | |
5492 | variable's value is a colon-separated list of directories, much like | |
5493 | @code{PATH}. When GNU CC searches for header files, it tries the | |
5494 | directories listed in the variable for the language you are using, after | |
5495 | the directories specified with @samp{-I} but before the standard header | |
5496 | file directories. | |
5497 | ||
5498 | @item DEPENDENCIES_OUTPUT | |
5499 | @findex DEPENDENCIES_OUTPUT | |
5500 | @cindex dependencies for make as output | |
5501 | If this variable is set, its value specifies how to output dependencies | |
5502 | for Make based on the header files processed by the compiler. This | |
5503 | output looks much like the output from the @samp{-M} option | |
5504 | (@pxref{Preprocessor Options}), but it goes to a separate file, and is | |
5505 | in addition to the usual results of compilation. | |
5506 | ||
5507 | The value of @code{DEPENDENCIES_OUTPUT} can be just a file name, in | |
5508 | which case the Make rules are written to that file, guessing the target | |
5509 | name from the source file name. Or the value can have the form | |
5510 | @samp{@var{file} @var{target}}, in which case the rules are written to | |
5511 | file @var{file} using @var{target} as the target name. | |
5512 | @end table | |
5513 | ||
5514 | @node Running Protoize | |
5515 | @section Running Protoize | |
5516 | ||
5517 | The program @code{protoize} is an optional part of GNU C. You can use | |
5518 | it to add prototypes to a program, thus converting the program to ANSI | |
5519 | C in one respect. The companion program @code{unprotoize} does the | |
5520 | reverse: it removes argument types from any prototypes that are found. | |
5521 | ||
5522 | When you run these programs, you must specify a set of source files as | |
5523 | command line arguments. The conversion programs start out by compiling | |
5524 | these files to see what functions they define. The information gathered | |
5525 | about a file @var{foo} is saved in a file named @file{@var{foo}.X}. | |
5526 | ||
5527 | After scanning comes actual conversion. The specified files are all | |
5528 | eligible to be converted; any files they include (whether sources or | |
5529 | just headers) are eligible as well. | |
5530 | ||
5531 | But not all the eligible files are converted. By default, | |
5532 | @code{protoize} and @code{unprotoize} convert only source and header | |
5533 | files in the current directory. You can specify additional directories | |
5534 | whose files should be converted with the @samp{-d @var{directory}} | |
5535 | option. You can also specify particular files to exclude with the | |
5536 | @samp{-x @var{file}} option. A file is converted if it is eligible, its | |
5537 | directory name matches one of the specified directory names, and its | |
5538 | name within the directory has not been excluded. | |
5539 | ||
5540 | Basic conversion with @code{protoize} consists of rewriting most | |
5541 | function definitions and function declarations to specify the types of | |
5542 | the arguments. The only ones not rewritten are those for varargs | |
5543 | functions. | |
5544 | ||
5545 | @code{protoize} optionally inserts prototype declarations at the | |
5546 | beginning of the source file, to make them available for any calls that | |
5547 | precede the function's definition. Or it can insert prototype | |
5548 | declarations with block scope in the blocks where undeclared functions | |
5549 | are called. | |
5550 | ||
5551 | Basic conversion with @code{unprotoize} consists of rewriting most | |
5552 | function declarations to remove any argument types, and rewriting | |
5553 | function definitions to the old-style pre-ANSI form. | |
5554 | ||
5555 | Both conversion programs print a warning for any function declaration or | |
5556 | definition that they can't convert. You can suppress these warnings | |
5557 | with @samp{-q}. | |
5558 | ||
5559 | The output from @code{protoize} or @code{unprotoize} replaces the | |
5560 | original source file. The original file is renamed to a name ending | |
5561 | with @samp{.save}. If the @samp{.save} file already exists, then | |
5562 | the source file is simply discarded. | |
5563 | ||
5564 | @code{protoize} and @code{unprotoize} both depend on GNU CC itself to | |
5565 | scan the program and collect information about the functions it uses. | |
5566 | So neither of these programs will work until GNU CC is installed. | |
5567 | ||
5568 | Here is a table of the options you can use with @code{protoize} and | |
5569 | @code{unprotoize}. Each option works with both programs unless | |
5570 | otherwise stated. | |
5571 | ||
5572 | @table @code | |
5573 | @item -B @var{directory} | |
5574 | Look for the file @file{SYSCALLS.c.X} in @var{directory}, instead of the | |
5575 | usual directory (normally @file{/usr/local/lib}). This file contains | |
5576 | prototype information about standard system functions. This option | |
5577 | applies only to @code{protoize}. | |
5578 | ||
5579 | @item -c @var{compilation-options} | |
5580 | Use @var{compilation-options} as the options when running @code{gcc} to | |
5581 | produce the @samp{.X} files. The special option @samp{-aux-info} is | |
5582 | always passed in addition, to tell @code{gcc} to write a @samp{.X} file. | |
5583 | ||
5584 | Note that the compilation options must be given as a single argument to | |
5585 | @code{protoize} or @code{unprotoize}. If you want to specify several | |
5586 | @code{gcc} options, you must quote the entire set of compilation options | |
5587 | to make them a single word in the shell. | |
5588 | ||
5589 | There are certain @code{gcc} arguments that you cannot use, because they | |
5590 | would produce the wrong kind of output. These include @samp{-g}, | |
5591 | @samp{-O}, @samp{-c}, @samp{-S}, and @samp{-o} If you include these in | |
5592 | the @var{compilation-options}, they are ignored. | |
5593 | ||
5594 | @item -C | |
5595 | Rename files to end in @samp{.C} instead of @samp{.c}. | |
5596 | This is convenient if you are converting a C program to C++. | |
5597 | This option applies only to @code{protoize}. | |
5598 | ||
5599 | @item -g | |
5600 | Add explicit global declarations. This means inserting explicit | |
5601 | declarations at the beginning of each source file for each function | |
5602 | that is called in the file and was not declared. These declarations | |
5603 | precede the first function definition that contains a call to an | |
5604 | undeclared function. This option applies only to @code{protoize}. | |
5605 | ||
5606 | @item -i @var{string} | |
5607 | Indent old-style parameter declarations with the string @var{string}. | |
5608 | This option applies only to @code{protoize}. | |
5609 | ||
5610 | @code{unprotoize} converts prototyped function definitions to old-style | |
5611 | function definitions, where the arguments are declared between the | |
5612 | argument list and the initial @samp{@{}. By default, @code{unprotoize} | |
5613 | uses five spaces as the indentation. If you want to indent with just | |
5614 | one space instead, use @samp{-i " "}. | |
5615 | ||
5616 | @item -k | |
5617 | Keep the @samp{.X} files. Normally, they are deleted after conversion | |
5618 | is finished. | |
5619 | ||
5620 | @item -l | |
5621 | Add explicit local declarations. @code{protoize} with @samp{-l} inserts | |
5622 | a prototype declaration for each function in each block which calls the | |
5623 | function without any declaration. This option applies only to | |
5624 | @code{protoize}. | |
5625 | ||
5626 | @item -n | |
5627 | Make no real changes. This mode just prints information about the conversions | |
5628 | that would have been done without @samp{-n}. | |
5629 | ||
5630 | @item -N | |
5631 | Make no @samp{.save} files. The original files are simply deleted. | |
5632 | Use this option with caution. | |
5633 | ||
5634 | @item -p @var{program} | |
5635 | Use the program @var{program} as the compiler. Normally, the name | |
5636 | @file{gcc} is used. | |
5637 | ||
5638 | @item -q | |
5639 | Work quietly. Most warnings are suppressed. | |
5640 | ||
5641 | @item -v | |
5642 | Print the version number, just like @samp{-v} for @code{gcc}. | |
5643 | @end table | |
5644 | ||
5645 | If you need special compiler options to compile one of your program's | |
5646 | source files, then you should generate that file's @samp{.X} file | |
5647 | specially, by running @code{gcc} on that source file with the | |
5648 | appropriate options and the option @samp{-aux-info}. Then run | |
5649 | @code{protoize} on the entire set of files. @code{protoize} will use | |
5650 | the existing @samp{.X} file because it is newer than the source file. | |
5651 | For example: | |
5652 | ||
5653 | @example | |
5654 | gcc -Dfoo=bar file1.c -aux-info | |
5655 | protoize *.c | |
5656 | @end example | |
5657 | ||
5658 | @noindent | |
5659 | You need to include the special files along with the rest in the | |
5660 | @code{protoize} command, even though their @samp{.X} files already | |
5661 | exist, because otherwise they won't get converted. | |
5662 | ||
5663 | @xref{Protoize Caveats}, for more information on how to use | |
5664 | @code{protoize} successfully. | |
5665 |