public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* Re: [PATCH] lto/114655 - -flto=4 at link time doesn't override -flto=auto at compile time
       [not found] <20240409124949.31FE93858289@sourceware.org>
@ 2024-04-09 12:52 ` Jan Hubicka
  2024-04-09 12:56   ` Richard Biener
  0 siblings, 1 reply; 4+ messages in thread
From: Jan Hubicka @ 2024-04-09 12:52 UTC (permalink / raw)
  To: Richard Biener; +Cc: gcc-patches, Jakub Jelinek

> The following adjusts -flto option processing in lto-wrapper to have
> link-time -flto override any compile time setting.
> 
> LTO-boostrapped on x86_64-unknown-linux-gnu, testing in progress.
> 
> OK for trunk and branches?  GCC 11 seems to be unaffected by this.
> 
> Thanks,
> Richard.
> 
> 	PR lto/114655
> 	* lto-wrapper.cc (merge_flto_options): Add force argument.
> 	(merge_and_complain): Do not force here.
> 	(run_gcc): But here to make the link-time -flto option override
> 	any compile-time one.
Looks good to me.  I am actually surprised we propagate -flto settings
from compile time at all.  I guess I never tried it since I never
assumed it to work :)

Honza

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] lto/114655 - -flto=4 at link time doesn't override -flto=auto at compile time
  2024-04-09 12:52 ` [PATCH] lto/114655 - -flto=4 at link time doesn't override -flto=auto at compile time Jan Hubicka
@ 2024-04-09 12:56   ` Richard Biener
  0 siblings, 0 replies; 4+ messages in thread
From: Richard Biener @ 2024-04-09 12:56 UTC (permalink / raw)
  To: Jan Hubicka; +Cc: gcc-patches, Jakub Jelinek

On Tue, 9 Apr 2024, Jan Hubicka wrote:

> > The following adjusts -flto option processing in lto-wrapper to have
> > link-time -flto override any compile time setting.
> > 
> > LTO-boostrapped on x86_64-unknown-linux-gnu, testing in progress.
> > 
> > OK for trunk and branches?  GCC 11 seems to be unaffected by this.
> > 
> > Thanks,
> > Richard.
> > 
> > 	PR lto/114655
> > 	* lto-wrapper.cc (merge_flto_options): Add force argument.
> > 	(merge_and_complain): Do not force here.
> > 	(run_gcc): But here to make the link-time -flto option override
> > 	any compile-time one.
> Looks good to me.  I am actually surprised we propagate -flto settings
> from compile time at all.  I guess I never tried it since I never
> assumed it to work :)

We do magic now ;)  I think this was done because while people manage
to use CFLAGS=-flto they eventually fail to adjust LDFLAGS and without
plugin auto-loading you won't get LTO and in particular not -flto=auto.

I checked that it now works as expected - fortunately -v now displays
the make invocation command, so it was easy to verify.

Richard.

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] lto/114655 - -flto=4 at link time doesn't override -flto=auto at compile time
       [not found] <49506.124040908491001343@us-mta-292.us.mimecast.lan>
@ 2024-04-09 12:51 ` Jakub Jelinek
  0 siblings, 0 replies; 4+ messages in thread
From: Jakub Jelinek @ 2024-04-09 12:51 UTC (permalink / raw)
  To: Richard Biener; +Cc: gcc-patches

On Tue, Apr 09, 2024 at 02:49:09PM +0200, Richard Biener wrote:
> The following adjusts -flto option processing in lto-wrapper to have
> link-time -flto override any compile time setting.
> 
> LTO-boostrapped on x86_64-unknown-linux-gnu, testing in progress.
> 
> OK for trunk and branches?  GCC 11 seems to be unaffected by this.
> 
> Thanks,
> Richard.
> 
> 	PR lto/114655
> 	* lto-wrapper.cc (merge_flto_options): Add force argument.
> 	(merge_and_complain): Do not force here.
> 	(run_gcc): But here to make the link-time -flto option override
> 	any compile-time one.

Ok.

	Jakub


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH] lto/114655 - -flto=4 at link time doesn't override -flto=auto at compile time
@ 2024-04-09 12:49 Richard Biener
  0 siblings, 0 replies; 4+ messages in thread
From: Richard Biener @ 2024-04-09 12:49 UTC (permalink / raw)
  To: gcc-patches; +Cc: Jakub Jelinek

The following adjusts -flto option processing in lto-wrapper to have
link-time -flto override any compile time setting.

LTO-boostrapped on x86_64-unknown-linux-gnu, testing in progress.

OK for trunk and branches?  GCC 11 seems to be unaffected by this.

Thanks,
Richard.

	PR lto/114655
	* lto-wrapper.cc (merge_flto_options): Add force argument.
	(merge_and_complain): Do not force here.
	(run_gcc): But here to make the link-time -flto option override
	any compile-time one.
---
 gcc/lto-wrapper.cc | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/gcc/lto-wrapper.cc b/gcc/lto-wrapper.cc
index 610594cdc2b..02579951569 100644
--- a/gcc/lto-wrapper.cc
+++ b/gcc/lto-wrapper.cc
@@ -218,15 +218,18 @@ find_option (vec<cl_decoded_option> &options, cl_decoded_option *option)
   return find_option (options, option->opt_index);
 }
 
-/* Merge -flto FOPTION into vector of DECODED_OPTIONS.  */
+/* Merge -flto FOPTION into vector of DECODED_OPTIONS.  If FORCE is true
+   then FOPTION overrides previous settings.  */
 
 static void
 merge_flto_options (vec<cl_decoded_option> &decoded_options,
-		    cl_decoded_option *foption)
+		    cl_decoded_option *foption, bool force)
 {
   int existing_opt = find_option (decoded_options, foption);
   if (existing_opt == -1)
     decoded_options.safe_push (*foption);
+  else if (force)
+    decoded_options[existing_opt].arg = foption->arg;
   else
     {
       if (strcmp (foption->arg, decoded_options[existing_opt].arg) != 0)
@@ -493,7 +496,7 @@ merge_and_complain (vec<cl_decoded_option> &decoded_options,
 	  break;
 
 	case OPT_flto_:
-	  merge_flto_options (decoded_options, foption);
+	  merge_flto_options (decoded_options, foption, false);
 	  break;
 	}
     }
@@ -1550,8 +1553,8 @@ run_gcc (unsigned argc, char *argv[])
 	  break;
 
 	case OPT_flto_:
-	  /* Merge linker -flto= option with what we have in IL files.  */
-	  merge_flto_options (fdecoded_options, option);
+	  /* Override IL file settings with a linker -flto= option.  */
+	  merge_flto_options (fdecoded_options, option, true);
 	  if (strcmp (option->arg, "jobserver") == 0)
 	    jobserver_requested = true;
 	  break;
-- 
2.35.3

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-04-09 12:56 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20240409124949.31FE93858289@sourceware.org>
2024-04-09 12:52 ` [PATCH] lto/114655 - -flto=4 at link time doesn't override -flto=auto at compile time Jan Hubicka
2024-04-09 12:56   ` Richard Biener
     [not found] <49506.124040908491001343@us-mta-292.us.mimecast.lan>
2024-04-09 12:51 ` Jakub Jelinek
2024-04-09 12:49 Richard Biener

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).