cygport may not create debug info if top directory contains a symlink

Christian Franke Christian.Franke@t-online.de
Mon Sep 18 10:41:55 GMT 2023


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
>>
>> Sidenote: we should probably also be using file-prefix-map, now we're 
>> on a gcc which supports it.

Definitely. in particular useful in conjunction with reproducible builds 
and this cygport patch:
https://sourceware.org/pipermail/cygwin-apps/2023-August/043108.html
The related newlib-cygwin patch has been pushed already:
https://cygwin.com/git/?p=newlib-cygwin.git;a=commit;h=f5e37b93


>>
>>
>>> The postinstall code then does not find any line number info with 
>>> source path /usr/src/debug/${PF}/...
>>>
>>> Could be fixed easily in line 414 of /bin/cygport:
>>>
>>> -declare -r top=$(cd ${_topdir}; pwd);
>>> +declare -r top=$(cd ${_topdir}; /bin/pwd);
>>
>> Can you explain why this makes a difference?
>
> In cygport, pwd is a bash builtin defaulting to -L; /bin/pwd defaults 
> to -P.
> Both commands support both options and we might expect the same output.
> It would be better to use builtin `pwd -P` if that produces the 
> correct result.

It does.


>
> An STC script which creates test dirs to demonstrate the issue and 
> show the alternative outputs would be nice so anyone can see.

$ ln -s /usr/src /tmp/source

$ cd /tmp/source

$ pwd
/tmp/source

$ /bin/pwd
/usr/src

$ pwd -P
/usr/src

$ /bin/pwd -L
/tmp/source

-- 
Regards,
Christian



More information about the Cygwin-apps mailing list