Commit f3ba16d0 by Richard Biener Committed by Richard Biener

gcc.c (PLUGIN_COND): Always enable unless -fno-use-linker-plugin or -fno-lto is…

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
parent df2b279c
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> 2014-03-06 Alexandre Oliva <aoliva@redhat.com>
PR debug/60381 PR debug/60381
......
...@@ -192,7 +192,11 @@ enum lto_mode_d { ...@@ -192,7 +192,11 @@ enum lto_mode_d {
}; };
/* Current LTO mode. */ /* 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; static enum lto_mode_d lto_mode = LTO_MODE_NONE;
#endif
bool debug; /* true if -debug */ bool debug; /* true if -debug */
bool helpflag; /* true if --help */ bool helpflag; /* true if --help */
...@@ -1018,15 +1022,11 @@ main (int argc, char **argv) ...@@ -1018,15 +1022,11 @@ main (int argc, char **argv)
debug = true; debug = true;
else if (! strcmp (argv[i], "-flto-partition=none")) else if (! strcmp (argv[i], "-flto-partition=none"))
no_partition = true; 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)) else if (!strncmp (argv[i], "-fno-lto", 8))
lto_mode = LTO_MODE_NONE; lto_mode = LTO_MODE_NONE;
else if (! strcmp (argv[i], "-plugin")) else if (! strcmp (argv[i], "-plugin"))
{ {
use_plugin = true; use_plugin = true;
lto_mode = LTO_MODE_NONE;
if (selected_linker == USE_DEFAULT_LD) if (selected_linker == USE_DEFAULT_LD)
selected_linker = USE_PLUGIN_LD; selected_linker = USE_PLUGIN_LD;
} }
...@@ -1056,6 +1056,8 @@ main (int argc, char **argv) ...@@ -1056,6 +1056,8 @@ main (int argc, char **argv)
} }
vflag = debug; vflag = debug;
find_file_set_debug (debug); find_file_set_debug (debug);
if (use_plugin)
lto_mode = LTO_MODE_NONE;
if (no_partition && lto_mode == LTO_MODE_WHOPR) if (no_partition && lto_mode == LTO_MODE_WHOPR)
lto_mode = LTO_MODE_LTO; lto_mode = LTO_MODE_LTO;
} }
......
...@@ -695,7 +695,7 @@ proper position among the other output files. */ ...@@ -695,7 +695,7 @@ proper position among the other output files. */
#if HAVE_LTO_PLUGIN > 0 #if HAVE_LTO_PLUGIN > 0
/* The linker used has full plugin support, use LTO plugin by default. */ /* The linker used has full plugin support, use LTO plugin by default. */
#if HAVE_LTO_PLUGIN == 2 #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 "}" #define PLUGIN_COND_CLOSE "}"
#else #else
/* The linker used has limited plugin support, use LTO plugin with explicit /* The linker used has limited plugin support, use LTO plugin with explicit
......
...@@ -459,6 +459,77 @@ merge_and_complain (struct cl_decoded_option **decoded_options, ...@@ -459,6 +459,77 @@ merge_and_complain (struct cl_decoded_option **decoded_options,
fatal ("Option %s not used consistently in all LTO input files", fatal ("Option %s not used consistently in all LTO input files",
foption->orig_option_with_args_text); foption->orig_option_with_args_text);
break; 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[]) ...@@ -610,6 +681,10 @@ run_gcc (unsigned argc, char *argv[])
case OPT_fwrapv: case OPT_fwrapv:
case OPT_ftrapv: case OPT_ftrapv:
case OPT_fstrict_overflow: case OPT_fstrict_overflow:
case OPT_O:
case OPT_Ofast:
case OPT_Og:
case OPT_Os:
break; break;
default: default:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment