From owner-freebsd-toolchain@FreeBSD.ORG Wed Apr 29 23:31:48 2015 Return-Path: Delivered-To: freebsd-toolchain@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id A979A587; Wed, 29 Apr 2015 23:31:48 +0000 (UTC) Received: from mail-pd0-x235.google.com (mail-pd0-x235.google.com [IPv6:2607:f8b0:400e:c02::235]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 76DA3175B; Wed, 29 Apr 2015 23:31:48 +0000 (UTC) Received: by pdbqa5 with SMTP id qa5so42163606pdb.1; Wed, 29 Apr 2015 16:31:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:content-type:subject:date:message-id:cc:to:mime-version; bh=erCiJdpHoC+eiePCdTIsO/AKpvE32lLd9GSoWSpCmnw=; b=Di4hgoLi/DlKY4P3XosBOqUrkQ/opbChMM9clNFSUnpdVi9Wz9nkI1wdYP2t5cwg1U MNloV7JbVbt2NCfE95i6X8/QDDFyNG2CqKiYj4Xqwht9q07eHsU5hmrOf4SHBF1rpSPW iCKFZw3im3UK5QjwoShX3QrM2qBEsLtFFlN2WyRJWYwJ0TQ+h8gR2z82LPrx5HHPAZKX F0IFwzDsOhKTueZWBLLJUXT6tegfpaeRQDRtRXy00dzzrefhclbZFIJ1exjDVACKcqHP DMycD9nb91LqVLpjaKMA4jVAzKw3hLmoxniZC9Sxg1vEyI25As6smE/mivF7USXlWoqZ 0Rww== X-Received: by 10.68.237.40 with SMTP id uz8mr2695178pbc.140.1430350308010; Wed, 29 Apr 2015 16:31:48 -0700 (PDT) Received: from ?IPv6:2601:8:ab80:7d6:857d:cd13:79bf:f40d? ([2601:8:ab80:7d6:857d:cd13:79bf:f40d]) by mx.google.com with ESMTPSA id nl16sm269191pdb.56.2015.04.29.16.31.46 (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 29 Apr 2015 16:31:47 -0700 (PDT) From: Garrett Cooper X-Pgp-Agent: GPGMail 2.5b6 Content-Type: multipart/signed; boundary="Apple-Mail=_2D05942A-C4E9-4980-82BA-3E7662F69B4F"; protocol="application/pgp-signature"; micalg=pgp-sha512 Subject: A better way to get runtime coverage with libprofile_rt (from compiler_rt) / gcov? Date: Wed, 29 Apr 2015 16:31:45 -0700 Message-Id: <1DCB7CE4-2AC1-4AC6-B630-8A55BAF546BB@gmail.com> Cc: Anthony Cornehl , Benno Rice To: FreeBSD Toolchain Mime-Version: 1.0 (Mac OS X Mail 7.3 \(1878.6\)) X-Mailer: Apple Mail (2.1878.6) X-BeenThere: freebsd-toolchain@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: Maintenance of FreeBSD's integrated toolchain List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 29 Apr 2015 23:31:48 -0000 --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--