How to build an executable with profiling?

Roman Divacky rdivacky at freebsd.org
Fri Jan 21 19:27:54 UTC 2011


> >This patch does three things:
> >
> >1) emits "call .mcount" at the begining of every function body
> >
> 
> The differences on i386 between profiled and non-profiled code are not 
> as obvious as with gcc (using diff on assembly output), but on first 
> inspection it looks correct.
 
cool :)

> >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
> >
> 
> Maybe it is wise to follow the gcc implementation here.
 
ok, makes sense

> >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.
> >
> 
> On both my systems (i386 and amd64) something goes severely wrong when 
> linking several objects (all compiled with -pg, this is amd64):
> 
> Perhaps the invocation of the linker still needs some work (or I must 
> redo my installation) but anyhow it looks like a good job. Thanks!

I rewrote the libraries rewriting part to match gcc as close as possible.
I also think that I solved your ld problem..


please revert the old patch and test the new one:

        http://lev.vlakno.cz/~rdivacky/clang-gprof.patch

I believe this one is ok (works for me just fine), please test and report
back so I can start integrating this upstream.

thank you!

roman
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 196 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-toolchain/attachments/20110121/8e61f092/attachment.pgp


More information about the freebsd-toolchain mailing list