]> git.ipfire.org Git - thirdparty/gcc.git/blob - gcc/doc/gcc/gcc-command-options/options-controlling-the-kind-of-output.rst
sphinx: add missing trailing newline
[thirdparty/gcc.git] / gcc / doc / gcc / gcc-command-options / options-controlling-the-kind-of-output.rst
1 ..
2 Copyright 1988-2022 Free Software Foundation, Inc.
3 This is part of the GCC manual.
4 For copying conditions, see the copyright.rst file.
5
6 .. _overall-options:
7
8 Options Controlling the Kind of Output
9 **************************************
10
11 Compilation can involve up to four stages: preprocessing, compilation
12 proper, assembly and linking, always in that order. GCC is capable of
13 preprocessing and compiling several files either into several
14 assembler input files, or into one assembler input file; then each
15 assembler input file produces an object file, and linking combines all
16 the object files (those newly compiled, and those specified as input)
17 into an executable file.
18
19 .. index:: file name suffix
20
21 For any given input file, the file name suffix determines what kind of
22 compilation is done:
23
24 :samp:`{file}.c`
25 C source code that must be preprocessed.
26
27 :samp:`{file}.i`
28 C source code that should not be preprocessed.
29
30 :samp:`{file}.ii`
31 C++ source code that should not be preprocessed.
32
33 :samp:`{file}.m`
34 Objective-C source code. Note that you must link with the :samp:`libobjc`
35 library to make an Objective-C program work.
36
37 :samp:`{file}.mi`
38 Objective-C source code that should not be preprocessed.
39
40 :samp:`{file}.mm` :samp:`{file}.M`
41 Objective-C++ source code. Note that you must link with the :samp:`libobjc`
42 library to make an Objective-C++ program work. Note that :samp:`.M` refers
43 to a literal capital M.
44
45 :samp:`{file}.mii`
46 Objective-C++ source code that should not be preprocessed.
47
48 :samp:`{file}.h`
49 C, C++, Objective-C or Objective-C++ header file to be turned into a
50 precompiled header (default), or C, C++ header file to be turned into an
51 Ada spec (via the :option:`-fdump-ada-spec` switch).
52
53 :samp:`{file}.cc` :samp:`{file}.cp` :samp:`{file}.cxx` :samp:`{file}.cpp` :samp:`{file}.CPP` :samp:`{file}.c++` :samp:`{file}.C`
54 C++ source code that must be preprocessed. Note that in :samp:`.cxx`,
55 the last two letters must both be literally :samp:`x`. Likewise,
56 :samp:`.C` refers to a literal capital C.
57
58 :samp:`{file}.mm` :samp:`{file}.M`
59 Objective-C++ source code that must be preprocessed.
60
61 :samp:`{file}.mii`
62 Objective-C++ source code that should not be preprocessed.
63
64 :samp:`{file}.hh` :samp:`{file}.H` :samp:`{file}.hp` :samp:`{file}.hxx` :samp:`{file}.hpp` :samp:`{file}.HPP` :samp:`{file}.h++` :samp:`{file}.tcc`
65 C++ header file to be turned into a precompiled header or Ada spec.
66
67 :samp:`{file}.f` :samp:`{file}.for` :samp:`{file}.ftn`
68 Fixed form Fortran source code that should not be preprocessed.
69
70 :samp:`{file}.F` :samp:`{file}.FOR` :samp:`{file}.fpp` :samp:`{file}.FPP` :samp:`{file}.FTN`
71 Fixed form Fortran source code that must be preprocessed (with the traditional
72 preprocessor).
73
74 :samp:`{file}.f90` :samp:`{file}.f95` :samp:`{file}.f03` :samp:`{file}.f08`
75 Free form Fortran source code that should not be preprocessed.
76
77 :samp:`{file}.F90` :samp:`{file}.F95` :samp:`{file}.F03` :samp:`{file}.F08`
78 Free form Fortran source code that must be preprocessed (with the
79 traditional preprocessor).
80
81 :samp:`{file}.go`
82 Go source code.
83
84 :samp:`{file}.d`
85 D source code.
86
87 :samp:`{file}.di`
88 D interface file.
89
90 :samp:`{file}.dd`
91 D documentation code (Ddoc).
92
93 :samp:`{file}.ads`
94 Ada source code file that contains a library unit declaration (a
95 declaration of a package, subprogram, or generic, or a generic
96 instantiation), or a library unit renaming declaration (a package,
97 generic, or subprogram renaming declaration). Such files are also
98 called :dfn:`specs`.
99
100 :samp:`{file}.adb`
101 Ada source code file containing a library unit body (a subprogram or
102 package body). Such files are also called :dfn:`bodies`.
103
104 .. GCC also knows about some suffixes for languages not yet included:
105 Ratfor:
106 @var{file}.r
107
108 :samp:`{file}.s`
109 Assembler code.
110
111 :samp:`{file}.S` :samp:`{file}.sx`
112 Assembler code that must be preprocessed.
113
114 ``other``
115 An object file to be fed straight into linking.
116 Any file name with no recognized suffix is treated this way.
117
118 .. index:: x
119
120 You can specify the input language explicitly with the :option:`-x` option:
121
122 :samp:`-x {language}`
123 Specify explicitly the :samp:`{language}` for the following input files
124 (rather than letting the compiler choose a default based on the file
125 name suffix). This option applies to all following input files until
126 the next :option:`-x` option. Possible values for :samp:`{language}` are:
127
128 :samp:`c` :samp:`c-header` :samp:`cpp-output`
129 :samp:`c++` :samp:`c++-header` :samp:`c++-system-header` :samp:`c++-user-header` :samp:`c++-cpp-output`
130 :samp:`objective-c` :samp:`objective-c-header` :samp:`objective-c-cpp-output`
131 :samp:`objective-c++` :samp:`objective-c++-header` :samp:`objective-c++-cpp-output`
132 :samp:`assembler` :samp:`assembler-with-cpp` :samp:`ada` :samp:`d`
133 :samp:`f77` :samp:`f77-cpp-input` :samp:`f95` :samp:`f95-cpp-input` :samp:`go`
134
135 ``-x none``
136 Turn off any specification of a language, so that subsequent files are
137 handled according to their file name suffixes (as they are if :option:`-x`
138 has not been used at all).
139
140 If you only want some of the stages of compilation, you can use
141 :option:`-x` (or filename suffixes) to tell :command:`gcc` where to start, and
142 one of the options :option:`-c`, :option:`-S`, or :option:`-E` to say where
143 :command:`gcc` is to stop. Note that some combinations (for example,
144 :samp:`-x cpp-output -E`) instruct :command:`gcc` to do nothing at all.
145
146 .. option:: -c
147
148 Compile or assemble the source files, but do not link. The linking
149 stage simply is not done. The ultimate output is in the form of an
150 object file for each source file.
151
152 By default, the object file name for a source file is made by replacing
153 the suffix :samp:`.c`, :samp:`.i`, :samp:`.s`, etc., with :samp:`.o`.
154
155 Unrecognized input files, not requiring compilation or assembly, are
156 ignored.
157
158 .. option:: -S
159
160 Stop after the stage of compilation proper; do not assemble. The output
161 is in the form of an assembler code file for each non-assembler input
162 file specified.
163
164 By default, the assembler file name for a source file is made by
165 replacing the suffix :samp:`.c`, :samp:`.i`, etc., with :samp:`.s`.
166
167 Input files that don't require compilation are ignored.
168
169 .. option:: -E
170
171 Stop after the preprocessing stage; do not run the compiler proper. The
172 output is in the form of preprocessed source code, which is sent to the
173 standard output.
174
175 Input files that don't require preprocessing are ignored.
176
177 .. index:: output file option
178
179 .. option:: -o {file}
180
181 Place the primary output in file :samp:`{file}`. This applies to whatever
182 sort of output is being produced, whether it be an executable file, an
183 object file, an assembler file or preprocessed C code.
184
185 If :option:`-o` is not specified, the default is to put an executable
186 file in :samp:`a.out`, the object file for
187 :samp:`{source}.{suffix}` in :samp:`{source}.o`, its
188 assembler file in :samp:`{source}.s`, a precompiled header file in
189 :samp:`{source}.{suffix}.gch`, and all preprocessed C source on
190 standard output.
191
192 Though :option:`-o` names only the primary output, it also affects the
193 naming of auxiliary and dump outputs. See the examples below. Unless
194 overridden, both auxiliary outputs and dump outputs are placed in the
195 same directory as the primary output. In auxiliary outputs, the suffix
196 of the input file is replaced with that of the auxiliary output file
197 type; in dump outputs, the suffix of the dump file is appended to the
198 input file suffix. In compilation commands, the base name of both
199 auxiliary and dump outputs is that of the primary output; in compile and
200 link commands, the primary output name, minus the executable suffix, is
201 combined with the input file name. If both share the same base name,
202 disregarding the suffix, the result of the combination is that base
203 name, otherwise, they are concatenated, separated by a dash.
204
205 .. code-block:: shell
206
207 gcc -c foo.c ...
208
209 will use :samp:`foo.o` as the primary output, and place aux outputs and
210 dumps next to it, e.g., aux file :samp:`foo.dwo` for
211 :option:`-gsplit-dwarf`, and dump file :samp:`foo.c.???r.final` for
212 :option:`-fdump-rtl-final`.
213
214 If a non-linker output file is explicitly specified, aux and dump files
215 by default take the same base name:
216
217 .. code-block:: shell
218
219 gcc -c foo.c -o dir/foobar.o ...
220
221 will name aux outputs :samp:`dir/foobar.*` and dump outputs
222 :samp:`dir/foobar.c.*`.
223
224 A linker output will instead prefix aux and dump outputs:
225
226 .. code-block:: shell
227
228 gcc foo.c bar.c -o dir/foobar ...
229
230 will generally name aux outputs :samp:`dir/foobar-foo.*` and
231 :samp:`dir/foobar-bar.*`, and dump outputs :samp:`dir/foobar-foo.c.*` and
232 :samp:`dir/foobar-bar.c.*`.
233
234 The one exception to the above is when the executable shares the base
235 name with the single input:
236
237 .. code-block:: shell
238
239 gcc foo.c -o dir/foo ...
240
241 in which case aux outputs are named :samp:`dir/foo.*` and dump outputs
242 named :samp:`dir/foo.c.*`.
243
244 The location and the names of auxiliary and dump outputs can be adjusted
245 by the options :option:`-dumpbase`, :option:`-dumpbase-ext`,
246 :option:`-dumpdir`, :option:`-save-temps=cwd`, and
247 :option:`-save-temps=obj`.
248
249 .. option:: -dumpbase {dumpbase}
250
251 This option sets the base name for auxiliary and dump output files. It
252 does not affect the name of the primary output file. Intermediate
253 outputs, when preserved, are not regarded as primary outputs, but as
254 auxiliary outputs:
255
256 .. code-block:: shell
257
258 gcc -save-temps -S foo.c
259
260 saves the (no longer) temporary preprocessed file in :samp:`foo.i`, and
261 then compiles to the (implied) output file :samp:`foo.s`, whereas:
262
263 .. code-block:: shell
264
265 gcc -save-temps -dumpbase save-foo -c foo.c
266
267 preprocesses to in :samp:`save-foo.i`, compiles to :samp:`save-foo.s` (now
268 an intermediate, thus auxiliary output), and then assembles to the
269 (implied) output file :samp:`foo.o`.
270
271 Absent this option, dump and aux files take their names from the input
272 file, or from the (non-linker) output file, if one is explicitly
273 specified: dump output files (e.g. those requested by :option:`-fdump-*`
274 options) with the input name suffix, and aux output files (those
275 requested by other non-dump options, e.g. ``-save-temps``,
276 ``-gsplit-dwarf``, ``-fcallgraph-info``) without it.
277
278 Similar suffix differentiation of dump and aux outputs can be attained
279 for explicitly-given :option:`-dumpbase basename.suf` by also specifying
280 :option:`-dumpbase-ext .suf`.
281
282 If :samp:`{dumpbase}` is explicitly specified with any directory component,
283 any :samp:`{dumppfx}` specification (e.g. :option:`-dumpdir` or
284 :option:`-save-temps=*`) is ignored, and instead of appending to it,
285 :samp:`{dumpbase}` fully overrides it:
286
287 .. code-block:: shell
288
289 gcc foo.c -c -o dir/foo.o -dumpbase alt/foo \
290 -dumpdir pfx- -save-temps=cwd ...
291
292 creates auxiliary and dump outputs named :samp:`alt/foo.*`, disregarding
293 :samp:`dir/` in :option:`-o`, the :samp:`./` prefix implied by
294 :option:`-save-temps=cwd`, and :samp:`pfx-` in :option:`-dumpdir`.
295
296 When :option:`-dumpbase` is specified in a command that compiles multiple
297 inputs, or that compiles and then links, it may be combined with
298 :samp:`{dumppfx}`, as specified under :option:`-dumpdir`. Then, each input
299 file is compiled using the combined :samp:`{dumppfx}`, and default values
300 for :samp:`{dumpbase}` and :samp:`{auxdropsuf}` are computed for each input
301 file:
302
303 .. code-block:: shell
304
305 gcc foo.c bar.c -c -dumpbase main ...
306
307 creates :samp:`foo.o` and :samp:`bar.o` as primary outputs, and avoids
308 overwriting the auxiliary and dump outputs by using the :samp:`{dumpbase}`
309 as a prefix, creating auxiliary and dump outputs named :samp:`main-foo.*`
310 and :samp:`main-bar.*`.
311
312 An empty string specified as :samp:`{dumpbase}` avoids the influence of the
313 output basename in the naming of auxiliary and dump outputs during
314 compilation, computing default values :
315
316 .. code-block:: shell
317
318 gcc -c foo.c -o dir/foobar.o -dumpbase '' ...
319
320 will name aux outputs :samp:`dir/foo.*` and dump outputs
321 :samp:`dir/foo.c.*`. Note how their basenames are taken from the input
322 name, but the directory still defaults to that of the output.
323
324 The empty-string dumpbase does not prevent the use of the output
325 basename for outputs during linking:
326
327 .. code-block:: shell
328
329 gcc foo.c bar.c -o dir/foobar -dumpbase '' -flto ...
330
331 The compilation of the source files will name auxiliary outputs
332 :samp:`dir/foo.*` and :samp:`dir/bar.*`, and dump outputs
333 :samp:`dir/foo.c.*` and :samp:`dir/bar.c.*`. LTO recompilation during
334 linking will use :samp:`dir/foobar.` as the prefix for dumps and
335 auxiliary files.
336
337 .. option:: -dumpbase-ext {auxdropsuf}
338
339 When forming the name of an auxiliary (but not a dump) output file, drop
340 trailing :samp:`{auxdropsuf}` from :samp:`{dumpbase}` before appending any
341 suffixes. If not specified, this option defaults to the suffix of a
342 default :samp:`{dumpbase}`, i.e., the suffix of the input file when
343 :option:`-dumpbase` is not present in the command line, or :samp:`{dumpbase}`
344 is combined with :samp:`{dumppfx}`.
345
346 .. code-block:: shell
347
348 gcc foo.c -c -o dir/foo.o -dumpbase x-foo.c -dumpbase-ext .c ...
349
350 creates :samp:`dir/foo.o` as the main output, and generates auxiliary
351 outputs in :samp:`dir/x-foo.*`, taking the location of the primary
352 output, and dropping the :samp:`.c` suffix from the :samp:`{dumpbase}`. Dump
353 outputs retain the suffix: :samp:`dir/x-foo.c.*`.
354
355 This option is disregarded if it does not match the suffix of a
356 specified :samp:`{dumpbase}`, except as an alternative to the executable
357 suffix when appending the linker output base name to :samp:`{dumppfx}`, as
358 specified below:
359
360 .. code-block:: shell
361
362 gcc foo.c bar.c -o main.out -dumpbase-ext .out ...
363
364 creates :samp:`main.out` as the primary output, and avoids overwriting
365 the auxiliary and dump outputs by using the executable name minus
366 :samp:`{auxdropsuf}` as a prefix, creating auxiliary outputs named
367 :samp:`main-foo.*` and :samp:`main-bar.*` and dump outputs named
368 :samp:`main-foo.c.*` and :samp:`main-bar.c.*`.
369
370 .. option:: -dumpdir {dumppfx}
371
372 When forming the name of an auxiliary or dump output file, use
373 :samp:`{dumppfx}` as a prefix:
374
375 .. code-block:: shell
376
377 gcc -dumpdir pfx- -c foo.c ...
378
379 creates :samp:`foo.o` as the primary output, and auxiliary outputs named
380 :samp:`pfx-foo.*`, combining the given :samp:`{dumppfx}` with the default
381 :samp:`{dumpbase}` derived from the default primary output, derived in turn
382 from the input name. Dump outputs also take the input name suffix:
383 :samp:`pfx-foo.c.*`.
384
385 If :samp:`{dumppfx}` is to be used as a directory name, it must end with a
386 directory separator:
387
388 .. code-block:: shell
389
390 gcc -dumpdir dir/ -c foo.c -o obj/bar.o ...
391
392 creates :samp:`obj/bar.o` as the primary output, and auxiliary outputs
393 named :samp:`dir/bar.*`, combining the given :samp:`{dumppfx}` with the
394 default :samp:`{dumpbase}` derived from the primary output name. Dump
395 outputs also take the input name suffix: :samp:`dir/bar.c.*`.
396
397 It defaults to the location of the output file, unless the output
398 file is a special file like ``/dev/null``. Options
399 :option:`-save-temps=cwd` and :option:`-save-temps=obj` override this
400 default, just like an explicit :option:`-dumpdir` option. In case
401 multiple such options are given, the last one prevails:
402
403 .. code-block:: shell
404
405 gcc -dumpdir pfx- -c foo.c -save-temps=obj ...
406
407 outputs :samp:`foo.o`, with auxiliary outputs named :samp:`foo.*` because
408 :option:`-save-temps=*` overrides the :samp:`{dumppfx}` given by the earlier
409 :option:`-dumpdir` option. It does not matter that =obj is the
410 default for :option:`-save-temps`, nor that the output directory is
411 implicitly the current directory. Dump outputs are named
412 :samp:`foo.c.*`.
413
414 When compiling from multiple input files, if :option:`-dumpbase` is
415 specified, :samp:`{dumpbase}`, minus a :samp:`{auxdropsuf}` suffix, and a dash
416 are appended to (or override, if containing any directory components) an
417 explicit or defaulted :samp:`{dumppfx}`, so that each of the multiple
418 compilations gets differently-named aux and dump outputs.
419
420 .. code-block:: shell
421
422 gcc foo.c bar.c -c -dumpdir dir/pfx- -dumpbase main ...
423
424 outputs auxiliary dumps to :samp:`dir/pfx-main-foo.*` and
425 :samp:`dir/pfx-main-bar.*`, appending :samp:`{dumpbase}` - to :samp:`{dumppfx}`.
426 Dump outputs retain the input file suffix: :samp:`dir/pfx-main-foo.c.*`
427 and :samp:`dir/pfx-main-bar.c.*`, respectively. Contrast with the
428 single-input compilation:
429
430 .. code-block:: shell
431
432 gcc foo.c -c -dumpdir dir/pfx- -dumpbase main ...
433
434 that, applying :option:`-dumpbase` to a single source, does not compute
435 and append a separate :samp:`{dumpbase}` per input file. Its auxiliary and
436 dump outputs go in :samp:`dir/pfx-main.*`.
437
438 When compiling and then linking from multiple input files, a defaulted
439 or explicitly specified :samp:`{dumppfx}` also undergoes the :samp:`{dumpbase}` -
440 transformation above (e.g. the compilation of :samp:`foo.c` and
441 :samp:`bar.c` above, but without :option:`-c`). If neither
442 :option:`-dumpdir` nor :option:`-dumpbase` are given, the linker output
443 base name, minus :samp:`{auxdropsuf}`, if specified, or the executable
444 suffix otherwise, plus a dash is appended to the default :samp:`{dumppfx}`
445 instead. Note, however, that unlike earlier cases of linking:
446
447 .. code-block:: shell
448
449 gcc foo.c bar.c -dumpdir dir/pfx- -o main ...
450
451 does not append the output name :samp:`main` to :samp:`{dumppfx}`, because
452 :option:`-dumpdir` is explicitly specified. The goal is that the
453 explicitly-specified :samp:`{dumppfx}` may contain the specified output name
454 as part of the prefix, if desired; only an explicitly-specified
455 :option:`-dumpbase` would be combined with it, in order to avoid simply
456 discarding a meaningful option.
457
458 When compiling and then linking from a single input file, the linker
459 output base name will only be appended to the default :samp:`{dumppfx}` as
460 above if it does not share the base name with the single input file
461 name. This has been covered in single-input linking cases above, but
462 not with an explicit :option:`-dumpdir` that inhibits the combination,
463 even if overridden by :option:`-save-temps=*` :
464
465 .. code-block:: shell
466
467 gcc foo.c -dumpdir alt/pfx- -o dir/main.exe -save-temps=cwd ...
468
469 Auxiliary outputs are named :samp:`foo.*`, and dump outputs
470 :samp:`foo.c.*`, in the current working directory as ultimately requested
471 by :option:`-save-temps=cwd`.
472
473 Summing it all up for an intuitive though slightly imprecise data flow:
474 the primary output name is broken into a directory part and a basename
475 part; :samp:`{dumppfx}` is set to the former, unless overridden by
476 :option:`-dumpdir` or :option:`-save-temps=*`, and :samp:`{dumpbase}` is set
477 to the latter, unless overriden by :option:`-dumpbase`. If there are
478 multiple inputs or linking, this :samp:`{dumpbase}` may be combined with
479 :samp:`{dumppfx}` and taken from each input file. Auxiliary output names
480 for each input are formed by combining :samp:`{dumppfx}`, :samp:`{dumpbase}`
481 minus suffix, and the auxiliary output suffix; dump output names are
482 only different in that the suffix from :samp:`{dumpbase}` is retained.
483
484 When it comes to auxiliary and dump outputs created during LTO
485 recompilation, a combination of :samp:`{dumppfx}` and :samp:`{dumpbase}`, as
486 given or as derived from the linker output name but not from inputs,
487 even in cases in which this combination would not otherwise be used as
488 such, is passed down with a trailing period replacing the compiler-added
489 dash, if any, as a :option:`-dumpdir` option to :command:`lto-wrapper`;
490 being involved in linking, this program does not normally get any
491 :option:`-dumpbase` and :option:`-dumpbase-ext`, and it ignores them.
492
493 When running sub-compilers, :command:`lto-wrapper` appends LTO stage
494 names to the received :samp:`{dumppfx}`, ensures it contains a directory
495 component so that it overrides any :option:`-dumpdir`, and passes that as
496 :option:`-dumpbase` to sub-compilers.
497
498 .. option:: -v
499
500 Print (on standard error output) the commands executed to run the stages
501 of compilation. Also print the version number of the compiler driver
502 program and of the preprocessor and the compiler proper.
503
504 .. option:: -###
505
506 Like :option:`-v` except the commands are not executed and arguments
507 are quoted unless they contain only alphanumeric characters or ``./-_``.
508 This is useful for shell scripts to capture the driver-generated command lines.
509
510 .. option:: --help
511
512 Print (on the standard output) a description of the command-line options
513 understood by :command:`gcc`. If the :option:`-v` option is also specified
514 then :option:`--help` is also passed on to the various processes
515 invoked by :command:`gcc`, so that they can display the command-line options
516 they accept. If the :option:`-Wextra` option has also been specified
517 (prior to the :option:`--help` option), then command-line options that
518 have no documentation associated with them are also displayed.
519
520 .. option:: --target-help
521
522 Print (on the standard output) a description of target-specific command-line
523 options for each tool. For some targets extra target-specific
524 information may also be printed.
525
526 .. option:: --help={class}|[^]qualifier}[,...]
527
528 Print (on the standard output) a description of the command-line
529 options understood by the compiler that fit into all specified classes
530 and qualifiers. These are the supported classes:
531
532 optimizers
533 Display all of the optimization options supported by the
534 compiler.
535
536 warnings
537 Display all of the options controlling warning messages
538 produced by the compiler.
539
540 target
541 Display target-specific options. Unlike the
542 :option:`--target-help` option however, target-specific options of the
543 linker and assembler are not displayed. This is because those
544 tools do not currently support the extended :option:`--help=` syntax.
545
546 params
547 Display the values recognized by the :option:`--param`
548 option.
549
550 language
551 Display the options supported for :samp:`{language}`, where
552 :samp:`{language}` is the name of one of the languages supported in this
553 version of GCC. If an option is supported by all languages, one needs
554 to select :samp:`common` class.
555
556 common
557 Display the options that are common to all languages.
558
559 These are the supported qualifiers:
560
561 undocumented
562 Display only those options that are undocumented.
563
564 joined
565 Display options taking an argument that appears after an equal
566 sign in the same continuous piece of text, such as:
567 :samp:`--help=target`.
568
569 separate
570 Display options taking an argument that appears as a separate word
571 following the original option, such as: :samp:`-o output-file`.
572
573 Thus for example to display all the undocumented target-specific
574 switches supported by the compiler, use:
575
576 :option:`--help=target,undocumented`
577 The sense of a qualifier can be inverted by prefixing it with the
578 :samp:`^` character, so for example to display all binary warning
579 options (i.e., ones that are either on or off and that do not take an
580 argument) that have a description, use:
581
582 :option:`--help=warnings,^joined,^undocumented`
583 The argument to :option:`--help=` should not consist solely of inverted
584 qualifiers.
585
586 Combining several classes is possible, although this usually
587 restricts the output so much that there is nothing to display. One
588 case where it does work, however, is when one of the classes is
589 :samp:`{target}`. For example, to display all the target-specific
590 optimization options, use:
591
592 :option:`--help=target,optimizers`
593 The :option:`--help=` option can be repeated on the command line. Each
594 successive use displays its requested class of options, skipping
595 those that have already been displayed. If :option:`--help` is also
596 specified anywhere on the command line then this takes precedence
597 over any :option:`--help=` option.
598
599 If the :option:`-Q` option appears on the command line before the
600 :option:`--help=` option, then the descriptive text displayed by
601 :option:`--help=` is changed. Instead of describing the displayed
602 options, an indication is given as to whether the option is enabled,
603 disabled or set to a specific value (assuming that the compiler
604 knows this at the point where the :option:`--help=` option is used).
605
606 Here is a truncated example from the ARM port of :command:`gcc`:
607
608 .. code-block:: shell-session
609
610 % gcc -Q -mabi=2 --help=target -c
611 The following options are target specific:
612 -mabi= 2
613 -mabort-on-noreturn [disabled]
614 -mapcs [disabled]
615
616 The output is sensitive to the effects of previous command-line
617 options, so for example it is possible to find out which optimizations
618 are enabled at :option:`-O2` by using:
619
620 :option:`-Q` :option:`-O2` :option:`--help=optimizers`
621 Alternatively you can discover which binary optimizations are enabled
622 by :option:`-O3` by using:
623
624 .. code-block:: shell
625
626 gcc -c -Q -O3 --help=optimizers > /tmp/O3-opts
627 gcc -c -Q -O2 --help=optimizers > /tmp/O2-opts
628 diff /tmp/O2-opts /tmp/O3-opts | grep enabled
629
630 .. option:: --version
631
632 Display the version number and copyrights of the invoked GCC.
633
634 .. option:: -pass-exit-codes
635
636 Normally the :command:`gcc` program exits with the code of 1 if any
637 phase of the compiler returns a non-success return code. If you specify
638 :option:`-pass-exit-codes`, the :command:`gcc` program instead returns with
639 the numerically highest error produced by any phase returning an error
640 indication. The C, C++, and Fortran front ends return 4 if an internal
641 compiler error is encountered.
642
643 .. option:: -pipe
644
645 Use pipes rather than temporary files for communication between the
646 various stages of compilation. This fails to work on some systems where
647 the assembler is unable to read from a pipe; but the GNU assembler has
648 no trouble.
649
650 .. option:: -specs={file}
651
652 Process :samp:`{file}` after the compiler reads in the standard :samp:`specs`
653 file, in order to override the defaults which the :command:`gcc` driver
654 program uses when determining what switches to pass to :command:`cc1`,
655 :command:`cc1plus`, :command:`as`, :command:`ld`, etc. More than one
656 :option:`-specs=file` can be specified on the command line, and they
657 are processed in order, from left to right. See :ref:`spec-files`, for
658 information about the format of the :samp:`{file}`.
659
660 .. option:: -wrapper
661
662 Invoke all subcommands under a wrapper program. The name of the
663 wrapper program and its parameters are passed as a comma separated
664 list.
665
666 .. code-block:: shell
667
668 gcc -c t.c -wrapper gdb,--args
669
670 This invokes all subprograms of :command:`gcc` under
671 :samp:`gdb --args`, thus the invocation of :command:`cc1` is
672 :samp:`gdb --args cc1 ...`.
673
674 .. option:: -ffile-prefix-map={old}={new}
675
676 When compiling files residing in directory :samp:`{old}`, record
677 any references to them in the result of the compilation as if the
678 files resided in directory :samp:`{new}` instead. Specifying this
679 option is equivalent to specifying all the individual
680 :option:`-f*-prefix-map` options. This can be used to make reproducible
681 builds that are location independent. See also
682 :option:`-fmacro-prefix-map`, :option:`-fdebug-prefix-map` and
683 :option:`-fprofile-prefix-map`.
684
685 .. option:: -fplugin={name}.so
686
687 Load the plugin code in file :samp:`{name}`.so, assumed to be a
688 shared object to be dlopen'd by the compiler. The base name of
689 the shared object file is used to identify the plugin for the
690 purposes of argument parsing (See
691 :option:`-fplugin-arg-name-key=value` below).
692 Each plugin should define the callback functions specified in the
693 Plugins API.
694
695 .. option:: -fplugin-arg-name-key={value}
696
697 Define an argument called :samp:`{key}` with a value of :samp:`{value}`
698 for the plugin called :samp:`{name}`.
699
700 .. option:: -fdump-ada-spec[-slim]
701
702 For C and C++ source and include files, generate corresponding Ada specs.
703 See :ref:`gnat_ugn:Generating_Ada_Bindings_for_C_and_C++_headers`, which provides detailed documentation on this feature.
704
705 .. option:: -fada-spec-parent={unit}
706
707 In conjunction with :option:`-fdump-ada-spec[-slim]` above, generate
708 Ada specs as child units of parent :samp:`{unit}`.
709
710 .. option:: -fdump-go-spec={file}
711
712 For input files in any language, generate corresponding Go
713 declarations in :samp:`{file}`. This generates Go ``const``,
714 ``type``, ``var``, and ``func`` declarations which may be a
715 useful way to start writing a Go interface to code written in some
716 other language.
717
718 .. This file is designed to be included in manuals that use
719 expandargv.
720
721 :samp:`@{file}`
722 Read command-line options from :samp:`{file}`. The options read are
723 inserted in place of the original :samp:`@{file}` option. If :samp:`{file}`
724 does not exist, or cannot be read, then the option will be treated
725 literally, and not removed.
726
727 Options in :samp:`{file}` are separated by whitespace. A whitespace
728 character may be included in an option by surrounding the entire
729 option in either single or double quotes. Any character (including a
730 backslash) may be included by prefixing the character to be included
731 with a backslash. The :samp:`{file}` may itself contain additional
732 :samp:`@{file}` options; any such options will be processed recursively.