aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Biener <rguenther@suse.de>2014-03-06 08:48:01 +0000
committerRichard Biener <rguenth@gcc.gnu.org>2014-03-06 08:48:01 +0000
commitf3ba16d0589db7548b76f381102759f2c4cc7558 (patch)
treefa7f9924d2c5057881344899e74b9fd4ecc3993d
parentdf2b279c5c77f5925e85246f3dbdad92508c573b (diff)
downloadgcc-f3ba16d0589db7548b76f381102759f2c4cc7558.zip
gcc-f3ba16d0589db7548b76f381102759f2c4cc7558.tar.gz
gcc-f3ba16d0589db7548b76f381102759f2c4cc7558.tar.bz2
gcc.c (PLUGIN_COND): Always enable unless -fno-use-linker-plugin or -fno-lto is specified and the...
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. From-SVN: r208375
-rw-r--r--gcc/ChangeLog12
-rw-r--r--gcc/collect2.c10
-rw-r--r--gcc/gcc.c2
-rw-r--r--gcc/lto-wrapper.c75
4 files changed, 94 insertions, 5 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog
index f231dd4..2a5b006 100644
--- a/gcc/ChangeLog
+++ b/gcc/ChangeLog
@@ -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
diff --git a/gcc/collect2.c b/gcc/collect2.c
index 38d3421..f0ab6b8 100644
--- a/gcc/collect2.c
+++ b/gcc/collect2.c
@@ -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;
}
diff --git a/gcc/gcc.c b/gcc/gcc.c
index 9f76f89..691623a 100644
--- 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
diff --git a/gcc/lto-wrapper.c b/gcc/lto-wrapper.c
index b17945a..cf587cb 100644
--- a/gcc/lto-wrapper.c
+++ b/gcc/lto-wrapper.c
@@ -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: