For reasons similar to what I explained in https://reviews.freebsd.org/D9168 (which includes a repro), more of the gcov symbols should be exposed in order for --coverage to "just work" with gcc like suggested in the toolchain manpage. Otherwise I have to explicitly use -lgcov when linking binaries, which is broken per the docs... From man 1 gcc:
This option is used to compile and link code instrumented for
coverage analysis. The option is a synonym for -fprofile-arcs
-ftest-coverage (when compiling) and -lgcov (when linking). See
the documentation for those options for more details.
/usr/local/bin/ld: foo.full: hidden symbol `__gcov_merge_add' in /usr/local/lib/gcc49/gcc/x86_64-portbld-freebsd12.0/4.9.4/libgcov.a(_gcov_merge_add.o) is referenced by DSO
/usr/local/bin/ld: final link failed: Bad value
collect2: error: ld returned 1 exit status
*** Error code 1
Andreas, is this something you can help with (upstream first, probably,
and then we'll see)?
(In reply to Gerald Pfeifer from comment #1)
Thank you for driving this. I'd really like to add --coverage support and lcov coverage gathering to FreeBSD for $work.
Can you help me bit?
I get this:
[m91p:~] andreast% gcc49 -o hashtest --coverage hashtest.c
[m91p:~] andreast% nm hashtest | grep gcov_merge
0000000000402080 T __gcov_merge_add