public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "esgergn at hotmail dot com" <gcc-bugzilla@gcc.gnu.org>
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	[thread overview]
Message-ID: <bug-105238-4-PizzPq2DMa@http.gcc.gnu.org/bugzilla/> (raw)
In-Reply-To: <bug-105238-4@http.gcc.gnu.org/bugzilla/>

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105238

--- Comment #4 from Esger Abbink <esgergn at hotmail dot com> ---
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 --coverage
-fprofile-prefix-map=/home/esger/src/application/coverage_test/dir1=dir2 -c
/home/esger/src/application/coverage_test/dir1/source/main.cpp 

cd /home/esger/src/application/coverage_test/dir1/source/ && g++-11 --coverage
-fprofile-prefix-map=/home/esger/src/application/coverage_test/dir1=dir2 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 the
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 still
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=/home/esger/src/application/coverage_test/dir1 ccache
/usr/bin/g++-11 --coverage
-fprofile-prefix-map=/home/esger/src/application/coverage_test/dir1=.
-fdebug-prefix-map=/home/esger/src/application/coverage_test/dir1=. -c
/home/esger/src/application/coverage_test/dir1/source/main.cpp

cd /home/esger/src/application/coverage_test/dir1/source/ &&
CCACHE_BASEDIR=/home/esger/src/application/coverage_test/dir1 ccache
/usr/bin/g++-11 --coverage
-fprofile-prefix-map=/home/esger/src/application/coverage_test/dir1=.
-fdebug-prefix-map=/home/esger/src/application/coverage_test/dir1=. main.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=1482908279,
lineno_checksum=0x2c72f060, cfg_checksum=0xc0bbb23e, `_GLOBAL__sub_I__Z5funcAi'
./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 paths
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 different
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.

  parent reply	other threads:[~2022-04-14  9:11 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-12 11:32 [Bug gcov-profile/105238] New: " esgergn at hotmail dot com
2022-04-12 12:25 ` [Bug gcov-profile/105238] " marxin at gcc dot gnu.org
2022-04-12 13:28 ` esgergn at hotmail dot com
2022-04-13  8:12 ` marxin at gcc dot gnu.org
2022-04-14  9:11 ` esgergn at hotmail dot com [this message]
2022-04-15 12:19 ` esgergn at hotmail dot com
2022-04-15 13:55 ` esgergn at hotmail dot com
2022-04-15 22:41 ` esgergn at hotmail dot com
2022-04-19  9:55 ` marxin at gcc dot gnu.org
2023-04-03  8:57 ` marxin at gcc dot gnu.org
2023-04-03  9:03 ` marxin at gcc dot gnu.org
2024-05-07  7:40 ` rguenth at gcc dot gnu.org

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-105238-4-PizzPq2DMa@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).