Option properties#
The second field of an option record can specify any of the following properties. When an option takes an argument, it is enclosed in parentheses following the option property name. The parser that handles option files is quite simplistic, and will be tricked by any nested parentheses within the argument text itself; in this case, the entire option argument can be wrapped in curly braces within the parentheses to demarcate it, e.g.:
Condition({defined (USE_CYGWIN_LIBSTDCXX_WRAPPERS)})
CommonThe option is available for all languages and targets.
TargetThe option is available for all languages but is target-specific.
DriverThe option is handled by the compiler driver using code not shared with the compilers proper (
cc1etc.).languageThe option is available when compiling for the given language.
It is possible to specify several different languages for the same option. Each
languagemust have been declared by an earlierLanguagerecord. See Option file format.RejectDriverThe option is only handled by the compilers proper (
cc1etc.) and should not be accepted by the driver.RejectNegativeThe option does not have a ‘no-’ form. All options beginning with ‘f’, ‘W’ or ‘m’ are assumed to have a ‘no-’ form unless this property is used.
Negative(othername)The option will turn off another option
othername, which is the option name with the leading ‘-’ removed. This chain action will propagate through theNegativeproperty of the option to be turned off. The driver will prune options, removing those that are turned off by some later option. This pruning is not done for options withJoinedorJoinedOrMissingproperties, unless the options have both theRejectNegativeproperty and theNegativeproperty mentions itself.As a consequence, if you have a group of mutually-exclusive options, their
Negativeproperties should form a circular chain. For example, if options-a,-band-care mutually exclusive, their respectiveNegativeproperties should beNegative(b),Negative(c)andNegative(a).JoinedSeparateThe option takes a mandatory argument.
Joinedindicates that the option and argument can be included in the sameargventry (as with-mflush-func=name, for example).Separateindicates that the option and argument can be separateargventries (as with-o). An option is allowed to have both of these properties.JoinedOrMissingThe option takes an optional argument. If the argument is given, it will be part of the same
argventry as the option itself.This property cannot be used alongside
JoinedorSeparate.MissingArgError(message)For an option marked
JoinedorSeparate, the messagemessagewill be used as an error message if the mandatory argument is missing; for options withoutMissingArgError, a generic error message is used.messageshould contain a single%qsformat, which will be used to format the name of the option passed.Args(n)For an option marked
Separate, indicate that it takesnarguments. The default is 1.UIntegerThe option’s argument is a non-negative integer consisting of either decimal or hexadecimal digits interpreted as
int. Hexadecimal integers may optionally start with the0xor0Xprefix. The option parser validates and converts the argument before passing it to the relevant option handler.UIntegershould also be used with options like-falign-loopswhere both-falign-loopsand-falign-loops=nare supported to make sure the saved options are given a full integer. Positive values of the argument in excess ofINT_MAXwrap around zero.Host_Wide_IntThe option’s argument is a non-negative integer consisting of either decimal or hexadecimal digits interpreted as the widest integer type on the host. As with an
UIntegerargument, hexadecimal integers may optionally start with the0xor0Xprefix. The option parser validates and converts the argument before passing it to the relevant option handler.Host_Wide_Intshould be used with options that need to accept very large values. Positive values of the argument in excess ofHOST_WIDE_INT_M1Uare assignedHOST_WIDE_INT_M1U.IntegerRange(n, m)The options’s arguments are integers of type
int. The option’s parser validates that the value of an option integer argument is within the closed range [n,m].ByteSizeA property applicable only to
UIntegerorHost_Wide_Intarguments. The option’s integer argument is interpreted as if in infinite precision using saturation arithmetic in the corresponding type. The argument may be followed by abyte-sizesuffix designating a multiple of bytes such askBandKiBfor kilobyte and kibibyte, respectively,MBandMiBfor megabyte and mebibyte,GBandGiBfor gigabyte and gigibyte, and so on.ByteSizeshould be used for with options that take a very large argument representing a size in bytes, such as-Wlarger-than=.ToLowerThe option’s argument should be converted to lowercase as part of putting it in canonical form, and before comparing with the strings indicated by any
Enumproperty.NoDriverArgFor an option marked
Separate, the option only takes an argument in the compiler proper, not in the driver. This is for compatibility with existing options that are used both directly and via-Wp,; new options should not have this property.Var(var)The state of this option should be stored in variable
var(actually a macro forglobal_options.x_var). The way that the state is stored depends on the type of option:WarnRemovedThe option is removed and every usage of such option will result in a warning. We use it option backward compatibility.
Var(var, set)The option controls an integer variable
varand is active whenvarequalsset. The option parser will setvartosetwhen the positive form of the option is used and!setwhen the ‘no-’ form is used.varis declared in the same way as for the single-argument form described above.If the option uses the
MaskorInverseMaskproperties,varis the integer variable that contains the mask.If the option is a normal on/off switch,
varis an integer variable that is nonzero when the option is enabled. The options parser will set the variable to 1 when the positive form of the option is used and 0 when the ‘no-’ form is used.If the option takes an argument and has the
UIntegerproperty,varis an integer variable that stores the value of the argument.If the option takes an argument and has the
Enumproperty,varis a variable (type given in theTypeproperty of theEnumrecord whoseNameproperty has the same argument as theEnumproperty of this option) that stores the value of the argument.If the option has the
Deferproperty,varis a pointer to aVEC(cl_deferred_option,heap)that stores the option for later processing. (varis declared with typevoid *and needs to be cast toVEC(cl_deferred_option,heap)before use.)Otherwise, if the option takes an argument,
varis a pointer to the argument string. The pointer will be null if the argument is optional and wasn’t given.
The option-processing script will usually zero-initialize
var. You can modify this behavior usingInit.Init(value)The variable specified by the
Varproperty should be statically initialized tovalue. If more than one option using the same variable specifiesInit, all must specify the same initializer.Mask(name)The option is associated with a bit in the
target_flagsvariable (see Run-time Target Specification) and is active when that bit is set. You may also specifyVarto select a variable other thantarget_flags.The options-processing script will automatically allocate a unique bit for the option. If the option is attached to
target_flags, the script will set the macroMASK_nameto the appropriate bitmask. It will also declare aTARGET_namemacro that has the value 1 when the option is active and 0 otherwise. If you useVarto attach the option to a different variable, the bitmask macro with be calledOPTION_MASK_name.InverseMask(othername)InverseMask(othername, thisname)The option is the inverse of another option that has the
Mask(othername)property. Ifthisnameis given, the options-processing script will declare aTARGET_thisnamemacro that is 1 when the option is active and 0 otherwise.Enum(name)The option’s argument is a string from the set of strings associated with the corresponding
Enumrecord. The string is checked and converted to the integer specified in the correspondingEnumValuerecord before being passed to option handlers.EnumSetMust be used together with the
Enum(name)property. CorrespondingEnumrecord must useSetproperties. The option’s argument is either a string from the set like forEnum(name), but with a slightly different behavior that the wholeVarisn’t overwritten, but only the bits in all the enumeration values with the same set bitwise ored together. Or option’s argument can be a comma separated list of strings where each string is from a differentSet(number).EnumBitSetMust be used together with the
Enum(name)property. Similar toEnumSet, but correspondingEnumrecord must not useSetproperties, eachEnumValueshould haveValuethat is a power of 2, each value is treated as its own set and its value as the set’s mask, so there are no mutually exclusive arguments.DeferThe option should be stored in a vector, specified with
Var, for later processing.Alias(opt)Alias(opt, arg)Alias(opt, posarg, negarg)The option is an alias for
-opt(or the negative form of that option, depending onNegativeAlias). In the first form, any argument passed to the alias is considered to be passed to-opt, and-optis considered to be negated if the alias is used in negated form. In the second form, the alias may not be negated or have an argument, andposargis considered to be passed as an argument to-opt. In the third form, the alias may not have an argument, if the alias is used in the positive form thenposargis considered to be passed to-opt, and if the alias is used in the negative form thennegargis considered to be passed to-opt.Aliases should not specify
VarorMaskorUInteger. Aliases should normally specify the same languages as the target of the alias; the flags on the target will be used to determine any diagnostic for use of an option for the wrong language, while those on the alias will be used to identify what command-line text is the option and what text is any argument to that option.When an
Aliasdefinition is used for an option, driver specs do not need to handle it and noOPT_enumeration value is defined for it; only the canonical form of the option will be seen in those places.NegativeAliasFor an option marked with
Alias(opt), the option is considered to be an alias for the positive form of-optif negated and for the negative form of-optif not negated.NegativeAliasmay not be used with the forms ofAliastaking more than one argument.IgnoreThis option is ignored apart from printing any warning specified using
Warn. The option will not be seen by specs and noOPT_enumeration value is defined for it.SeparateAliasFor an option marked with
Joined,SeparateandAlias, the option only acts as an alias when passed a separate argument; with a joined argument it acts as a normal option, with anOPT_enumeration value. This is for compatibility with the Java-doption and should not be used for new options.Warn(message)If this option is used, output the warning
message.messageis a format string, either taking a single operand with a%qsformat which is the option name, or not taking any operands, which is passed to thewarningfunction. If an alias is markedWarn, the target of the alias must not also be markedWarn.WarningThis is a warning option and should be shown as such in
--helpoutput. This flag does not currently affect anything other than--help.OptimizationThis is an optimization option. It should be shown as such in
--helpoutput, and any associated variable named usingVarshould be saved and restored when the optimization level is changed withoptimizeattributes.PerFunctionThis is an option that can be overridden on a per-function basis.
OptimizationimpliesPerFunction, but options that do not affect executable code generation may use this flag instead, so that the option is not taken into account in ways that might affect executable code generation.ParamThis is an option that is a parameter.
UndocumentedThe option is deliberately missing documentation and should not be included in the
--helpoutput.Condition(cond)The option should only be accepted if preprocessor condition
condis true. Note that any C declarations associated with the option will be present even ifcondis false;condsimply controls whether the option is accepted and whether it is printed in the--helpoutput.SaveBuild the
cl_target_optionstructure to hold a copy of the option, add the functionscl_target_option_saveandcl_target_option_restoreto save and restore the options.SetByCombinedThe option may also be set by a combined option such as
-ffast-math. This causes thegcc_optionsstruct to have a fieldfrontend_set_name, wherenameis the name of the field holding the value of this option (without the leadingx_). This gives the front end a way to indicate that the value has been set explicitly and should not be changed by the combined option. For example, some front ends use this to prevent-ffast-mathand-fno-fast-mathfrom changing the value of-fmath-errnofor languages that do not useerrno.EnabledBy(opt)EnabledBy(opt || opt2)EnabledBy(opt && opt2)If not explicitly set, the option is set to the value of
-opt; multiple options can be given, separated by||. The third form using&&specifies that the option is only set if bothoptandopt2are set. The optionsoptandopt2must have theCommonproperty; otherwise, useLangEnabledBy.LangEnabledBy(language, opt)LangEnabledBy(language, opt, posarg, negarg)When compiling for the given language, the option is set to the value of
-opt, if not explicitly set.optcan be also a list of||separated options. In the second form, ifoptis used in the positive form thenposargis considered to be passed to the option, and ifoptis used in the negative form thennegargis considered to be passed to the option. It is possible to specify several different languages. Eachlanguagemust have been declared by an earlierLanguagerecord. See Option file format.NoDWARFRecordThe option is omitted from the producer string written by
-grecord-gcc-switches.PchIgnoreEven if this is a target option, this option will not be recorded / compared to determine if a precompiled header file matches.
CPP(var)The state of this option should be kept in sync with the preprocessor option
var. If this property is set, then propertiesVarandInitmust be set as well.CppReason(CPP_W_Enum)This warning option corresponds to
cpplib.hwarning reason codeCPP_W_Enum. This should only be used for warning options of the C-family front-ends.