Hi Guys,
Last month I submitted a patch to add a new switch to gcc:
--print-optimizers. The idea of this switch was that it would only
display those switches that controlled optimizations, and that it
would show their current status (activated/not activated). Mark
Mitchell suggested that it would be better to integrate this feature
into the current --help switch, so here is my proposal:
I would like to extend the --help switch so that, optionally, it
takes a parameter describing what type of information is required:
--help Does exactly the same as before.
--help=target Displays target specific switches only.
--target-help now becomes an alias for this
switch.
--help=warnings Displays switches that control warnings.
Displays switch status as described below.
--help=optimizers Displays switches that control optimizations.
Display switch status as described below.
--help={tool} Displays the --help output of the specified
tool (cpp, cc1, cc1plus, as, collect-ld, ld).
--help=pre-processor-symbols Displays all the symbols predefined
by the pre-processor. (Not sure if this option
will be popular. I like it because I can never
remember the magic incantation to get this
information emitted into the .i file, and
besides I do not want the information in a .i
file, I want it listed to stdout).
For the --help=warnings and --help=optimizers switch extra
information is also displayed about each switch. If the -Q switch
has been enabled earlier on the command line, then the descriptive
help text for each of the switches is displayed alongside the
switch. Otherwise the help text is omitted and instead an
indication is given as to whether the switch is currently enabled or
disabled. This information is sensitive to the position of the
--help=... switch on the command line, so that it is possible for
example to use:
gcc -O2 --help=optimizers
to find out which optimizations are active at -O2, or even:
gcc -O3 --help=optimizers > /tmp/O3-opts
gcc -O2 --help=optimizers > /tmp/O2-opts
diff /tmp/O2-opts /tmp/O3-opts | grep enabled
to find out which extra optimizations are enabled by the -O3 switch.
This enabled/disabled output will also be in a well defined format,
making it machine parsable. This is helpful for another project we
are working on - the automatic selection of the most effective
optimization options to compile any given particular application.
For switches which are not binary in nature, the current state of
the switch would be displayed.
What do you think ?
Cheers
Nick