public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Richard Biener <rguenth@gcc.gnu.org>
To: gcc-cvs@gcc.gnu.org
Subject: [gcc r14-9872] lto/114655 - -flto=4 at link time doesn't override -flto=auto at compile time
Date: Tue,  9 Apr 2024 13:30:12 +0000 (GMT)	[thread overview]
Message-ID: <20240409133012.140AE3857C4F@sourceware.org> (raw)

https://gcc.gnu.org/g:32fb04adae90a0ea68e64e8fc3cb04b613b2e9f3

commit r14-9872-g32fb04adae90a0ea68e64e8fc3cb04b613b2e9f3
Author: Richard Biener <rguenther@suse.de>
Date:   Tue Apr 9 14:25:57 2024 +0200

    lto/114655 - -flto=4 at link time doesn't override -flto=auto at compile time
    
    The following adjusts -flto option processing in lto-wrapper to have
    link-time -flto override any compile time setting.
    
            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.

Diff:
---
 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;

                 reply	other threads:[~2024-04-09 13:30 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240409133012.140AE3857C4F@sourceware.org \
    --to=rguenth@gcc.gnu.org \
    --cc=gcc-cvs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).