On Jan 16, 2020, Alexandre Oliva <ol...@adacore.com> wrote:

> On Jan  9, 2020, Alexandre Oliva <ol...@adacore.com> wrote:
>> On Jan  9, 2020, Richard Biener <rguent...@suse.de> wrote:
>>> Did I miss the actual (non-documentation) patch?

>> No, I didn't post it.  It's kind of big, and only yesterday did I get it
>> to work as expected and now extensively documented, passing all of the
>> extensive testsuite I wrote for it.

> Here it is, at last, regstrapped on x86_64-linux-gnu.  Ok to install?

And here's a followup that fixes a limitation (bug?) in libiberty that
was hit when I attempted a last-minute simplification in lto-wrapper.

Regstrapped separately on x86_64-linux-gnu.  Ok to install?


[libiberty] output empty args as a pair of quotes

From: Alexandre Oliva <ol...@adacore.com>

writeargv writes out empty arguments in a way that expandargv skips
them instead of preserving them.  Fixed by writing out a pair of
quotes for them.

This enables lto-wrapper to pass down an empty string, as desired.


for  libiberty/ChangeLog

        * argv.c (writeargv): Output empty args as "".

for  gcc/ChangeLog

        * lto-wrapper.c (run_gcc): Use an empty string for -dumpdir.
---
 gcc/lto-wrapper.c |    5 +----
 libiberty/argv.c  |    8 ++++++++
 2 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/gcc/lto-wrapper.c b/gcc/lto-wrapper.c
index ed076e3..aa71f1e 100644
--- a/gcc/lto-wrapper.c
+++ b/gcc/lto-wrapper.c
@@ -1482,10 +1482,7 @@ run_gcc (unsigned argc, char *argv[])
   if (!incoming_dumppfx)
     {
       obstack_ptr_grow (&argv_obstack, "-dumpdir");
-      /* An empty string would do, if only writeargv would write it
-        out in a way that would not be skipped by expandargv and
-        buildargv.  */
-      obstack_ptr_grow (&argv_obstack, current_dir);
+      obstack_ptr_grow (&argv_obstack, "");
     }
   obstack_ptr_grow (&argv_obstack, "-dumpbase");
 
diff --git a/libiberty/argv.c b/libiberty/argv.c
index 8c9794db..6a72208 100644
--- a/libiberty/argv.c
+++ b/libiberty/argv.c
@@ -327,6 +327,14 @@ writeargv (char * const *argv, FILE *f)
           arg++;
         }
 
+      /* Write out a pair of quotes for an empty argument.  */
+      if (arg == *argv)
+       if (EOF == fputs ("\"\"", f))
+         {
+           status = 1;
+           goto done;
+         }
+
       if (EOF == fputc ('\n', f))
         {
           status = 1;


-- 
Alexandre Oliva, freedom fighter   he/him   https://FSFLA.org/blogs/lxo
Free Software Evangelist           Stallman was right, but he's left :(
GNU Toolchain Engineer    FSMatrix: It was he who freed the first of us
FSF & FSFLA board member                The Savior shall return (true);

Reply via email to