From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id BABF53858C54; Thu, 14 Apr 2022 09:11:10 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org BABF53858C54 From: "esgergn at hotmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug gcov-profile/105238] Regression: using -fprofile-dir: gcno files not ccache cachable anymore / gcovr report broken Date: Thu, 14 Apr 2022 09:11:10 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: gcov-profile X-Bugzilla-Version: 9.4.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: esgergn at hotmail dot com X-Bugzilla-Status: NEW X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 14 Apr 2022 09:11:10 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D105238 --- Comment #4 from Esger Abbink --- We use Ubuntu 20.04 currently for our jenkins images. With gcc built from master with patch using -fprofile-prefix-map works as expected: with a main.cpp in /home/esger/src/application/coverage_test/dir1/source compiling with: cd /home/esger/src/application/coverage_test/dir1/source/ && g++-11 --cover= age -fprofile-prefix-map=3D/home/esger/src/application/coverage_test/dir1=3Ddir= 2 -c /home/esger/src/application/coverage_test/dir1/source/main.cpp=20 cd /home/esger/src/application/coverage_test/dir1/source/ && g++-11 --cover= age -fprofile-prefix-map=3D/home/esger/src/application/coverage_test/dir1=3Ddir= 2 main.o -o ../bin/a.out results in a main.gcno in the source directory, and after running ./dir1/bin/a.out from /home/esger/src/application/coverage_test there is a main.gcda (non-mangled) in dir2/source. Note that I was not able to produce a meaningful coverage report even for t= he simplest/first case of the four above with gcc 11. I think gcovr might not = yet support newer formats used? So I can't currently verify if with -fprofile-prefix-map the coverage report is ok, but I would assume so. (Still, I don't quite understand why behavior that was working is now broken/changed and needs a new option? ie. why is -fprofile-dir mangling the name, and -fprofile-prefix-map not? and 9.4 behavior with -fprofile-dir sti= ll seems broken when explicitly specifying the default?) If I perform a small experiment more closely resembling what cmake + ccache= do: cd /home/esger/src/application/coverage_test/dir1/source/ && CCACHE_BASEDIR=3D/home/esger/src/application/coverage_test/dir1 ccache /usr/bin/g++-11 --coverage -fprofile-prefix-map=3D/home/esger/src/application/coverage_test/dir1=3D. -fdebug-prefix-map=3D/home/esger/src/application/coverage_test/dir1=3D. -c /home/esger/src/application/coverage_test/dir1/source/main.cpp cd /home/esger/src/application/coverage_test/dir1/source/ && CCACHE_BASEDIR=3D/home/esger/src/application/coverage_test/dir1 ccache /usr/bin/g++-11 --coverage -fprofile-prefix-map=3D/home/esger/src/application/coverage_test/dir1=3D. -fdebug-prefix-map=3D/home/esger/src/application/coverage_test/dir1=3D. mai= n.o -o ../bin/a.out and then from /home/esger/src/application/coverage_test/dir2 run ../dir1/bin/a.out (to simulate a run with a binary built from cached .o and .gcno run from a different directory) again the gcda is created in the dir2/source directory with a non-mangled name. yey :) I can also see the source file paths in the gcno are relative: main.gcno:note:magic `gcno':version `B20 ' main.gcno:stamp 625107654 main.gcno:checksum 0 main.gcno:cwd: /home/esger/src/application/coverage_test/dir1/source main.gcno: 01000000: 83:FUNCTION ident=3D1482908279, lineno_checksum=3D0x2c72f060, cfg_checksum=3D0xc0bbb23e, `_GLOBAL__sub_I__Z= 5funcAi' ./source/main.cpp:21:1-21:1, artificial main.gcno: 01410000: 4:BLOCKS 4 blocks main.gcno: 01430000: 12:ARCS 1 arcs main.gcno: 01430000: 20:ARCS 2 arcs main.gcno: 01430000: 12:ARCS 1 arcs main.gcno: 01450000: 42:LINES main.gcno: 01450000: 42:LINES ... So with a patched gcc11, dropping -fprofile-dir and using -fprofile-prefix-= map instead, gcda creation seems ok. The gcno files seem to contain relative pa= ths to the source file too. However, the gcno file also still contains the compilation CWD which interferes with caching it and re-using it for differ= ent build dirs. Is there any way to get rid of that? And of course I still need to verify such created gcda files will actually result in a proper coverage report. Applying the patch to 9.4 or 10.3 as vit9696 did should allow me to test that. Will try that tomorrow if I have time.=