Using -p (or -pg) with gcc-1.39

William Roberts; liam at cs.qmw.ac.uk
Wed Feb 6 05:31:33 AEST 1991


In <532 at rafos.UUCP> jimg at zeno.gso.uri.edu (James Gallagher) writes:

>I have had no success. 

>Here's what I've tried: 

>1) I tried compiling a simple program with 'gcc -p -v -D_BSD_SOURCE
>-D_SYSV_SOURCE simple.c' and got the error 'linker cant find -lc_p'.

>2) I tried 'cc -v -p simple.c' (I can use cc on simple.c, but not on the ANSI
>program I want to profile). That works. So, I tried using the linker that way
>cc did (it used /lib/libp/libc rather than the non-existant libc_p). However,
>I got an undefined symbol error (d0 and mcount 'referenced but not defined').

>Any help would be grately appreciated.

You didn't look closely enough at the difference between A/UX cc and A/UX cc 
with the -p (I presume you used the -v option to find out what is happening).

% /nfs/CDROM/bin/cc -v -p foo.c
/nfs/CDROM/lib/cpp -Dmc68k32 foo.c /usr/tmp/ctmAAAa004914
/nfs/CDROM/lib/ccom -Xn -XI -U /usr/tmp/ctmAAAa004914 /usr/tmp/ctmAAAa004913 
-XP
/nfs/CDROM/bin/as -o foo.o /usr/tmp/ctmAAAa004913
/nfs/CDROM/bin/ld /nfs/CDROM/lib/mcrt0.o /nfs/CDROM/lib/crt2.o -L/lib/libp 
foo.o -lc /nfs/CDROM/lib/crtn.o /nfs/CDROM/usr/lib/shlib.ld

% /nfs/CDROM/bin/cc -v foo.c
/nfs/CDROM/lib/cpp -Dmc68k32 foo.c /usr/tmp/ctmAAAa004964
/nfs/CDROM/lib/ccom -Xn -XI -U /usr/tmp/ctmAAAa004964 /usr/tmp/ctmAAAa004963
/nfs/CDROM/bin/as -o foo.o /usr/tmp/ctmAAAa004963
/nfs/CDROM/bin/ld /nfs/CDROM/lib/crt1.o /nfs/CDROM/lib/crt2.o foo.o -lc 
/nfs/CDROM/lib/crtn.o /nfs/CDROM/usr/lib/shlib.ld

Don't worry about /nfs/CDROM - it is just a disk image mounted read-only. The 
salient features are:

Profiling: link with mcrt0.o crt2.o and -L/lib/libp 
Normal:    link with crt1.o  crt2.o and no tricks about libraries.

The thing you are missing is mcrt0.o which starts things up correctly and 
provides those missing symbols. Personally I prefer the _p trick for naming 
profiled libraries because it is more generic that having cc invoke ld with an 
additional -L option: do I really want to put my profiled X libraries into 
/lib/libp?

This is another problem for the long suffering John Coolidge to look into, 
though personally I'd recommend fixing the mcrt0.o part and ignoring the 
-L/lib/libp stuff.
--

William Roberts                 ARPA: liam at cs.qmw.ac.uk
Queen Mary & Westfield College  UUCP: liam at qmw-cs.UUCP
Mile End Road                   AppleLink: UK0087
LONDON, E1 4NS, UK              Tel:  071-975 5250 (Fax: 081-980 6533)



More information about the Comp.unix.aux mailing list