Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 20 Jan 2011 22:52:11 +0100
From:      Roman Divacky <rdivacky@freebsd.org>
To:        Steve Kargl <sgk@troutmask.apl.washington.edu>
Cc:        freebsd-toolchain@freebsd.org
Subject:   Re: How to build an executable with profiling?
Message-ID:  <20110120215211.GA15379@freebsd.org>
In-Reply-To: <20110120214503.GA19077@troutmask.apl.washington.edu>
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>

next in thread | previous in thread | raw e-mail | index | archive | help
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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20110120215211.GA15379>