This is the mail archive of the
binutils@sourceware.org
mailing list for the binutils project.
PATCH: Add -plugin-save-temps
- From: "H.J. Lu" <hongjiu dot lu at intel dot com>
- To: binutils at sourceware dot org
- Date: Sun, 15 May 2011 14:15:03 -0700
- Subject: PATCH: Add -plugin-save-temps
- Reply-to: "H.J. Lu" <hjl dot tools at gmail dot com>
Hi,
This patch adds -plugin-save-temps, which can be used to debug LTO
problems.
H.J.
---
2011-05-15 H.J. Lu <hongjiu.lu@intel.com>
* lexsup.c (option_values): Add OPTION_PLUGIN_SAVE_TEMPS.
(ld_options): Add -plugin-save-temps.
(parse_args): Handle OPTION_PLUGIN_SAVE_TEMPS.
* plugin.c (plugin_save_temps): New.
(plugin_call_cleanup): Don't call plugin cleanup_handler if
plugin_save_temps is true.
* plugin.h (plugin_save_temps): New.
diff --git a/ld/lexsup.c b/ld/lexsup.c
index 4f6a77b..6750356 100644
--- a/ld/lexsup.c
+++ b/ld/lexsup.c
@@ -173,6 +173,7 @@ enum option_values
#ifdef ENABLE_PLUGINS
OPTION_PLUGIN,
OPTION_PLUGIN_OPT,
+ OPTION_PLUGIN_SAVE_TEMPS,
#endif /* ENABLE_PLUGINS */
OPTION_DEFAULT_SCRIPT,
};
@@ -283,6 +284,9 @@ static const struct ld_option ld_options[] =
'\0', N_("PLUGIN"), N_("Load named plugin"), ONE_DASH },
{ {"plugin-opt", required_argument, NULL, OPTION_PLUGIN_OPT},
'\0', N_("ARG"), N_("Send arg to last-loaded plugin"), ONE_DASH },
+ { {"plugin-save-temps", no_argument, NULL, OPTION_PLUGIN_SAVE_TEMPS},
+ '\0', NULL, N_("Store plugin intermediate files permanently"),
+ ONE_DASH },
{ {"flto", optional_argument, NULL, OPTION_IGNORE},
'\0', NULL, N_("Ignored for GCC LTO option compatibility"),
ONE_DASH },
@@ -1069,6 +1073,9 @@ parse_args (unsigned argc, char **argv)
if (plugin_opt_plugin_arg (optarg))
einfo(_("%P%F: bad -plugin-opt option\n"));
break;
+ case OPTION_PLUGIN_SAVE_TEMPS:
+ plugin_save_temps = TRUE;
+ break;
#endif /* ENABLE_PLUGINS */
case 'q':
link_info.emitrelocations = TRUE;
diff --git a/ld/plugin.c b/ld/plugin.c
index 9c09387..d3a4023 100644
--- a/ld/plugin.c
+++ b/ld/plugin.c
@@ -39,6 +39,9 @@
/* Report plugin symbols. */
bfd_boolean report_plugin_symbols;
+/* Store plugin intermediate files permanently. */
+bfd_boolean plugin_save_temps;
+
/* The suffix to append to the name of the real (claimed) object file
when generating a dummy BFD to hold the IR symbols sent from the
plugin. For cosmetic use only; appears in maps, crefs etc. */
@@ -895,13 +898,16 @@ plugin_call_cleanup (void)
{
if (curplug->cleanup_handler && !curplug->cleanup_done)
{
- enum ld_plugin_status rv;
- curplug->cleanup_done = TRUE;
- called_plugin = curplug;
- rv = (*curplug->cleanup_handler) ();
- called_plugin = NULL;
- if (rv != LDPS_OK)
- set_plugin_error (curplug->name);
+ if (!plugin_save_temps)
+ {
+ enum ld_plugin_status rv;
+ curplug->cleanup_done = TRUE;
+ called_plugin = curplug;
+ rv = (*curplug->cleanup_handler) ();
+ called_plugin = NULL;
+ if (rv != LDPS_OK)
+ set_plugin_error (curplug->name);
+ }
dlclose (curplug->dlhandle);
}
curplug = curplug->next;
diff --git a/ld/plugin.h b/ld/plugin.h
index ee29b7c..96b3264 100644
--- a/ld/plugin.h
+++ b/ld/plugin.h
@@ -24,6 +24,9 @@
/* Report plugin symbols. */
extern bfd_boolean report_plugin_symbols;
+/* Store plugin intermediate files permanently. */
+extern bfd_boolean plugin_save_temps;
+
/* Set at all symbols read time, to avoid recursively offering the plugin
its own newly-added input files and libs to claim. */
extern bfd_boolean no_more_claiming;