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