Replace translate_options with .opt aliases

Richard Guenther richard.guenther@gmail.com
Sat Sep 11 12:50:00 GMT 2010


On Wed, Sep 8, 2010 at 5:32 PM, Joseph S. Myers <joseph@codesourcery.com> wrote:
> This patch replaces translate_options, a textual substitution pass
> over the command line taking place before the options are decoded,
> with use of the .opt option alias facility and handling variants such
> as -- for -f at the time options are decoded (while keeping the
> original spellings available for diagnostics).
>
> For the most part, entries in the old option_map are converted to
> Alias entries in the relevant .opt files.  Where an option is listed
> in multiple .opt files, I listed the alias in the same .opt files,
> with the same languages, although the languages listed for an alias
> don't matter much.  Because of how option handling works, the
> --comments alias for -C, the --define-macro alias for -D and the
> --include-barrier alias for -I- will continue to act as aliases for
> those options for Java, where -C, -D and -I- have different meanings
> making the long names inappropriate, just as they did before the
> patch, although I did not put them in java/lang.opt as the long names
> are logically inappropriate there.
>
> Where an option in the old option_map took an argument, this is
> generally equivalent to two aliases - one with a trailing '=' and
> "Joined", one without a trailing '=' and with "Separate".  It is
> necessary to decide in each case whether to use Joined or
> JoinedOrMissing.  The old alias code would accept an empty joined
> argument - but in cases marked "aj" would then join the empty string
> to the new option name, which in cases such as --define-macro= mapping
> to -D would result in an option swallowing the next command-line
> argument.  Such swallowing of subsequent arguments cannot occur with
> the new code.  If it appeared that empty arguments would be useless
> (and in particular if they would always give errors later from other
> code), Joined is used.
>
> Certain options do not in fact need both Joined and Separate forms
> because the mapping is from --option to -foption= so the generic "--"
> to "-f" mapping works for "--option=".  This applies to the Java
> options --CLASSPATH, --bootclasspath, --classpath, --encoding,
> --extdirs.
>
> The --entry alias for -e was an alias without arguments (so only
> --entry symbol worked, not --entry=symbol), and is changed by this
> patch to one with arguments, with both forms accepted.  The
> --for-assembler option mapped to "-Wa" with a separate argument, which
> was broken; it is made an alias for -Xassembler to match --for-linker
> being an alias for -Xlinker.  --no-precompiled-includes was an alias
> for a nonexistent option -noprecomp, so is removed.
>
> --write-dependencies and --write-user-dependencies were no-argument
> aliases for the no-argument driver options -MD and -MMD.  They will
> now also operate in cc1 as aliases with an argument for the versions
> with arguments in cc1, but no versions with trailing '=' and joined
> operand are added.
>
> The old option alias support allowed unambiguous abbreviations of long
> option aliases.  With the new code, abbreviations are allowed of
> options starting "--" in the option table, but still not of "--option"
> mapping to -foption and similar cases for -m and -W options.
> (Ideally, the options should act as similarly to getopt_long as
> possible, and so allow abbreviations in all those cases; the special
> handling of "--", "--machine-" etc. should be an implementation detail
> that isn't visible to the user through affecting what abbreviations
> are valid.)
>
> Special cases such as "--machine", "--std" etc. that are not simply an
> alias of one option to another but provide an alternative way of
> writing many options are handled through a table used in
> decode_cmdline_option.  TARGET_OPTION_TRANSLATE_TABLE is handled in
> decode_cmdline_options_to_array; it still works based on textual
> replacement of options, and if you look at how Darwin uses it you'll
> see that it is required that options produced by such translations not
> be subject to translation again themselves, and so that the
> translations only take place in the driver.  The Darwin uses could
> probably largely be replaced by specs or conventional aliases; the
> original intended purpose of this macro, as described in
> <http://gcc.gnu.org/ml/gcc-patches/2001-07/msg00220.html>, was for one
> option to map to a group of others while still acting as a single
> option for multilib selection, and converting that to conventional
> option implication will require later stages of my multilibs changes
> (it may however be possible to replace it with use of CC1_SPEC now).
>
> With this patch, --help, --target-help, --version and --help= can be
> the canonical forms of those options instead of the -f variants.  The
> -f variants are made into aliases of the canonical "--" versions.
> This requires specs to pass the "--" versions down to subprocesses;
> the existing such specs were broken (extra initial "-" in matching the
> option, and using %(VALUE) in a place where %* was required); they are
> fixed, and a spec for passing down --version added.
>
> The patch also removes the comment in gcc.c about adding command-line
> options (which originated in
> <http://gcc.gnu.org/ml/gcc-patches/2001-02/msg01335.html>), which was
> essentially entirely obsolete with the present .opt machinery,
> documented in options.texi.
>
> Bootstrapped with no regressions on x86_64-unknown-linux-gnu.  Also
> tested with cross to mep-elf (patched as described in
> <http://gcc.gnu.org/ml/gcc-patches/2010-09/msg00664.html>) that
> appropriate translations were made in the
> TARGET_OPTION_TRANSLATE_TABLE case.  OK to commit?

Ok for the non-frontend specific pieces.

Thanks,
Richard.

> 2010-09-08  Joseph Myers  <joseph@codesourcery.com>
>
>        * common.opt (-assemble, -combine, -compile, -coverage, -debug,
>        -dump, -dump=, -dumpbase, -dumpdir, -entry, -entry=,
>        -extra-warnings, -for-assembler, -for-assembler=, -for-linker,
>        -for-linker=, -force-link, -force-link=, -language, -language=,
>        -library-directory, -library-directory=, -no-canonical-prefixes,
>        -no-standard-libraries, -no-warnings, -optimize, -output,
>        -output=, -pass-exit-codes, -pedantic, -pedantic-errors, -pie,
>        -pipe, -prefix, -prefix=, -preprocess, -print-file-name,
>        -print-file-name=, -print-libgcc-file-name,
>        -print-multi-directory, -print-multi-lib,
>        -print-multi-os-directory, -print-prog-name, -print-prog-name=,
>        -print-search-dirs, -print-sysroot, -print-sysroot-headers-suffix,
>        -profile, -save-temps, -shared, -specs, -specs=, -static,
>        -symbolic, -time, -verbose, -param=, -sysroot, coverage, e, u,
>        symbolic): New.
>        (fhelp, fhelp=, ftarget-help, fversion): Make into aliases.
>        * gcc.c (A Short Introduction to Adding a Command-Line Option):
>        Remove comment.
>        (cc1_options): Correct specs for passing down --help,
>        --target-help and --help=*.  Add spec for passing down --version.
>        (struct option_map, option_map, target_option_translations,
>        translate_options): Remove.
>        (driver_handle_option): Handle OPT__version, OPT__help, OPT__help_
>        and OPT__target_help instead of OPT_fversion, OPT_fhelp,
>        OPT_fhelp_ and OPT_ftarget_help.
>        (process_command): Don't call translate_options.  Call
>        decode_cmdline_options_to_array before checking for
>        -no-canonical-prefixes using decoded options.
>        * opts-common.c (tm.h): Update comment on #include.
>        (find_opt): Allow abbreviations of long options.
>        (struct option_map, option_map): New.
>        (decode_cmdline_option): Use them instead of hardcoding -Wno, -fno
>        and -mno handling.
>        (target_option_translations): New.
>        (decode_cmdline_options_to_array): Handle
>        TARGET_OPTION_TRANSLATE_TABLE in driver.
>        * opts.c (common_handle_option): Don't handle OPT_fhelp,
>        OPT_ftarget_help, OPT_fhelp_ or OPT_fversion.
>
> ada:
> 2010-09-08  Joseph Myers  <joseph@codesourcery.com>
>
>        * gcc-interface/lang.opt (-all-warnings, -include-barrier,
>        -include-directory, -include-directory=, -no-standard-includes,
>        -no-standard-libraries): New.
>
> c-family:
> 2010-09-08  Joseph Myers  <joseph@codesourcery.com>
>
>        * c.opt (-all-warnings, -ansi, -assert, -assert=, -comments,
>        -comments-in-macros, -define-macro, -define-macro=, -dependencies,
>        -dump, -dump=, -imacros, -imacros=, -include, -include=,
>        -include-barrier, -include-directory, -include-directory=,
>        -include-directory-after, -include-directory-after=,
>        -include-prefix, -include-prefix=, -include-with-prefix,
>        -include-with-prefix=, -include-with-prefix-after,
>        -include-with-prefix-after=, -include-with-prefix-before,
>        -include-with-prefix-before=, -no-integrated-cpp,
>        -no-line-commands, -no-standard-includes, -no-warnings, -output,
>        -output=, -pedantic, -pedantic-errors, -preprocess,
>        -print-missing-file-dependencies, -trace-includes, -traditional,
>        -traditional-cpp, -trigraphs, -undefine-macro, -undefine-macro=,
>        -user-dependencies, -verbose, -write-dependencies,
>        -write-user-dependencies, no-integrated-cpp, traditional): New.
>
> fortran:
> 2010-09-08  Joseph Myers  <joseph@codesourcery.com>
>
>        * gfortranspec.c (lang_specific_driver): Handle OPT__version and
>        OPT__help instead of OPT_fversion and OPT_fhelp.
>        * lang.opt (-all-warnings, -assert, -assert=, -comments,
>        -comments-in-macros, -define-macro, -define-macro=, -dependencies,
>        -dump, -dump=, -include-barrier, -include-directory,
>        -include-directory=, -include-directory-after,
>        -include-directory-after=, -include-prefix, -include-prefix=,
>        -no-line-commands, -no-standard-includes, -output, -output=,
>        -preprocess, -print-missing-file-dependencies, -trace-includes,
>        -undefine-macro, -undefine-macro=, -user-dependencies, -verbose,
>        -write-dependencies, -write-user-dependencies): New.
>
> java:
> 2010-09-08  Joseph Myers  <joseph@codesourcery.com>
>
>        * jvspec.c (lang_specific_driver): Handle OPT__help instead of
>        OPT_fhelp.
>        * lang.opt (-CLASSPATH, -all-warnings, -bootclasspath, -classpath,
>        -dependencies, -encoding, -extdirs, -include-directory,
>        -include-directory=, -output-class-directory,
>        -output-class-directory=, -resource, -resource=,
>        -user-dependencies): New.
>
> Index: gcc/opts-common.c
> ===================================================================
> --- gcc/opts-common.c   (revision 163844)
> +++ gcc/opts-common.c   (working copy)
> @@ -24,7 +24,8 @@ along with GCC; see the file COPYING3.
>  #include "opts.h"
>  #include "options.h"
>  #include "diagnostic.h"
> -#include "tm.h" /* For SWITCH_TAKES_ARG and WORD_SWITCH_TAKES_ARG.  */
> +#include "tm.h" /* For SWITCH_TAKES_ARG, WORD_SWITCH_TAKES_ARG and
> +                  TARGET_OPTION_TRANSLATE_TABLE.  */
>
>  /* Perform a binary search to find which option the command-line INPUT
>    matches.  Returns its index in the option array, and
> @@ -53,7 +54,7 @@ along with GCC; see the file COPYING3.
>  size_t
>  find_opt (const char *input, int lang_mask)
>  {
> -  size_t mn, mx, md, opt_len;
> +  size_t mn, mn_orig, mx, md, opt_len;
>   size_t match_wrong_lang;
>   int comp;
>
> @@ -74,6 +75,8 @@ find_opt (const char *input, int lang_ma
>        mn = md;
>     }
>
> +  mn_orig = mn;
> +
>   /* This is the switch that is the best match but for a different
>      front end, or OPT_SPECIAL_unknown if there is no match at all.  */
>   match_wrong_lang = OPT_SPECIAL_unknown;
> @@ -106,6 +109,40 @@ find_opt (const char *input, int lang_ma
>     }
>   while (mn != cl_options_count);
>
> +  if (match_wrong_lang == OPT_SPECIAL_unknown && input[0] == '-')
> +    {
> +      /* Long options, starting "--", may be abbreviated if the
> +        abbreviation is unambiguous.  This only applies to options
> +        not taking a joined argument, and abbreviations of "--option"
> +        are permitted even if there is a variant "--option=".  */
> +      size_t mnc = mn_orig + 1;
> +      size_t cmp_len = strlen (input);
> +      while (mnc < cl_options_count
> +            && strncmp (input, cl_options[mnc].opt_text + 1, cmp_len) == 0)
> +       {
> +         /* Option matching this abbreviation.  OK if it is the first
> +            match and that does not take a joined argument, or the
> +            second match, taking a joined argument and with only '='
> +            added to the first match; otherwise considered
> +            ambiguous.  */
> +         if (mnc == mn_orig + 1
> +             && !(cl_options[mnc].flags & CL_JOINED))
> +           match_wrong_lang = mnc;
> +         else if (mnc == mn_orig + 2
> +                  && match_wrong_lang == mn_orig + 1
> +                  && (cl_options[mnc].flags & CL_JOINED)
> +                  && (cl_options[mnc].opt_len
> +                      == cl_options[mn_orig + 1].opt_len + 1)
> +                  && strncmp (cl_options[mnc].opt_text + 1,
> +                              cl_options[mn_orig + 1].opt_text + 1,
> +                              cl_options[mn_orig + 1].opt_len) == 0)
> +           ; /* OK, as long as there are no more matches.  */
> +         else
> +           return OPT_SPECIAL_unknown;
> +         mnc++;
> +       }
> +    }
> +
>   /* Return the best wrong match, or OPT_SPECIAL_unknown if none.  */
>   return match_wrong_lang;
>  }
> @@ -197,6 +234,46 @@ generate_canonical_option (size_t opt_in
>     }
>  }
>
> +/* Structure describing mappings from options on the command line to
> +   options to look up with find_opt.  */
> +struct option_map
> +{
> +  /* Prefix of the option on the command line.  */
> +  const char *opt0;
> +  /* If two argv elements are considered to be merged into one option,
> +     prefix for the second element, otherwise NULL.  */
> +  const char *opt1;
> +  /* The new prefix to map to.  */
> +  const char *new_prefix;
> +  /* Whether at least one character is needed following opt1 or opt0
> +     for this mapping to be used.  (--optimize= is valid for -O, but
> +     --warn- is not valid for -W.)  */
> +  bool another_char_needed;
> +  /* Whether the original option is a negated form of the option
> +     resulting from this map.  */
> +  bool negated;
> +};
> +static const struct option_map option_map[] =
> +  {
> +    { "-Wno-", NULL, "-W", false, true },
> +    { "-fno-", NULL, "-f", false, true },
> +    { "-mno-", NULL, "-m", false, true },
> +    { "--debug=", NULL, "-g", false, false },
> +    { "--machine-", NULL, "-m", true, false },
> +    { "--machine-no-", NULL, "-m", false, true },
> +    { "--machine=", NULL, "-m", false, false },
> +    { "--machine=no-", NULL, "-m", false, true },
> +    { "--machine", "", "-m", false, false },
> +    { "--machine", "no-", "-m", false, true },
> +    { "--optimize=", NULL, "-O", false, false },
> +    { "--std=", NULL, "-std=", false, false },
> +    { "--std", "", "-std=", false, false },
> +    { "--warn-", NULL, "-W", true, false },
> +    { "--warn-no-", NULL, "-W", false, true },
> +    { "--", NULL, "-f", true, false },
> +    { "--no-", NULL, "-f", false, true }
> +  };
> +
>  /* Decode the switch beginning at ARGV for the language indicated by
>    LANG_MASK (including CL_COMMON and CL_TARGET if applicable), into
>    the structure *DECODED.  Returns the number of switches
> @@ -207,10 +284,10 @@ decode_cmdline_option (const char **argv
>                       struct cl_decoded_option *decoded)
>  {
>   size_t opt_index;
> -  const char *opt, *arg = 0;
> -  char *dup = 0;
> +  const char *arg = 0;
>   int value = 1;
> -  unsigned int result = 1, i;
> +  unsigned int result = 1, i, extra_args;
> +  int adjust_len = 0;
>   size_t total_len;
>   char *p;
>   const struct cl_option *option;
> @@ -220,28 +297,50 @@ decode_cmdline_option (const char **argv
>   bool joined_arg_flag;
>   bool have_separate_arg = false;
>
> -  opt = argv[0];
> +  extra_args = 0;
> +
> +  opt_index = find_opt (argv[0] + 1, lang_mask);
> +  i = 0;
> +  while (opt_index == OPT_SPECIAL_unknown
> +        && i < ARRAY_SIZE (option_map))
> +    {
> +      const char *opt0 = option_map[i].opt0;
> +      const char *opt1 = option_map[i].opt1;
> +      const char *new_prefix = option_map[i].new_prefix;
> +      bool another_char_needed = option_map[i].another_char_needed;
> +      size_t opt0_len = strlen (opt0);
> +      size_t opt1_len = (opt1 == NULL ? 0 : strlen (opt1));
> +      size_t optn_len = (opt1 == NULL ? opt0_len : opt1_len);
> +      size_t new_prefix_len = strlen (new_prefix);
> +
> +      extra_args = (opt1 == NULL ? 0 : 1);
> +      value = !option_map[i].negated;
> +
> +      if (strncmp (argv[0], opt0, opt0_len) == 0
> +         && (opt1 == NULL
> +             || (argv[1] != NULL && strncmp (argv[1], opt1, opt1_len) == 0))
> +         && (!another_char_needed
> +             || argv[extra_args][optn_len] != 0))
> +       {
> +         size_t arglen = strlen (argv[extra_args]);
> +         char *dup;
>
> -  opt_index = find_opt (opt + 1, lang_mask);
> -  if (opt_index == OPT_SPECIAL_unknown
> -      && (opt[1] == 'W' || opt[1] == 'f' || opt[1] == 'm')
> -      && opt[2] == 'n' && opt[3] == 'o' && opt[4] == '-')
> -    {
> -      /* Drop the "no-" from negative switches.  */
> -      size_t len = strlen (opt) - 3;
> -
> -      dup = XNEWVEC (char, len + 1);
> -      dup[0] = '-';
> -      dup[1] = opt[1];
> -      memcpy (dup + 2, opt + 5, len - 2 + 1);
> -      opt = dup;
> -      value = 0;
> -      opt_index = find_opt (opt + 1, lang_mask);
> +         adjust_len = (int) optn_len - (int) new_prefix_len;
> +         dup = XNEWVEC (char, arglen + 1 - adjust_len);
> +         memcpy (dup, new_prefix, new_prefix_len);
> +         memcpy (dup + new_prefix_len, argv[extra_args] + optn_len,
> +                 arglen - optn_len + 1);
> +         opt_index = find_opt (dup + 1, lang_mask);
> +         free (dup);
> +       }
> +      i++;
>     }
>
>   if (opt_index == OPT_SPECIAL_unknown)
>     {
>       arg = argv[0];
> +      extra_args = 0;
> +      value = 1;
>       goto done;
>     }
>
> @@ -257,6 +356,7 @@ decode_cmdline_option (const char **argv
>       goto done;
>     }
>
> +  result = extra_args + 1;
>   warn_message = option->warn_message;
>
>   /* Check to see if the option is disabled for this configuration.  */
> @@ -276,18 +376,16 @@ decode_cmdline_option (const char **argv
>       /* Have arg point to the original switch.  This is because
>         some code, such as disable_builtin_function, expects its
>         argument to be persistent until the program exits.  */
> -      arg = argv[0] + cl_options[opt_index].opt_len + 1;
> -      if (!value)
> -       arg += strlen ("no-");
> +      arg = argv[extra_args] + cl_options[opt_index].opt_len + 1 + adjust_len;
>
>       if (*arg == '\0' && !(option->flags & CL_MISSING_OK))
>        {
>          if (separate_arg_flag)
>            {
> -             arg = argv[1];
> -             result = 2;
> +             arg = argv[extra_args + 1];
> +             result = extra_args + 2;
>              if (arg == NULL)
> -               result = 1;
> +               result = extra_args + 1;
>              else
>                have_separate_arg = true;
>            }
> @@ -298,10 +396,10 @@ decode_cmdline_option (const char **argv
>     }
>   else if (separate_arg_flag)
>     {
> -      arg = argv[1];
> -      result = 2;
> +      arg = argv[extra_args + 1];
> +      result = extra_args + 2;
>       if (arg == NULL)
> -       result = 1;
> +       result = extra_args + 1;
>       else
>        have_separate_arg = true;
>     }
> @@ -329,7 +427,8 @@ decode_cmdline_option (const char **argv
>          const struct cl_option *new_option = &cl_options[new_opt_index];
>
>          /* The new option must not be an alias itself.  */
> -         gcc_assert (new_option->alias_target == N_OPTS);
> +         gcc_assert (new_option->alias_target == N_OPTS
> +                     || (new_option->flags & CL_SEPARATE_ALIAS));
>
>          if (option->neg_alias_arg)
>            {
> @@ -363,7 +462,11 @@ decode_cmdline_option (const char **argv
>          if (!(errors & CL_ERR_MISSING_ARG))
>            {
>              if (separate_arg_flag || joined_arg_flag)
> -               gcc_assert (arg != NULL);
> +               {
> +                 if ((option->flags & CL_MISSING_OK) && arg == NULL)
> +                   arg = "";
> +                 gcc_assert (arg != NULL);
> +               }
>              else
>                gcc_assert (arg == NULL);
>            }
> @@ -392,8 +495,6 @@ decode_cmdline_option (const char **argv
>     }
>
>  done:
> -  if (dup)
> -    free (dup);
>   decoded->opt_index = opt_index;
>   decoded->arg = arg;
>   decoded->value = value;
> @@ -455,6 +556,17 @@ decode_cmdline_option (const char **argv
>   return result;
>  }
>
> +#ifdef TARGET_OPTION_TRANSLATE_TABLE
> +static const struct {
> +  const char *const option_found;
> +  const char *const replacements;
> +} target_option_translations[] =
> +{
> +  TARGET_OPTION_TRANSLATE_TABLE,
> +  { 0, 0 }
> +};
> +#endif
> +
>  /* Decode command-line options (ARGC and ARGV being the arguments of
>    main) into an array, setting *DECODED_OPTIONS to a pointer to that
>    array and *DECODED_OPTIONS_COUNT to the number of entries in the
> @@ -470,9 +582,10 @@ decode_cmdline_options_to_array (unsigne
>                                 struct cl_decoded_option **decoded_options,
>                                 unsigned int *decoded_options_count)
>  {
> -  unsigned int n, i;
> +  unsigned int n, i, target_translate_from;
>   struct cl_decoded_option *opt_array;
>   unsigned int num_decoded_options;
> +  bool argv_copied = false;
>
>   opt_array = XNEWVEC (struct cl_decoded_option, argc);
>
> @@ -489,6 +602,7 @@ decode_cmdline_options_to_array (unsigne
>   opt_array[0].errors = 0;
>   num_decoded_options = 1;
>
> +  target_translate_from = 1;
>   for (i = 1; i < argc; i += n)
>     {
>       const char *opt = argv[i];
> @@ -502,11 +616,88 @@ decode_cmdline_options_to_array (unsigne
>          continue;
>        }
>
> +      if (i >= target_translate_from && (lang_mask & CL_DRIVER))
> +       {
> +#ifdef TARGET_OPTION_TRANSLATE_TABLE
> +         int tott_idx;
> +
> +         for (tott_idx = 0;
> +              target_option_translations[tott_idx].option_found;
> +              tott_idx++)
> +           {
> +             if (strcmp (target_option_translations[tott_idx].option_found,
> +                         argv[i]) == 0)
> +               {
> +                 unsigned int spaces = 0;
> +                 unsigned int m = 0;
> +                 const char *sp;
> +                 char *np;
> +
> +                 for (sp = target_option_translations[tott_idx].replacements;
> +                      *sp; sp++)
> +                   {
> +                     if (*sp == ' ')
> +                       {
> +                         spaces++;
> +                         while (*sp == ' ')
> +                           sp++;
> +                         sp--;
> +                       }
> +                   }
> +
> +                 if (spaces)
> +                   {
> +                     int new_argc = argc + spaces;
> +                     if (argv_copied)
> +                       argv = XRESIZEVEC (const char *, argv, new_argc + 1);
> +                     else
> +                       {
> +                         const char **new_argv = XNEWVEC (const char *,
> +                                                          new_argc + 1);
> +                         memcpy (new_argv, argv,
> +                                 (argc + 1) * sizeof (const char *));
> +                         argv = new_argv;
> +                         argv_copied = true;
> +                       }
> +                     memmove (&argv[i] + spaces, &argv[i],
> +                              (argc + 1 - i) * sizeof (const char *));
> +                     argc = new_argc;
> +                     opt_array = XRESIZEVEC (struct cl_decoded_option,
> +                                             opt_array, argc);
> +                   }
> +
> +                 sp = target_option_translations[tott_idx].replacements;
> +                 np = xstrdup (sp);
> +
> +                 while (1)
> +                   {
> +                     while (*np == ' ')
> +                       np++;
> +                     if (*np == 0)
> +                       break;
> +                     argv[i + m++] = np;
> +                     while (*np != ' ' && *np)
> +                       np++;
> +                     if (*np == 0)
> +                       break;
> +                     *np++ = 0;
> +                   }
> +
> +                 target_translate_from = i + m;
> +                 gcc_assert (m == spaces + 1);
> +                 break;
> +               }
> +           }
> +#endif
> +       }
> +
>       n = decode_cmdline_option (argv + i, lang_mask,
>                                 &opt_array[num_decoded_options]);
>       num_decoded_options++;
>     }
>
> +  if (argv_copied)
> +    free (argv);
>   opt_array = XRESIZEVEC (struct cl_decoded_option, opt_array,
>                          num_decoded_options);
>   *decoded_options = opt_array;
> Index: gcc/c-family/c.opt
> ===================================================================
> --- gcc/c-family/c.opt  (revision 163844)
> +++ gcc/c-family/c.opt  (working copy)
> @@ -34,9 +34,153 @@ C++
>  Language
>  ObjC++
>
> +-all-warnings
> +C ObjC C++ ObjC++ Warning Alias(Wall)
> +
> +-ansi
> +C ObjC C++ ObjC++ Alias(ansi)
> +
> +-assert
> +C ObjC C++ ObjC++ Separate Alias(A) MissingArgError(assertion missing after %qs)
> +
> +-assert=
> +C ObjC C++ ObjC++ Joined Alias(A) MissingArgError(assertion missing after %qs)
> +
> +-comments
> +C ObjC C++ ObjC++ Alias(C)
> +
> +-comments-in-macros
> +C ObjC C++ ObjC++ Alias(CC)
> +
> +-define-macro
> +C ObjC C++ ObjC++ Separate Alias(D) MissingArgError(macro name missing after %qs)
> +
> +-define-macro=
> +C ObjC C++ ObjC++ Joined Alias(D) MissingArgError(macro name missing after %qs)
> +
> +-dependencies
> +C ObjC C++ ObjC++ Alias(M)
> +
> +-dump
> +C ObjC C++ ObjC++ Separate Alias(d)
> +
> +-dump=
> +C ObjC C++ ObjC++ Joined Alias(d)
> +
> +-imacros
> +C ObjC C++ ObjC++ Separate Alias(imacros) MissingArgError(missing filename after %qs)
> +
> +-imacros=
> +C ObjC C++ ObjC++ Joined Alias(imacros) MissingArgError(missing filename after %qs)
> +
> +-include
> +C ObjC C++ ObjC++ Separate Alias(include) MissingArgError(missing filename after %qs)
> +
> +-include=
> +C ObjC C++ ObjC++ Joined Alias(include) MissingArgError(missing filename after %qs)
> +
> +-include-barrier
> +C ObjC C++ ObjC++ Alias(I, -)
> +
> +-include-directory
> +C ObjC C++ ObjC++ Separate Alias(I) MissingArgError(missing path after %qs)
> +
> +-include-directory=
> +C ObjC C++ ObjC++ Joined Alias(I) MissingArgError(missing path after %qs)
> +
> +-include-directory-after
> +C ObjC C++ ObjC++ Separate Alias(idirafter) MissingArgError(missing path after %qs)
> +
> +-include-directory-after=
> +C ObjC C++ ObjC++ Joined Alias(idirafter) MissingArgError(missing path after %qs)
> +
> +-include-prefix
> +C ObjC C++ ObjC++ Separate Alias(iprefix)
> +
> +-include-prefix=
> +C ObjC C++ ObjC++ JoinedOrMissing Alias(iprefix)
> +
> +-include-with-prefix
> +C ObjC C++ ObjC++ Separate Alias(iwithprefix)
> +
> +-include-with-prefix=
> +C ObjC C++ ObjC++ JoinedOrMissing Alias(iwithprefix)
> +
> +-include-with-prefix-after
> +C ObjC C++ ObjC++ Separate Alias(iwithprefix)
> +
> +-include-with-prefix-after=
> +C ObjC C++ ObjC++ JoinedOrMissing Alias(iwithprefix)
> +
> +-include-with-prefix-before
> +C ObjC C++ ObjC++ Separate Alias(iwithprefixbefore)
> +
> +-include-with-prefix-before=
> +C ObjC C++ ObjC++ JoinedOrMissing Alias(iwithprefixbefore)
> +
> +-no-integrated-cpp
> +Driver Alias(no-integrated-cpp)
> +
> +-no-line-commands
> +C ObjC C++ ObjC++ Alias(P)
> +
> +-no-standard-includes
> +C ObjC C++ ObjC++ Alias(nostdinc)
> +
> +-no-warnings
> +C ObjC C++ ObjC++ Alias(w)
> +
> +-output
> +C ObjC C++ ObjC++ Separate Alias(o)
> +
> +-output=
> +C ObjC C++ ObjC++ Joined Alias(o)
> +
>  -output-pch=
>  C ObjC C++ ObjC++ Joined Separate
>
> +-pedantic
> +C ObjC C++ ObjC++ Alias(pedantic)
> +
> +-pedantic-errors
> +C ObjC C++ ObjC++ Alias(pedantic-errors)
> +
> +-preprocess
> +C ObjC C++ ObjC++ Undocumented Alias(E)
> +
> +-print-missing-file-dependencies
> +C ObjC C++ ObjC++ Alias(MG)
> +
> +-trace-includes
> +C ObjC C++ ObjC++ Alias(H)
> +
> +-traditional
> +Driver Alias(traditional)
> +
> +-traditional-cpp
> +C ObjC C++ ObjC++ Alias(traditional-cpp)
> +
> +-trigraphs
> +C ObjC C++ ObjC++ Alias(trigraphs)
> +
> +-undefine-macro
> +C ObjC C++ ObjC++ Separate Alias(U) MissingArgError(macro name missing after %qs)
> +
> +-undefine-macro=
> +C ObjC C++ ObjC++ Joined Alias(U) MissingArgError(macro name missing after %qs)
> +
> +-user-dependencies
> +C ObjC C++ ObjC++ Alias(MM)
> +
> +-verbose
> +Common C ObjC C++ ObjC++ Alias(v)
> +
> +-write-dependencies
> +C ObjC C++ ObjC++ NoDriverArg Separate Alias(MD) MissingArgError(missing filename after %qs)
> +
> +-write-user-dependencies
> +C ObjC C++ ObjC++ NoDriverArg Separate Alias(MMD) MissingArgError(missing filename after %qs)
> +
>  A
>  C ObjC C++ ObjC++ Joined Separate MissingArgError(assertion missing after %qs)
>  -A<question>=<answer>  Assert the <answer> to <question>.  Putting '-' before <question> disables the <answer> to <question>
> @@ -928,6 +1072,9 @@ C ObjC C++ ObjC++ Joined Separate
>  lang-asm
>  C Undocumented RejectDriver
>
> +no-integrated-cpp
> +Driver
> +
>  nostdinc
>  C ObjC C++ ObjC++
>  Do not search standard system include directories (those specified with -isystem will still be used)
> @@ -1034,6 +1181,9 @@ std=iso9899:199x
>  C ObjC Alias(std=c99)
>  Deprecated in favor of -std=iso9899:1999
>
> +traditional
> +Driver
> +
>  traditional-cpp
>  C ObjC C++ ObjC++
>  Enable traditional preprocessing
> Index: gcc/java/jvspec.c
> ===================================================================
> --- gcc/java/jvspec.c   (revision 163844)
> +++ gcc/java/jvspec.c   (working copy)
> @@ -238,7 +238,7 @@ lang_specific_driver (struct cl_decoded_
>          added--;
>          break;
>
> -       case OPT_fhelp:
> +       case OPT__help:
>          want_spec_file = 0;
>          break;
>
> Index: gcc/java/lang.opt
> ===================================================================
> --- gcc/java/lang.opt   (revision 163844)
> +++ gcc/java/lang.opt   (working copy)
> @@ -24,6 +24,48 @@
>  Language
>  Java
>
> +-CLASSPATH
> +Java Separate Alias(fclasspath=)
> +
> +-all-warnings
> +Java Alias(Wall)
> +
> +-bootclasspath
> +Java Separate Alias(fbootclasspath=)
> +
> +-classpath
> +Java Separate Alias(fclasspath=)
> +
> +-dependencies
> +Java Alias(M)
> +
> +-encoding
> +Java Separate Alias(fencoding=)
> +
> +-extdirs
> +Java Separate Alias(fextdirs=)
> +
> +-include-directory
> +Java Separate Alias(I)
> +
> +-include-directory=
> +Java Joined Alias(I)
> +
> +-output-class-directory
> +Java Separate Alias(foutput-class-dir=)
> +
> +-output-class-directory=
> +Java Joined Alias(foutput-class-dir=)
> +
> +-resource
> +Java Separate Alias(fcompile-resource=)
> +
> +-resource=
> +Java Joined Alias(fcompile-resource=)
> +
> +-user-dependencies
> +Java Alias(MM)
> +
>  C
>  Driver
>  ; Java driver option in fact distinct from C-family option with the same name.
> Index: gcc/gcc.c
> ===================================================================
> --- gcc/gcc.c   (revision 163844)
> +++ gcc/gcc.c   (working copy)
> @@ -30,44 +30,6 @@ CC recognizes how to compile each input
>  Once it knows which kind of compilation to perform, the procedure for
>  compilation is specified by a string called a "spec".  */
>
> -/* A Short Introduction to Adding a Command-Line Option.
> -
> -   Before adding a command-line option, consider if it is really
> -   necessary.  Each additional command-line option adds complexity and
> -   is difficult to remove in subsequent versions.
> -
> -   In the following, consider adding the command-line argument
> -   `--bar'.
> -
> -   1. Each command-line option is specified in the specs file.  The
> -   notation is described below in the comment entitled "The Specs
> -   Language".  Read it.
> -
> -   2. In this file, add an entry to "option_map" equating the long
> -   `--' argument version and any shorter, single letter version.  Read
> -   the comments in the declaration of "struct option_map" for an
> -   explanation.  Do not omit the first `-'.
> -
> -   3. Look in the "specs" file to determine which program or option
> -   list should be given the argument, e.g., "cc1_options".  Add the
> -   appropriate syntax for the shorter option version to the
> -   corresponding "const char *" entry in this file.  Omit the first
> -   `-' from the option.  For example, use `-bar', rather than `--bar'.
> -
> -   4. If the argument takes an argument, e.g., `--baz argument1',
> -   modify either DEFAULT_SWITCH_TAKES_ARG or
> -   DEFAULT_WORD_SWITCH_TAKES_ARG in gcc.h.  Omit the first `-'
> -   from `--baz'.
> -
> -   5. Document the option in this file's display_help().  If the
> -   option is passed to a subprogram, modify its corresponding
> -   function, e.g., cppinit.c:print_help() or toplev.c:display_help(),
> -   instead.
> -
> -   6. Compile and test.  Make sure that your new specs file is being
> -   read.  For example, use a debugger to investigate the value of
> -   "specs_file" in main().  */
> -
>  #include "config.h"
>  #include "system.h"
>  #include "coretypes.h"
> @@ -263,7 +225,6 @@ static void add_prefix (struct path_pref
>                        int, int, int);
>  static void add_sysrooted_prefix (struct path_prefix *, const char *,
>                                  const char *, int, int, int);
> -static void translate_options (int *, const char *const **);
>  static char *skip_whitespace (char *);
>  static void delete_if_ordinary (const char *);
>  static void delete_temp_files (void);
> @@ -802,9 +763,10 @@ static const char *cc1_options =
>  %{!fcompare-debug-second:%{c|S:%{o*:-auxbase-strip %*}%{!o*:-auxbase %b}}}%{!c:%{!S:-auxbase %b}} \
>  %{g*} %{O*} %{W*&pedantic*} %{w} %{std*&ansi&trigraphs}\
>  %{v:-version} %{pg:-p} %{p} %{f*} %{undef}\
> - %{Qn:-fno-ident} %{--help:--help}\
> - %{--target-help:--target-help}\
> - %{--help=*:--help=%(VALUE)}\
> + %{Qn:-fno-ident} %{-help:--help}\
> + %{-target-help:--target-help}\
> + %{-version:--version}\
> + %{-help=*:--help=%*}\
>  %{!fsyntax-only:%{S:%W{o*}%{!o*:-o %b.s}}}\
>  %{fsyntax-only:-o %j} %{-param*}\
>  %{fmudflap|fmudflapth:-fno-builtin -fno-merge-constants}\
> @@ -1049,342 +1011,6 @@ static char **assembler_options;
>  static int n_preprocessor_options;
>  static char **preprocessor_options;
>
> -/* Define how to map long options into short ones.  */
> -
> -/* This structure describes one mapping.  */
> -struct option_map
> -{
> -  /* The long option's name.  */
> -  const char *const name;
> -  /* The equivalent short option.  */
> -  const char *const equivalent;
> -  /* Argument info.  A string of flag chars; NULL equals no options.
> -     a => argument required.
> -     o => argument optional.
> -     j => join argument to equivalent, making one word.
> -     * => require other text after NAME as an argument.  */
> -  const char *const arg_info;
> -};
> -
> -/* This is the table of mappings.  Mappings are tried sequentially
> -   for each option encountered; the first one that matches, wins.  */
> -
> -static const struct option_map option_map[] =
> - {
> -   {"--all-warnings", "-Wall", 0},
> -   {"--ansi", "-ansi", 0},
> -   {"--assemble", "-S", 0},
> -   {"--assert", "-A", "a"},
> -   {"--classpath", "-fclasspath=", "aj"},
> -   {"--bootclasspath", "-fbootclasspath=", "aj"},
> -   {"--CLASSPATH", "-fclasspath=", "aj"},
> -   {"--combine", "-combine", 0},
> -   {"--comments", "-C", 0},
> -   {"--comments-in-macros", "-CC", 0},
> -   {"--compile", "-c", 0},
> -   {"--debug", "-g", "oj"},
> -   {"--define-macro", "-D", "aj"},
> -   {"--dependencies", "-M", 0},
> -   {"--dump", "-d", "aj"},
> -   {"--dumpbase", "-dumpbase", "a"},
> -   {"--dumpdir", "-dumpdir", "a"},
> -   {"--encoding", "-fencoding=", "aj"},
> -   {"--entry", "-e", 0},
> -   {"--extra-warnings", "-W", 0},
> -   {"--extdirs", "-fextdirs=", "aj"},
> -   {"--for-assembler", "-Wa", "a"},
> -   {"--for-linker", "-Xlinker", "a"},
> -   {"--force-link", "-u", "a"},
> -   {"--coverage", "-coverage", 0},
> -   {"--imacros", "-imacros", "a"},
> -   {"--include", "-include", "a"},
> -   {"--include-barrier", "-I-", 0},
> -   {"--include-directory", "-I", "aj"},
> -   {"--include-directory-after", "-idirafter", "a"},
> -   {"--include-prefix", "-iprefix", "a"},
> -   {"--include-with-prefix", "-iwithprefix", "a"},
> -   {"--include-with-prefix-before", "-iwithprefixbefore", "a"},
> -   {"--include-with-prefix-after", "-iwithprefix", "a"},
> -   {"--language", "-x", "a"},
> -   {"--library-directory", "-L", "a"},
> -   {"--machine", "-m", "aj"},
> -   {"--machine-", "-m", "*j"},
> -   {"--no-canonical-prefixes", "-no-canonical-prefixes", 0},
> -   {"--no-integrated-cpp", "-no-integrated-cpp", 0},
> -   {"--no-line-commands", "-P", 0},
> -   {"--no-precompiled-includes", "-noprecomp", 0},
> -   {"--no-standard-includes", "-nostdinc", 0},
> -   {"--no-standard-libraries", "-nostdlib", 0},
> -   {"--no-warnings", "-w", 0},
> -   {"--optimize", "-O", "oj"},
> -   {"--output", "-o", "a"},
> -   {"--output-class-directory", "-foutput-class-dir=", "ja"},
> -   {"--param", "--param", "a"},
> -   {"--pass-exit-codes", "-pass-exit-codes", 0},
> -   {"--pedantic", "-pedantic", 0},
> -   {"--pedantic-errors", "-pedantic-errors", 0},
> -   {"--pie", "-pie", 0},
> -   {"--pipe", "-pipe", 0},
> -   {"--prefix", "-B", "a"},
> -   {"--preprocess", "-E", 0},
> -   {"--print-search-dirs", "-print-search-dirs", 0},
> -   {"--print-file-name", "-print-file-name=", "aj"},
> -   {"--print-libgcc-file-name", "-print-libgcc-file-name", 0},
> -   {"--print-missing-file-dependencies", "-MG", 0},
> -   {"--print-multi-lib", "-print-multi-lib", 0},
> -   {"--print-multi-directory", "-print-multi-directory", 0},
> -   {"--print-multi-os-directory", "-print-multi-os-directory", 0},
> -   {"--print-prog-name", "-print-prog-name=", "aj"},
> -   {"--print-sysroot", "-print-sysroot", 0},
> -   {"--print-sysroot-headers-suffix", "-print-sysroot-headers-suffix", 0},
> -   {"--profile", "-p", 0},
> -   {"--resource", "-fcompile-resource=", "aj"},
> -   {"--save-temps", "-save-temps", 0},
> -   {"--shared", "-shared", 0},
> -   {"--specs", "-specs=", "aj"},
> -   {"--static", "-static", 0},
> -   {"--std", "-std=", "aj"},
> -   {"--symbolic", "-symbolic", 0},
> -   {"--sysroot", "--sysroot=", "aj"},
> -   {"--time", "-time", 0},
> -   {"--trace-includes", "-H", 0},
> -   {"--traditional", "-traditional", 0},
> -   {"--traditional-cpp", "-traditional-cpp", 0},
> -   {"--trigraphs", "-trigraphs", 0},
> -   {"--undefine-macro", "-U", "aj"},
> -   {"--user-dependencies", "-MM", 0},
> -   {"--verbose", "-v", 0},
> -   {"--warn-", "-W", "*j"},
> -   {"--write-dependencies", "-MD", 0},
> -   {"--write-user-dependencies", "-MMD", 0},
> -   {"--", "-f", "*j"}
> - };
> -
> -
> -#ifdef TARGET_OPTION_TRANSLATE_TABLE
> -static const struct {
> -  const char *const option_found;
> -  const char *const replacements;
> -} target_option_translations[] =
> -{
> -  TARGET_OPTION_TRANSLATE_TABLE,
> -  { 0, 0 }
> -};
> -#endif
> -
> -/* Translate the options described by *ARGCP and *ARGVP.
> -   Make a new vector and store it back in *ARGVP,
> -   and store its length in *ARGCP.  */
> -
> -static void
> -translate_options (int *argcp, const char *const **argvp)
> -{
> -  int i;
> -  int argc = *argcp;
> -  const char *const *argv = *argvp;
> -  int newvsize = (argc + 2) * 2 * sizeof (const char *);
> -  const char **newv = XNEWVAR (const char *, newvsize);
> -  int newindex = 0;
> -
> -  i = 0;
> -  newv[newindex++] = argv[i++];
> -
> -  while (i < argc)
> -    {
> -#ifdef TARGET_OPTION_TRANSLATE_TABLE
> -      int tott_idx;
> -
> -      for (tott_idx = 0;
> -          target_option_translations[tott_idx].option_found;
> -          tott_idx++)
> -       {
> -         if (strcmp (target_option_translations[tott_idx].option_found,
> -                     argv[i]) == 0)
> -           {
> -             int spaces = 1;
> -             const char *sp;
> -             char *np;
> -
> -             for (sp = target_option_translations[tott_idx].replacements;
> -                  *sp; sp++)
> -               {
> -                 if (*sp == ' ')
> -                   spaces ++;
> -               }
> -
> -             newvsize += spaces * sizeof (const char *);
> -             newv =  XRESIZEVAR (const char *, newv, newvsize);
> -
> -             sp = target_option_translations[tott_idx].replacements;
> -             np = xstrdup (sp);
> -
> -             while (1)
> -               {
> -                 while (*np == ' ')
> -                   np++;
> -                 if (*np == 0)
> -                   break;
> -                 newv[newindex++] = np;
> -                 while (*np != ' ' && *np)
> -                   np++;
> -                 if (*np == 0)
> -                   break;
> -                 *np++ = 0;
> -               }
> -
> -             i ++;
> -             break;
> -           }
> -       }
> -      if (target_option_translations[tott_idx].option_found)
> -       continue;
> -#endif
> -
> -      /* Translate -- options.  */
> -      if (argv[i][0] == '-' && argv[i][1] == '-')
> -       {
> -         size_t j;
> -         /* Find a mapping that applies to this option.  */
> -         for (j = 0; j < ARRAY_SIZE (option_map); j++)
> -           {
> -             size_t optlen = strlen (option_map[j].name);
> -             size_t arglen = strlen (argv[i]);
> -             size_t complen = arglen > optlen ? optlen : arglen;
> -             const char *arginfo = option_map[j].arg_info;
> -
> -             if (arginfo == 0)
> -               arginfo = "";
> -
> -             if (!strncmp (argv[i], option_map[j].name, complen))
> -               {
> -                 const char *arg = 0;
> -
> -                 if (arglen < optlen)
> -                   {
> -                     size_t k;
> -                     for (k = j + 1; k < ARRAY_SIZE (option_map); k++)
> -                       if (strlen (option_map[k].name) >= arglen
> -                           && !strncmp (argv[i], option_map[k].name, arglen))
> -                         {
> -                           error ("ambiguous abbreviation %s", argv[i]);
> -                           break;
> -                         }
> -
> -                     if (k != ARRAY_SIZE (option_map))
> -                       break;
> -                   }
> -
> -                 if (arglen > optlen)
> -                   {
> -                     /* If the option has an argument, accept that.  */
> -                     if (argv[i][optlen] == '=')
> -                       arg = argv[i] + optlen + 1;
> -
> -                     /* If this mapping requires extra text at end of name,
> -                        accept that as "argument".  */
> -                     else if (strchr (arginfo, '*') != 0)
> -                       arg = argv[i] + optlen;
> -
> -                     /* Otherwise, extra text at end means mismatch.
> -                        Try other mappings.  */
> -                     else
> -                       continue;
> -                   }
> -
> -                 else if (strchr (arginfo, '*') != 0)
> -                   {
> -                     error ("incomplete %qs option", option_map[j].name);
> -                     break;
> -                   }
> -
> -                 /* Handle arguments.  */
> -                 if (strchr (arginfo, 'a') != 0)
> -                   {
> -                     if (arg == 0)
> -                       {
> -                         if (i + 1 == argc)
> -                           {
> -                             error ("missing argument to %qs option",
> -                                    option_map[j].name);
> -                             break;
> -                           }
> -
> -                         arg = argv[++i];
> -                       }
> -                   }
> -                 else if (strchr (arginfo, '*') != 0)
> -                   ;
> -                 else if (strchr (arginfo, 'o') == 0)
> -                   {
> -                     if (arg != 0)
> -                       error ("extraneous argument to %qs option",
> -                              option_map[j].name);
> -                     arg = 0;
> -                   }
> -
> -                 /* Store the translation as one argv elt or as two.  */
> -                 if (arg != 0 && strchr (arginfo, 'j') != 0)
> -                   newv[newindex++] = concat (option_map[j].equivalent, arg,
> -                                              NULL);
> -                 else if (arg != 0)
> -                   {
> -                     newv[newindex++] = option_map[j].equivalent;
> -                     newv[newindex++] = arg;
> -                   }
> -                 else
> -                   newv[newindex++] = option_map[j].equivalent;
> -
> -                 break;
> -               }
> -           }
> -         i++;
> -       }
> -
> -      /* Handle old-fashioned options--just copy them through,
> -        with their arguments.  */
> -      else if (argv[i][0] == '-')
> -       {
> -         const char *p = argv[i] + 1;
> -         int c = *p;
> -         int nskip = 1;
> -
> -         if (SWITCH_TAKES_ARG (c) > (p[1] != 0))
> -           nskip += SWITCH_TAKES_ARG (c) - (p[1] != 0);
> -         else if (WORD_SWITCH_TAKES_ARG (p))
> -           nskip += WORD_SWITCH_TAKES_ARG (p);
> -         else if ((c == 'B' || c == 'b' || c == 'x')
> -                  && p[1] == 0)
> -           nskip += 1;
> -         else if (! strcmp (p, "Xlinker"))
> -           nskip += 1;
> -         else if (! strcmp (p, "Xpreprocessor"))
> -           nskip += 1;
> -         else if (! strcmp (p, "Xassembler"))
> -           nskip += 1;
> -
> -         /* Watch out for an option at the end of the command line that
> -            is missing arguments, and avoid skipping past the end of the
> -            command line.  */
> -         if (nskip + i > argc)
> -           nskip = argc - i;
> -
> -         while (nskip > 0)
> -           {
> -             newv[newindex++] = argv[i++];
> -             nskip--;
> -           }
> -       }
> -      else
> -       /* Ordinary operands.  */
> -       newv[newindex++] = argv[i++];
> -    }
> -
> -  newv[newindex] = 0;
> -
> -  *argvp = newv;
> -  *argcp = newindex;
> -}
> -
>  static char *
>  skip_whitespace (char *p)
>  {
> @@ -3555,8 +3181,7 @@ driver_handle_option (const struct cl_de
>       printf ("%s\n", spec_machine);
>       exit (0);
>
> -    case OPT_fversion:
> -      /* translate_options () has turned --version into -fversion.  */
> +    case OPT__version:
>       print_version = 1;
>
>       /* CPP driver cannot obtain switch from cc1_options.  */
> @@ -3566,8 +3191,7 @@ driver_handle_option (const struct cl_de
>       add_linker_option ("--version", strlen ("--version"));
>       break;
>
> -    case OPT_fhelp:
> -      /* translate_options () has turned --help into -fhelp.  */
> +    case OPT__help:
>       print_help_list = 1;
>
>       /* CPP driver cannot obtain switch from cc1_options.  */
> @@ -3577,13 +3201,11 @@ driver_handle_option (const struct cl_de
>       add_linker_option ("--help", 6);
>       break;
>
> -    case OPT_fhelp_:
> -      /* translate_options () has turned --help into -fhelp.  */
> +    case OPT__help_:
>       print_subprocess_help = 2;
>       break;
>
> -    case OPT_ftarget_help:
> -      /* translate_options() has turned --target-help into -ftarget-help.  */
> +    case OPT__target_help:
>       print_subprocess_help = 1;
>
>       /* CPP driver cannot obtain switch from cc1_options.  */
> @@ -3896,7 +3518,6 @@ driver_handle_option (const struct cl_de
>  static void
>  process_command (int argc, const char **argv)
>  {
> -  int i;
>   const char *temp;
>   char *temp1;
>   const char *tooldir_prefix;
> @@ -3925,18 +3546,16 @@ process_command (int argc, const char **
>        }
>     }
>
> -  /* Convert new-style -- options to old-style.  */
> -  translate_options (&argc,
> -                    CONST_CAST2 (const char *const **, const char ***,
> -                                 &argv));
> +  decode_cmdline_options_to_array (argc, argv, CL_DRIVER,
> +                                  &decoded_options, &decoded_options_count);
>
>   /* Handle any -no-canonical-prefixes flag early, to assign the function
>      that builds relative prefixes.  This function creates default search
>      paths that are needed later in normal option handling.  */
>
> -  for (i = 1; i < argc; i++)
> +  for (j = 1; j < decoded_options_count; j++)
>     {
> -      if (! strcmp (argv[i], "-no-canonical-prefixes"))
> +      if (decoded_options[j].opt_index == OPT_no_canonical_prefixes)
>        {
>          get_relative_prefix = make_relative_prefix_ignore_links;
>          break;
> @@ -3985,9 +3604,6 @@ process_command (int argc, const char **
>      is relocated. The toolchain was either relocated using GCC_EXEC_PREFIX
>      or an automatically created GCC_EXEC_PREFIX from argv[0].  */
>
> -  decode_cmdline_options_to_array (argc, argv, CL_DRIVER,
> -                                  &decoded_options, &decoded_options_count);
> -
>   /* Do language-specific adjustment/addition of flags.  */
>   lang_specific_driver (&decoded_options, &decoded_options_count,
>                        &added_libraries);
> Index: gcc/opts.c
> ===================================================================
> --- gcc/opts.c  (revision 163844)
> +++ gcc/opts.c  (working copy)
> @@ -1431,7 +1431,6 @@ common_handle_option (const struct cl_de
>       verbose = true;
>       break;
>
> -    case OPT_fhelp:
>     case OPT__help:
>       {
>        unsigned int all_langs_mask = (1U << cl_lang_count) - 1;
> @@ -1453,7 +1452,6 @@ common_handle_option (const struct cl_de
>        break;
>       }
>
> -    case OPT_ftarget_help:
>     case OPT__target_help:
>       print_specific_help (CL_TARGET, CL_UNDOCUMENTED, 0);
>       exit_after_options = true;
> @@ -1463,7 +1461,6 @@ common_handle_option (const struct cl_de
>        targetm.help ();
>       break;
>
> -    case OPT_fhelp_:
>     case OPT__help_:
>       {
>        const char * a = arg;
> @@ -1582,7 +1579,6 @@ common_handle_option (const struct cl_de
>        break;
>       }
>
> -    case OPT_fversion:
>     case OPT__version:
>       exit_after_options = true;
>       break;
> Index: gcc/ada/gcc-interface/lang.opt
> ===================================================================
> --- gcc/ada/gcc-interface/lang.opt      (revision 163844)
> +++ gcc/ada/gcc-interface/lang.opt      (working copy)
> @@ -1,5 +1,5 @@
>  ; Options for the Ada front end.
> -; Copyright (C) 2003, 2007, 2008 Free Software Foundation, Inc.
> +; Copyright (C) 2003, 2007, 2008, 2010 Free Software Foundation, Inc.
>  ;
>  ; This file is part of GCC.
>  ;
> @@ -25,6 +25,24 @@
>  Language
>  Ada
>
> +-all-warnings
> +Ada Alias(Wall)
> +
> +-include-barrier
> +Ada Alias(I, -)
> +
> +-include-directory
> +Ada Separate Alias(I)
> +
> +-include-directory=
> +Ada Joined Alias(I)
> +
> +-no-standard-includes
> +Ada Alias(nostdinc)
> +
> +-no-standard-libraries
> +Ada Alias(nostdlib)
> +
>  I
>  Ada Joined Separate
>  ; Documented for C
> Index: gcc/fortran/lang.opt
> ===================================================================
> --- gcc/fortran/lang.opt        (revision 163844)
> +++ gcc/fortran/lang.opt        (working copy)
> @@ -25,6 +25,96 @@
>  Language
>  Fortran
>
> +-all-warnings
> +Fortran Alias(Wall)
> +
> +-assert
> +Fortran Separate Alias(A)
> +
> +-assert=
> +Fortran Joined Alias(A)
> +
> +-comments
> +Fortran Alias(C)
> +
> +-comments-in-macros
> +Fortran Alias(CC)
> +
> +-define-macro
> +Fortran Separate Alias(D)
> +
> +-define-macro=
> +Fortran Joined Alias(D)
> +
> +-dependencies
> +Fortran Alias(M)
> +
> +-dump
> +Fortran Separate Alias(d)
> +
> +-dump=
> +Fortran Joined Alias(d)
> +
> +-include-barrier
> +Fortran Alias(I, -)
> +
> +-include-directory
> +Fortran Separate Alias(I)
> +
> +-include-directory=
> +Fortran Joined Alias(I)
> +
> +-include-directory-after
> +Fortran Separate Alias(idirafter)
> +
> +-include-directory-after=
> +Fortran Joined Alias(idirafter)
> +
> +-include-prefix
> +Fortran Separate Alias(iprefix)
> +
> +-include-prefix=
> +Fortran JoinedOrMissing Alias(iprefix)
> +
> +-no-line-commands
> +Fortran Alias(P)
> +
> +-no-standard-includes
> +Fortran Alias(nostdinc)
> +
> +-output
> +Fortran Separate Alias(o)
> +
> +-output=
> +Fortran Joined Alias(o)
> +
> +-preprocess
> +Fortran Undocumented Alias(E)
> +
> +-print-missing-file-dependencies
> +Fortran Alias(MG)
> +
> +-trace-includes
> +Fortran Alias(H)
> +
> +-undefine-macro
> +Fortran Separate Alias(U)
> +
> +-undefine-macro=
> +Fortran Joined Alias(U)
> +
> +-user-dependencies
> +Fortran Alias(MM)
> +
> +-verbose
> +Fortran Alias(v)
> +
> +-write-dependencies
> +Fortran NoDriverArg Separate Alias(MD)
> +
> +-write-user-dependencies
> +Fortran NoDriverArg Separate Alias(MMD)
> +
>  A
>  Fortran Joined Separate
>  ; Documented in C
> Index: gcc/fortran/gfortranspec.c
> ===================================================================
> --- gcc/fortran/gfortranspec.c  (revision 163844)
> +++ gcc/fortran/gfortranspec.c  (working copy)
> @@ -271,7 +271,7 @@ lang_specific_driver (struct cl_decoded_
>          verbose = 1;
>          break;
>
> -       case OPT_fversion:
> +       case OPT__version:
>          printf ("GNU Fortran %s%s\n", pkgversion_string, version_string);
>          printf ("Copyright %s 2010 Free Software Foundation, Inc.\n\n",
>                  _("(C)"));
> @@ -282,7 +282,7 @@ For more information about these matters
>          exit (0);
>          break;
>
> -       case OPT_fhelp:
> +       case OPT__help:
>          /* Let gcc.c handle this, as it has a really
>             cool facility for handling --help and --verbose --help.  */
>          return;
> Index: gcc/common.opt
> ===================================================================
> --- gcc/common.opt      (revision 163844)
> +++ gcc/common.opt      (working copy)
> @@ -26,37 +26,211 @@
>  ###
>  Driver
>
> +-assemble
> +Driver Alias(S)
> +
> +-combine
> +Driver Alias(combine)
> +
> +-compile
> +Driver Alias(c)
> +
> +-coverage
> +Driver Alias(coverage)
> +
> +-debug
> +Common Alias(g)
> +
> +-dump
> +Common Separate Alias(d)
> +
> +-dump=
> +Common Joined Alias(d)
> +
> +-dumpbase
> +Common Separate Alias(dumpbase)
> +
> +-dumpdir
> +Common Separate Alias(dumpdir)
> +
> +-entry
> +Driver Separate Alias(e)
> +
> +-entry=
> +Driver Joined Alias(e)
> +
> +-extra-warnings
> +Common Warning Alias(Wextra)
> +
> +-for-assembler
> +Driver Separate Alias(Xassembler)
> +
> +-for-assembler=
> +Driver JoinedOrMissing Alias(Xassembler)
> +
> +-for-linker
> +Driver Separate Alias(Xlinker)
> +
> +-for-linker=
> +Driver JoinedOrMissing Alias(Xlinker)
> +
> +-force-link
> +Driver Separate Alias(u)
> +
> +-force-link=
> +Driver Joined Alias(u)
> +
>  -help
> -Common Driver
> +Common Driver Var(help_flag)
>  Display this information
>
>  -help=
>  Common Driver Report Joined
>  --help=<class> Display descriptions of a specific class of options.  <class> is one or more of optimizers, target, warnings, undocumented, params
>
> +-language
> +Driver Separate Alias(x)
> +
> +-language=
> +Driver Joined Alias(x)
> +
> +-library-directory
> +Driver Separate Alias(L)
> +
> +-library-directory=
> +Driver Joined Alias(L)
> +
> +-no-canonical-prefixes
> +Driver Alias(no-canonical-prefixes)
> +
> +-no-standard-libraries
> +Driver Alias(nostdlib)
> +
> +-no-warnings
> +Common Alias(w)
> +
> +-optimize
> +Common Alias(O)
> +
> +-output
> +Common Driver Separate Alias(o) MissingArgError(missing filename after %qs)
> +
> +-output=
> +Common Driver Joined Alias(o) MissingArgError(missing filename after %qs)
> +
> +-pass-exit-codes
> +Driver Alias(pass-exit-codes)
> +
> +-pedantic
> +Common Alias(pedantic)
> +
> +-pedantic-errors
> +Common Alias(pedantic-errors)
> +
> +-pie
> +Common Alias(pie)
> +
> +-pipe
> +Driver Alias(pipe)
> +
> +-prefix
> +Driver Separate Alias(B)
> +
> +-prefix=
> +Driver JoinedOrMissing Alias(B)
> +
> +-preprocess
> +Driver Alias(E)
> +
> +-print-file-name
> +Driver Separate Alias(print-file-name=)
> +
> +-print-file-name=
> +Driver JoinedOrMissing Alias(print-file-name=)
> +
> +-print-libgcc-file-name
> +Driver Alias(print-libgcc-file-name)
> +
> +-print-multi-directory
> +Driver Alias(print-multi-directory)
> +
> +-print-multi-lib
> +Driver Alias(print-multi-lib)
> +
> +-print-multi-os-directory
> +Driver Alias(print-multi-os-directory)
> +
> +-print-prog-name
> +Driver Separate Alias(print-prog-name=)
> +
> +-print-prog-name=
> +Driver JoinedOrMissing Alias(print-prog-name=)
> +
> +-print-search-dirs
> +Driver Alias(print-search-dirs)
> +
> +-print-sysroot
> +Driver Alias(print-sysroot)
> +
> +-print-sysroot-headers-suffix
> +Driver Alias(print-sysroot-headers-suffix)
> +
> +-profile
> +Common Alias(p)
> +
> +-save-temps
> +Driver Alias(save-temps)
> +
> +-shared
> +Common Alias(shared)
> +
> +-specs
> +Driver Separate Alias(specs=)
> +
> +-specs=
> +Driver Joined Alias(specs=)
> +
> +-static
> +Driver Alias(static)
> +
> +-symbolic
> +Driver Alias(symbolic)
> +
>  -target-help
>  Common Driver
>  Alias for --help=target
>
> -;; The following four entries are to work around the gcc driver
> -;; program's insatiable desire to turn options starting with a
> -;; double dash (--) into options starting with a dash f (-f).
> +-time
> +Driver Alias(time)
> +
> +-verbose
> +Driver Alias(v)
> +
> +;; The driver used to convert options such as --help into forms such
> +;; as -fhelp; the following four entries are for compatibility with
> +;; any direct uses of those (undocumented) -f forms
>  fhelp
> -Common Driver Var(help_flag)
> +Common Driver Alias(-help)
>
>  fhelp=
> -Common Driver Joined
> +Common Driver Joined Alias(-help=)
>
>  ftarget-help
> -Common Driver
> +Common Driver Alias(-target-help)
>
>  fversion
> -Common Driver
> +Common Driver Alias(-version)
>
>  -param
>  Common Separate
>  --param <param>=<value>        Set parameter <param> to value.  See below for a complete list of parameters
>
> +-param=
> +Common Joined Alias(-param)
> +
> +-sysroot
> +Driver Separate Alias(-sysroot=)
> +
>  -sysroot=
>  Driver JoinedOrMissing
>
> @@ -312,6 +486,9 @@ Common Separate RejectDriver
>  combine
>  Driver Var(combine_flag)
>
> +coverage
> +Driver
> +
>  c
>  Driver
>
> @@ -336,6 +513,9 @@ Driver
>  dumpversion
>  Driver
>
> +e
> +Driver Joined Separate
> +
>  ; The version of the C++ ABI in use.  The following values are allowed:
>  ;
>  ; 0: The version of the ABI believed most conformant with the C++ ABI
> @@ -1733,6 +1913,9 @@ Driver Var(report_times)
>  time=
>  Driver JoinedOrMissing
>
> +u
> +Driver Joined Separate
> +
>  v
>  Driver
>
> @@ -1776,6 +1959,9 @@ Driver
>  static-libstdc++
>  Driver
>
> +symbolic
> +Driver
> +
>  pie
>  Common RejectNegative Negative(shared)
>  Create a position independent executable
>
> --
> Joseph S. Myers
> joseph@codesourcery.com
>



More information about the Fortran mailing list