]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
add -ltrans-objects lto-plugin debug option
authorRichard Biener <rguenther@suse.de>
Tue, 22 Jun 2021 06:43:15 +0000 (08:43 +0200)
committerRichard Biener <rguenther@suse.de>
Fri, 25 Jun 2021 06:48:52 +0000 (08:48 +0200)
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.

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

index ff79f4ac462e82aa76569580b9a1ef521697dae6..6ab9822f36910bea1ca5ecc2330e6bc9a5f3ae10 100644 (file)
@@ -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;