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-libs-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-libs-freebsd/Makefile.inc#L9 . If I didn’t, 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’t 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(GCDAProfiling.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 ===> lib (obj) ===> bin (obj) ===> lib (depend) ===> bin (depend) ===> lib (all) ===> bin (all) $ make get-coverage LD_LIBRARY_PATH=/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)
signature.asc
Description: Message signed with OpenPGP using GPGMail