-profile vs. -pg

John Salmon johns@wealhtheow.cacr.caltech.edu
Thu Sep 10 14:35:00 GMT 1998


I just installed egcs-1.1b on a Linux 2.1 system. I observe the following:

It appears that the '-pg' flag does not tell the driver (gcc) to link
with the -lc_p libraries.

It appears that the '-profile' flag does tell the driver to link with -lc_p.

It appears that the '-profile' flag also implies -p (not -pg) during
compilation.

The -profile flag is not mentioned in the man page or info pages.

This leads to some rather strange results (i.e., bugs):

1 - the documentation gives no hint about how to get profiling info about
libc.

2 - 'gcc -profile foo.c' is equivalent to 'gcc -pg -profile foo.c', but is
different from 'gcc -pg -profile foo.c'.  The first two give you prof-style
profiling, despite the presence of the -pg flag.  The last one will give you
gprof-style profiling of system libs. 

I'm not entirely sure how to "fix" it because I'm not entirely sure
what the desired behavior should be.  Maybe the only thing that needs
repair is the documentation.  But maybe not.  I think the problem
stems from a desire to support (at least) two styles of profiling (-p,
-pg), and (at least) two C libraries (-lc, -lc_p).  Maybe these should
be controlled by two separate and independent switches?  I.e., maybe
the -profile flag should not imply -p during compilation.  If that
seems right, then maybe the -profile flag should also undergo a
name-change to something more descriptive like -profile-system-libs.

In any event, the -profile flag should be documented.

Thanks,
John Salmon



More information about the Gcc-bugs mailing list