How to build an executable with profiling?

Steve Kargl sgk at troutmask.apl.washington.edu
Wed Jan 19 16:40:27 UTC 2011


On Wed, Jan 19, 2011 at 11:18:22AM +0100, Hans Ottevanger wrote:
> On 01/18/11 22:12, Roman Divacky wrote:
> >On Tue, Jan 18, 2011 at 09:35:17AM -0800, Steve Kargl wrote:
> >>On Tue, Jan 18, 2011 at 06:16:57PM +0100, Roman Divacky wrote:
> >>>On Tue, Jan 18, 2011 at 04:43:13PM +0200, Kostik Belousov wrote:
> >>>>On Tue, Jan 18, 2011 at 03:32:05PM +0100, Roman Divacky wrote:
> >>>>>On Mon, Jan 17, 2011 at 10:44:11AM -0800, Steve Kargl wrote:
> >>>>>>How does one build an executable for profiling with clang?
> >>>>>
> >>>>>LLVM (and thus clang) does not support GPROF profiling.
> >>>>>
> >>>>>>clang -o testf -O2 -march=native -pipe -static -pg 
> >>>>>>-I/usr/local/include -I../mp testf.c -L/usr/local/lib -L../mp -lsgk 
> >>>>>>-lmpfr -lgmp -L/usr/home/kargl/work/lib -lm_clang_p
> >>>>>>clang: warning: the clang compiler does not support '-pg'
> >>>>>>
> 
> If you are really desperate to find the hotspots in your program when 
> compiled with clang, you could call clang with -v to find the call to 
> /bin/ld. Then append _p to the appropriate libs if still needed and 
> replace crt1.o by gcrt1.o while calling ld directly. E.g.

I am working on implementations of missing long double functions
and complex function from libm.  In doing this work, there are
two overriding desires: accuracy and speed.  In addition, I 
want to compare and *profile* a clang built libm against a
gcc built libm.  I already have anecdotal evidence that a clang
libm is usually slower and sometime less accurate than a gcc
libm.  Thus, the desire to build a clang libm with something
equivalent to 'gcc -pg'.

> "/usr/bin/ld" -Bstatic -o testcoll /usr/lib/gcrt1.o /usr/lib/crti.o 
> /usr/lib/crtbegin.o testcoll.o angle.o apsis.o error.o minmax.o qags.o 
> qext.o qk21.o sort.o timint.o zero.o vmol.o -lm_p -lgcc -lgcc_eh -lc_p 
> -lgcc -lgcc_eh -t /usr/lib/crtend.o /usr/lib/crtn.o

How do I create libm_p.a with clang?  That's the issue.

-- 
Steve


More information about the freebsd-toolchain mailing list