]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
2014-03-06 Richard Biener <rguenther@suse.de>
authorrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 6 Mar 2014 08:48:01 +0000 (08:48 +0000)
committerrguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4>
Thu, 6 Mar 2014 08:48:01 +0000 (08:48 +0000)
* gcc.c (PLUGIN_COND): Always enable unless -fno-use-linker-plugin
or -fno-lto is specified and the linker has full plugin support.
* collect2.c (lto_mode): Default to LTO_MODE_WHOPR if LTO is
enabled.
(main): Remove -flto processing, adjust lto_mode using
use_plugin late.
* lto-wrapper.c (merge_and_complain): Merge compile-time
optimization levels.
(run_gcc): And pass it through to the link options.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@208375 138bc75d-0d04-0410-961f-82ee72b054a4

gcc/ChangeLog
gcc/collect2.c
gcc/gcc.c
gcc/lto-wrapper.c

index f231dd4f8d9a8a9b644abce5847f9b19a02a757f..2a5b0069ea2d8da3eb1a58bc747bbd651ee5553c 100644 (file)
@@ -1,3 +1,15 @@
+2014-03-06  Richard Biener  <rguenther@suse.de>
+
+       * gcc.c (PLUGIN_COND): Always enable unless -fno-use-linker-plugin
+       or -fno-lto is specified and the linker has full plugin support.
+       * collect2.c (lto_mode): Default to LTO_MODE_WHOPR if LTO is
+       enabled.
+       (main): Remove -flto processing, adjust lto_mode using
+       use_plugin late.
+       * lto-wrapper.c (merge_and_complain): Merge compile-time
+       optimization levels.
+       (run_gcc): And pass it through to the link options.
+
 2014-03-06  Alexandre Oliva <aoliva@redhat.com>
 
        PR debug/60381
index 38d3421c0dfd6603d47a98cdba3970ad2f91c295..f0ab6b8c8f108e18f0c4a7c5474e99948b778fc0 100644 (file)
@@ -192,7 +192,11 @@ enum lto_mode_d {
 };
 
 /* Current LTO mode.  */
+#ifdef ENABLE_LTO
+static enum lto_mode_d lto_mode = LTO_MODE_WHOPR;
+#else
 static enum lto_mode_d lto_mode = LTO_MODE_NONE;
+#endif
 
 bool debug;                            /* true if -debug */
 bool helpflag;                 /* true if --help */
@@ -1018,15 +1022,11 @@ main (int argc, char **argv)
          debug = true;
         else if (! strcmp (argv[i], "-flto-partition=none"))
          no_partition = true;
-        else if ((! strncmp (argv[i], "-flto=", 6)
-                 || ! strcmp (argv[i], "-flto")) && ! use_plugin)
-         lto_mode = LTO_MODE_WHOPR;
        else if (!strncmp (argv[i], "-fno-lto", 8))
          lto_mode = LTO_MODE_NONE;
         else if (! strcmp (argv[i], "-plugin"))
          {
            use_plugin = true;
-           lto_mode = LTO_MODE_NONE;
            if (selected_linker == USE_DEFAULT_LD)
              selected_linker = USE_PLUGIN_LD;
          }
@@ -1056,6 +1056,8 @@ main (int argc, char **argv)
       }
     vflag = debug;
     find_file_set_debug (debug);
+    if (use_plugin)
+      lto_mode = LTO_MODE_NONE;
     if (no_partition && lto_mode == LTO_MODE_WHOPR)
       lto_mode = LTO_MODE_LTO;
   }
index 9f76f89a4507172413da80273593bbbe75864e3b..691623ae081f3e7a891ee97a2f645e4615fdf7fd 100644 (file)
--- a/gcc/gcc.c
+++ b/gcc/gcc.c
@@ -695,7 +695,7 @@ proper position among the other output files.  */
 #if HAVE_LTO_PLUGIN > 0
 /* The linker used has full plugin support, use LTO plugin by default.  */
 #if HAVE_LTO_PLUGIN == 2
-#define PLUGIN_COND "!fno-use-linker-plugin:%{flto|flto=*|fuse-linker-plugin"
+#define PLUGIN_COND "!fno-use-linker-plugin:%{!fno-lto"
 #define PLUGIN_COND_CLOSE "}"
 #else
 /* The linker used has limited plugin support, use LTO plugin with explicit
index b17945a2ffea8f7ddd7436a5bfc8fbac42afd1a2..cf587cbc7573eba6bac51909fc51f07f3d7146a7 100644 (file)
@@ -459,6 +459,77 @@ merge_and_complain (struct cl_decoded_option **decoded_options,
            fatal ("Option %s not used consistently in all LTO input files",
                   foption->orig_option_with_args_text);
          break;
+
+       case OPT_O:
+       case OPT_Ofast:
+       case OPT_Og:
+       case OPT_Os:
+         for (j = 0; j < *decoded_options_count; ++j)
+           if ((*decoded_options)[j].opt_index == OPT_O
+               || (*decoded_options)[j].opt_index == OPT_Ofast
+               || (*decoded_options)[j].opt_index == OPT_Og
+               || (*decoded_options)[j].opt_index == OPT_Os)
+             break;
+         if (j == *decoded_options_count)
+           append_option (decoded_options, decoded_options_count, foption);
+         else if ((*decoded_options)[j].opt_index == foption->opt_index
+                  && foption->opt_index != OPT_O)
+           /* Exact same options get merged.  */
+           ;
+         else
+           {
+             /* For mismatched option kinds preserve the optimization
+                level only, thus merge it as -On.  This also handles
+                merging of same optimization level -On.  */
+             int level = 0;
+             switch (foption->opt_index)
+               {
+               case OPT_O:
+                 if (foption->arg[0] == '\0')
+                   level = MAX (level, 1);
+                 else
+                   level = MAX (level, atoi (foption->arg));
+                 break;
+               case OPT_Ofast:
+                 level = MAX (level, 3);
+                 break;
+               case OPT_Og:
+                 level = MAX (level, 1);
+                 break;
+               case OPT_Os:
+                 level = MAX (level, 2);
+                 break;
+               default:
+                 gcc_unreachable ();
+               }
+             switch ((*decoded_options)[j].opt_index)
+               {
+               case OPT_O:
+                 if ((*decoded_options)[j].arg[0] == '\0')
+                   level = MAX (level, 1);
+                 else
+                   level = MAX (level, atoi ((*decoded_options)[j].arg));
+                 break;
+               case OPT_Ofast:
+                 level = MAX (level, 3);
+                 break;
+               case OPT_Og:
+                 level = MAX (level, 1);
+                 break;
+               case OPT_Os:
+                 level = MAX (level, 2);
+                 break;
+               default:
+                 gcc_unreachable ();
+               }
+             (*decoded_options)[j].opt_index = OPT_O;
+             char *tem;
+             asprintf (&tem, "-O%d", level);
+             (*decoded_options)[j].arg = &tem[2];
+             (*decoded_options)[j].canonical_option[0] = tem;
+             (*decoded_options)[j].value = 1;
+           }
+         break;
        }
     }
 }
@@ -610,6 +681,10 @@ run_gcc (unsigned argc, char *argv[])
        case OPT_fwrapv:
        case OPT_ftrapv:
        case OPT_fstrict_overflow:
+       case OPT_O:
+       case OPT_Ofast:
+       case OPT_Og:
+       case OPT_Os:
          break;
 
        default: