OSDN Git Service

Improve error for undefined name in imported package.
[pf3gnuchains/gcc-fork.git] / gcc / lto-wrapper.c
index fe5b346..f26b3ac 100644 (file)
@@ -32,27 +32,18 @@ along with GCC; see the file COPYING3.  If not see
    The above will print something like
    /tmp/ccwbQ8B2.lto.o
 
-   If -fwhopr is used instead, more than one file might be produced
+   If WHOPR is used instead, more than one file might be produced
    ./ccXj2DTk.lto.ltrans.o
    ./ccCJuXGv.lto.ltrans.o
 */
 
 #include "config.h"
 #include "system.h"
-#include <errno.h>
-#include <signal.h>
-#if ! defined( SIGCHLD ) && defined( SIGCLD )
-#  define SIGCHLD SIGCLD
-#endif
-#include "defaults.h"
+#include "coretypes.h"
 #include "intl.h"
-#include "libiberty.h"
+#include "diagnostic.h"
 #include "obstack.h"
 
-#ifndef HAVE_KILL
-#define kill(p,s) raise(s)
-#endif
-
 int debug;                             /* true if -save-temps.  */
 int verbose;                           /* true if -v.  */
 
@@ -303,6 +294,8 @@ run_gcc (unsigned argc, char *argv[])
   struct obstack env_obstack;
   bool seen_o = false;
   int parallel = 0;
+  int jobserver = 0;
+  bool no_partition = false;
 
   /* Get the driver and options.  */
   collect_gcc = getenv ("COLLECT_GCC");
@@ -365,26 +358,42 @@ run_gcc (unsigned argc, char *argv[])
        if (strcmp (option, "-v") == 0)
          verbose = 1;
 
+       if (strcmp (option, "-flto-partition=none") == 0)
+         no_partition = true;
        /* We've handled these LTO options, do not pass them on.  */
-       if (strcmp (option, "-flto") == 0)
-         lto_mode = LTO_MODE_LTO;
-       else if (strncmp (option, "-fwhopr", 7) == 0)
+       if (strncmp (option, "-flto=", 6) == 0
+           || !strcmp (option, "-flto"))
          {
            lto_mode = LTO_MODE_WHOPR;
-           if (option[7] == '=')
+           if (option[5] == '=')
              {
-               parallel = atoi (option+8);
-               if (parallel <= 1)
-                 parallel = 0;
+               if (!strcmp (option + 6, "jobserver"))
+                 {
+                   jobserver = 1;
+                   parallel = 1;
+                 }
+               else
+                 {
+                   parallel = atoi (option + 6);
+                   if (parallel <= 1)
+                     parallel = 0;
+                 }
              }
          }
        else
          *argv_ptr++ = option;
       }
+  if (no_partition)
+    {
+      lto_mode = LTO_MODE_LTO;
+      jobserver = 0;
+      parallel = 0;
+    }
 
   if (linker_output)
     {
       char *output_dir, *base, *name;
+      bool bit_bucket = strcmp (linker_output, HOST_BIT_BUCKET) == 0;
 
       output_dir = xstrdup (linker_output);
       base = output_dir;
@@ -399,8 +408,11 @@ run_gcc (unsigned argc, char *argv[])
          static char current_dir[] = { '.', DIR_SEPARATOR, '\0' };
          output_dir = current_dir;
        }
-      *argv_ptr++ = "-dumpdir";
-      *argv_ptr++ = output_dir;
+      if (!bit_bucket)
+       {
+         *argv_ptr++ = "-dumpdir";
+         *argv_ptr++ = output_dir;
+       }
 
       *argv_ptr++ = "-dumpbase";
     }
@@ -414,9 +426,8 @@ run_gcc (unsigned argc, char *argv[])
        argv_ptr[0] = linker_output;
       argv_ptr[1] = "-o";
       argv_ptr[2] = flto_out;
-      argv_ptr[3] = "-combine";
     }
-  else if (lto_mode == LTO_MODE_WHOPR)
+  else 
     {
       const char *list_option = "-fltrans-output-list=";
       size_t list_option_len = strlen (list_option);
@@ -450,15 +461,12 @@ run_gcc (unsigned argc, char *argv[])
       strcpy (tmp, ltrans_output_file);
 
       argv_ptr[2] = "-fwpa";
-      argv_ptr[3] = "-combine";
     }
-  else
-    fatal ("invalid LTO mode");
 
   /* Append the input objects and possible preceeding arguments.  */
   for (i = 1; i < argc; ++i)
-    argv_ptr[3 + i] = argv[i];
-  argv_ptr[3 + i] = NULL;
+    argv_ptr[2 + i] = argv[i];
+  argv_ptr[2 + i] = NULL;
 
   fork_execute (CONST_CAST (char **, new_argv));
 
@@ -468,7 +476,7 @@ run_gcc (unsigned argc, char *argv[])
       free (flto_out);
       flto_out = NULL;
     }
-  else if (lto_mode == LTO_MODE_WHOPR)
+  else
     {
       FILE *stream = fopen (ltrans_output_file, "r");
       FILE *mstream = NULL;
@@ -567,23 +575,32 @@ cont:
        {
          struct pex_obj *pex;
          char jobs[32];
+
          fprintf (mstream, "all:");
          for (i = 0; i < nr; ++i)
            fprintf (mstream, " \\\n\t%s", output_names[i]);
          fprintf (mstream, "\n");
          fclose (mstream);
-         /* Avoid passing --jobserver-fd= and similar flags.  */
-         putenv (xstrdup ("MAKEFLAGS="));
-         putenv (xstrdup ("MFLAGS="));
+         if (!jobserver)
+           {
+             /* Avoid passing --jobserver-fd= and similar flags 
+                unless jobserver mode is explicitly enabled.  */
+             putenv (xstrdup ("MAKEFLAGS="));
+             putenv (xstrdup ("MFLAGS="));
+           }
          new_argv[0] = getenv ("MAKE");
          if (!new_argv[0])
            new_argv[0] = "make";
          new_argv[1] = "-f";
          new_argv[2] = makefile;
-         snprintf (jobs, 31, "-j%d", parallel);
-         new_argv[3] = jobs;
-         new_argv[4] = "all";
-         new_argv[5] = NULL;
+         i = 3;
+         if (!jobserver)
+           {
+             snprintf (jobs, 31, "-j%d", parallel);
+             new_argv[i++] = jobs;
+           }
+         new_argv[i++] = "all";
+         new_argv[i++] = NULL;
          pex = collect_execute (CONST_CAST (char **, new_argv));
          collect_wait (new_argv[0], pex);
          maybe_unlink_file (makefile);
@@ -601,8 +618,6 @@ cont:
       free (input_names);
       free (list_option_full);
     }
-  else
-    fatal ("invalid LTO mode");
 
   obstack_free (&env_obstack, NULL);
 }
@@ -613,8 +628,19 @@ cont:
 int
 main (int argc, char *argv[])
 {
+  const char *p;
+
+  p = argv[0] + strlen (argv[0]);
+  while (p != argv[0] && !IS_DIR_SEPARATOR (p[-1]))
+    --p;
+  progname = p;
+
+  xmalloc_set_program_name (progname);
+
   gcc_init_libintl ();
 
+  diagnostic_initialize (global_dc, 0);
+
   if (signal (SIGINT, SIG_IGN) != SIG_IGN)
     signal (SIGINT, fatal_signal);
 #ifdef SIGHUP