Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 29 Apr 2015 16:31:45 -0700
From:      Garrett Cooper <yaneurabeya@gmail.com>
To:        FreeBSD Toolchain <freebsd-toolchain@freebsd.org>
Cc:        Anthony Cornehl <accornehl@gmail.com>, Benno Rice <benno@FreeBSD.org>
Subject:   A better way to get runtime coverage with libprofile_rt (from compiler_rt) / gcov?
Message-ID:  <1DCB7CE4-2AC1-4AC6-B630-8A55BAF546BB@gmail.com>

next in thread | raw e-mail | index | archive | help

--Apple-Mail=_2D05942A-C4E9-4980-82BA-3E7662F69B4F
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain;
	charset=windows-1252

Hi all,
	In order to adapt an existing process to clang, I went and tried =
to figure out how to get coverage generation to work on FreeBSD with =
shared binaries (not static binaries), which is the default for =
clang/gcc: =
https://github.com/yaneurabeya/scratch/blob/master/coverage-with-shared-li=
bs-freebsd . In doing this I had to commit a few cardinal sins:
	1. I had to specify -lgcov, even though the gcc docs said =
--coverage implied this.
	2. I had to link in static libraries directly using LDADD: =
https://github.com/yaneurabeya/scratch/blob/master/coverage-with-shared-li=
bs-freebsd/Makefile.inc#L9 . If I didn=92t, things would blow when it =
tried to link lib/libfoo.so into bin/foo , so there might be a =
difference in behavior between clang and gcc in that regard (I tried =
using LDFLAGS + LDADD with just -lclang_rt.profile-x86_64, but that =
didn=92t seem to work either):

/usr/bin/ld: foo: hidden symbol `llvm_gcda_emit_arcs' in =
/usr/bin/../lib/clang/3.6.0/lib/freebsd/libclang_rt.profile-x86_64.a(GCDAP=
rofiling.o) is referenced by DSO
/usr/bin/ld: final link failed: Nonrepresentable section on output

	Does anyone know of a better way to solve this problem, i.e. =
avoid having to hardcode the full path to libclang_rt.profile-x86_64.a =
(or perhaps make clang do the right thing when trying to link in the =
library)?
Thanks!
-NGie

$ make -s obj depend all
=3D=3D=3D> lib (obj)
=3D=3D=3D> bin (obj)
=3D=3D=3D> lib (depend)
=3D=3D=3D> bin (depend)
=3D=3D=3D> lib (all)
=3D=3D=3D> bin (all)
$ make get-coverage
LD_LIBRARY_PATH=3D/usr/obj/usr/src.svn/tests/foo/lib =
/usr/obj/usr/src.svn/tests/foo/bin/foo
This is foo
lcov --capture --directory /usr/obj/usr/src.svn/tests/foo --output-file =
/usr/obj/usr/src.svn/tests/foo/coverage.info
Capturing coverage data from /usr/obj/usr/src.svn/tests/foo
Found gcov version: 4.2.1
Scanning /usr/obj/usr/src.svn/tests/foo for .gcda files ...
Found 2 data files in /usr/obj/usr/src.svn/tests/foo
Processing lib/foo.gcda
/usr/obj/usr/src.svn/tests/foo/lib/foo.gcno:version '402*', prefer =
'402p'
/usr/obj/usr/src.svn/tests/foo/lib/foo.gcda:version '402*', prefer =
version '402p'
/usr/obj/usr/src.svn/tests/foo/lib/foo.gcno:'foo' has arcs from exit =
block
Processing bin/foo.gcda
/usr/obj/usr/src.svn/tests/foo/bin/foo.gcno:version '402*', prefer =
'402p'
/usr/obj/usr/src.svn/tests/foo/bin/foo.gcda:version '402*', prefer =
version '402p'
Finished .info-file creation
genhtml /usr/obj/usr/src.svn/tests/foo/coverage.info --output-directory =
output
Reading data file /usr/obj/usr/src.svn/tests/foo/coverage.info
Found 2 entries.
Found common filename prefix "/usr/src.svn/tests/foo"
Writing .css and .png files.
Generating output.
Processing file bin/foo.c
Processing file lib/foo.c
Writing directory view page.
Overall coverage rate:
  lines......: 100.0% (4 of 4 lines)
  functions..: 100.0% (2 of 2 functions)


--Apple-Mail=_2D05942A-C4E9-4980-82BA-3E7662F69B4F
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
	filename=signature.asc
Content-Type: application/pgp-signature;
	name=signature.asc
Content-Description: Message signed with OpenPGP using GPGMail

-----BEGIN PGP SIGNATURE-----
Comment: GPGTools - https://gpgtools.org

iQEcBAEBCgAGBQJVQWnhAAoJEMZr5QU6S73eyooH/REUPj4X5HNiEO72U7GmJrr+
hkSEKUT9oLYhtSNIaChKESr+a0Yb48j2XGgDHPEMD6hKxsKz4HXVSXiWgBUVVsRK
J/71kvGwamyoUv+jCgMwVZ+5su0si/n+DCfA/RjowRf0yRLSiJGavPUFhnJG2ZAF
pqsoxr2MuMn7apxnHAVGkxGV3Hke94UD4OkFaaG9ijnaVsHffuVT+P1vGVb2lDGz
HpeMtLLwyQGl0T9MXKRQgRx+QLhrI/dGwuJIDRII9ZzOiNkn6vfJm4yEq0e7fJ/e
y/DApeaJOblJgLAijVWZ7KdrSeVyoiANuvTa9kMBTdpsPHeZsW3wQ6ebEJ885no=
=+lQL
-----END PGP SIGNATURE-----

--Apple-Mail=_2D05942A-C4E9-4980-82BA-3E7662F69B4F--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?1DCB7CE4-2AC1-4AC6-B630-8A55BAF546BB>