OSDN Git Service

PR target/49313
[pf3gnuchains/gcc-fork.git] / gcc / lto-wrapper.c
index 0ef8b87..f26b3ac 100644 (file)
@@ -32,7 +32,7 @@ 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
 */
@@ -40,19 +40,10 @@ along with GCC; see the file COPYING3.  If not see
 #include "config.h"
 #include "system.h"
 #include "coretypes.h"
-#include <errno.h>
-#include <signal.h>
-#if ! defined( SIGCHLD ) && defined( SIGCLD )
-#  define SIGCHLD SIGCLD
-#endif
 #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.  */
 
@@ -304,6 +295,7 @@ run_gcc (unsigned argc, char *argv[])
   bool seen_o = false;
   int parallel = 0;
   int jobserver = 0;
+  bool no_partition = false;
 
   /* Get the driver and options.  */
   collect_gcc = getenv ("COLLECT_GCC");
@@ -366,22 +358,23 @@ 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] == '=')
              {
-               if (!strcmp (option + 8, "jobserver"))
+               if (!strcmp (option + 6, "jobserver"))
                  {
                    jobserver = 1;
                    parallel = 1;
                  }
                else
                  {
-                   parallel = atoi (option+8);
+                   parallel = atoi (option + 6);
                    if (parallel <= 1)
                      parallel = 0;
                  }
@@ -390,10 +383,17 @@ run_gcc (unsigned argc, char *argv[])
        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;
@@ -408,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";
     }
@@ -423,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);
@@ -459,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));
 
@@ -477,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;
@@ -619,8 +618,6 @@ cont:
       free (input_names);
       free (list_option_full);
     }
-  else
-    fatal ("invalid LTO mode");
 
   obstack_free (&env_obstack, NULL);
 }
@@ -631,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