* Makefile.in: Update.
* c-opts.c (c_common_handle_option): opt_text now contains the '-'.
* c.opt: Update documentation.
* common.opt: Add some help text.
* opts.c: Include intl.h.
(wrap_help, print_help): New.
(find_opt, handle_option, common_handle_option): opt_text now
contains the '-'. Use print_help to output help.
* opts.h (struct cl_option): New member "help".
* opts.sh: Update to handle help text output and to prepend
options with '-'.
* toplev.c (display_help): Remove some help text.
From-SVN: r69068
$(SHELL) $(srcdir)/move-if-change tmp-specs.h specs.h
$(STAMP) s-specs
-options.c: $(lang_opt_files) $(srcdir)/opts.sh options.h
+options.c: $(lang_opt_files) $(srcdir)/opts.sh options.h intl.h
options.h: $(lang_opt_files) $(srcdir)/opts.sh
AWK=$(AWK) $(SHELL) $(srcdir)/opts.sh options.c options.h \
input.h toplev.h intl.h langhooks.h $(LANGHOOKS_DEF_H)
opts.o : opts.c opts.h options.h toplev.h $(CONFIG_H) $(SYSTEM_H) \
coretypes.h $(TREE_H) $(TM_H) $(LANGHOOKS_H) $(GGC_H) $(RTL_H) \
- output.h diagnostic.h $(TM_P_H) $(INSN_ATTR_H)
+ output.h diagnostic.h $(TM_P_H) $(INSN_ATTR_H) intl.h
toplev.o : toplev.c $(CONFIG_H) $(SYSTEM_H) coretypes.h $(TM_H) $(TREE_H) $(RTL_H) \
function.h flags.h xcoffout.h input.h $(INSN_ATTR_H) output.h diagnostic.h \
debug.h insn-config.h intl.h $(RECOG_H) Makefile toplev.h \
case OPT_fthis_is_variable:
case OPT_fvtable_thunks:
case OPT_fxref:
- warning ("switch \"-%s\" is no longer supported", option->opt_text);
+ warning ("switch \"%s\" is no longer supported", option->opt_text);
break;
case OPT_fabi_version_:
if (value)
flag_external_templates = true;
cp_deprecated:
- warning ("switch \"-%s\" is deprecated, please see documentation "
+ warning ("switch \"%s\" is deprecated, please see documentation "
"for details", option->opt_text);
break;
; decoder will convert the argument for you, or complain to the user
; if the argument is invalid.
+; The third field is the help text to output with --help. This is
+; automatically line-wrapped on output. Normally the switch is output
+; automatically, with the help text on the right hand side of the
+; output. However, if the help text contains a tab character, the
+; text to the left of the tab is output instead of the switch, and the
+; text to its right forms the help. This is useful for elaborating on
+; what type of argument a switch takes, for example.
+
; Comments can appear on their own line anwhere in the file, preceded
; by a semicolon. Whitespace is permitted before the semicolon.
-help
Common
+Display this information
-param
Common Separate
G
Common Joined Separate UInteger
+-G<number> Put global and static data smaller than <number> bytes into a special section (on some targets)
O
Common JoinedOrMissing
+-O<number> Set optimization level to <number>
Os
Common
+Optimize for space rather than speed
W
Common RejectNegative
Wextra
Common
+Print extra (possibly unwanted) warnings
Winline
Common
Wlarger-than-
Common RejectNegative Joined UInteger
+-Wlarger-than-<number> Warn if an object is larger than <number> bytes
Wmissing-noreturn
Common
Wunused
Common
+Enable all -Wunused- warnings
Wunused-function
Common
aux-info
Common Separate
+-aux-info <file> Emit declaration information into <file>
aux-info=
Common Joined
d
Common Joined
+-d<letters> Enable dumps from specific passes of the compiler
dumpbase
Common Separate
+-dumpbase <file> Set the file basename to be used for dumps
fPIC
Common
fcall-saved-
Common Joined RejectNegative
+-fcall-saved-<register> Mark <register> as being preserved across functions
fcall-used-
Common Joined RejectNegative
+-fcall-used-<register> Mark <register> as being corrupted by function calls
fcaller-saves
Common
fdiagnostics-show-location=
Common Joined RejectNegative
+-fdiagnostics-show-location=[once|every-line] How often to emit source location at the beginning of line-wrapped diagnostics
fdump-unnumbered
Common
ffixed-
Common Joined RejectNegative
+-ffixed-<register> Mark <register> as being unavailable to the compiler
ffloat-store
Common
finline-limit=
Common RejectNegative Joined UInteger
+-finline-limit=<number> Limit the size of inlined functions to <number>
finstrument-functions
Common
fmessage-length=
Common RejectNegative Joined UInteger
+-fmessage-length=<number> Limit diagnostics to <number> characters per line. 0 suppresses line-wrapping
fmove-all-movables
Common
frandom-seed=
Common Joined RejectNegative
+-frandom-seed=<string> Make compile reproducible using <string>
freduce-all-givs
Common
fsched-verbose=
Common RejectNegative Joined
+-fsched-verbose=<number> Set the verbosity level of the scheduler
fsched2-use-superblocks
Common
fstack-limit-register=
Common RejectNegative Joined
+-fstack-limit-register=<register> Trap if the stack goes past <register>
fstack-limit-symbol=
Common RejectNegative Joined
+-fstack-limit-symbol=<name> Trap if the stack goes past symbol <name>
fstrength-reduce
Common
ftls-model=
Common Joined RejectNegative
+-ftls-model=[global-dynamic|local-dynamic|initial-exec|local-exec] Set the default thread-local storage code generation model
ftracer
Common
o
Common Joined Separate
+-o <file> Place output into <file>
p
Common
+Enable function profiling
pedantic
Common
+Issue warnings needed for strict compliance to the standard
pedantic-errors
Common
+Like -pedantic but issue them as errors
quiet
Common
+Do not display functions compiled or elapsed time
version
Common
+Display the compiler's version
w
Common
+Suppress warnings
; This comment is to ensure we retain the blank line above.
#include "config.h"
#include "system.h"
+#include "intl.h"
#include "coretypes.h"
#include "tm.h"
#include "tree.h"
static void complain_wrong_lang (const char *, const struct cl_option *,
unsigned int lang_mask);
static void handle_options (unsigned int, const char **, unsigned int);
+static void wrap_help (const char *help, const char *item, size_t item_width);
+static void print_help (void);
/* Perform a binary search to find which option the command-line INPUT
matches. Returns its index in the option array, and N_OPTS
{
md = (mn + mx) / 2;
opt_len = cl_options[md].opt_len;
- comp = strncmp (input, cl_options[md].opt_text, opt_len);
+ comp = strncmp (input, cl_options[md].opt_text + 1, opt_len);
if (comp < 0)
mx = md;
const struct cl_option *opt = &cl_options[mn];
/* Is this switch a prefix of the input? */
- if (!strncmp (input, opt->opt_text, opt->opt_len))
+ if (!strncmp (input, opt->opt_text + 1, opt->opt_len))
{
/* If language is OK, and the match is exact or the switch
takes a joined argument, return it. */
value = integral_argument (arg);
if (value == -1)
{
- error ("argument to \"-%s\" should be a non-negative integer",
+ error ("argument to \"%s\" should be a non-negative integer",
option->opt_text);
goto done;
}
abort ();
case OPT__help:
- display_help ();
+ print_help ();
exit_after_options = true;
break;
&& flag_finite_math_only
&& !flag_errno_math);
}
+
+/* Output --help text. */
+static void
+print_help (void)
+{
+ size_t i, len;
+
+ printf (_("\nThe following options are language-independent:\n"));
+
+ for (i = 0; i < cl_options_count; i++)
+ {
+ const char *help = cl_options[i].help;
+ const char *opt, *tab;
+
+ /* During transition, ignore switches with no help. */
+ if (!help)
+ continue;
+
+ /* Get the translation. */
+ help = _(help);
+
+ tab = strchr (help, '\t');
+ if (tab)
+ {
+ len = tab - help;
+ opt = help;
+ help = tab + 1;
+ }
+ else
+ {
+ opt = cl_options[i].opt_text;
+ len = strlen (opt);
+ }
+
+ wrap_help (help, opt, len);
+ }
+
+ puts ( "\n" );
+ display_help ();
+}
+
+/* Output ITEM, of length ITEM_WIDTH, in the left column, followed by
+ word-wrapped HELP in a second column. */
+static void
+wrap_help (const char *help, const char *item, size_t item_width)
+{
+ const size_t columns = 80, col_width = 27;
+ size_t remaining, room, len;
+
+ remaining = strlen (help);
+
+ do
+ {
+ room = columns - 3 - MAX (col_width, item_width);
+ len = remaining;
+
+ if (room < len)
+ {
+ size_t i;
+
+ for (i = 0; help[i]; i++)
+ {
+ if (i >= room && len != remaining)
+ break;
+ if (help[i] == ' ')
+ len = i;
+ else if (help[i] == '-')
+ len = i + 1;
+ }
+ }
+
+ printf( " %-*.*s %.*s\n", col_width, item_width, item, len, help);
+ item_width = 0;
+ while (help[len] == ' ')
+ len++;
+ help += len;
+ remaining -= len;
+ }
+ while (remaining);
+}
struct cl_option
{
const char *opt_text;
+ const char *help;
unsigned short back_chain;
unsigned char opt_len;
unsigned int flags;
# Ignore comments and blank lines
/^[ \t]*(;|$)/ { next }
# Note that RS="" falls foul of gawk 3.1.2 bugs
- /^[^ \t]/ { getline tmp; print $0 "\034" tmp}
+ /^[^ \t]/ { record = $0
+ do { getline tmp;
+ if (tmp != "" )
+ record = record "\034" tmp
+ } while (tmp != "")
+ print record
+ }
' "$@" | ${SORT} | ${AWK} '
function switch_flags (flags, result)
{
} else {
opts[n_opts] = $1
flags[n_opts] = $2
+ help[n_opts] = $3
n_opts++;
}
}
comma = ","
print "/* This file is auto-generated by opts.sh. */\n" > c_file
+ print "#include <intl.h>" >> c_file
print "#include \"" h_file "\"" >> c_file
print "#include \"opts.h\"\n" >> c_file
print "const char * const lang_names[] =\n{" >> c_file
if (i + 1 == n_opts)
comma = ""
+ if (help[i] == "")
+ hlp = "0"
+ else
+ hlp = "N_(\"" help[i] "\")";
+
printf(" %s,%s/* -%s */\n", enum, s, opts[i]) >> h_file
- printf(" { \"%s\", (unsigned short) %s, %u,\n\t%s }%s\n",
- opts[i], back_chain[i], len, switch_flags(flags[i]),
- comma) >> c_file
+ printf(" { \"-%s\",\n %s,\n %s, %u, %s }%s\n",
+ opts[i], hlp, back_chain[i], len,
+ switch_flags(flags[i]), comma) >> c_file
}
print " N_OPTS\n};" >> h_file
unsigned long i;
const char *lang;
- printf (_(" -ffixed-<register> Mark <register> as being unavailable to the compiler\n"));
- printf (_(" -fcall-used-<register> Mark <register> as being corrupted by function calls\n"));
- printf (_(" -fcall-saved-<register> Mark <register> as being preserved across functions\n"));
- printf (_(" -finline-limit=<number> Limits the size of inlined functions to <number>\n"));
- printf (_(" -fmessage-length=<number> Limits diagnostics messages lengths to <number> characters per line. 0 suppresses line-wrapping\n"));
- printf (_(" -fdiagnostics-show-location=[once | every-line] Indicates how often source location information should be emitted, as prefix, at the beginning of diagnostics when line-wrapping\n"));
- printf (_(" -ftls-model=[global-dynamic | local-dynamic | initial-exec | local-exec] Indicates the default thread-local storage code generation model\n"));
- printf (_(" -fstack-limit-register=<register> Trap if the stack goes past <register>\n"));
- printf (_(" -fstack-limit-symbol=<name> Trap if the stack goes past symbol <name>\n"));
- printf (_(" -frandom-seed=<string> Make compile reproducible using <string>\n"));
-
-
for (i = ARRAY_SIZE (f_options); i--;)
{
const char *description = f_options[i].description;
f_options[i].string, _(description));
}
- printf (_(" -O[number] Set optimization level to [number]\n"));
- printf (_(" -Os Optimize for space rather than speed\n"));
for (i = LAST_PARAM; i--;)
{
const char *description = compiler_params[i].help;
length > 0 ? length : 1, " ",
_(description));
}
- printf (_(" -pedantic Issue warnings needed by strict compliance to ISO C\n"));
- printf (_(" -pedantic-errors Like -pedantic except that errors are produced\n"));
- printf (_(" -w Suppress warnings\n"));
for (i = ARRAY_SIZE (W_options); i--;)
{
W_options[i].string, _(description));
}
- printf (_(" -Wextra Print extra (possibly unwanted) warnings\n"));
- printf (_(" -Wunused Enable unused warnings\n"));
- printf (_(" -Wlarger-than-<number> Warn if an object is larger than <number> bytes\n"));
- printf (_(" -p Enable function profiling\n"));
- printf (_(" -o <file> Place output into <file> \n"));
- printf (_("\
- -G <number> Put global and static data smaller than <number>\n\
- bytes into a special section (on some targets)\n"));
-
for (i = ARRAY_SIZE (debug_args); i--;)
{
if (debug_args[i].description != NULL)
debug_args[i].arg, _(debug_args[i].description));
}
- printf (_(" -aux-info <file> Emit declaration info into <file>\n"));
- printf (_(" -quiet Do not display functions compiled or elapsed time\n"));
- printf (_(" -version Display the compiler's version\n"));
- printf (_(" -d[letters] Enable dumps from specific passes of the compiler\n"));
- printf (_(" -dumpbase <file> Base name to be used for dumps from specific passes\n"));
-#if defined INSN_SCHEDULING
- printf (_(" -fsched-verbose=<number> Set the verbosity level of the scheduler\n"));
-#endif
- printf (_(" --help Display this information\n"));
-
undoc = 0;
lang = "language";