summaryrefslogtreecommitdiffstats
path: root/lto-plugin
diff options
context:
space:
mode:
authorRichard Biener <rguenther@suse.de>2021-06-22 08:43:15 +0200
committerRichard Biener <rguenther@suse.de>2021-06-25 08:48:52 +0200
commitc6c7ac0499c722ad03259013d6dc50e585a71860 (patch)
treebf89dc9925462e9eb0ab94e058075969483aca8b /lto-plugin
parenttestsuite: avoid no-stack-protector-attr-3 fail on mips*-*-* (diff)
downloadgcc-c6c7ac0499c722ad03259013d6dc50e585a71860.tar.gz
gcc-c6c7ac0499c722ad03259013d6dc50e585a71860.tar.bz2
gcc-c6c7ac0499c722ad03259013d6dc50e585a71860.tar.xz
add -ltrans-objects lto-plugin debug option
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.
Diffstat (limited to 'lto-plugin')
-rw-r--r--lto-plugin/lto-plugin.c12
1 files changed, 12 insertions, 0 deletions
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;
190static char **pass_through_items = NULL; 190static char **pass_through_items = NULL;
191static unsigned int num_pass_through_items; 191static unsigned int num_pass_through_items;
192 192
193static char *ltrans_objects = NULL;
194
193static bool debug; 195static bool debug;
194static bool save_temps; 196static bool save_temps;
195static bool verbose; 197static bool verbose;
@@ -739,6 +741,14 @@ all_symbols_read_handler (void)
739 return LDPS_OK; 741 return LDPS_OK;
740 } 742 }
741 743
744 if (ltrans_objects)
745 {
746 FILE *objs = fopen (ltrans_objects, "r");
747 add_output_files (objs);
748 fclose (objs);
749 return LDPS_OK;
750 }
751
742 lto_argv = (char **) xcalloc (sizeof (char *), num_lto_args); 752 lto_argv = (char **) xcalloc (sizeof (char *), num_lto_args);
743 lto_arg_ptr = (const char **) lto_argv; 753 lto_arg_ptr = (const char **) lto_argv;
744 assert (lto_wrapper_argv); 754 assert (lto_wrapper_argv);
@@ -1345,6 +1355,8 @@ process_option (const char *option)
1345 break; 1355 break;
1346 } 1356 }
1347 } 1357 }
1358 else if (startswith (option, "-ltrans-objects="))
1359 ltrans_objects = xstrdup (option + strlen ("-ltrans-objects="));
1348 else 1360 else
1349 { 1361 {
1350 int size; 1362 int size;