[PATCH] gcc-ar: Turn plugin not found case into a warning

Andi Kleen andi@firstfloor.org
Mon Sep 1 16:35:00 GMT 2014


From: Andi Kleen <ak@linux.intel.com>

Only give a warning when gcc-ar/nm/ranlib cannot find the plugin.
In this case do not pass a plugin argument to the wrapped program.

This should make it work on non linker plugin systems, so
that the build system can use it unconditionally.

gcc/:

2014-09-01  Andi Kleen  <ak@linux.intel.com>

	* gcc-ar (main): Only warn when plugin not found.
---
 gcc/gcc-ar.c | 27 ++++++++++++++++-----------
 1 file changed, 16 insertions(+), 11 deletions(-)

diff --git a/gcc/gcc-ar.c b/gcc/gcc-ar.c
index fdff89c..e27ea3b 100644
--- a/gcc/gcc-ar.c
+++ b/gcc/gcc-ar.c
@@ -182,8 +182,8 @@ main (int ac, char **av)
   plugin = find_a_file (&target_path, LTOPLUGINSONAME, R_OK);
   if (!plugin)
     {
-      fprintf (stderr, "%s: Cannot find plugin '%s'\n", av[0], LTOPLUGINSONAME);
-      exit (1);
+      fprintf (stderr, "%s: Warning: Cannot find plugin '%s'\n", av[0], LTOPLUGINSONAME);
+      /* Fall back to not using a plugin.  */
     }
 
   /* Find the wrapped binutils program.  */
@@ -204,15 +204,20 @@ main (int ac, char **av)
     }
 
   /* Create new command line with plugin */
-  nargv = XCNEWVEC (const char *, ac + 4);
-  nargv[0] = exe_name;
-  nargv[1] = "--plugin";
-  nargv[2] = plugin;
-  if (is_ar && av[1] && av[1][0] != '-')
-    av[1] = concat ("-", av[1], NULL);
-  for (k = 1; k < ac; k++)
-    nargv[2 + k] = av[k];
-  nargv[2 + k] = NULL;
+  if (plugin != NULL)
+    {
+      nargv = XCNEWVEC (const char *, ac + 4);
+      nargv[0] = exe_name;
+      nargv[1] = "--plugin";
+      nargv[2] = plugin;
+      if (is_ar && av[1] && av[1][0] != '-')
+        av[1] = concat ("-", av[1], NULL);
+      for (k = 1; k < ac; k++)
+        nargv[2 + k] = av[k];
+      nargv[2 + k] = NULL;
+    }
+  else
+    nargv = CONST_CAST2 (const char **, char **, av);
 
   /* Run utility */
   /* ??? the const is misplaced in pex_one's argv? */
-- 
2.1.0



More information about the Gcc-patches mailing list