Red Hat axp-list: Linux on Alpha (1995-2022)
 help / color / mirror / Atom feed
From: Craig Burley <burley@gnu.org>
To: axp-list@redhat.com
Subject: Re: gprof on mixed gcc/g77 code
Date: Wed, 20 May 1998 15:03:35 -0400 (EDT)	[thread overview]
Message-ID: <199805201903.PAA19569@melange.gnu.org> (raw)
In-Reply-To: <356324A9.BA4DCCEF@paralleldata.com> (wsb@paralleldata.com)

>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


  reply	other threads:[~1998-05-20 19:03 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-05-20  8:56 gprof on mixed gcc/g77 code Wes Bauske
1998-05-20 15:13 ` Craig Burley
1998-05-20 18:44   ` Wes Bauske
1998-05-20 19:03     ` Craig Burley [this message]
1998-05-20 21:40       ` Wes Bauske
1998-05-21  1:38         ` Craig Burley
1998-05-21  2:56           ` Wes Bauske
1998-05-21  3:55             ` Craig Burley
1998-05-21  4:32               ` Wes Bauske
1998-05-21  5:37               ` Maurice Hilarius
1998-05-21 15:26                 ` Craig Burley
     [not found] <199805201453.IAA23638@ellpspace.math.ualberta.ca>
1998-05-20 21:45 ` Wes Bauske
read-only archive

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox