diff mbox

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

Message ID 1409589225-11481-1-git-send-email-andi@firstfloor.org
State New
Headers show

Commit Message

Andi Kleen Sept. 1, 2014, 4:33 p.m. UTC
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(-)

Comments

Richard Biener Sept. 2, 2014, 7:31 a.m. UTC | #1
On Mon, Sep 1, 2014 at 6:33 PM, Andi Kleen <andi@firstfloor.org> wrote:
> 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.

Hmm, maybe conditionalize the error on HAVE_LTO_PLUGIN == 2
instead?  And not warn for HAVE_LTO_PLUGIN == 0 at all?

Richard.

> 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
>
diff mbox

Patch

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? */