1 @c Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008
2 @c Free Software Foundation, Inc.
3 @c This is part of the GCC manual.
4 @c For copying conditions, see the file gcc.texi.
7 @chapter Option specification files
8 @cindex option specification files
9 @cindex @samp{optc-gen.awk}
11 Most GCC command-line options are described by special option
12 definition files, the names of which conventionally end in
13 @code{.opt}. This chapter describes the format of these files.
16 * Option file format:: The general layout of the files
17 * Option properties:: Supported option properties
20 @node Option file format
21 @section Option file format
23 Option files are a simple list of records in which each field occupies
24 its own line and in which the records themselves are separated by
25 blank lines. Comments may appear on their own line anywhere within
26 the file and are preceded by semicolons. Whitespace is allowed before
29 The files can contain the following types of record:
33 A language definition record. These records have two fields: the
34 string @samp{Language} and the name of the language. Once a language
35 has been declared in this way, it can be used as an option property.
36 @xref{Option properties}.
39 A target specific save record to save additional information. These
40 records have two fields: the string @samp{TargetSave}, and a
41 declaration type to go in the @code{cl_target_option} structure.
46 the name of the option, with the leading ``-'' removed
48 a space-separated list of option properties (@pxref{Option properties})
50 the help text to use for @option{--help} (omitted if the second field
51 contains the @code{Undocumented} property).
54 By default, all options beginning with ``f'', ``W'' or ``m'' are
55 implicitly assumed to take a ``no-'' form. This form should not be
56 listed separately. If an option beginning with one of these letters
57 does not have a ``no-'' form, you can use the @code{RejectNegative}
58 property to reject it.
60 The help text is automatically line-wrapped before being displayed.
61 Normally the name of the option is printed on the left-hand side of
62 the output and the help text is printed on the right. However, if the
63 help text contains a tab character, the text to the left of the tab is
64 used instead of the option's name and the text to the right of the
65 tab forms the help text. This allows you to elaborate on what type
66 of argument the option takes.
69 A target mask record. These records have one field of the form
70 @samp{Mask(@var{x})}. The options-processing script will automatically
71 allocate a bit in @code{target_flags} (@pxref{Run-time Target}) for
72 each mask name @var{x} and set the macro @code{MASK_@var{x}} to the
73 appropriate bitmask. It will also declare a @code{TARGET_@var{x}}
74 macro that has the value 1 when bit @code{MASK_@var{x}} is set and
77 They are primarily intended to declare target masks that are not
78 associated with user options, either because these masks represent
79 internal switches or because the options are not available on all
80 configurations and yet the masks always need to be defined.
83 @node Option properties
84 @section Option properties
86 The second field of an option record can specify the following properties:
90 The option is available for all languages and targets.
93 The option is available for all languages but is target-specific.
96 The option is available when compiling for the given language.
98 It is possible to specify several different languages for the same
99 option. Each @var{language} must have been declared by an earlier
100 @code{Language} record. @xref{Option file format}.
103 The option does not have a ``no-'' form. All options beginning with
104 ``f'', ``W'' or ``m'' are assumed to have a ``no-'' form unless this
107 @item Negative(@var{othername})
108 The option will turn off another option @var{othername}, which is the
109 the option name with the leading ``-'' removed. This chain action will
110 propagate through the @code{Negative} property of the option to be
115 The option takes a mandatory argument. @code{Joined} indicates
116 that the option and argument can be included in the same @code{argv}
117 entry (as with @code{-mflush-func=@var{name}}, for example).
118 @code{Separate} indicates that the option and argument can be
119 separate @code{argv} entries (as with @code{-o}). An option is
120 allowed to have both of these properties.
122 @item JoinedOrMissing
123 The option takes an optional argument. If the argument is given,
124 it will be part of the same @code{argv} entry as the option itself.
126 This property cannot be used alongside @code{Joined} or @code{Separate}.
129 The option's argument is a non-negative integer. The option parser
130 will check and convert the argument before passing it to the relevant
131 option handler. @code{UInteger} should also be used on options like
132 @code{-falign-loops} where both @code{-falign-loops} and
133 @code{-falign-loops}=@var{n} are supported to make sure the saved
134 options are given a full integer.
137 The state of this option should be stored in variable @var{var}.
138 The way that the state is stored depends on the type of option:
142 If the option uses the @code{Mask} or @code{InverseMask} properties,
143 @var{var} is the integer variable that contains the mask.
146 If the option is a normal on/off switch, @var{var} is an integer
147 variable that is nonzero when the option is enabled. The options
148 parser will set the variable to 1 when the positive form of the
149 option is used and 0 when the ``no-'' form is used.
152 If the option takes an argument and has the @code{UInteger} property,
153 @var{var} is an integer variable that stores the value of the argument.
156 Otherwise, if the option takes an argument, @var{var} is a pointer to
157 the argument string. The pointer will be null if the argument is optional
161 The option-processing script will usually declare @var{var} in
162 @file{options.c} and leave it to be zero-initialized at start-up time.
163 You can modify this behavior using @code{VarExists} and @code{Init}.
165 @item Var(@var{var}, @var{set})
166 The option controls an integer variable @var{var} and is active when
167 @var{var} equals @var{set}. The option parser will set @var{var} to
168 @var{set} when the positive form of the option is used and @code{!@var{set}}
169 when the ``no-'' form is used.
171 @var{var} is declared in the same way as for the single-argument form
175 The variable specified by the @code{Var} property already exists.
176 No definition should be added to @file{options.c} in response to
179 You should use this property only if the variable is declared outside
182 @item Init(@var{value})
183 The variable specified by the @code{Var} property should be statically
184 initialized to @var{value}.
186 @item Mask(@var{name})
187 The option is associated with a bit in the @code{target_flags}
188 variable (@pxref{Run-time Target}) and is active when that bit is set.
189 You may also specify @code{Var} to select a variable other than
192 The options-processing script will automatically allocate a unique bit
193 for the option. If the option is attached to @samp{target_flags},
194 the script will set the macro @code{MASK_@var{name}} to the appropriate
195 bitmask. It will also declare a @code{TARGET_@var{name}} macro that has
196 the value 1 when the option is active and 0 otherwise. If you use @code{Var}
197 to attach the option to a different variable, the associated macros are
198 called @code{OPTION_MASK_@var{name}} and @code{OPTION_@var{name}} respectively.
200 You can disable automatic bit allocation using @code{MaskExists}.
202 @item InverseMask(@var{othername})
203 @itemx InverseMask(@var{othername}, @var{thisname})
204 The option is the inverse of another option that has the
205 @code{Mask(@var{othername})} property. If @var{thisname} is given,
206 the options-processing script will declare a @code{TARGET_@var{thisname}}
207 macro that is 1 when the option is active and 0 otherwise.
210 The mask specified by the @code{Mask} property already exists.
211 No @code{MASK} or @code{TARGET} definitions should be added to
212 @file{options.h} in response to this option record.
214 The main purpose of this property is to support synonymous options.
215 The first option should use @samp{Mask(@var{name})} and the others
216 should use @samp{Mask(@var{name}) MaskExists}.
219 The state of the option should be printed by @option{-fverbose-asm}.
222 The option is deliberately missing documentation and should not
223 be included in the @option{--help} output.
225 @item Condition(@var{cond})
226 The option should only be accepted if preprocessor condition
227 @var{cond} is true. Note that any C declarations associated with the
228 option will be present even if @var{cond} is false; @var{cond} simply
229 controls whether the option is accepted and whether it is printed in
230 the @option{--help} output.
233 Build the @code{cl_target_option} structure to hold a copy of the
234 option, add the functions @code{cl_target_option_save} and
235 @code{cl_target_option_restore} to save and restore the options.