From mboxrd@z Thu Jan 1 00:00:00 1970 Received: (qmail 7735 invoked from network); 20 May 1998 19:03:38 -0000 Received: from mescaline.gnu.org (we-refuse-to-spy-on-our-users@158.121.106.21) by mail2.redhat.com with SMTP; 20 May 1998 19:03:38 -0000 Received: from melange.gnu.org by mescaline.gnu.org (8.8.5/8.6.12GNU) with ESMTP id PAA04397 for ; Wed, 20 May 1998 15:03:37 -0400 Received: (burley@localhost) by melange.gnu.org (8.8.5/8.6.12GNU) id PAA19569; Wed, 20 May 1998 15:03:35 -0400 (EDT) Date: Wed, 20 May 1998 15:03:35 -0400 (EDT) Message-Id: <199805201903.PAA19569@melange.gnu.org> From: Craig Burley To: axp-list@redhat.com In-reply-to: <356324A9.BA4DCCEF@paralleldata.com> (wsb@paralleldata.com) Subject: Re: gprof on mixed gcc/g77 code >Craig Burley wrote: > >> >I've got binaries where I mix C/FORTRAN and am trying >> >to gprof them on a RH5.0 system. Strictly C programs >> >appear to profile fine after adding the '-pg' flag to the >> >compile/link. However, when I add this flag to g77, >> >it seems to convert it to '-p'. Not what I want to >> >have happen. Is this what it does?? If so, why?? >> >> 1) What does "appear to profile fine" have to do with "seems to convert >> it to `-p'"? > >The C program shows maybe 50 routines, with reasonable >looking cpu times. That seems completely unrelated. `-p' clearly has nothing to do with the problem, since both cc1 and f771 -- *internal* programs for gcc and g77 -- get passed `-p' to enable profiling (even when *you* specify `-pg'). And they both share the bulk of their code, including much of their options processing and code generation (where profiling is mostly, if not entirely, handled). >> 2) Why isn't converting it to `-p' what you want to have happen? > >>>From what I've used in the past, '-p' is for prof, '-pg' is for >gprof, and only gprof exists on my system. You're talking about the gcc and g77 commands there. What gcc and g77 accept for options is not always directly related to what the internal programs cc1 and f771 accept. There are some similarities, but it's incorrect to assume that any option you pass to gcc or g77 must necessarily be passed "unmolested" through to cc1 or f771 (or cc1plus or cc1obj, etc.). >> 3) Are you sure gcc isn't doing the same thing -- converting `-pg' >> to `-p'? (It does on my box.) > >It may, but whatever gcc does, it seems to work. Yet, that's not what you said earlier. You said the bug was that f771 was passed `-p', yet that's the same thing cc1 is passed, as you now verify. I just don't think that's the bug, and your original reasoning as to why it was seemed clearly flawed to me, and, being unaccompanied by complete information on the problems you were encountering, made it difficult to guess as to what might be wrong. >What g77 >does doesn't. Only clues I have are the '-p' and the resulting >gprof output contains NO FORTRAN routine information. Perhaps you should submit a bug report? Both g77 and gcc come with extensive documentation, including on how and where to file bug reports. >Maybe FORTRAN >requires a MAIN routine to trigger the counting?? That might be. I don't know how profiling works in the gcc/g77 environment (yet). You might try making your own C version of the f/runtime/libF77/main.c file, compiling it with -pg, and linking it ahead of libf2c.a on the command line, and see if that helps. So this could just become Yet Another Reason Not To Put main() In A Library. g77 already has a longish such list for libf2c improvements. >I do see that the C runtime >routine seems to be switched for profiling according to >the gcc specs file, gcrt1.o vs crt1.o. By looking at the >specs, it appears '-p' and '-pg' do the same thing. So, >that leads back to how does FORTRAN hook up >profiling. See if `g77 -v -pg ...' reports the same kind of switching to gcrt1.o and such as does `gcc -v -pg ...' on your system. If so, then I'd guess it's the main-not-compiled-with--pg problem suggested above. -- "Practice random senselessness and act kind of beautiful." James Craig Burley, Software Craftsperson burley@gnu.org