lto-streamer.h (LTO_major_version): Bump to 5.
[gcc.git] / gcc / gcc.c
index 4cb4ba32618e1ea2a19d99297ad0692de29c2c14..0f29b7870fb0ca07059a5a905f1e4694121b548e 100644 (file)
--- a/gcc/gcc.c
+++ b/gcc/gcc.c
@@ -1,5 +1,5 @@
 /* Compiler driver program that can handle many languages.
-   Copyright (C) 1987-2014 Free Software Foundation, Inc.
+   Copyright (C) 1987-2015 Free Software Foundation, Inc.
 
 This file is part of GCC.
 
@@ -41,7 +41,6 @@ compilation is specified by a string called a "spec".  */
 #include "flags.h"
 #include "opts.h"
 #include "params.h"
-#include "vec.h"
 #include "filenames.h"
 
 /* By default there is no special suffix for target executables.  */
@@ -728,18 +727,66 @@ proper position among the other output files.  */
 
 #ifndef LINK_SSP_SPEC
 #ifdef TARGET_LIBC_PROVIDES_SSP
-#define LINK_SSP_SPEC "%{fstack-protector:}"
+#define LINK_SSP_SPEC "%{fstack-protector|fstack-protector-all" \
+                      "|fstack-protector-strong|fstack-protector-explicit:}"
 #else
-#define LINK_SSP_SPEC "%{fstack-protector|fstack-protector-strong|fstack-protector-all:-lssp_nonshared -lssp}"
+#define LINK_SSP_SPEC "%{fstack-protector|fstack-protector-all" \
+                      "|fstack-protector-strong|fstack-protector-explicit" \
+                      ":-lssp_nonshared -lssp}"
 #endif
 #endif
 
+#ifdef ENABLE_DEFAULT_PIE
+#define NO_PIE_SPEC            "no-pie|static"
+#define PIE_SPEC               NO_PIE_SPEC "|r|shared:;"
+#define NO_FPIE1_SPEC          "fno-pie"
+#define FPIE1_SPEC             NO_FPIE1_SPEC ":;"
+#define NO_FPIE2_SPEC          "fno-PIE"
+#define FPIE2_SPEC             NO_FPIE2_SPEC ":;"
+#define NO_FPIE_SPEC           NO_FPIE1_SPEC "|" NO_FPIE2_SPEC
+#define FPIE_SPEC              NO_FPIE_SPEC ":;"
+#define NO_FPIC1_SPEC          "fno-pic"
+#define FPIC1_SPEC             NO_FPIC1_SPEC ":;"
+#define NO_FPIC2_SPEC          "fno-PIC"
+#define FPIC2_SPEC             NO_FPIC2_SPEC ":;"
+#define NO_FPIC_SPEC           NO_FPIC1_SPEC "|" NO_FPIC2_SPEC
+#define FPIC_SPEC              NO_FPIC_SPEC ":;"
+#define NO_FPIE1_AND_FPIC1_SPEC        NO_FPIE1_SPEC "|" NO_FPIC1_SPEC
+#define FPIE1_OR_FPIC1_SPEC    NO_FPIE1_AND_FPIC1_SPEC ":;"
+#define NO_FPIE2_AND_FPIC2_SPEC        NO_FPIE2_SPEC "|" NO_FPIC2_SPEC
+#define FPIE2_OR_FPIC2_SPEC    NO_FPIE2_AND_FPIC2_SPEC ":;"
+#define NO_FPIE_AND_FPIC_SPEC  NO_FPIE_SPEC "|" NO_FPIC_SPEC
+#define FPIE_OR_FPIC_SPEC      NO_FPIE_AND_FPIC_SPEC ":;"
+#else
+#define PIE_SPEC               "pie"
+#define NO_PIE_SPEC            PIE_SPEC "|r|shared:;"
+#define FPIE1_SPEC             "fpie"
+#define NO_FPIE1_SPEC          FPIE1_SPEC ":;"
+#define FPIE2_SPEC             "fPIE"
+#define NO_FPIE2_SPEC          FPIE2_SPEC ":;"
+#define FPIE_SPEC              FPIE1_SPEC "|" FPIE2_SPEC
+#define NO_FPIE_SPEC           FPIE_SPEC ":;"
+#define FPIC1_SPEC             "fpic"
+#define NO_FPIC1_SPEC          FPIC1_SPEC ":;"
+#define FPIC2_SPEC             "fPIC"
+#define NO_FPIC2_SPEC          FPIC2_SPEC ":;"
+#define FPIC_SPEC              FPIC1_SPEC "|" FPIC2_SPEC
+#define NO_FPIC_SPEC           FPIC_SPEC ":;"
+#define FPIE1_OR_FPIC1_SPEC    FPIE1_SPEC "|" FPIC1_SPEC
+#define NO_FPIE1_AND_FPIC1_SPEC        FPIE1_OR_FPIC1_SPEC ":;"
+#define FPIE2_OR_FPIC2_SPEC    FPIE2_SPEC "|" FPIC2_SPEC
+#define NO_FPIE2_AND_FPIC2_SPEC        FPIE1_OR_FPIC2_SPEC ":;"
+#define FPIE_OR_FPIC_SPEC      FPIE_SPEC "|" FPIC_SPEC
+#define NO_FPIE_AND_FPIC_SPEC  FPIE_OR_FPIC_SPEC ":;"
+#endif
+
 #ifndef LINK_PIE_SPEC
 #ifdef HAVE_LD_PIE
-#define LINK_PIE_SPEC "%{pie:-pie} "
+#define LD_PIE_SPEC "-pie"
 #else
-#define LINK_PIE_SPEC "%{pie:} "
+#define LD_PIE_SPEC ""
 #endif
+#define LINK_PIE_SPEC "%{no-pie:} " "%{" PIE_SPEC ":" LD_PIE_SPEC "} "
 #endif
 
 #ifndef LINK_BUILDID_SPEC
@@ -768,12 +815,12 @@ proper position among the other output files.  */
 #define PLUGIN_COND_CLOSE ""
 #endif
 #define LINK_PLUGIN_SPEC \
-    "%{"PLUGIN_COND": \
+    "%{" PLUGIN_COND": \
     -plugin %(linker_plugin_file) \
     -plugin-opt=%(lto_wrapper) \
     -plugin-opt=-fresolution=%u.res \
     %{!nostdlib:%{!nodefaultlibs:%:pass-through-libs(%(link_gcc_c_sequence))}} \
-    }"PLUGIN_COND_CLOSE
+    }" PLUGIN_COND_CLOSE
 #else
 /* The linker used doesn't support -plugin, reject -fuse-linker-plugin.  */
 #define LINK_PLUGIN_SPEC "%{fuse-linker-plugin:\
@@ -809,6 +856,10 @@ proper position among the other output files.  */
     %{fvtable-verify=preinit: -lvtv -u_vtable_map_vars_start -u_vtable_map_vars_end}}"
 #endif
 
+#ifndef CHKP_SPEC
+#define CHKP_SPEC ""
+#endif
+
 /* -u* was put back because both BSD and SysV seem to support it.  */
 /* %{static:} simply prevents an error message if the target machine
    doesn't handle -static.  */
@@ -829,7 +880,8 @@ proper position among the other output files.  */
    "%X %{o*} %{e*} %{N} %{n} %{r}\
     %{s} %{t} %{u*} %{z} %{Z} %{!nostdlib:%{!nostartfiles:%S}} " VTABLE_VERIFICATION_SPEC " \
     %{static:} %{L*} %(mfwrap) %(link_libgcc) " SANITIZER_EARLY_SPEC " %o\
-    %{fopenmp|ftree-parallelize-loops=*:%:include(libgomp.spec)%(link_gomp)}\
+    " CHKP_SPEC " \
+    %{fopenacc|fopenmp|ftree-parallelize-loops=*:%:include(libgomp.spec)%(link_gomp)}\
     %{fcilkplus:%:include(libcilkrts.spec)%(link_cilkrts)}\
     %{fgnu-tm:%:include(libitm.spec)%(link_itm)}\
     %(mflib) " STACK_SPLIT_SPEC "\
@@ -990,7 +1042,8 @@ static const char *const multilib_defaults_raw[] = MULTILIB_DEFAULTS;
 /* Linking to libgomp implies pthreads.  This is particularly important
    for targets that use different start files and suchlike.  */
 #ifndef GOMP_SELF_SPECS
-#define GOMP_SELF_SPECS "%{fopenmp|ftree-parallelize-loops=*: -pthread}"
+#define GOMP_SELF_SPECS "%{fopenacc|fopenmp|ftree-parallelize-loops=*: " \
+  "-pthread}"
 #endif
 
 /* Likewise for -fgnu-tm.  */
@@ -1122,12 +1175,14 @@ static const struct compiler default_compilers[] =
                %(cpp_options) -o %{save-temps*:%b.i} %{!save-temps*:%g.i} \n\
                    cc1 -fpreprocessed %{save-temps*:%b.i} %{!save-temps*:%g.i} \
                        %(cc1_options)\
-                        %{!fdump-ada-spec*:-o %g.s %{!o*:--output-pch=%i.gch}\
-                        %W{o*:--output-pch=%*}}%V}\
+                       %{!fsyntax-only:-o %g.s \
+                           %{!fdump-ada-spec*:%{!o*:--output-pch=%i.gch}\
+                                              %W{o*:--output-pch=%*}}%V}}\
          %{!save-temps*:%{!traditional-cpp:%{!no-integrated-cpp:\
                cc1 %(cpp_unique_options) %(cc1_options)\
-                    %{!fdump-ada-spec*:-o %g.s %{!o*:--output-pch=%i.gch}\
-                    %W{o*:--output-pch=%*}}%V}}}}}}", 0, 0, 0},
+                   %{!fsyntax-only:-o %g.s \
+                       %{!fdump-ada-spec*:%{!o*:--output-pch=%i.gch}\
+                                          %W{o*:--output-pch=%*}}%V}}}}}}}", 0, 0, 0},
   {".i", "@cpp-output", 0, 0, 0},
   {"@cpp-output",
    "%{!M:%{!MM:%{!E:cc1 -fpreprocessed %i %(cc1_options) %{!fsyntax-only:%(invoke_as)}}}}", 0, 0, 0},
@@ -1892,7 +1947,8 @@ read_specs (const char *filename, bool main_p, bool user_p)
                p1++;
 
              if (*p1++ != '<' || p[-2] != '>')
-               fatal_error ("specs %%include syntax malformed after "
+               fatal_error (input_location,
+                            "specs %%include syntax malformed after "
                             "%ld characters",
                             (long) (p1 - buffer + 1));
 
@@ -1912,7 +1968,8 @@ read_specs (const char *filename, bool main_p, bool user_p)
                p1++;
 
              if (*p1++ != '<' || p[-2] != '>')
-               fatal_error ("specs %%include syntax malformed after "
+               fatal_error (input_location,
+                            "specs %%include syntax malformed after "
                             "%ld characters",
                             (long) (p1 - buffer + 1));
 
@@ -1938,7 +1995,8 @@ read_specs (const char *filename, bool main_p, bool user_p)
                p1++;
 
              if (! ISALPHA ((unsigned char) *p1))
-               fatal_error ("specs %%rename syntax malformed after "
+               fatal_error (input_location,
+                            "specs %%rename syntax malformed after "
                             "%ld characters",
                             (long) (p1 - buffer));
 
@@ -1947,7 +2005,8 @@ read_specs (const char *filename, bool main_p, bool user_p)
                p2++;
 
              if (*p2 != ' ' && *p2 != '\t')
-               fatal_error ("specs %%rename syntax malformed after "
+               fatal_error (input_location,
+                            "specs %%rename syntax malformed after "
                             "%ld characters",
                             (long) (p2 - buffer));
 
@@ -1957,7 +2016,8 @@ read_specs (const char *filename, bool main_p, bool user_p)
                p2++;
 
              if (! ISALPHA ((unsigned char) *p2))
-               fatal_error ("specs %%rename syntax malformed after "
+               fatal_error (input_location,
+                            "specs %%rename syntax malformed after "
                             "%ld characters",
                             (long) (p2 - buffer));
 
@@ -1967,7 +2027,8 @@ read_specs (const char *filename, bool main_p, bool user_p)
                p3++;
 
              if (p3 != p - 1)
-               fatal_error ("specs %%rename syntax malformed after "
+               fatal_error (input_location,
+                            "specs %%rename syntax malformed after "
                             "%ld characters",
                             (long) (p3 - buffer));
              *p3 = '\0';
@@ -1977,14 +2038,16 @@ read_specs (const char *filename, bool main_p, bool user_p)
                  break;
 
              if (!sl)
-               fatal_error ("specs %s spec was not found to be renamed", p1);
+               fatal_error (input_location,
+                            "specs %s spec was not found to be renamed", p1);
 
              if (strcmp (p1, p2) == 0)
                continue;
 
              for (newsl = specs; newsl; newsl = newsl->next)
                if (strcmp (newsl->name, p2) == 0)
-                 fatal_error ("%s: attempt to rename spec %qs to "
+                 fatal_error (input_location,
+                              "%s: attempt to rename spec %qs to "
                               "already defined spec %qs",
                    filename, p1, p2);
 
@@ -2005,7 +2068,8 @@ read_specs (const char *filename, bool main_p, bool user_p)
              continue;
            }
          else
-           fatal_error ("specs unknown %% command after %ld characters",
+           fatal_error (input_location,
+                        "specs unknown %% command after %ld characters",
                         (long) (p1 - buffer));
        }
 
@@ -2016,7 +2080,8 @@ read_specs (const char *filename, bool main_p, bool user_p)
 
       /* The colon shouldn't be missing.  */
       if (*p1 != ':')
-       fatal_error ("specs file malformed after %ld characters",
+       fatal_error (input_location,
+                    "specs file malformed after %ld characters",
                     (long) (p1 - buffer));
 
       /* Skip back over trailing whitespace.  */
@@ -2029,7 +2094,8 @@ read_specs (const char *filename, bool main_p, bool user_p)
       /* Find the next line.  */
       p = skip_whitespace (p1 + 1);
       if (p[1] == 0)
-       fatal_error ("specs file malformed after %ld characters",
+       fatal_error (input_location,
+                    "specs file malformed after %ld characters",
                     (long) (p - buffer));
 
       p1 = p;
@@ -2081,7 +2147,7 @@ read_specs (const char *filename, bool main_p, bool user_p)
     }
 
   if (link_command_spec == 0)
-    fatal_error ("spec file has no spec for linking");
+    fatal_error (input_location, "spec file has no spec for linking");
 }
 \f
 /* Record the names of temporary files we tell compilers to write,
@@ -2626,7 +2692,7 @@ add_sysrooted_prefix (struct path_prefix *pprefix, const char *prefix,
                      int require_machine_suffix, int os_multilib)
 {
   if (!IS_ABSOLUTE_PATH (prefix))
-    fatal_error ("system path %qs is not absolute", prefix);
+    fatal_error (input_location, "system path %qs is not absolute", prefix);
 
   if (target_system_root)
     {
@@ -2714,7 +2780,7 @@ execute (void)
     if (arg && strcmp (arg, "|") == 0)
       {                                /* each command.  */
 #if defined (__MSDOS__) || defined (OS2) || defined (VMS)
-       fatal_error ("-pipe not supported");
+       fatal_error (input_location, "-pipe not supported");
 #endif
        argbuf[i] = 0; /* Termination of
                                                     command args.  */
@@ -2837,7 +2903,7 @@ execute (void)
                                   ? PEX_RECORD_TIMES : 0),
                  progname, temp_filename);
   if (pex == NULL)
-    fatal_error ("pex_init failed: %m");
+    fatal_error (input_location, "pex_init failed: %m");
 
   for (i = 0; i < n_commands; i++)
     {
@@ -2853,7 +2919,7 @@ execute (void)
       if (errmsg != NULL)
        {
          if (err == 0)
-           fatal_error (errmsg);
+           fatal_error (input_location, errmsg);
          else
            {
              errno = err;
@@ -2876,13 +2942,13 @@ execute (void)
 
     statuses = (int *) alloca (n_commands * sizeof (int));
     if (!pex_get_status (pex, n_commands, statuses))
-      fatal_error ("failed to get exit status: %m");
+      fatal_error (input_location, "failed to get exit status: %m");
 
     if (report_times || report_times_to_file)
       {
        times = (struct pex_time *) alloca (n_commands * sizeof (struct pex_time));
        if (!pex_get_times (pex, n_commands, times))
-         fatal_error ("failed to get process times: %m");
+         fatal_error (input_location, "failed to get process times: %m");
       }
 
     pex_free (pex);
@@ -2908,8 +2974,9 @@ execute (void)
              }
            else
 #endif
-             internal_error ("%s (program %s)",
-                             strsignal (WTERMSIG (status)), commands[i].prog);
+             internal_error_no_backtrace ("%s (program %s)",
+                                          strsignal (WTERMSIG (status)),
+                                          commands[i].prog);
          }
        else if (WIFEXITED (status)
                 && WEXITSTATUS (status) >= MIN_FATAL_STATUS)
@@ -3415,7 +3482,8 @@ handle_foffload_option (const char *arg)
        }
 
       if (!c)
-       fatal_error ("GCC is not configured to support %s as offload target",
+       fatal_error (input_location,
+                    "GCC is not configured to support %s as offload target",
                     target);
 
       if (!offload_targets)
@@ -3608,6 +3676,10 @@ driver_handle_option (struct gcc_options *opts,
       save_switch (compare_debug_replacement_opt, 0, NULL, validated, true);
       return true;
 
+    case OPT_fdiagnostics_color_:
+      diagnostic_color_init (dc, value);
+      break;
+
     case OPT_Wa_:
       {
        int prev, j;
@@ -3710,7 +3782,7 @@ driver_handle_option (struct gcc_options *opts,
               || strcmp (arg, "object") == 0)
        save_temps_flag = SAVE_TEMPS_OBJ;
       else
-       fatal_error ("%qs is an unknown -save-temps option",
+       fatal_error (input_location, "%qs is an unknown -save-temps option",
                     decoded->orig_option_with_args_text);
       break;
 
@@ -3821,6 +3893,11 @@ driver_handle_option (struct gcc_options *opts,
       save_switch ("-o", 1, &arg, validated, true);
       return true;
 
+#ifdef ENABLE_DEFAULT_PIE
+    case OPT_pie:
+      /* -pie is turned on by default.  */
+#endif
+
     case OPT_static_libgcc:
     case OPT_shared_libgcc:
     case OPT_static_libgfortran:
@@ -4165,7 +4242,8 @@ process_command (unsigned int decoded_options_count,
       for (i = 0; i < n_infiles; i++)
        if ((!infiles[i].language || infiles[i].language[0] != '*')
            && canonical_filename_eq (infiles[i].name, output_file))
-         fatal_error ("input file %qs is the same as output file",
+         fatal_error (input_location,
+                      "input file %qs is the same as output file",
                       output_file);
     }
 
@@ -4646,10 +4724,12 @@ do_self_spec (const char *spec)
              /* Specs should only generate options, not input
                 files.  */
              if (strcmp (decoded_options[j].arg, "-") != 0)
-               fatal_error ("switch %qs does not start with %<-%>",
+               fatal_error (input_location,
+                            "switch %qs does not start with %<-%>",
                             decoded_options[j].arg);
              else
-               fatal_error ("spec-generated switch is just %<-%>");
+               fatal_error (input_location,
+                            "spec-generated switch is just %<-%>");
              break;
 
            case OPT_fcompare_debug_second:
@@ -4672,6 +4752,8 @@ do_self_spec (const char *spec)
            }
        }
 
+      free (decoded_options);
+
       alloc_switch ();
       switches[n_switches].part1 = 0;
     }
@@ -4740,19 +4822,20 @@ create_at_file (char **argv)
   int status;
 
   if (f == NULL)
-    fatal_error ("could not open temporary response file %s",
+    fatal_error (input_location, "could not open temporary response file %s",
                 temp_file);
 
   status = writeargv (argv, f);
 
   if (status)
-    fatal_error ("could not write to temporary response file %s",
+    fatal_error (input_location,
+                "could not write to temporary response file %s",
                 temp_file);
 
   status = fclose (f);
 
   if (EOF == status)
-    fatal_error ("could not close temporary response file %s",
+    fatal_error (input_location, "could not close temporary response file %s",
                 temp_file);
 
   store_arg (at_argument, 0, 0);
@@ -4875,7 +4958,7 @@ do_spec_1 (const char *spec, int inswitch, const char *soft_matched_part)
        switch (c = *p++)
          {
          case 0:
-           fatal_error ("spec %qs invalid", spec);
+           fatal_error (input_location, "spec %qs invalid", spec);
 
          case 'b':
            if (save_temps_length)
@@ -5024,7 +5107,8 @@ do_spec_1 (const char *spec, int inswitch, const char *soft_matched_part)
                    p += 2;
                    /* We don't support extra suffix characters after %O.  */
                    if (*p == '.' || ISALNUM ((unsigned char) *p))
-                     fatal_error ("spec %qs has invalid %<%%0%c%>", spec, *p);
+                     fatal_error (input_location,
+                                  "spec %qs has invalid %<%%0%c%>", spec, *p);
                    if (suffix_length == 0)
                      suffix = TARGET_OBJECT_SUFFIX;
                    else
@@ -5343,7 +5427,8 @@ do_spec_1 (const char *spec, int inswitch, const char *soft_matched_part)
              unsigned int cur_index = argbuf.length ();
              /* Handle the {...} following the %W.  */
              if (*p != '{')
-               fatal_error ("spec %qs has invalid %<%%W%c%>", spec, *p);
+               fatal_error (input_location,
+                            "spec %qs has invalid %<%%W%c%>", spec, *p);
              p = handle_braces (p + 1);
              if (p == 0)
                return -1;
@@ -5365,7 +5450,8 @@ do_spec_1 (const char *spec, int inswitch, const char *soft_matched_part)
 
              /* Skip past the option value and make a copy.  */
              if (*p != '{')
-               fatal_error ("spec %qs has invalid %<%%x%c%>", spec, *p);
+               fatal_error (input_location,
+                            "spec %qs has invalid %<%%x%c%>", spec, *p);
              while (*p++ != '}')
                ;
              string = save_string (p1 + 1, p - p1 - 2);
@@ -5681,7 +5767,7 @@ eval_spec_function (const char *func, const char *args)
 
   sf = lookup_spec_function (func);
   if (sf == NULL)
-    fatal_error ("unknown spec function %qs", func);
+    fatal_error (input_location, "unknown spec function %qs", func);
 
   /* Push the spec processing context.  */
   save_argbuf = argbuf;
@@ -5711,7 +5797,7 @@ eval_spec_function (const char *func, const char *args)
 
   alloc_args ();
   if (do_spec_2 (args) < 0)
-    fatal_error ("error in args to spec function %qs", func);
+    fatal_error (input_location, "error in args to spec function %qs", func);
 
   /* argbuf_index is an index for the next argument to be inserted, and
      so contains the count of the args already inserted.  */
@@ -5765,10 +5851,10 @@ handle_spec_function (const char *p, bool *retval_nonnull)
         break;
       /* Only allow [A-Za-z0-9], -, and _ in function names.  */
       if (!ISALNUM (*endp) && !(*endp == '-' || *endp == '_'))
-       fatal_error ("malformed spec function name");
+       fatal_error (input_location, "malformed spec function name");
     }
   if (*endp != '(')            /* ) */
-    fatal_error ("no arguments for spec function");
+    fatal_error (input_location, "no arguments for spec function");
   func = save_string (p, endp - p);
   p = ++endp;
 
@@ -5787,7 +5873,7 @@ handle_spec_function (const char *p, bool *retval_nonnull)
     }
   /* ( */
   if (*endp != ')')
-    fatal_error ("malformed spec function arguments");
+    fatal_error (input_location, "malformed spec function arguments");
   args = save_string (p, endp - p);
   p = ++endp;
 
@@ -6061,7 +6147,7 @@ handle_braces (const char *p)
   return p;
 
  invalid:
-  fatal_error ("braced spec %qs is invalid at %qc", orig, *p);
+  fatal_error (input_location, "braced spec %qs is invalid at %qc", orig, *p);
 
 #undef SKIP_WHITE
 }
@@ -6149,7 +6235,7 @@ process_brace_body (const char *p, const char *atom, const char *end_atom,
   return p;
 
  invalid:
-  fatal_error ("braced spec body %qs is invalid", body);
+  fatal_error (input_location, "braced spec body %qs is invalid", body);
 }
 \f
 /* Return 0 iff switch number SWITCHNUM is obsoleted by a later switch
@@ -6322,10 +6408,10 @@ print_configuration (FILE *file)
 
   if (! strncmp (version_string, compiler_version, n)
       && compiler_version[n] == 0)
-    fnotice (file, "gcc version %s %s\n\n", version_string,
+    fnotice (file, "gcc version %s %s\n", version_string,
             pkgversion_string);
   else
-    fnotice (file, "gcc driver version %s %sexecuting gcc version %s\n\n",
+    fnotice (file, "gcc driver version %s %sexecuting gcc version %s\n",
             version_string, pkgversion_string, compiler_version);
 
 }
@@ -6429,6 +6515,7 @@ run_attempt (const char **new_argv, const char *out_temp,
     {
       FILE *file_out = fopen (err_temp, "a");
       print_configuration (file_out);
+      fputs ("\n", file_out);
       fclose (file_out);
     }
 
@@ -6444,7 +6531,7 @@ run_attempt (const char **new_argv, const char *out_temp,
 
   pex = pex_init (PEX_USE_PIPES, new_argv[0], NULL);
   if (!pex)
-    fatal_error ("pex_init failed: %m");
+    fatal_error (input_location, "pex_init failed: %m");
 
   errmsg = pex_run (pex, pex_flags, new_argv[0],
                    CONST_CAST2 (char *const *, const char **, &new_argv[1]), out_temp,
@@ -6452,7 +6539,7 @@ run_attempt (const char **new_argv, const char *out_temp,
   if (errmsg != NULL)
     {
       if (err == 0)
-       fatal_error (errmsg);
+       fatal_error (input_location, errmsg);
       else
        {
          errno = err;
@@ -6482,6 +6569,29 @@ out:
   return status;
 }
 
+/* This routine reads lines from IN file, adds C++ style comments
+   at the begining of each line and writes result into OUT.  */
+
+static void
+insert_comments (const char *file_in, const char *file_out)
+{
+  FILE *in = fopen (file_in, "rb");
+  FILE *out = fopen (file_out, "wb");
+  char line[256];
+
+  bool add_comment = true;
+  while (fgets (line, sizeof (line), in))
+    {
+      if (add_comment)
+       fputs ("// ", out);
+      fputs (line, out);
+      add_comment = strchr (line, '\n') != NULL;
+    }
+
+  fclose (in);
+  fclose (out);
+}
+
 /* This routine adds preprocessed source code into the given ERR_FILE.
    To do this, it adds "-E" to NEW_ARGV and execute RUN_ATTEMPT routine to
    add information in report file.  RUN_ATTEMPT should return
@@ -6518,19 +6628,6 @@ do_report_bug (const char **new_argv, const int nargs,
     }
 }
 
-/* Append string STR to file FILE.  */
-
-static void
-append_text (char *file, const char *str)
-{
-  int fd = open (file, O_RDWR | O_APPEND);
-  if (fd < 0)
-    return;
-
-  write (fd, str, strlen (str));
-  close (fd);
-}
-
 /* Try to reproduce ICE.  If bug is reproducible, generate report .err file
    containing GCC configuration, backtrace, compiler's command line options
    and preprocessed source code.  */
@@ -6593,16 +6690,10 @@ try_generate_repro (const char **argv)
          emit_system_info = 1;
        }
 
-      if (emit_system_info)
-       append_text (temp_stderr_files[attempt], "/*\n");
-
       status = run_attempt (new_argv, temp_stdout_files[attempt],
                            temp_stderr_files[attempt], emit_system_info,
                            append);
 
-      if (emit_system_info)
-       append_text (temp_stderr_files[attempt], "*/\n");
-
       if (status != ATTEMPT_STATUS_ICE)
        {
          fnotice (stderr, "The bug is not reproducible, so it is"
@@ -6614,11 +6705,17 @@ try_generate_repro (const char **argv)
   if (!check_repro (temp_stdout_files, temp_stderr_files))
     goto out;
 
-  /* In final attempt we append compiler options and preprocesssed code to last
-     generated .err file with configuration and backtrace.  */
-  do_report_bug (new_argv, nargs,
-                &temp_stderr_files[RETRY_ICE_ATTEMPTS - 1],
-                &temp_stdout_files[RETRY_ICE_ATTEMPTS - 1]);
+  {
+    /* Insert commented out backtrace into report file.  */
+    char **stderr_commented = &temp_stdout_files[RETRY_ICE_ATTEMPTS - 1];
+    insert_comments (temp_stderr_files[RETRY_ICE_ATTEMPTS - 1],
+                    *stderr_commented);
+
+    /* In final attempt we append compiler options and preprocesssed code to last
+       generated .out file with configuration and backtrace.  */
+    char **output = &temp_stdout_files[RETRY_ICE_ATTEMPTS - 1];
+    do_report_bug (new_argv, nargs, stderr_commented, output);
+  }
 
 out:
   for (i = 0; i < RETRY_ICE_ATTEMPTS * 2; i++)
@@ -6841,52 +6938,6 @@ compare_files (char *cmpfile[])
   return ret;
 }
 
-/* The top-level "main" within the driver would be ~1000 lines long.
-   This class breaks it up into smaller functions and contains some
-   state shared by them.  */
-
-class driver
-{
- public:
-  int main (int argc, char **argv);
-
- private:
-  void set_progname (const char *argv0) const;
-  void expand_at_files (int *argc, char ***argv) const;
-  void decode_argv (int argc, const char **argv);
-  void global_initializations ();
-  void build_multilib_strings () const;
-  void set_up_specs () const;
-  void putenv_COLLECT_GCC (const char *argv0) const;
-  void maybe_putenv_COLLECT_LTO_WRAPPER () const;
-  void maybe_putenv_OFFLOAD_TARGETS () const;
-  void handle_unrecognized_options () const;
-  int maybe_print_and_exit () const;
-  bool prepare_infiles ();
-  void do_spec_on_infiles () const;
-  void maybe_run_linker (const char *argv0) const;
-  void final_actions () const;
-  int get_exit_code () const;
-
- private:
-  char *explicit_link_files;
-  struct cl_decoded_option *decoded_options;
-  unsigned int decoded_options_count;
-};
-
-/* Implement the top-level "main" within the driver in terms of
-   driver::main.  */
-
-extern int main (int, char **);
-
-int
-main (int argc, char **argv)
-{
-  driver d;
-
-  return d.main (argc, argv);
-}
-
 /* driver::main is implemented as a series of driver:: method calls.  */
 
 int
@@ -6975,6 +7026,7 @@ driver::global_initializations ()
   gcc_init_libintl ();
 
   diagnostic_initialize (global_dc, 0);
+  diagnostic_color_init (global_dc);
 
 #ifdef GCC_DRIVER_HOST_INITIALIZATION
   /* Perform host dependent initialization when needed.  */
@@ -6982,7 +7034,7 @@ driver::global_initializations ()
 #endif
 
   if (atexit (delete_temp_files) != 0)
-    fatal_error ("atexit failed");
+    fatal_error (input_location, "atexit failed");
 
   if (signal (SIGINT, SIG_IGN) != SIG_IGN)
     signal (SIGINT, fatal_signal);
@@ -7506,7 +7558,8 @@ driver::maybe_print_and_exit () const
       else
        /* The error status indicates that only one set of fixed
           headers should be built.  */
-       fatal_error ("not configured with sysroot headers suffix");
+       fatal_error (input_location,
+                    "not configured with sysroot headers suffix");
     }
 
   if (print_help_list)
@@ -7533,7 +7586,7 @@ driver::maybe_print_and_exit () const
     {
       printf (_("%s %s%s\n"), progname, pkgversion_string,
              version_string);
-      printf ("Copyright %s 2014 Free Software Foundation, Inc.\n",
+      printf ("Copyright %s 2015 Free Software Foundation, Inc.\n",
              _("(C)"));
       fputs (_("This is free software; see the source for copying conditions.  There is NO\n\
 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n\n"),
@@ -7567,7 +7620,7 @@ driver::prepare_infiles ()
   int lang_n_infiles = 0;
 
   if (n_infiles == added_libraries)
-    fatal_error ("no input files");
+    fatal_error (input_location, "no input files");
 
   if (seen_error ())
     /* Early exit needed from main.  */
@@ -7617,7 +7670,8 @@ driver::prepare_infiles ()
     }
 
   if (!combine_inputs && have_c && have_o && lang_n_infiles > 1)
-    fatal_error ("cannot specify -o with -c, -S or -E with multiple files");
+    fatal_error (input_location,
+                "cannot specify -o with -c, -S or -E with multiple files");
 
   /* No early exit needed from main; we can continue.  */
   return false;
@@ -7823,7 +7877,8 @@ driver::maybe_run_linker (const char *argv0) const
                                             LTOPLUGINSONAME, R_OK,
                                             false);
              if (!temp_spec)
-               fatal_error ("-fuse-linker-plugin, but %s not found",
+               fatal_error (input_location,
+                            "-fuse-linker-plugin, but %s not found",
                             LTOPLUGINSONAME);
              linker_plugin_file_spec = convert_white_space (temp_spec);
            }
@@ -8135,7 +8190,7 @@ used_arg (const char *p, int len)
              if (*q == '\0')
                {
                invalid_matches:
-                 fatal_error ("multilib spec %qs is invalid",
+                 fatal_error (input_location, "multilib spec %qs is invalid",
                               multilib_matches);
                }
              q++;
@@ -8329,7 +8384,7 @@ set_multilib_dir (void)
          if (*p == '\0')
            {
            invalid_exclusions:
-             fatal_error ("multilib exclusions %qs is invalid",
+             fatal_error (input_location, "multilib exclusions %qs is invalid",
                           multilib_exclusions);
            }
 
@@ -8393,7 +8448,7 @@ set_multilib_dir (void)
          if (*p == '\0')
            {
            invalid_select:
-             fatal_error ("multilib select %qs %qs is invalid",
+             fatal_error (input_location, "multilib select %qs %qs is invalid",
                           multilib_select, multilib_reuse);
            }
          ++p;
@@ -8554,7 +8609,8 @@ print_multilib_info (void)
          if (*p == '\0')
            {
            invalid_select:
-             fatal_error ("multilib select %qs is invalid", multilib_select);
+             fatal_error (input_location,
+                          "multilib select %qs is invalid", multilib_select);
            }
 
          ++p;
@@ -8593,7 +8649,8 @@ print_multilib_info (void)
                if (*e == '\0')
                  {
                  invalid_exclusion:
-                   fatal_error ("multilib exclusion %qs is invalid",
+                   fatal_error (input_location,
+                                "multilib exclusion %qs is invalid",
                                 multilib_exclusions);
                  }
 
@@ -8799,7 +8856,8 @@ getenv_spec_function (int argc, const char **argv)
 
   value = getenv (argv[0]);
   if (!value)
-    fatal_error ("environment variable %qs not defined", argv[0]);
+    fatal_error (input_location,
+                "environment variable %qs not defined", argv[0]);
 
   /* We have to escape every character of the environment variable so
      they are not interpreted as active spec characters.  A
@@ -8938,12 +8996,12 @@ compare_version_strings (const char *v1, const char *v2)
     abort ();
   rresult = regexec (&r, v1, 0, NULL, 0);
   if (rresult == REG_NOMATCH)
-    fatal_error ("invalid version number %qs", v1);
+    fatal_error (input_location, "invalid version number %qs", v1);
   else if (rresult != 0)
     abort ();
   rresult = regexec (&r, v2, 0, NULL, 0);
   if (rresult == REG_NOMATCH)
-    fatal_error ("invalid version number %qs", v2);
+    fatal_error (input_location, "invalid version number %qs", v2);
   else if (rresult != 0)
     abort ();
 
@@ -8986,13 +9044,13 @@ version_compare_spec_function (int argc, const char **argv)
   bool result;
 
   if (argc < 3)
-    fatal_error ("too few arguments to %%:version-compare");
+    fatal_error (input_location, "too few arguments to %%:version-compare");
   if (argv[0][0] == '\0')
     abort ();
   if ((argv[0][1] == '<' || argv[0][1] == '>') && argv[0][0] != '!')
     nargs = 2;
   if (argc != nargs + 3)
-    fatal_error ("too many arguments to %%:version-compare");
+    fatal_error (input_location, "too many arguments to %%:version-compare");
 
   switch_len = strlen (argv[nargs + 1]);
   for (i = 0; i < n_switches; i++)
@@ -9033,7 +9091,8 @@ version_compare_spec_function (int argc, const char **argv)
       break;
 
     default:
-      fatal_error ("unknown operator %qs in %%:version-compare", argv[0]);
+      fatal_error (input_location,
+                  "unknown operator %qs in %%:version-compare", argv[0]);
     }
   if (! result)
     return NULL;
@@ -9156,7 +9215,8 @@ compare_debug_dump_opt_spec_function (int arg,
   static char random_seed[HOST_BITS_PER_WIDE_INT / 4 + 3];
 
   if (arg != 0)
-    fatal_error ("too many arguments to %%:compare-debug-dump-opt");
+    fatal_error (input_location,
+                "too many arguments to %%:compare-debug-dump-opt");
 
   do_spec_2 ("%{fdump-final-insns=*:%*}");
   do_spec_1 (" ", 0, NULL);
@@ -9228,7 +9288,8 @@ compare_debug_self_opt_spec_function (int arg,
                                      const char **argv ATTRIBUTE_UNUSED)
 {
   if (arg != 0)
-    fatal_error ("too many arguments to %%:compare-debug-self-opt");
+    fatal_error (input_location,
+                "too many arguments to %%:compare-debug-self-opt");
 
   if (compare_debug >= 0)
     return NULL;
@@ -9263,17 +9324,19 @@ compare_debug_auxbase_opt_spec_function (int arg,
   int len;
 
   if (arg == 0)
-    fatal_error ("too few arguments to %%:compare-debug-auxbase-opt");
+    fatal_error (input_location,
+                "too few arguments to %%:compare-debug-auxbase-opt");
 
   if (arg != 1)
-    fatal_error ("too many arguments to %%:compare-debug-auxbase-opt");
+    fatal_error (input_location,
+                "too many arguments to %%:compare-debug-auxbase-opt");
 
   if (compare_debug >= 0)
     return NULL;
 
   len = strlen (argv[0]);
   if (len < 3 || strcmp (argv[0] + len - 3, ".gk") != 0)
-    fatal_error ("argument to %%:compare-debug-auxbase-opt "
+    fatal_error (input_location, "argument to %%:compare-debug-auxbase-opt "
                 "does not end in .gk");
 
   if (debug_auxbase_opt)
@@ -9347,7 +9410,7 @@ replace_extension_spec_func (int argc, const char **argv)
   int i;
 
   if (argc != 2)
-    fatal_error ("too few arguments to %%:replace-extension");
+    fatal_error (input_location, "too few arguments to %%:replace-extension");
 
   name = xstrdup (argv[0]);
 
@@ -9412,3 +9475,39 @@ convert_white_space (char *orig)
   else
     return orig;
 }
+
+/* PR jit/64810.
+   Targets can provide configure-time default options in
+   OPTION_DEFAULT_SPECS.  The jit needs to access these, but
+   they are expressed in the spec language.
+
+   Run just enough of the driver to be able to expand these
+   specs, and then call the callback CB on each
+   such option.  The options strings are *without* a leading
+   '-' character e.g. ("march=x86-64").  Finally, clean up.  */
+
+void
+driver_get_configure_time_options (void (*cb) (const char *option,
+                                              void *user_data),
+                                  void *user_data)
+{
+  size_t i;
+
+  obstack_init (&obstack);
+  gcc_obstack_init (&opts_obstack);
+  n_switches = 0;
+
+  for (i = 0; i < ARRAY_SIZE (option_default_specs); i++)
+    do_option_spec (option_default_specs[i].name,
+                   option_default_specs[i].spec);
+
+  for (i = 0; (int) i < n_switches; i++)
+    {
+      gcc_assert (switches[i].part1);
+      (*cb) (switches[i].part1, user_data);
+    }
+
+  obstack_free (&opts_obstack, NULL);
+  obstack_free (&obstack, NULL);
+  n_switches = 0;
+}