This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC 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]

Re: [lto][patch] Use @args when calling lto-wrapper


> There is already a function in libiberty which is able to write out
> the @-file (writeargv), I think you should use that instead of doing
> it yourself.  writeargv is able to handle arguments which have white
> spaces and quotes.

The attached patch changes the plugin to use it.


> Also lto-plugin should use the pex interface instead of fork/execv.

What is the advantage for the simple case of just one subcommand? The plugin
only works on ELF systems...


> Thanks,
> Andrew Pinski
>

2009-02-04  Rafael Avila de Espindola  <espindola@google.com>

	* lto-plugin.c (exec_lto_wrapper): Use writeargv.

Cheers,
-- 
Rafael Avila de Espindola

Google | Gordon House | Barrow Street | Dublin 4 | Ireland
Registered in Dublin, Ireland | Registration Number: 368047
diff --git a/lto-plugin/lto-plugin.c b/lto-plugin/lto-plugin.c
index c42cc85..d1e0b9a 100644
--- a/lto-plugin/lto-plugin.c
+++ b/lto-plugin/lto-plugin.c
@@ -356,7 +356,7 @@ add_output_files (int fd)
    argument list. */
 
 static void
-exec_lto_wrapper (char *const argv[])
+exec_lto_wrapper (char *argv[])
 {
   int pipefd[2];
   int pid;
@@ -366,7 +366,6 @@ exec_lto_wrapper (char *const argv[])
   char *at_args;
   char *args_name;
   FILE *args;
-  int i;
   char *new_argv[3];
 
   /* Write argv to a file to avoid a command line that is too long. */
@@ -376,11 +375,9 @@ exec_lto_wrapper (char *const argv[])
   args_name = at_args + 1;
   args = fopen (args_name, "w");
   assert (args);
-  for (i = 1; argv[i]; i++)
-    {
-      t = fprintf(args, "%s\n", argv[i]);
-      assert (t >= 0);
-    }
+
+  t = writeargv (&argv[1], args);
+  assert (t == 0);
   t = fclose (args);
   assert (t == 0);
 
@@ -390,6 +387,7 @@ exec_lto_wrapper (char *const argv[])
 
   if (debug)
     {
+      int i;
       for (i = 0; new_argv[i]; i++)
 	fprintf (stderr, "%s ", new_argv[i]);
       fprintf (stderr, "\n");

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