Message ID | 1292503308-11258-1-git-send-email-andi@firstfloor.org |
---|---|
State | New |
Headers | show |
On Thu, Dec 16, 2010 at 1:41 PM, Andi Kleen <andi@firstfloor.org> wrote: > From: Andi Kleen <ak@linux.intel.com> > > This fixes PR lto/46905. > > It's sometimes convenient in large Makefiles to globally enable LTO > in CFLAGS, but disable it again for specific files. The simplest > way to do that is appending -fno-lto, but that didn't work. > Add explicit code to handle this case. > > Passes bootstrap and full test on x86_64-linux. Ok? Do you really need the common.opt and opts.c hunks? > gcc/ > > 2010-12-15 Andi Kleen <ak@linux.intel.com> > > PR lto/46905 > * collect2.c (main): Handle -fno-lto. > * common.opt (fno-lto): Add. > * opts.c (common_handle_option): Handle OPT_fno_lto. > --- > gcc/collect2.c | 2 ++ > gcc/common.opt | 4 ++++ > gcc/opts.c | 4 ++++ > 3 files changed, 10 insertions(+), 0 deletions(-) > > diff --git a/gcc/collect2.c b/gcc/collect2.c > index 89b21d5..77f794f 100644 > --- a/gcc/collect2.c > +++ b/gcc/collect2.c > @@ -1211,6 +1211,8 @@ main (int argc, char **argv) > 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; > diff --git a/gcc/common.opt b/gcc/common.opt > index 32df6fc..e6cb5e4 100644 > --- a/gcc/common.opt > +++ b/gcc/common.opt > @@ -1302,6 +1302,10 @@ floop-optimize > Common Ignore > Does nothing. Preserved for backward compatibility. > > +fno-lto > +Common RejectNegative > +Disable link-time optimization > + > flto > Common > Enable link-time optimization. > diff --git a/gcc/opts.c b/gcc/opts.c > index 2c8e767..fc6f272 100644 > --- a/gcc/opts.c > +++ b/gcc/opts.c > @@ -1673,6 +1673,10 @@ common_handle_option (struct gcc_options *opts, > opts->x_flag_lto = ""; > break; > > + case OPT_fno_lto: > + opts->x_flag_lto = NULL; > + break; > + > case OPT_w: > dc->dc_inhibit_warnings = true; > break; > -- > 1.7.1 > >
Richard Guenther <richard.guenther@gmail.com> writes: > On Thu, Dec 16, 2010 at 1:41 PM, Andi Kleen <andi@firstfloor.org> wrote: >> From: Andi Kleen <ak@linux.intel.com> >> >> This fixes PR lto/46905. >> >> It's sometimes convenient in large Makefiles to globally enable LTO >> in CFLAGS, but disable it again for specific files. The simplest >> way to do that is appending -fno-lto, but that didn't work. >> Add explicit code to handle this case. >> >> Passes bootstrap and full test on x86_64-linux. Ok? > > Do you really need the common.opt and opts.c hunks? Yes. The previous state without them didn't work. I also tried to do it without opts.c, but setting an 0 initialization value for the -fno-lto entry, but that didn't work either. -Andi
On Thu, Dec 16, 2010 at 2:20 PM, Andi Kleen <andi@firstfloor.org> wrote: > Richard Guenther <richard.guenther@gmail.com> writes: > >> On Thu, Dec 16, 2010 at 1:41 PM, Andi Kleen <andi@firstfloor.org> wrote: >>> From: Andi Kleen <ak@linux.intel.com> >>> >>> This fixes PR lto/46905. >>> >>> It's sometimes convenient in large Makefiles to globally enable LTO >>> in CFLAGS, but disable it again for specific files. The simplest >>> way to do that is appending -fno-lto, but that didn't work. >>> Add explicit code to handle this case. >>> >>> Passes bootstrap and full test on x86_64-linux. Ok? >> >> Do you really need the common.opt and opts.c hunks? > > Yes. The previous state without them didn't work. > > I also tried to do it without opts.c, but setting an 0 initialization > value for the -fno-lto entry, but that didn't work either. Huh, that's strange. Joseph, do you have any idea why? Is it because of how flags get passed to collect2? Richard. > -Andi > > -- > ak@linux.intel.com -- Speaking for myself only. >
> On Thu, Dec 16, 2010 at 2:20 PM, Andi Kleen <andi@firstfloor.org> wrote: > > Richard Guenther <richard.guenther@gmail.com> writes: > > > >> On Thu, Dec 16, 2010 at 1:41 PM, Andi Kleen <andi@firstfloor.org> wrote: > >>> From: Andi Kleen <ak@linux.intel.com> > >>> > >>> This fixes PR lto/46905. > >>> > >>> It's sometimes convenient in large Makefiles to globally enable LTO > >>> in CFLAGS, but disable it again for specific files. The simplest > >>> way to do that is appending -fno-lto, but that didn't work. > >>> Add explicit code to handle this case. > >>> > >>> Passes bootstrap and full test on x86_64-linux. Ok? > >> > >> Do you really need the common.opt and opts.c hunks? > > > > Yes. The previous state without them didn't work. > > > > I also tried to do it without opts.c, but setting an 0 initialization > > value for the -fno-lto entry, but that didn't work either. > > Huh, that's strange. Joseph, do you have any idea why? Is it because > of how flags get passed to collect2? I think it is because -flto is not switch but accept string argument? Honza > > Richard. > > > -Andi > > > > -- > > ak@linux.intel.com -- Speaking for myself only. > >
On Thu, 16 Dec 2010, Richard Guenther wrote: > > I also tried to do it without opts.c, but setting an 0 initialization > > value for the -fno-lto entry, but that didn't work either. > > Huh, that's strange. Joseph, do you have any idea why? Is it because > of how flags get passed to collect2? Having both flto and fno-lto in common.opt seems dodgy. Try making the code in opts.c that handles OPT_flto check "value" (value == 0 meaning -fno-lto) instead.
diff --git a/gcc/collect2.c b/gcc/collect2.c index 89b21d5..77f794f 100644 --- a/gcc/collect2.c +++ b/gcc/collect2.c @@ -1211,6 +1211,8 @@ main (int argc, char **argv) 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; diff --git a/gcc/common.opt b/gcc/common.opt index 32df6fc..e6cb5e4 100644 --- a/gcc/common.opt +++ b/gcc/common.opt @@ -1302,6 +1302,10 @@ floop-optimize Common Ignore Does nothing. Preserved for backward compatibility. +fno-lto +Common RejectNegative +Disable link-time optimization + flto Common Enable link-time optimization. diff --git a/gcc/opts.c b/gcc/opts.c index 2c8e767..fc6f272 100644 --- a/gcc/opts.c +++ b/gcc/opts.c @@ -1673,6 +1673,10 @@ common_handle_option (struct gcc_options *opts, opts->x_flag_lto = ""; break; + case OPT_fno_lto: + opts->x_flag_lto = NULL; + break; + case OPT_w: dc->dc_inhibit_warnings = true; break;
From: Andi Kleen <ak@linux.intel.com> This fixes PR lto/46905. It's sometimes convenient in large Makefiles to globally enable LTO in CFLAGS, but disable it again for specific files. The simplest way to do that is appending -fno-lto, but that didn't work. Add explicit code to handle this case. Passes bootstrap and full test on x86_64-linux. Ok? gcc/ 2010-12-15 Andi Kleen <ak@linux.intel.com> PR lto/46905 * collect2.c (main): Handle -fno-lto. * common.opt (fno-lto): Add. * opts.c (common_handle_option): Handle OPT_fno_lto. --- gcc/collect2.c | 2 ++ gcc/common.opt | 4 ++++ gcc/opts.c | 4 ++++ 3 files changed, 10 insertions(+), 0 deletions(-)