]> git.ipfire.org Git - thirdparty/gcc.git/blame - gcc/doc/gccint/option-properties.rst
sphinx: add missing trailing newline
[thirdparty/gcc.git] / gcc / doc / gccint / option-properties.rst
CommitLineData
c63539ff
ML
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.. _option-properties:
7
8Option properties
9*****************
10
11The second field of an option record can specify any of the following
12properties. When an option takes an argument, it is enclosed in parentheses
13following the option property name. The parser that handles option files
14is quite simplistic, and will be tricked by any nested parentheses within
15the argument text itself; in this case, the entire option argument can
16be wrapped in curly braces within the parentheses to demarcate it, e.g.:
17
18.. code-block:: c++
19
20 Condition({defined (USE_CYGWIN_LIBSTDCXX_WRAPPERS)})
21
22``Common``
23 The option is available for all languages and targets.
24
25``Target``
26 The option is available for all languages but is target-specific.
27
28``Driver``
29 The option is handled by the compiler driver using code not shared
30 with the compilers proper (:samp:`cc1` etc.).
31
32``language``
33 The option is available when compiling for the given language.
34
35 It is possible to specify several different languages for the same
36 option. Each :samp:`{language}` must have been declared by an earlier
37 ``Language`` record. See :ref:`option-file-format`.
38
39``RejectDriver``
40 The option is only handled by the compilers proper (:samp:`cc1` etc.)
41 and should not be accepted by the driver.
42
43``RejectNegative``
44 The option does not have a 'no-' form. All options beginning with
45 'f', 'W' or 'm' are assumed to have a 'no-' form unless this
46 property is used.
47
48:samp:`Negative({othername})`
49 The option will turn off another option :samp:`{othername}`, which is
50 the option name with the leading '-' removed. This chain action will
51 propagate through the ``Negative`` property of the option to be
52 turned off. The driver will prune options, removing those that are
53 turned off by some later option. This pruning is not done for options
54 with ``Joined`` or ``JoinedOrMissing`` properties, unless the
55 options have both the ``RejectNegative`` property and the ``Negative``
56 property mentions itself.
57
58 As a consequence, if you have a group of mutually-exclusive
59 options, their ``Negative`` properties should form a circular chain.
60 For example, if options :option:`-a`, :option:`-b` and
61 :option:`-c` are mutually exclusive, their respective ``Negative``
62 properties should be :samp:`Negative({b})`, :samp:`Negative({c})`
63 and :samp:`Negative({a})`.
64
65``Joined`` ``Separate``
66 The option takes a mandatory argument. ``Joined`` indicates
67 that the option and argument can be included in the same ``argv``
68 entry (as with ``-mflush-func=name``, for example).
69 ``Separate`` indicates that the option and argument can be
70 separate ``argv`` entries (as with ``-o``). An option is
71 allowed to have both of these properties.
72
73``JoinedOrMissing``
74 The option takes an optional argument. If the argument is given,
75 it will be part of the same ``argv`` entry as the option itself.
76
77 This property cannot be used alongside ``Joined`` or ``Separate``.
78
79:samp:`MissingArgError({message})`
80 For an option marked ``Joined`` or ``Separate``, the message
81 :samp:`{message}` will be used as an error message if the mandatory
82 argument is missing; for options without ``MissingArgError``, a
83 generic error message is used. :samp:`{message}` should contain a single
84 :samp:`%qs` format, which will be used to format the name of the option
85 passed.
86
87:samp:`Args({n})`
88 For an option marked ``Separate``, indicate that it takes :samp:`{n}`
89 arguments. The default is 1.
90
91``UInteger``
92 The option's argument is a non-negative integer consisting of either
93 decimal or hexadecimal digits interpreted as ``int``. Hexadecimal
94 integers may optionally start with the ``0x`` or ``0X`` prefix.
95 The option parser validates and converts the argument before passing
96 it to the relevant option handler. ``UInteger`` should also be used
97 with options like ``-falign-loops`` where both ``-falign-loops``
98 and ``-falign-loops`` = :samp:`{n}` are supported to make sure the saved
99 options are given a full integer. Positive values of the argument in
100 excess of ``INT_MAX`` wrap around zero.
101
102``Host_Wide_Int``
103 The option's argument is a non-negative integer consisting of either
104 decimal or hexadecimal digits interpreted as the widest integer type
105 on the host. As with an ``UInteger`` argument, hexadecimal integers
106 may optionally start with the ``0x`` or ``0X`` prefix. The option
107 parser validates and converts the argument before passing it to
108 the relevant option handler. ``Host_Wide_Int`` should be used with
109 options that need to accept very large values. Positive values of
110 the argument in excess of ``HOST_WIDE_INT_M1U`` are assigned
111 ``HOST_WIDE_INT_M1U``.
112
113:samp:`IntegerRange({n}, {m})`
114 The options's arguments are integers of type ``int``. The option's
115 parser validates that the value of an option integer argument is within
116 the closed range [ :samp:`{n}`, :samp:`{m}` ].
117
118``ByteSize``
119 A property applicable only to ``UInteger`` or ``Host_Wide_Int``
120 arguments. The option's integer argument is interpreted as if in infinite
121 precision using saturation arithmetic in the corresponding type. The argument
122 may be followed by a :samp:`byte-size` suffix designating a multiple of bytes
123 such as ``kB`` and ``KiB`` for kilobyte and kibibyte, respectively,
124 ``MB`` and ``MiB`` for megabyte and mebibyte, ``GB`` and ``GiB``
125 for gigabyte and gigibyte, and so on. ``ByteSize`` should be used for
126 with options that take a very large argument representing a size in bytes,
127 such as :option:`-Wlarger-than=`.
128
129``ToLower``
130 The option's argument should be converted to lowercase as part of
131 putting it in canonical form, and before comparing with the strings
132 indicated by any ``Enum`` property.
133
134``NoDriverArg``
135 For an option marked ``Separate``, the option only takes an
136 argument in the compiler proper, not in the driver. This is for
137 compatibility with existing options that are used both directly and
138 via :option:`-Wp,` ; new options should not have this property.
139
140:samp:`Var({var})`
141 The state of this option should be stored in variable :samp:`{var}`
142 (actually a macro for ``global_options.x_var``).
143 The way that the state is stored depends on the type of option:
144
145``WarnRemoved``
146 The option is removed and every usage of such option will
147 result in a warning. We use it option backward compatibility.
148
149:samp:`Var({var}, {set})`
150 The option controls an integer variable :samp:`{var}` and is active when
151 :samp:`{var}` equals :samp:`{set}`. The option parser will set :samp:`{var}` to
152 :samp:`{set}` when the positive form of the option is used and ``!set``
153 when the 'no-' form is used.
154
155 :samp:`{var}` is declared in the same way as for the single-argument form
156 described above.
157
158 * If the option uses the ``Mask`` or ``InverseMask`` properties,
159 :samp:`{var}` is the integer variable that contains the mask.
160
161 * If the option is a normal on/off switch, :samp:`{var}` is an integer
162 variable that is nonzero when the option is enabled. The options
163 parser will set the variable to 1 when the positive form of the
164 option is used and 0 when the 'no-' form is used.
165
166 * If the option takes an argument and has the ``UInteger`` property,
167 :samp:`{var}` is an integer variable that stores the value of the argument.
168
169 * If the option takes an argument and has the ``Enum`` property,
170 :samp:`{var}` is a variable (type given in the ``Type`` property of the
171 :samp:`Enum` record whose ``Name`` property has the same argument as
172 the ``Enum`` property of this option) that stores the value of the
173 argument.
174
175 * If the option has the ``Defer`` property, :samp:`{var}` is a pointer to
176 a ``VEC(cl_deferred_option,heap)`` that stores the option for later
177 processing. (:samp:`{var}` is declared with type ``void *`` and needs
178 to be cast to ``VEC(cl_deferred_option,heap)`` before use.)
179
180 * Otherwise, if the option takes an argument, :samp:`{var}` is a pointer to
181 the argument string. The pointer will be null if the argument is optional
182 and wasn't given.
183
184 The option-processing script will usually zero-initialize :samp:`{var}`.
185 You can modify this behavior using ``Init``.
186
187:samp:`Init({value})`
188 The variable specified by the ``Var`` property should be statically
189 initialized to :samp:`{value}`. If more than one option using the same
190 variable specifies ``Init``, all must specify the same initializer.
191
192:samp:`Mask({name})`
193 The option is associated with a bit in the ``target_flags``
194 variable (see :ref:`run-time-target`) and is active when that bit is set.
195 You may also specify ``Var`` to select a variable other than
196 ``target_flags``.
197
198 The options-processing script will automatically allocate a unique bit
199 for the option. If the option is attached to :samp:`target_flags`,
200 the script will set the macro ``MASK_name`` to the appropriate
201 bitmask. It will also declare a ``TARGET_name`` macro that has
202 the value 1 when the option is active and 0 otherwise. If you use ``Var``
203 to attach the option to a different variable, the bitmask macro with be
204 called ``OPTION_MASK_name``.
205
206:samp:`InverseMask({othername})` :samp:`InverseMask({othername}, {thisname})`
207 The option is the inverse of another option that has the
208 ``Mask(othername)`` property. If :samp:`{thisname}` is given,
209 the options-processing script will declare a ``TARGET_thisname``
210 macro that is 1 when the option is active and 0 otherwise.
211
212:samp:`Enum({name})`
213 The option's argument is a string from the set of strings associated
214 with the corresponding :samp:`Enum` record. The string is checked and
215 converted to the integer specified in the corresponding
216 :samp:`EnumValue` record before being passed to option handlers.
217
218``EnumSet``
219 Must be used together with the ``Enum(name)`` property.
220 Corresponding :samp:`Enum` record must use ``Set`` properties.
221 The option's argument is either a string from the set like for
222 ``Enum(name)``, but with a slightly different behavior that
223 the whole ``Var`` isn't overwritten, but only the bits in all the
224 enumeration values with the same set bitwise ored together.
225 Or option's argument can be a comma separated list of strings where
226 each string is from a different ``Set(number)``.
227
228``EnumBitSet``
229 Must be used together with the ``Enum(name)`` property.
230 Similar to :samp:`EnumSet`, but corresponding :samp:`Enum` record must
231 not use ``Set`` properties, each ``EnumValue`` should have
232 ``Value`` that is a power of 2, each value is treated as its own
233 set and its value as the set's mask, so there are no mutually
234 exclusive arguments.
235
236``Defer``
237 The option should be stored in a vector, specified with ``Var``,
238 for later processing.
239
240:samp:`Alias({opt})` :samp:`Alias({opt}, {arg})` :samp:`Alias({opt}, {posarg}, {negarg})`
241 The option is an alias for :option:`-opt` (or the negative form
242 of that option, depending on ``NegativeAlias``). In the first form,
243 any argument passed to the alias is considered to be passed to
244 :option:`-opt`, and :option:`-opt` is considered to be
245 negated if the alias is used in negated form. In the second form, the
246 alias may not be negated or have an argument, and :samp:`{posarg}` is
247 considered to be passed as an argument to :option:`-opt`. In the
248 third form, the alias may not have an argument, if the alias is used
249 in the positive form then :samp:`{posarg}` is considered to be passed to
250 :option:`-opt`, and if the alias is used in the negative form
251 then :samp:`{negarg}` is considered to be passed to :option:`-opt`.
252
253 Aliases should not specify ``Var`` or ``Mask`` or
254 ``UInteger``. Aliases should normally specify the same languages
255 as the target of the alias; the flags on the target will be used to
256 determine any diagnostic for use of an option for the wrong language,
257 while those on the alias will be used to identify what command-line
258 text is the option and what text is any argument to that option.
259
260 When an ``Alias`` definition is used for an option, driver specs do
261 not need to handle it and no :samp:`OPT_` enumeration value is defined
262 for it; only the canonical form of the option will be seen in those
263 places.
264
265``NegativeAlias``
266 For an option marked with ``Alias(opt)``, the option is
267 considered to be an alias for the positive form of :option:`-opt`
268 if negated and for the negative form of :option:`-opt` if not
269 negated. ``NegativeAlias`` may not be used with the forms of
270 ``Alias`` taking more than one argument.
271
272``Ignore``
273 This option is ignored apart from printing any warning specified using
274 ``Warn``. The option will not be seen by specs and no :samp:`OPT_`
275 enumeration value is defined for it.
276
277``SeparateAlias``
278 For an option marked with ``Joined``, ``Separate`` and
279 ``Alias``, the option only acts as an alias when passed a separate
280 argument; with a joined argument it acts as a normal option, with an
281 :samp:`OPT_` enumeration value. This is for compatibility with the
282 Java :option:`-d` option and should not be used for new options.
283
284:samp:`Warn({message})`
285 If this option is used, output the warning :samp:`{message}`.
286 :samp:`{message}` is a format string, either taking a single operand with
287 a :samp:`%qs` format which is the option name, or not taking any
288 operands, which is passed to the :samp:`warning` function. If an alias
289 is marked ``Warn``, the target of the alias must not also be marked
290 ``Warn``.
291
292``Warning``
293 This is a warning option and should be shown as such in
294 :option:`--help` output. This flag does not currently affect anything
295 other than :option:`--help`.
296
297``Optimization``
298 This is an optimization option. It should be shown as such in
299 :option:`--help` output, and any associated variable named using
300 ``Var`` should be saved and restored when the optimization level is
301 changed with ``optimize`` attributes.
302
303``PerFunction``
304 This is an option that can be overridden on a per-function basis.
305 ``Optimization`` implies ``PerFunction``, but options that do not
306 affect executable code generation may use this flag instead, so that the
307 option is not taken into account in ways that might affect executable
308 code generation.
309
310``Param``
311 This is an option that is a parameter.
312
313``Undocumented``
314 The option is deliberately missing documentation and should not
315 be included in the :option:`--help` output.
316
317:samp:`Condition({cond})`
318 The option should only be accepted if preprocessor condition
319 :samp:`{cond}` is true. Note that any C declarations associated with the
320 option will be present even if :samp:`{cond}` is false; :samp:`{cond}` simply
321 controls whether the option is accepted and whether it is printed in
322 the :option:`--help` output.
323
324``Save``
325 Build the ``cl_target_option`` structure to hold a copy of the
326 option, add the functions ``cl_target_option_save`` and
327 ``cl_target_option_restore`` to save and restore the options.
328
329``SetByCombined``
330 The option may also be set by a combined option such as
331 :option:`-ffast-math`. This causes the ``gcc_options`` struct to
332 have a field ``frontend_set_name``, where ``name``
333 is the name of the field holding the value of this option (without the
334 leading ``x_``). This gives the front end a way to indicate that
335 the value has been set explicitly and should not be changed by the
336 combined option. For example, some front ends use this to prevent
337 :option:`-ffast-math` and :option:`-fno-fast-math` from changing the
338 value of :option:`-fmath-errno` for languages that do not use
339 ``errno``.
340
341:samp:`EnabledBy({opt})` :samp:`EnabledBy({opt} || {opt2})` :samp:`EnabledBy({opt} && {opt2})`
342 If not explicitly set, the option is set to the value of
343 :option:`-opt` ; multiple options can be given, separated by
344 ``||``. The third form using ``&&`` specifies that the option is
345 only set if both :samp:`{opt}` and :samp:`{opt2}` are set. The options :samp:`{opt}`
346 and :samp:`{opt2}` must have the ``Common`` property; otherwise, use
347 ``LangEnabledBy``.
348
349:samp:`LangEnabledBy({language}, {opt})` :samp:`LangEnabledBy({language}, {opt}, {posarg}, {negarg})`
350 When compiling for the given language, the option is set to the value
351 of :option:`-opt`, if not explicitly set. :samp:`{opt}` can be also a list
352 of ``||`` separated options. In the second form, if
353 :samp:`{opt}` is used in the positive form then :samp:`{posarg}` is considered
354 to be passed to the option, and if :samp:`{opt}` is used in the negative
355 form then :samp:`{negarg}` is considered to be passed to the option. It
356 is possible to specify several different languages. Each
357 :samp:`{language}` must have been declared by an earlier ``Language``
358 record. See :ref:`option-file-format`.
359
360``NoDWARFRecord``
361 The option is omitted from the producer string written by
362 :option:`-grecord-gcc-switches`.
363
364``PchIgnore``
365 Even if this is a target option, this option will not be recorded / compared
366 to determine if a precompiled header file matches.
367
368:samp:`CPP({var})`
369 The state of this option should be kept in sync with the preprocessor
370 option :samp:`{var}`. If this property is set, then properties ``Var``
371 and ``Init`` must be set as well.
372
373:samp:`CppReason({CPP_W_Enum})`
374 This warning option corresponds to ``cpplib.h`` warning reason code
375 :samp:`{CPP_W_Enum}`. This should only be used for warning options of the
3ed1b4ce 376 C-family front-ends.