public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "rguenth at gcc dot gnu.org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug debug/109805] LTO affecting -fdebug-prefix-map
Date: Mon, 15 May 2023 06:34:30 +0000	[thread overview]
Message-ID: <bug-109805-4-n7LVhIxWw5@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

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |jakub at gcc dot gnu.org

--- Comment #10 from Richard Biener <rguenth at gcc dot gnu.org> ---
(In reply to Sergio Durigan Junior from comment #9)
> at(In reply to Richard Biener from comment #8)
> > This works for me.  The consistency check is not fully implemented and
> > instead
> > of passing down no -fdebug-prefix-map the patch passes the first but warns:
> >
> > > ./xgcc -B. t.o t2.o -o t
> > lto-wrapper: warning: option
> > -fdebug-prefix-map=/home/rguenther/obj-trunk-g/gcc=/bbb with different
> > values, using /home/rguenther/obj-trunk-g/gcc=/aaa
> >
> > to make consistency checking work we need to record -fcanon-prefix-map
> > and the full set of -f{file,debug}-prefix-map options in order (I think
> > file and debug variants can be considered the same) of the first TU and
> > compare that to each of the following TUs.
> 
> Thanks a lot for the patch.  I tried it locally, and it indeed works for the
> simple example I posted in the description of this bug.  However, for some
> reason it doesn't seem to make a difference for the vim compilation.  I'm
> still seeing a directory table like the following:
> 
> Directory table:
>       [path(line_strp)]
>  0     /home/ubuntu/vim/vim-9.0.1378/src/vim-basic (0)
>  1     /usr/include/x86_64-linux-gnu/bits (57)
>  2     /usr/include (92)
> 
> whereas if I pass -fdebug-prefix-map to LDFLAGS, the directory table becomes:
> 
> Directory table:
>       [path(line_strp)]
>  0     /usr/src/vim-2:9.0.1378-2ubuntu2~ppa1/src/vim-basic (0)
>  1     /usr/include/x86_64-linux-gnu/bits (65)
>  2     /usr/include (100)
> 
> which is what I expected to see.

Odd.

> > Note a link-time specified option will simply ignore all options from the
> > compile-time (but only for the link-time unit, the compile-time debug info
> > has already been generated with the originally specified options).
> 
> FWIW, I think this bug is related to #108534 (and the related discussion at
> https://gcc.gnu.org/pipermail/gcc-patches/2022-November/606205.html).

Yes, that looks related.  Note we do remap the file part of locations
but indeed not the streamed PWD.

When I remap PWD as well I get

 The Directory Table (offset 0x10a, lines 2, columns 1):
  Entry Name
  0     (indirect line string, offset: 0x18): /aaa
  1     (indirect line string, offset: 0xd): ../../../../aaa

 The File Name Table (offset 0x118, lines 2, columns 2):
  Entry Dir     Name
  0     0       (indirect line string, offset: 0x0): <artificial>
  1     1       (indirect line string, offset: 0x1d): t.c

for the toy example.  That's quite odd, but possibly the behavior of the
original intent of the patch you quoted - but it also shows that the
remapping of the streamed PWD is likely wrong?

For the record the above is with just

diff --git a/gcc/lto-streamer-out.cc b/gcc/lto-streamer-out.cc
index 0bca530313c..89b602f080b 100644
--- a/gcc/lto-streamer-out.cc
+++ b/gcc/lto-streamer-out.cc
@@ -231,7 +231,8 @@ lto_output_location_1 (struct output_block *ob, struct
bitpack_d *bp,
            }
          bp_pack_value (bp, stream_pwd, 1);
          if (stream_pwd)
-           bp_pack_string (ob, bp, get_src_pwd (), true);
+           bp_pack_string (ob, bp, remap_debug_filename (get_src_pwd ()),
+                           true);
          bp_pack_string (ob, bp, remapped, true);
          bp_pack_value (bp, xloc.sysp, 1);
        }

r10-6887-gd12153046816f9 did the original bits of remapping and shows we
originally passed through the remapping options.  r11-3096-g3d0af0c997fe42
was Jakubs fix for .debug_line and relative paths vs. changing CWD.

  parent reply	other threads:[~2023-05-15  6:34 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
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 [this message]
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-n7LVhIxWw5@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).