From owner-freebsd-toolchain@FreeBSD.ORG Thu Jan 20 21:52:15 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 58516106566B for ; Thu, 20 Jan 2011 21:52:15 +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 AF80C8FC16 for ; Thu, 20 Jan 2011 21:52:14 +0000 (UTC) Received: from lev.vlakno.cz (localhost [127.0.0.1]) by vlakno.cz (Postfix) with ESMTP id 114B69CB0CC; Thu, 20 Jan 2011 22:52:13 +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 88mJwT212CtT; Thu, 20 Jan 2011 22:52:11 +0100 (CET) Received: from vlk.vlakno.cz (localhost [127.0.0.1]) by vlakno.cz (Postfix) with ESMTP id BC3B49CB153; Thu, 20 Jan 2011 22:52:11 +0100 (CET) Received: (from rdivacky@localhost) by vlk.vlakno.cz (8.14.4/8.14.4/Submit) id p0KLqBSu016084; Thu, 20 Jan 2011 22:52:11 +0100 (CET) (envelope-from rdivacky) Date: Thu, 20 Jan 2011 22:52:11 +0100 From: Roman Divacky To: Steve Kargl Message-ID: <20110120215211.GA15379@freebsd.org> References: <20110117184411.GA54556@troutmask.apl.washington.edu> <20110118143205.GA34216@freebsd.org> <20110118160252.GA6506@troutmask.apl.washington.edu> <20110120185449.GA92860@freebsd.org> <20110120214503.GA19077@troutmask.apl.washington.edu> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20110120214503.GA19077@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 21:52:15 -0000 On Thu, Jan 20, 2011 at 01:45:03PM -0800, Steve Kargl wrote: > On Thu, Jan 20, 2011 at 07:54:49PM +0100, Roman Divacky wrote: > > > > ok, I sat down and implemented what Hans Ottevanger told me to do :) > > > > http://lev.vlakno.cz/~rdivacky/clang-gprof.patch > > > > Wow. Thanks. > > I tried applying your patch to > > % svn update > At revision 217661. > % cd /usr/src/contrib/llvm/tools/clang > % patch < /usr/home/kargl/clang-gprof.patch | & tee sgk.log > > Inspection of sgk.log found > > |Index: include/clang/Frontend/CodeGenOptions.h > |=================================================================== > |--- include/clang/Frontend/CodeGenOptions.h (revision 123935) > |+++ include/clang/Frontend/CodeGenOptions.h (working copy) > -------------------------- > Patching file include/clang/Frontend/CodeGenOptions.h using Plan A... > Hunk #1 failed at 56. > Hunk #2 failed at 126. > 2 out of 2 hunks failed--saving rejects to include/clang/Frontend/CodeGenOptions.h.rej > > |Index: lib/Driver/Tools.cpp > |=================================================================== > |--- lib/Driver/Tools.cpp (revision 123935) > |+++ lib/Driver/Tools.cpp (working copy) > -------------------------- > Patching file lib/Driver/Tools.cpp using Plan A... > Hunk #1 failed at 1280. > Hunk #2 succeeded at 1452 (offset -259 lines). > Hunk #3 succeeded at 3131 (offset -7 lines). > Hunk #4 succeeded at 2967 (offset -245 lines). > 1 out of 4 hunks failed--saving rejects to lib/Driver/Tools.cpp.rej > > I applied the rejected parts by hand (which might be a cause for > the problem below). > > % cd ../../ > % svn status > ? tools/clang/sgk.log > M tools/clang/include/clang/Frontend/CodeGenOptions.h > M tools/clang/include/clang/Driver/CC1Options.td > M tools/clang/lib/Frontend/CompilerInvocation.cpp > M tools/clang/lib/Driver/Tools.cpp > M tools/clang/lib/CodeGen/CodeGenFunction.cpp > M tools/clang/lib/CodeGen/CodeGenFunction.h > > % cd /usr/src/usr.bin/clang > % make clean && make && make install > > troutmask:kargl[211] make testf > clang -o testf -O2 -march=native -pipe -pg -v -I/usr/local/include -I../mp testf.c -L/usr/local/lib -L../mp -lsgk -lmpfr -lgmp -lm > FreeBSD clang version 2.8 (tags/RELEASE_28 115870) 20101007 > Target: x86_64-undermydesk-freebsd9.0 > Thread model: posix > clang: warning: the clang compiler does not support '-pg' > "/usr/bin/clang" -cc1 -triple x86_64-undermydesk-freebsd9.0 -S -disable-free -main-file-name testf.c -mrelocation-model static -mdisable-fp-elim -mconstructor-aliases -munwind-tables -target-cpu athlon-fx -v -resource-dir /usr/lib/clang/2.8 -I /usr/local/include -I ../mp -O2 -ferror-limit 19 -fmessage-length 96 -fgnu-runtime -fdiagnostics-show-option -fcolor-diagnostics -o /tmp/cc-sShp59.s -x c testf.c > clang -cc1 version 2.8 based upon llvm 2.8svn hosted on x86_64-undermydesk-freebsd9.0 > ignoring nonexistent directory "/usr/lib/clang/2.8/include" > #include "..." search starts here: > #include <...> search starts here: > /usr/local/include > ../mp > /usr/include/clang/2.8 > /usr/include > End of search list. > "/usr/bin/as" -o /tmp/cc-Rz3bps.o /tmp/cc-sShp59.s > "/usr/bin/ld" --eh-frame-hdr -dynamic-linker /libexec/ld-elf.so.1 -o testf /usr/lib/crt1.o /usr/lib/crti.o /usr/lib/crtbegin.o -L/usr/local/lib -L../mp /tmp/cc-Rz3bps.o -lsgk -lmpfr -lgmp -lm -lgcc --as-needed -lgcc_s --no-as-needed -lc -lgcc --as-needed -lgcc_s --no-as-needed /usr/lib/crtend.o /usr/lib/crtn.o > > So, I must be doing something wrong. I'll poke around in my tree. :( steve, I believe you're better off using TRUNK llvm/clang with this (and for your benchmarking purposes - as trunk llvm improved considerably compared to 2.8). dim@ will be importing newer clang/llvm RSN so the patch should apply. anyway, regardless of the warnings - does the "call .mcount" show in your app? the -pg argument was handled in a way of "shout a warning but proceed" so it may very well be that clang is (due to a mismerge) complaining but working fine. roman