How to build an executable with profiling?

Roman Divacky rdivacky at freebsd.org
Thu Jan 20 18:54:53 UTC 2011


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
-------------- 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/20110120/cf17e784/attachment.pgp


More information about the freebsd-toolchain mailing list