This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH] Use the LTO linker plugin by default
- From: Richard Biener <rguenther at suse dot de>
- To: Jan Hubicka <hubicka at ucw dot cz>
- Cc: gcc-patches at gcc dot gnu dot org, Jakub Jelinek <jakub at redhat dot com>
- Date: Wed, 5 Mar 2014 09:52:02 +0100 (CET)
- Subject: Re: [PATCH] Use the LTO linker plugin by default
- Authentication-results: sourceware.org; auth=none
- References: <alpine dot LSU dot 2 dot 11 dot 1403041241510 dot 11121 at zhemvz dot fhfr dot qr> <20140304184210 dot GA17491 at kam dot mff dot cuni dot cz>
On Tue, 4 Mar 2014, Jan Hubicka wrote:
> >
> > 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.
Yeah, I think we should eventually remove that capability.
Now as of the two patches (compute a default link-time optimization
level and this patch, make considering LTO at link-time the default),
they only make sense together (at least the default opt level at
link-time doesn't improve real-world situations without also considering
all links to be possibly -flto).
So the question remains if we want to have both patches at this
stage or if we want to wait with them for 4.10 (we do have the
user-visible change of slim-lto objects by default with 4.9
already).
Thanks,
Richard.
> 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;
> > }
>
>
--
Richard Biener <rguenther@suse.de>
SUSE / SUSE Labs
SUSE LINUX Products GmbH - Nuernberg - AG Nuernberg - HRB 16746
GF: Jeff Hawn, Jennifer Guild, Felix Imend"orffer