+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
};
/* 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 */
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;
}
}
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;
}
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;
}
}
}
case OPT_fwrapv:
case OPT_ftrapv:
case OPT_fstrict_overflow:
+ case OPT_O:
+ case OPT_Ofast:
+ case OPT_Og:
+ case OPT_Os:
break;
default: