On Tue, 6 Sep 2016, Markus Trippelsdorf wrote:

> On 2016.09.06 at 14:26 +0200, Richard Biener wrote:
> > On Tue, 6 Sep 2016, Markus Trippelsdorf wrote:
> > 
> > > On 2016.09.06 at 13:17 +0200, Richard Biener wrote:
> > > > 
> > > > The following is an updated patch, mainly stripped out old unnecessary
> > > > cruft and some fixes for an issue that arised when LTOing Firefox.
> > > 
> > > One minor issue that I've noticed is that the patch generates a lot of
> > > empty *debugobj* files in $TMPDIR, e.g.:
> > > 
> > >  % echo 'int main(){}' | g++ -flto -o /dev/null-x c++ -
> > >  % ls -l $TMPDIR
> > > total 0
> > > -rw-------. 1 trippels trippels 0 Sep  6 12:11 ccenD5Tcdebugobj
> > > -rw-------. 1 trippels trippels 0 Sep  6 12:11 ccXzvE4udebugobjtem
> > 
> > Ah, make_temp_file actually _creates_ the files already...
> > 
> > Fixed with the patch below.
> 
> Thanks, it takes care of the debugobjtems, but still creates bogus
> debugobjs.

Ah, yeah.  The following incremental patch fixes that as well.

Richard.

Index: early-lto-debug/gcc/lto-wrapper.c
===================================================================
--- early-lto-debug.orig/gcc/lto-wrapper.c      2016-09-07 09:12:25.339333496 
+0200
+++ early-lto-debug/gcc/lto-wrapper.c   2016-09-07 09:09:19.017138725 +0200
@@ -1435,17 +1435,24 @@ cont1:
        }
     }
   else
-    skip_debug = true;
+    {
+      unlink_if_ordinary (debug_obj);
+      free (debug_obj);
+      debug_obj = NULL;
+      skip_debug = true;
+    }
 
   if (lto_mode == LTO_MODE_LTO)
     {
       printf ("%s\n", flto_out);
       if (!skip_debug)
-       printf ("%s\n", debug_obj);
+       {
+         printf ("%s\n", debug_obj);
+         free (debug_obj);
+         debug_obj = NULL;
+       }
       free (flto_out);
       flto_out = NULL;
-      free (debug_obj);
-      debug_obj = NULL;
     }
   else
     {
@@ -1593,9 +1600,11 @@ cont:
            maybe_unlink (input_names[i]);
        }
       if (!skip_debug)
-       printf ("%s\n", debug_obj);
-      free (debug_obj);
-      debug_obj = NULL;
+       {
+         printf ("%s\n", debug_obj);
+         free (debug_obj);
+         debug_obj = NULL;
+       }
       for (i = 0; i < nr; ++i)
        {
          fputs (output_names[i], stdout);

Reply via email to