GCC’s command-line options are visible from Python scripts as instances of gcc.Option.
Wrapper around one of GCC’s command-line options.
You can locate a specific option using its text attribute:
option = gcc.Option('-Wdiv-by-zero')
The plugin will raise a ValueError if the option is not recognized.
It does not appear to be possible to create new options from the plugin.
(string) The text used at the command-line to affect this option e.g. -Werror.
(string) The help text for this option (e.g. “Warn about uninitialized automatic variables”)
(bool) Is this option enabled?
Unfortunately, for many options, the internal implementation makes it difficult to extract this. The plugin will raise a NotImplementedError exception when querying this attribute for such an option.
Calling gcc.warning() with such an option will lead to GCC’s warning machinery treating the option as enabled and emitting a warning, regardless of whether or not the option was actually enabled.
It appears that this must be fixed on an option-by-option basis within the plugin.
(bool) Is this a driver option?
(bool) Does this option control an optimization?
(bool) Is this a target-specific option?
(bool) Does this option control a warning message?
Internally, the class wraps GCC’s enum opt_code (and thus a struct cl_option)