This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [lto][patch] Use @args when calling lto-wrapper
- From: Rafael Espindola <espindola at google dot com>
- To: Andrew Pinski <pinskia at gmail dot com>
- Cc: GCC Patches <gcc-patches at gcc dot gnu dot org>
- Date: Wed, 4 Feb 2009 15:19:33 +0000
- Subject: Re: [lto][patch] Use @args when calling lto-wrapper
- References: <38a0d8450901290457y547be78cgb108d26f8a5f1aa1@mail.gmail.com> <38a0d8450901290459n2ca61c6h1227ed4a55430bdf@mail.gmail.com> <de8d50360901291131v6e53a1dkbfe87579a22a0d97@mail.gmail.com>
> 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");