public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Richard Biener <rguenther@suse.de>
To: gcc-patches@gcc.gnu.org
Cc: hubicka@ucw.cz, jakub@redhat.com, hjl.tools@gmail.com
Subject: [PATCH] add -ltrans-objects lto-plugin debug option
Date: Tue, 22 Jun 2021 08:49:49 +0200 (CEST)	[thread overview]
Message-ID: <o51psp2q-3o96-o5r-213r-n7p6rr2n2on2@fhfr.qr> (raw)

This adds a -ltrans-objects option to lto-plugin that by-passes
lto-wrapper invocation and instead feeds LD the final LTRANS objects
directly from the response file given as argument to the option.
This allows LD issues involving the linker-plugin path to be
debugged in an easier way with just the IR objects (their symtab)
and the LTRANS objects as testcase.

I've tested the path re-building stage2 build/genmatch from an
LTO bootstrap and got a bit-identical executable by adding
-plugin-opt=-ltrans-objects=y to the original collect2 invocation,
seeding y with the final objects as printed by building genmatch
with -save-temps -v.

Bootstrapped and tested on x86_64-unknown-linux-gnu.

OK?

2021-06-22  Richard Biener  <rguenther@suse.de>

lto-plugin/
	* lto-plugin.c (ltrans_objects): New global.
	(all_symbols_read_handler): If -ltrans-objects was specified,
	add the output files from the specified file directly.
	(process_option): Handle -ltrans-objects.
---
 lto-plugin/lto-plugin.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/lto-plugin/lto-plugin.c b/lto-plugin/lto-plugin.c
index ff79f4ac462..6ab9822f369 100644
--- a/lto-plugin/lto-plugin.c
+++ b/lto-plugin/lto-plugin.c
@@ -190,6 +190,8 @@ static int lto_wrapper_num_args;
 static char **pass_through_items = NULL;
 static unsigned int num_pass_through_items;
 
+static char *ltrans_objects = NULL;
+
 static bool debug;
 static bool save_temps;
 static bool verbose;
@@ -739,6 +741,14 @@ all_symbols_read_handler (void)
       return LDPS_OK;
     }
 
+  if (ltrans_objects)
+    {
+      FILE *objs = fopen (ltrans_objects, "r");
+      add_output_files (objs);
+      fclose (objs);
+      return LDPS_OK;
+    }
+
   lto_argv = (char **) xcalloc (sizeof (char *), num_lto_args);
   lto_arg_ptr = (const char **) lto_argv;
   assert (lto_wrapper_argv);
@@ -1345,6 +1355,8 @@ process_option (const char *option)
 	  break;
 	}
     }
+  else if (startswith (option, "-ltrans-objects="))
+    ltrans_objects = xstrdup (option + strlen ("-ltrans-objects="));
   else
     {
       int size;
-- 
2.26.2

             reply	other threads:[~2021-06-22  6:49 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-22  6:49 Richard Biener [this message]
2021-06-24 14:31 ` Jeff Law

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=o51psp2q-3o96-o5r-213r-n7p6rr2n2on2@fhfr.qr \
    --to=rguenther@suse.de \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=hjl.tools@gmail.com \
    --cc=hubicka@ucw.cz \
    --cc=jakub@redhat.com \
    /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).