]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/doc/options.texi
Update copyright years.
[thirdparty/gcc.git] / gcc / doc / options.texi
CommitLineData
a5544970 1@c Copyright (C) 2003-2019 Free Software Foundation, Inc.
75685792
RS
2@c This is part of the GCC manual.
3@c For copying conditions, see the file gcc.texi.
4
5@node Options
6@chapter Option specification files
7@cindex option specification files
af47e6ac 8@cindex @samp{optc-gen.awk}
75685792
RS
9
10Most GCC command-line options are described by special option
11definition files, the names of which conventionally end in
12@code{.opt}. This chapter describes the format of these files.
13
14@menu
15* Option file format:: The general layout of the files
16* Option properties:: Supported option properties
17@end menu
18
19@node Option file format
20@section Option file format
21
22Option files are a simple list of records in which each field occupies
23its own line and in which the records themselves are separated by
24blank lines. Comments may appear on their own line anywhere within
25the file and are preceded by semicolons. Whitespace is allowed before
26the semicolon.
27
fe609b0f 28The files can contain the following types of record:
75685792 29
fe609b0f
EB
30@itemize @bullet
31@item
6ccde948
RW
32A language definition record. These records have two fields: the
33string @samp{Language} and the name of the language. Once a language
fe609b0f 34has been declared in this way, it can be used as an option property.
75685792
RS
35@xref{Option properties}.
36
fe609b0f 37@item
ab442df7
MM
38A target specific save record to save additional information. These
39records have two fields: the string @samp{TargetSave}, and a
40declaration type to go in the @code{cl_target_option} structure.
75685792 41
e90afde6
JM
42@item
43A variable record to define a variable used to store option
44information. These records have two fields: the string
45@samp{Variable}, and a declaration of the type and name of the
46variable, optionally with an initializer (but without any trailing
47@samp{;}). These records may be used for variables used for many
f0036cca
JM
48options where declaring the initializer in a single option definition
49record, or duplicating it in many records, would be inappropriate, or
50for variables set in option handlers rather than referenced by
51@code{Var} properties.
e90afde6 52
fd438373
MM
53@item
54A variable record to define a variable used to store option
55information. These records have two fields: the string
56@samp{TargetVariable}, and a declaration of the type and name of the
57variable, optionally with an initializer (but without any trailing
58@samp{;}). @samp{TargetVariable} is a combination of @samp{Variable}
59and @samp{TargetSave} records in that the variable is defined in the
60@code{gcc_options} structure, but these variables are also stored in
61the @code{cl_target_option} structure. The variables are saved in the
62target save code and restored in the target restore code.
63
64@item
65A variable record to record any additional files that the
66@file{options.h} file should include. This is useful to provide
67enumeration or structure definitions needed for target variables.
68These records have two fields: the string @samp{HeaderInclude} and the
69name of the include file.
70
71@item
72A variable record to record any additional files that the
57dfdff0
JM
73@file{options.c} or @file{options-save.c} file should include. This
74is useful to provide
fd438373
MM
75inline functions needed for target variables and/or @code{#ifdef}
76sequences to properly set up the initialization. These records have
77two fields: the string @samp{SourceInclude} and the name of the
78include file.
79
e6d4b984
JM
80@item
81An enumeration record to define a set of strings that may be used as
82arguments to an option or options. These records have three fields:
83the string @samp{Enum}, a space-separated list of properties and help
84text used to describe the set of strings in @option{--help} output.
85Properties use the same format as option properties; the following are
86valid:
87@table @code
88@item Name(@var{name})
89This property is required; @var{name} must be a name (suitable for use
90in C identifiers) used to identify the set of strings in @code{Enum}
91option properties.
92
93@item Type(@var{type})
94This property is required; @var{type} is the C type for variables set
95by options using this enumeration together with @code{Var}.
96
97@item UnknownError(@var{message})
98The message @var{message} will be used as an error message if the
99argument is invalid; for enumerations without @code{UnknownError}, a
100generic error message is used. @var{message} should contain a single
101@samp{%qs} format, which will be used to format the invalid argument.
102@end table
103
104@item
105An enumeration value record to define one of the strings in a set
106given in an @samp{Enum} record. These records have two fields: the
107string @samp{EnumValue} and a space-separated list of properties.
108Properties use the same format as option properties; the following are
109valid:
110@table @code
111@item Enum(@var{name})
112This property is required; @var{name} says which @samp{Enum} record
113this @samp{EnumValue} record corresponds to.
114
115@item String(@var{string})
116This property is required; @var{string} is the string option argument
117being described by this record.
118
119@item Value(@var{value})
120This property is required; it says what value (representable as
121@code{int}) should be used for the given string.
122
123@item Canonical
124This property is optional. If present, it says the present string is
125the canonical one among all those with the given value. Other strings
126yielding that value will be mapped to this one so specs do not need to
127handle them.
128
129@item DriverOnly
130This property is optional. If present, the present string will only
131be accepted by the driver. This is used for cases such as
132@option{-march=native} that are processed by the driver so that
133@samp{gcc -v} shows how the options chosen depended on the system on
134which the compiler was run.
135@end table
136
ab442df7 137@item
b3cdf3cb 138An option definition record. These records have the following fields:
75685792
RS
139@enumerate
140@item
141the name of the option, with the leading ``-'' removed
142@item
143a space-separated list of option properties (@pxref{Option properties})
144@item
145the help text to use for @option{--help} (omitted if the second field
146contains the @code{Undocumented} property).
147@end enumerate
148
149By default, all options beginning with ``f'', ``W'' or ``m'' are
150implicitly assumed to take a ``no-'' form. This form should not be
151listed separately. If an option beginning with one of these letters
152does not have a ``no-'' form, you can use the @code{RejectNegative}
153property to reject it.
154
155The help text is automatically line-wrapped before being displayed.
156Normally the name of the option is printed on the left-hand side of
157the output and the help text is printed on the right. However, if the
158help text contains a tab character, the text to the left of the tab is
159used instead of the option's name and the text to the right of the
160tab forms the help text. This allows you to elaborate on what type
161of argument the option takes.
162
fe609b0f 163@item
6ccde948
RW
164A target mask record. These records have one field of the form
165@samp{Mask(@var{x})}. The options-processing script will automatically
fe609b0f
EB
166allocate a bit in @code{target_flags} (@pxref{Run-time Target}) for
167each mask name @var{x} and set the macro @code{MASK_@var{x}} to the
6ccde948 168appropriate bitmask. It will also declare a @code{TARGET_@var{x}}
fe609b0f
EB
169macro that has the value 1 when bit @code{MASK_@var{x}} is set and
1700 otherwise.
171
172They are primarily intended to declare target masks that are not
173associated with user options, either because these masks represent
174internal switches or because the options are not available on all
175configurations and yet the masks always need to be defined.
176@end itemize
177
75685792
RS
178@node Option properties
179@section Option properties
180
88c2fd3d 181The second field of an option record can specify any of the following
a4ce9883 182properties. When an option takes an argument, it is enclosed in parentheses
88c2fd3d
DK
183following the option property name. The parser that handles option files
184is quite simplistic, and will be tricked by any nested parentheses within
185the argument text itself; in this case, the entire option argument can
186be wrapped in curly braces within the parentheses to demarcate it, e.g.:
187
188@smallexample
189Condition(@{defined (USE_CYGWIN_LIBSTDCXX_WRAPPERS)@})
190@end smallexample
75685792
RS
191
192@table @code
193@item Common
194The option is available for all languages and targets.
195
196@item Target
197The option is available for all languages but is target-specific.
198
603349bf
JM
199@item Driver
200The option is handled by the compiler driver using code not shared
201with the compilers proper (@file{cc1} etc.).
202
75685792
RS
203@item @var{language}
204The option is available when compiling for the given language.
205
206It is possible to specify several different languages for the same
207option. Each @var{language} must have been declared by an earlier
208@code{Language} record. @xref{Option file format}.
209
603349bf
JM
210@item RejectDriver
211The option is only handled by the compilers proper (@file{cc1} etc.)@:
212and should not be accepted by the driver.
213
75685792
RS
214@item RejectNegative
215The option does not have a ``no-'' form. All options beginning with
216``f'', ``W'' or ``m'' are assumed to have a ``no-'' form unless this
217property is used.
218
48b06e94 219@item Negative(@var{othername})
e4ae5e77 220The option will turn off another option @var{othername}, which is
48b06e94
L
221the option name with the leading ``-'' removed. This chain action will
222propagate through the @code{Negative} property of the option to be
223turned off.
224
77b10485
RS
225As a consequence, if you have a group of mutually-exclusive
226options, their @code{Negative} properties should form a circular chain.
227For example, if options @option{-@var{a}}, @option{-@var{b}} and
228@option{-@var{c}} are mutually exclusive, their respective @code{Negative}
229properties should be @samp{Negative(@var{b})}, @samp{Negative(@var{c})}
230and @samp{Negative(@var{a})}.
231
75685792
RS
232@item Joined
233@itemx Separate
234The option takes a mandatory argument. @code{Joined} indicates
235that the option and argument can be included in the same @code{argv}
236entry (as with @code{-mflush-func=@var{name}}, for example).
237@code{Separate} indicates that the option and argument can be
238separate @code{argv} entries (as with @code{-o}). An option is
239allowed to have both of these properties.
240
241@item JoinedOrMissing
242The option takes an optional argument. If the argument is given,
243it will be part of the same @code{argv} entry as the option itself.
244
245This property cannot be used alongside @code{Joined} or @code{Separate}.
246
61ff2bdc
JM
247@item MissingArgError(@var{message})
248For an option marked @code{Joined} or @code{Separate}, the message
249@var{message} will be used as an error message if the mandatory
250argument is missing; for options without @code{MissingArgError}, a
251generic error message is used. @var{message} should contain a single
252@samp{%qs} format, which will be used to format the name of the option
253passed.
254
c243beb0
JM
255@item Args(@var{n})
256For an option marked @code{Separate}, indicate that it takes @var{n}
257arguments. The default is 1.
258
75685792 259@item UInteger
00abf86c
MS
260The option's argument is a non-negative integer consisting of either
261decimal or hexadecimal digits interpreted as @code{int}. Hexadecimal
262integers may optionally start with the @code{0x} or @code{0X} prefix.
263The option parser validates and converts the argument before passing
264it to the relevant option handler. @code{UInteger} should also be used
265with options like @code{-falign-loops} where both @code{-falign-loops}
266and @code{-falign-loops}=@var{n} are supported to make sure the saved
267options are given a full integer. Positive values of the argument in
268excess of @code{INT_MAX} wrap around zero.
269
270@item Host_Wide_Int
271The option's argument is a non-negative integer consisting of either
272decimal or hexadecimal digits interpreted as the widest integer type
273on the host. As with an @code{UInteger} argument, hexadecimal integers
274may optionally start with the @code{0x} or @code{0X} prefix. The option
275parser validates and converts the argument before passing it to
276the relevant option handler. @code{Host_Wide_Int} should be used with
277options that need to accept very large values. Positive values of
278the argument in excess of @code{HOST_WIDE_INT_M1U} are assigned
279@code{HOST_WIDE_INT_M1U}.
75685792 280
9f51da53 281@item IntegerRange(@var{n}, @var{m})
00abf86c
MS
282The options's arguments are integers of type @code{int}. The option's
283parser validates that the value of an option integer argument is within
284the closed range [@var{n}, @var{m}].
285
286@item ByteSize
287A property applicable only to @code{UInteger} or @code{Host_Wide_Int}
288arguments. The option's integer argument is interpreted as if in infinite
289precision using saturation arithmetic in the corresponding type. The argument
290may be followed by a @samp{byte-size} suffix designating a multiple of bytes
291such as @code{kB} and @code{KiB} for kilobyte and kibibyte, respectively,
292@code{MB} and @code{MiB} for megabyte and mebibyte, @code{GB} and @code{GiB}
293for gigabyte and gigibyte, and so on. @code{ByteSize} should be used for
294with options that take a very large argument representing a size in bytes,
295such as @option{-Wlarger-than=}.
9f51da53 296
413519ae
JM
297@item ToLower
298The option's argument should be converted to lowercase as part of
299putting it in canonical form, and before comparing with the strings
300indicated by any @code{Enum} property.
301
c878765b
JM
302@item NoDriverArg
303For an option marked @code{Separate}, the option only takes an
304argument in the compiler proper, not in the driver. This is for
305compatibility with existing options that are used both directly and
306via @option{-Wp,}; new options should not have this property.
307
75685792 308@item Var(@var{var})
f0036cca
JM
309The state of this option should be stored in variable @var{var}
310(actually a macro for @code{global_options.x_@var{var}}).
55bea00a
RS
311The way that the state is stored depends on the type of option:
312
3713f2e2
ML
313@item Deprecated
314The option is deprecated and every usage of such option will
315result in a warning.
316
86f36311
ST
317@item Var(@var{var}, @var{set})
318The option controls an integer variable @var{var} and is active when
319@var{var} equals @var{set}. The option parser will set @var{var} to
320@var{set} when the positive form of the option is used and @code{!@var{set}}
321when the ``no-'' form is used.
322
323@var{var} is declared in the same way as for the single-argument form
324described above.
325
55bea00a
RS
326@itemize @bullet
327@item
328If the option uses the @code{Mask} or @code{InverseMask} properties,
329@var{var} is the integer variable that contains the mask.
330
331@item
332If the option is a normal on/off switch, @var{var} is an integer
333variable that is nonzero when the option is enabled. The options
334parser will set the variable to 1 when the positive form of the
335option is used and 0 when the ``no-'' form is used.
336
337@item
338If the option takes an argument and has the @code{UInteger} property,
339@var{var} is an integer variable that stores the value of the argument.
340
e6d4b984
JM
341@item
342If the option takes an argument and has the @code{Enum} property,
343@var{var} is a variable (type given in the @code{Type} property of the
344@samp{Enum} record whose @code{Name} property has the same argument as
345the @code{Enum} property of this option) that stores the value of the
346argument.
347
21bf1558
JM
348@item
349If the option has the @code{Defer} property, @var{var} is a pointer to
350a @code{VEC(cl_deferred_option,heap)} that stores the option for later
351processing. (@var{var} is declared with type @code{void *} and needs
352to be cast to @code{VEC(cl_deferred_option,heap)} before use.)
353
55bea00a
RS
354@item
355Otherwise, if the option takes an argument, @var{var} is a pointer to
356the argument string. The pointer will be null if the argument is optional
357and wasn't given.
358@end itemize
75685792 359
f0036cca
JM
360The option-processing script will usually zero-initialize @var{var}.
361You can modify this behavior using @code{Init}.
75685792 362
75685792
RS
363@item Init(@var{value})
364The variable specified by the @code{Var} property should be statically
f0036cca
JM
365initialized to @var{value}. If more than one option using the same
366variable specifies @code{Init}, all must specify the same initializer.
75685792
RS
367
368@item Mask(@var{name})
f7f655c7
DD
369The option is associated with a bit in the @code{target_flags}
370variable (@pxref{Run-time Target}) and is active when that bit is set.
371You may also specify @code{Var} to select a variable other than
372@code{target_flags}.
373
374The options-processing script will automatically allocate a unique bit
375for the option. If the option is attached to @samp{target_flags},
376the script will set the macro @code{MASK_@var{name}} to the appropriate
377bitmask. It will also declare a @code{TARGET_@var{name}} macro that has
378the value 1 when the option is active and 0 otherwise. If you use @code{Var}
90922d36
MM
379to attach the option to a different variable, the bitmask macro with be
380called @code{OPTION_MASK_@var{name}}.
f7f655c7 381
75685792
RS
382@item InverseMask(@var{othername})
383@itemx InverseMask(@var{othername}, @var{thisname})
384The option is the inverse of another option that has the
385@code{Mask(@var{othername})} property. If @var{thisname} is given,
386the options-processing script will declare a @code{TARGET_@var{thisname}}
387macro that is 1 when the option is active and 0 otherwise.
388
e6d4b984
JM
389@item Enum(@var{name})
390The option's argument is a string from the set of strings associated
391with the corresponding @samp{Enum} record. The string is checked and
392converted to the integer specified in the corresponding
393@samp{EnumValue} record before being passed to option handlers.
394
21bf1558
JM
395@item Defer
396The option should be stored in a vector, specified with @code{Var},
397for later processing.
398
5de8299c
JM
399@item Alias(@var{opt})
400@itemx Alias(@var{opt}, @var{arg})
401@itemx Alias(@var{opt}, @var{posarg}, @var{negarg})
666a21a2
JM
402The option is an alias for @option{-@var{opt}} (or the negative form
403of that option, depending on @code{NegativeAlias}). In the first form,
5de8299c
JM
404any argument passed to the alias is considered to be passed to
405@option{-@var{opt}}, and @option{-@var{opt}} is considered to be
406negated if the alias is used in negated form. In the second form, the
407alias may not be negated or have an argument, and @var{posarg} is
408considered to be passed as an argument to @option{-@var{opt}}. In the
409third form, the alias may not have an argument, if the alias is used
410in the positive form then @var{posarg} is considered to be passed to
411@option{-@var{opt}}, and if the alias is used in the negative form
412then @var{negarg} is considered to be passed to @option{-@var{opt}}.
413
414Aliases should not specify @code{Var} or @code{Mask} or
415@code{UInteger}. Aliases should normally specify the same languages
416as the target of the alias; the flags on the target will be used to
417determine any diagnostic for use of an option for the wrong language,
418while those on the alias will be used to identify what command-line
419text is the option and what text is any argument to that option.
420
421When an @code{Alias} definition is used for an option, driver specs do
422not need to handle it and no @samp{OPT_} enumeration value is defined
423for it; only the canonical form of the option will be seen in those
424places.
425
666a21a2
JM
426@item NegativeAlias
427For an option marked with @code{Alias(@var{opt})}, the option is
428considered to be an alias for the positive form of @option{-@var{opt}}
429if negated and for the negative form of @option{-@var{opt}} if not
430negated. @code{NegativeAlias} may not be used with the forms of
431@code{Alias} taking more than one argument.
432
2d2bd949
JM
433@item Ignore
434This option is ignored apart from printing any warning specified using
435@code{Warn}. The option will not be seen by specs and no @samp{OPT_}
436enumeration value is defined for it.
437
d1583032
JM
438@item SeparateAlias
439For an option marked with @code{Joined}, @code{Separate} and
440@code{Alias}, the option only acts as an alias when passed a separate
441argument; with a joined argument it acts as a normal option, with an
442@samp{OPT_} enumeration value. This is for compatibility with the
443Java @option{-d} option and should not be used for new options.
444
2d2bd949
JM
445@item Warn(@var{message})
446If this option is used, output the warning @var{message}.
447@var{message} is a format string, either taking a single operand with
448a @samp{%qs} format which is the option name, or not taking any
449operands, which is passed to the @samp{warning} function. If an alias
450is marked @code{Warn}, the target of the alias must not also be marked
451@code{Warn}.
452
75685792
RS
453@item Report
454The state of the option should be printed by @option{-fverbose-asm}.
455
1dbadbbe
JM
456@item Warning
457This is a warning option and should be shown as such in
458@option{--help} output. This flag does not currently affect anything
459other than @option{--help}.
460
461@item Optimization
462This is an optimization option. It should be shown as such in
463@option{--help} output, and any associated variable named using
464@code{Var} should be saved and restored when the optimization level is
465changed with @code{optimize} attributes.
466
ff98fa95
AO
467@item PerFunction
468This is an option that can be overridden on a per-function basis.
469@code{Optimization} implies @code{PerFunction}, but options that do not
470affect executable code generation may use this flag instead, so that the
471option is not taken into account in ways that might affect executable
472code generation.
473
75685792
RS
474@item Undocumented
475The option is deliberately missing documentation and should not
476be included in the @option{--help} output.
aeb70e78
RS
477
478@item Condition(@var{cond})
479The option should only be accepted if preprocessor condition
480@var{cond} is true. Note that any C declarations associated with the
481option will be present even if @var{cond} is false; @var{cond} simply
482controls whether the option is accepted and whether it is printed in
483the @option{--help} output.
ab442df7
MM
484
485@item Save
486Build the @code{cl_target_option} structure to hold a copy of the
487option, add the functions @code{cl_target_option_save} and
488@code{cl_target_option_restore} to save and restore the options.
5e46b0c6
ILT
489
490@item SetByCombined
491The option may also be set by a combined option such as
492@option{-ffast-math}. This causes the @code{gcc_options} struct to
493have a field @code{frontend_set_@var{name}}, where @code{@var{name}}
494is the name of the field holding the value of this option (without the
495leading @code{x_}). This gives the front end a way to indicate that
496the value has been set explicitly and should not be changed by the
497combined option. For example, some front ends use this to prevent
498@option{-ffast-math} and @option{-fno-fast-math} from changing the
499value of @option{-fmath-errno} for languages that do not use
500@code{errno}.
501
7d5a5747 502@item EnabledBy(@var{opt})
27e51192 503@itemx EnabledBy(@var{opt} || @var{opt2})
d919140b
MLI
504@itemx EnabledBy(@var{opt} && @var{opt2})
505If not explicitly set, the option is set to the value of
27e51192
TB
506@option{-@var{opt}}; multiple options can be given, separated by
507@code{||}. The third form using @code{&&} specifies that the option is
c2d89095
MLI
508only set if both @var{opt} and @var{opt2} are set. The options @var{opt}
509and @var{opt2} must have the @code{Common} property; otherwise, use
510@code{LangEnabledBy}.
f2bc201f
MLI
511
512@item LangEnabledBy(@var{language}, @var{opt})
65d4f2cd 513@itemx LangEnabledBy(@var{language}, @var{opt}, @var{posarg}, @var{negarg})
f2bc201f 514When compiling for the given language, the option is set to the value
27e51192
TB
515of @option{-@var{opt}}, if not explicitly set. @var{opt} can be also a list
516of @code{||} separated options. In the second form, if
65d4f2cd
MLI
517@var{opt} is used in the positive form then @var{posarg} is considered
518to be passed to the option, and if @var{opt} is used in the negative
519form then @var{negarg} is considered to be passed to the option. It
520is possible to specify several different languages. Each
521@var{language} must have been declared by an earlier @code{Language}
522record. @xref{Option file format}.
77ee7190
SB
523
524@item NoDWARFRecord
525The option is omitted from the producer string written by
526@option{-grecord-gcc-switches}.
212bfe71
JR
527
528@item PchIgnore
529Even if this is a target option, this option will not be recorded / compared
530to determine if a precompiled header file matches.
43f9a13c
MLI
531
532@item CPP(@var{var})
533The state of this option should be kept in sync with the preprocessor
2b71f4a4
MLI
534option @var{var}. If this property is set, then properties @code{Var}
535and @code{Init} must be set as well.
43f9a13c 536
b559c810
MLI
537@item CppReason(@var{CPP_W_Enum})
538This warning option corresponds to @code{cpplib.h} warning reason code
539@var{CPP_W_Enum}. This should only be used for warning options of the
540C-family front-ends.
541
75685792 542@end table