From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mailout02.t-online.de (mailout02.t-online.de [194.25.134.17]) by sourceware.org (Postfix) with ESMTPS id 67F5E38582BE for ; Mon, 30 Oct 2023 16:37:44 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 67F5E38582BE Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=t-online.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=t-online.de ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 67F5E38582BE Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=194.25.134.17 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1698683866; cv=none; b=sURnpU7yv6XVtNM47ZakwUaJexCRCWS5p5ZZHS+bKoIad/cXiAfH4Mnt20O7QybgapXcQ3/c4nRW4/PEa4TGjV362tnVC3An1QLfRtGq/8y+cTmu2t4aLB+fC/ggnU9I+2aZgcdmAmqGUHxSFoopDUvkc+uZWBw4AE0aaiZnle8= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1698683866; c=relaxed/simple; bh=UOt+m2qKO80+m/8AKxdIuDbvhJpDQWZII5Jcutcxbmo=; h=From:Subject:To:Message-ID:Date:MIME-Version; b=PkoKZtPVHFEMx86xEKeDy5x5WUXh+J4ZRVoILXrUmnIorBlORH7/tcISDBw7Jdr4x57HrqBq9hXk0FNvrScJdVO7wKCd3+A9ZZJ4SwU5a7z4TScvrdJDayAKh9qQpvPd/hKT0QYbQ3Xp2jXYHOimL+qVFeOQsVYT2rTmIXscx/4= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from fwd75.aul.t-online.de (fwd75.aul.t-online.de [10.223.144.101]) by mailout02.t-online.de (Postfix) with SMTP id 2E2743FF9 for ; Mon, 30 Oct 2023 17:37:42 +0100 (CET) Received: from [192.168.2.101] ([79.230.168.59]) by fwd75.t-online.de with (TLSv1.3:TLS_AES_256_GCM_SHA384 encrypted) esmtp id 1qxVGj-0JKeBc0; Mon, 30 Oct 2023 17:37:37 +0100 From: Christian Franke Subject: Re: cygport may not create debug info if top directory contains a symlink To: cygwin-apps@cygwin.com References: <9bc07a5f-86d9-76ee-f45d-e1956c9035f8@t-online.de> <8f480c7f-e2d0-c2b2-f6fb-24a1e54c2b19@t-online.de> <86ec734a-4277-f9be-81bb-75a4bbae6e76@Shaw.ca> <6ecfe72d-1f77-af76-9430-8594b8f13384@t-online.de> <7cecd318-a2ca-49cd-978d-5a27e0072e72@dronecode.org.uk> Message-ID: <4b32eb45-e167-9a30-1a67-2fac6e57f39e@t-online.de> Date: Mon, 30 Oct 2023 17:37:36 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 SeaMonkey/2.53.16 MIME-Version: 1.0 In-Reply-To: <7cecd318-a2ca-49cd-978d-5a27e0072e72@dronecode.org.uk> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-TOI-EXPURGATEID: 150726::1698683857-9B7FD9D6-91C0F3A5/0/0 CLEAN NORMAL X-TOI-MSGID: ff9e50ac-fec0-4ab7-baa4-6561eab00ee3 X-Spam-Status: No, score=-2.7 required=5.0 tests=BAYES_00,BODY_8BITS,FREEMAIL_FROM,KAM_DMARC_STATUS,NICE_REPLY_A,RCVD_IN_BARRACUDACENTRAL,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: 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)