[PATCH] Handle AR_NM_RANLIB_DEFAULT_PLUGIN environment variable
Markus Trippelsdorf
markus@trippelsdorf.de
Wed Sep 19 10:23:00 GMT 2012
This patch introduces a new environment variable:
AR_NM_RANLIB_DEFAULT_PLUGIN
It allows one to easily switch from one LTO plugin to another without
the need to use wrappers (scripts, gcc-ar, etc.).
(For example if one wants to build a project with clang using link time
optimizations one simply points it to /usr/local/lib/LLVMgold.so.
If one wants to use gcc with slim LTO on simply points it to e.g.:
/usr/libexec/gcc/x86_64-pc-linux-gnu/4.8.0/liblto_plugin.so)
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-19 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..6fe2ad3 100644
--- a/binutils/ar.c
+++ b/binutils/ar.c
@@ -675,6 +675,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
expandargv (&argc, &argv);
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
More information about the Binutils
mailing list