This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Use the LTO linker plugin by default


> 
> The following patch addresses the common (?) issue of people
> omitting -flto from the linker command-line which gets more
> severe with GCC 4.9 where slim LTO objects are emitted by
> default.  The patch simply _always_ arranges for the linker
> plugin to be used, so if there are any (slim) LTO objects
> on the link LTO will be done on them.  Similarly the
> non-linker-plugin path in collect2 is adjusted.
> 
> You can still disable this by specifying -fno-lto on the 
> linker command-line.
> 
> One side-effect of enabling the linker-plugin by default
> (for HAVE_LTO_PLUGIN == 2) is that collect2 will then
> use the configured plugin ld rather than the default ld.
> Not sure if that is desired.
> 
> Comments?

I like it; it was on my TODO list, but I was only worried about
--with-plugin-ld and did not find time, yet, to look into the consequences.
These days, I do not think we need to worry much aboud --with-plugin-ld.

Honza
> 
> Thanks,
> Richard.
> 
> 2014-03-04  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.
> 
> Index: gcc/gcc.c
> ===================================================================
> --- gcc/gcc.c	(revision 208310)
> +++ gcc/gcc.c	(working copy)
> @@ -695,7 +695,7 @@ proper position among the other output f
>  #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: gcc/collect2.c
> ===================================================================
> --- gcc/collect2.c	(revision 208310)
> +++ gcc/collect2.c	(working copy)
> @@ -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 Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]