From owner-freebsd-toolchain@FreeBSD.ORG Thu Jan 20 18:54:53 2011 Return-Path: Delivered-To: freebsd-toolchain@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C890E106566B for ; Thu, 20 Jan 2011 18:54:53 +0000 (UTC) (envelope-from rdivacky@vlk.vlakno.cz) Received: from vlakno.cz (lev.vlakno.cz [77.93.215.190]) by mx1.freebsd.org (Postfix) with ESMTP id 81A858FC16 for ; Thu, 20 Jan 2011 18:54:52 +0000 (UTC) Received: from lev.vlakno.cz (localhost [127.0.0.1]) by vlakno.cz (Postfix) with ESMTP id 4111B9CB0DC; Thu, 20 Jan 2011 19:54:51 +0100 (CET) X-Virus-Scanned: amavisd-new at vlakno.cz Received: from vlakno.cz ([127.0.0.1]) by lev.vlakno.cz (lev.vlakno.cz [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 4HM8Ot5JTLAS; Thu, 20 Jan 2011 19:54:50 +0100 (CET) Received: from vlk.vlakno.cz (localhost [127.0.0.1]) by vlakno.cz (Postfix) with ESMTP id 799C19CB153; Thu, 20 Jan 2011 19:54:50 +0100 (CET) Received: (from rdivacky@localhost) by vlk.vlakno.cz (8.14.4/8.14.4/Submit) id p0KIsnbG093645; Thu, 20 Jan 2011 19:54:49 +0100 (CET) (envelope-from rdivacky) Date: Thu, 20 Jan 2011 19:54:49 +0100 From: Roman Divacky To: Steve Kargl Message-ID: <20110120185449.GA92860@freebsd.org> References: <20110117184411.GA54556@troutmask.apl.washington.edu> <20110118143205.GA34216@freebsd.org> <20110118160252.GA6506@troutmask.apl.washington.edu> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="MGYHOYXEY6WxJCY8" Content-Disposition: inline In-Reply-To: <20110118160252.GA6506@troutmask.apl.washington.edu> User-Agent: Mutt/1.4.2.3i Cc: freebsd-toolchain@freebsd.org Subject: Re: How to build an executable with profiling? X-BeenThere: freebsd-toolchain@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Maintenance of FreeBSD's integrated toolchain List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 20 Jan 2011 18:54:53 -0000 --MGYHOYXEY6WxJCY8 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline ok, I sat down and implemented what Hans Ottevanger told me to do :) http://lev.vlakno.cz/~rdivacky/clang-gprof.patch This patch does three things: 1) emits "call .mcount" at the begining of every function body 2) changes the driver to link in gcrt1.o instead of crt1.o 3) changes all -lfoo to -lfoo_p except when the foo ends with _s in the linker invocation I am not sure that I did the right thing, especially in (3). Anyway, the patch works for me (ie. produces a.out.gmon that seems to contain meaningful data). I would appreciate if you guys could test and review this. Letting me know if this is correct. Thank you! roman p.s. the patch is against TRUNK clang but there should not be any/much trouble applying it to contrib/llvm/tools/clang I hope --MGYHOYXEY6WxJCY8 Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v2.0.16 (FreeBSD) iEYEARECAAYFAk04hPkACgkQLVEj6D3CBExztACeIvoImxMie+vyGF5yTn2W7Szz NF8AnRGWWICgAKOr1QPmHNIzxo6YzeA/ =RYR8 -----END PGP SIGNATURE----- --MGYHOYXEY6WxJCY8--