public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Richard Biener <rguenther@suse.de>
To: Markus Trippelsdorf <markus@trippelsdorf.de>
Cc: gcc-patches@gcc.gnu.org
Subject: Re: [PATCH][RFC] Early LTO debug
Date: Tue, 06 Sep 2016 12:26:00 -0000	[thread overview]
Message-ID: <alpine.LSU.2.11.1609061419400.26629@t29.fhfr.qr> (raw)
In-Reply-To: <20160906121544.GB316@x4>

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.

> The new patch builds LLVM fine with "-flto -g".

Great.

Richard.

Index: early-lto-debug/gcc/lto-wrapper.c
===================================================================
--- early-lto-debug.orig/gcc/lto-wrapper.c	2016-09-06 14:26:29.233142490 +0200
+++ early-lto-debug/gcc/lto-wrapper.c	2016-09-06 14:25:44.316618249 +0200
@@ -943,9 +943,10 @@ find_and_merge_options (int fd, off_t fi
   return true;
 }
 
-int
-debug_objcopy (const char *infile, const char *outfile)
+const char *
+debug_objcopy (const char *infile)
 {
+  const char *outfile;
   const char *errmsg;
   int err;
 
@@ -966,12 +967,12 @@ debug_objcopy (const char *infile, const
     }
   int infd = open (infile, O_RDONLY);
   if (infd == -1)
-    return 1;
+    return NULL;
   simple_object_read *inobj = simple_object_start_read (infd, inoff,
 							"__GNU_LTO",
 							&errmsg, &err);
   if (!inobj)
-    return 1;
+    return NULL;
 
   off_t off, len;
   if (simple_object_find_section (inobj, ".gnu.debuglto_.debug_info",
@@ -982,17 +983,21 @@ debug_objcopy (const char *infile, const
 
       simple_object_release_read (inobj);
       close (infd);
-      return 1;
+      return NULL;
     }
 
+  outfile = make_temp_file ("debugobjtem");
   errmsg = simple_object_copy_lto_debug_sections (inobj, outfile, &err);
   if (errmsg)
-    fatal_error (0, "%s: %s\n", errmsg, xstrerror (err));
+    {
+      unlink_if_ordinary (outfile);
+      fatal_error (0, "%s: %s\n", errmsg, xstrerror (err));
+    }
 
   simple_object_release_read (inobj);
   close (infd);
 
-  return 0;
+  return outfile;
 }
 
 
@@ -1401,8 +1406,8 @@ cont1:
   if (! skip_debug)
     for (i = 0; i < ltoobj_argc; ++i)
       {
-	char *tem = make_temp_file ("debugobjtem");
-	if (!debug_objcopy (ltoobj_argv[i], tem))
+	const char *tem;
+	if ((tem = debug_objcopy (ltoobj_argv[i])))
 	  {
 	    obstack_ptr_grow (&argv_obstack, tem);
 	    n_debugobj++;

  reply	other threads:[~2016-09-06 12:26 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-26 10:11 Richard Biener
2016-09-06 11:18 ` Richard Biener
2016-09-06 12:26   ` Markus Trippelsdorf
2016-09-06 12:26     ` Richard Biener [this message]
2016-09-06 14:40       ` Markus Trippelsdorf
2016-09-07  7:44         ` Richard Biener
2016-09-12 20:20   ` Jeff Law

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=alpine.LSU.2.11.1609061419400.26629@t29.fhfr.qr \
    --to=rguenther@suse.de \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=markus@trippelsdorf.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).