This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Handle AR_NM_RANLIB_DEFAULT_PLUGIN environment variable


On 2012.09.15 at 15:47 -0700, Ian Lance Taylor wrote:
> On Fri, Sep 14, 2012 at 9:53 AM, Markus Trippelsdorf
> <markus@trippelsdorf.de> wrote:
> > Wouldn't it make sense to add a configure option that enables the plugin
> > by default for ar,nm and ranlib? The path to the plugin could be
> > specified at configure time. That would allow one to eventually get rid
> > of the various wrappers (gcc-ar, etc.) that are currently in use.
> 
> In the usual course of events, the binutils are built first, then GCC
> is built.  So configuring the binutils to use a GCC plugin would mean
> building them once, building GCC, then building them again.  That
> doesn't seem to make much sense to me.

OK.

> What I think might make sense would be to have the binutils support an
> environment variable for a default plugin.  If the environment
> variable is set and no -plugin option is used, the plugin named by the
> environment variable would automatically be used.

The following patch implements this idea. An explicit "--plugin"
command line switch overrides the environment variable (so that existing
wrappers keep functioning).

If this looks acceptable it would be nice if someone could commit this,
because I don't have access.
Thanks.

2012-09-16  Markus Trippelsdorf  <markus@trippelsdorf.de>

binutils/
	* ar.c (decode_options): Handle AR_NM_RANLIB_DEFAULT_PLUGIN
	environment variable.
	(ranlib_main): Likewise.
	* nm.c (main): Likewise.


diff --git a/binutils/ar.c b/binutils/ar.c
index aceb9d1..002ccf8 100644
--- a/binutils/ar.c
+++ b/binutils/ar.c
@@ -61,7 +61,7 @@ static void write_archive (bfd *);
 static int  ranlib_only (const char *archname);
 static int  ranlib_touch (const char *archname);
 static void usage (int);
-
+
 /** Globals and flags.  */
 
 static int mri_mode;
@@ -453,6 +453,16 @@ decode_options (int argc, char **argv)
       argv = new_argv;
     }
 
+#if BFD_SUPPORTS_PLUGINS
+  char *plugin_path = getenv ("AR_NM_RANLIB_DEFAULT_PLUGIN");
+
+  if (plugin_path)
+    {
+      plugin_target = "plugin";
+      bfd_plugin_set_plugin (plugin_path);
+    }
+#endif
+
   while ((c = getopt_long (argc, argv, "hdmpqrtxlcoVsSuvabiMNfPTDU",
 			   long_options, NULL)) != EOF)
     {
@@ -591,6 +601,16 @@ ranlib_main (int argc, char **argv)
   bfd_boolean touch = FALSE;
   int c;
 
+#if BFD_SUPPORTS_PLUGINS
+  char *plugin_path = getenv ("AR_NM_RANLIB_DEFAULT_PLUGIN");
+
+  if (plugin_path)
+    {
+      plugin_target = "plugin";
+      bfd_plugin_set_plugin (plugin_path);
+    }
+#endif
+
   while ((c = getopt_long (argc, argv, "DhHUvVt", long_options, NULL)) != EOF)
     {
       switch (c)
diff --git a/binutils/nm.c b/binutils/nm.c
index ad38e27..f1d2aab 100644
--- a/binutils/nm.c
+++ b/binutils/nm.c
@@ -1536,6 +1536,13 @@ main (int argc, char **argv)
   xmalloc_set_program_name (program_name);
 #if BFD_SUPPORTS_PLUGINS
   bfd_plugin_set_program_name (program_name);
+  char *plugin_path = getenv ("AR_NM_RANLIB_DEFAULT_PLUGIN");
+
+  if (plugin_path)
+    {
+      plugin_target = "plugin";
+      bfd_plugin_set_plugin (plugin_path);
+    }
 #endif
 
   START_PROGRESS (program_name, 0);
-- 
Markus


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]