From: Christian Franke <Christian.Franke@t-online.de>
To: cygwin-apps@cygwin.com
Subject: Re: cygport may not create debug info if top directory contains a symlink
Date: Mon, 30 Oct 2023 17:37:36 +0100 [thread overview]
Message-ID: <4b32eb45-e167-9a30-1a67-2fac6e57f39e@t-online.de> (raw)
In-Reply-To: <7cecd318-a2ca-49cd-978d-5a27e0072e72@dronecode.org.uk>
Jon Turney wrote:
> On 20/09/2023 11:58, Christian Franke via Cygwin-apps wrote:
>> Brian Inglis wrote:
>>> On 2023-09-18 04:41, Christian Franke via Cygwin-apps wrote:
>>>> Brian Inglis wrote:
>>>>> On 2023-09-17 08:01, Jon Turney via Cygwin-apps wrote:
>>>>>> On 16/09/2023 15:17, Christian Franke via Cygwin wrote:
>>>>>>> Found during tests of busybox package:
>>>>>>> If the path of the top build directory contains a symlink and
>>>>>>> the project's build scripts normalize pathnames, no debug info
>>>>>>> is created by cygport.
>>>>>>>
>>>>>>> This is because options like
>>>>>>> -fdebug-prefix-map=${B}=/usr/src/debug/${PF}
>>>>>>> have no effect because ${B} contains a symlink but the compiler
>>>>>>> is run with the real source path.
>>>>>>
>>>>>> I think that there was some historical bug with gcc where a
>>>>>> relative path for the old path in this mapping wasn't correctly
>>>>>> handled, which is why were using an absolute path here at all.
>>>>>>
>>>>>> So changing it to something like [1] (if that works), might be
>>>>>> better.
>>>>>>
>>>>>> [1]
>>>>>> https://github.com/jon-turney/cygport/commit/4175d456a9184c5cdebd8bfb4b5ba30583cedd66
>>>
>>> Should bin/cygport.in:534: not have $B between the == as in line 531:
>>>
>>> declare ${flags}+=" -fdebug-prefix-map=${B}=/usr/src/debug/${PF}"
>>> ...
>>> declare ${flags}+=" -fdebug-prefix-map==/usr/src/debug/${PF}"
>>>
>>> or be hoist above the condition if identical, unless that is some
>>> undocumented default for cwd?
>>
>> I guess the == without ${B} is intentional because it makes the debug
>> source path relative to ${B} as lines 535-536 also do.
>
> Yeah, I think that "==" is shorthand for "=.=", i.e. relative to cwd.
>
Further tests show that "==" behaves strange and is not useful at all
(no problem as it doesn't actually appear in cygport.in).
The "=.=" only does a simple replacement of first "." in source name.
Testcases with file.c in /var/tmp/test:
$ gcc -g file.c && objdump -dl a.exe | grep -F file.c
/var/tmp/test/file.c:1
$ gcc -g ./file.c && objdump -dl a.exe | grep -F file.c
/var/tmp/test/./file.c:1
$ gcc -g ../test/file.c && objdump -dl a.exe | grep -F file.c
/var/tmp/test/../test/file.c:1
$ gcc -g -fdebug-prefix-map==/foo/bar file.c && ...
/foo/bar/foo/barfile.c:1
$ gcc -g -fdebug-prefix-map=.=/foo/bar file.c && ...
/var/tmp/test/file.c:1
$ gcc -g -fdebug-prefix-map=.=/foo/bar ./file.c && ...
/foo/bar/file.c:1
$ gcc -g -fdebug-prefix-map=/var/tmp/test=/foo/bar file.c && ...
/foo/bar/file.c:1
Source directories with symlinks are preserved in line number info like
with 'pwd -L'.
> Does using relative paths in the prefix-map resolve the original issue
> seen with busybox?
No, relative paths do not work. Adding this to top of src_compile() works:
CFLAGS+=" -fdebug-prefix-map=$(cd ${S} && pwd -P)=/usr/src/debug/${PF}"
Same for ${B} is not required for this project. This also works (B and S
are not set yet):
DEBUG_PREFIX_MAPS=( "$(pwd -P)/${PF}.${ARCH}/src/${PN}-${PV}" )
> (It's unclear to me how gcc compares paths to apply this mapping. If
> it's a literal string prefix, rather than on some (semi-)canonicalized
> path, then we're maybe going to lose here sometimes, depending on the
> vagaries of the build-system, unless we list all of relative,
> absolute, and canonical absolute paths?)
>
> (But then maybe we can push dealing with or indicating which of those
> is correct off onto the individual cygport?)
>
Adding this if "$(cd ${S} && pwd -P)" != "${S}" should IMO be safe:
-fdebug-prefix-map=$(cd ${B} && pwd -P)=/usr/src/debug/${PF}
-fdebug-prefix-map=$(cd ${S} && pwd -P)=/usr/src/debug/${PF}
(or use realpath)
next prev parent reply other threads:[~2023-10-30 16:37 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <9bc07a5f-86d9-76ee-f45d-e1956c9035f8@t-online.de>
2023-09-17 14:01 ` Jon Turney
2023-09-17 15:56 ` Brian Inglis
2023-09-18 10:41 ` Christian Franke
2023-09-18 10:58 ` Achim Gratz
2023-09-18 17:24 ` Brian Inglis
2023-09-20 10:58 ` Christian Franke
2023-10-29 16:05 ` Jon Turney
2023-10-30 16:37 ` Christian Franke [this message]
2024-02-11 17:01 ` Jon Turney
2024-04-29 19:44 ` Jon Turney
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=4b32eb45-e167-9a30-1a67-2fac6e57f39e@t-online.de \
--to=christian.franke@t-online.de \
--cc=cygwin-apps@cygwin.com \
/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).