public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "sergiodj at sergiodj dot net" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug debug/109805] LTO affecting -fdebug-prefix-map
Date: Thu, 11 May 2023 14:36:29 +0000	[thread overview]
Message-ID: <bug-109805-4-fpjcLo0iyv@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-109805-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=109805

--- Comment #5 from Sergio Durigan Junior <sergiodj at sergiodj dot net> ---
(In reply to Richard Biener from comment #4)
> It works for the actual source file translation units for me, it's just the
> LTRANS units that have a DW_AT_comp_dir that's not remapped.  It's actually
> difficult to do the right thing here and I think the correct thing to do if
> you don't like the "bogus" DW_AT_comp_dir is to actually specify
> -fdebug-prefix-map at link time.
>
> The issue it's difficult to do the right thing is because you have to
> consider
>
> gcc -c t1.c -flto -fdebug-prefix-map=`pwd`=/aaaa
> gcc -c t2.c -flto -fdebug-prefix-map=`pwd`=/bbbb
> gcc t1.o t2.o
>
> now, what DW_AT_comp_dir should the possibly single LTRANS CU use?

Thanks for the reply.

I understand the problem here.  But taking the vim package as an example, the
remapping was done to a specific directory, for all object files.

> One "fix" might be to emit multiple DWARF CUs for each LTRANS unit and thus
> keep the association to the original CUs 1:1 (I have some patches for this
> lying around for a few years).  But then we're still mixing CUs by means
> of inlining and cloning.
>
> Note the DW_AT_name of the LTRANS CUs is <artificial> (DWARF doesn't allow
> to omit it).  What's more "problematic" is that somehow the file list of
> the CU contains t.c - it might be worth figuring out how this gets there.
>
> A pragmatic fix could be to detect the case where all LTO inputs had the
> same -fdebug-prefix-map specified and carry that over to link time
> automatically in lto-wrapper (we are currently not streaming the various
> remapping flags).

That'd solve the problem I'm seeing, I believe.

> Can you clarify what the actual problem with the generated dwarf is?

If we take the vim package as an example (again), the problem I'm seeing is
that -fdebug-prefix-map is being used when compiling all .o files, but the
generated binary ends up with the old path in its directory table.  This
confuses debuginfod, which uses this information to determine where the source
files are located.  It's interesting to note that I also see the new path
listed in the DWARF, but for some reason debuginfod/GDB get confused about it.

I found yet another package that seems to be affected by this problem: samba. 
Curiously enough, there are other packages that don't seem to be affected, even
though they're also being compiled using LTO.

  parent reply	other threads:[~2023-05-11 14:36 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-05-11  0:48 [Bug debug/109805] New: " sergiodj at sergiodj dot net
2023-05-11  0:52 ` [Bug debug/109805] " sergiodj at sergiodj dot net
2023-05-11  2:49 ` pinskia at gcc dot gnu.org
2023-05-11  2:50 ` pinskia at gcc dot gnu.org
2023-05-11  6:43 ` rguenth at gcc dot gnu.org
2023-05-11 14:36 ` sergiodj at sergiodj dot net [this message]
2023-05-11 14:38 ` sergiodj at sergiodj dot net
2023-05-12  7:25 ` rguenth at gcc dot gnu.org
2023-05-12 12:13 ` rguenth at gcc dot gnu.org
2023-05-12 12:21 ` rguenth at gcc dot gnu.org
2023-05-13 19:21 ` sergiodj at sergiodj dot net
2023-05-15  6:34 ` rguenth at gcc dot gnu.org
2023-05-15  9:20 ` rguenth at gcc dot gnu.org
2023-05-16 22:25 ` sergiodj at sergiodj dot net
2023-05-17  7:23 ` rguenther at suse dot de

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=bug-109805-4-fpjcLo0iyv@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /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).