Relocation error with -Mprof

I’m trying to compile a shared library with profiling enabled, however I get relocation errors despite compiling with -fPIC. The problem seems to be the profiling flag (-Mprof=func). Is it possible to include profiling with shared libraries?

[chulbert@fourier tmp]$ cat junk.f90
module a
contains
subroutine a_foo()
end subroutine
end module

subroutine b()
end subroutine
[chulbert@fourier tmp]$ cat junk.c
void a(void)
{
}
[chulbert@fourier tmp]$ pgfortran -V

pgfortran 12.3-0 64-bit target on x86-64 Linux -tp nehalem
Copyright 1989-2000, The Portland Group, Inc. All Rights Reserved.
Copyright 2000-2012, STMicroelectronics, Inc. All Rights Reserved.
[chulbert@fourier tmp]$ pgfortran -fPIC -shared -Mprof=func junk.f90
/usr/bin/ld: /tmp/pgfortranFP7DzlQHdvu.o: relocation R_X86_64_32S against .data' can not be used when making a shared object; recompile with -fPIC /tmp/pgfortranFP7DzlQHdvu.o: could not read symbols: Bad value [chulbert@fourier tmp]$ pgcc -fPIC -shared -Mprof=func junk.c /usr/bin/ld: /tmp/pgccu-88MyhhPob.o: relocation R_X86_64_32S against .data’ can not be used when making a shared object; recompile with -fPIC
/tmp/pgccu-88MyhhPob.o: could not read symbols: Bad value

Hi Chris,

Right now we don’t support instrumented profiling within FPIC code. We have a old open feature request for it (TPR#14852) but it doesn’t look like it was ever given a high enough priority to implement. I have a mail into the Compile Engineering Manager to see what can be done.

Before I push on engineering, can you see if use the sample based profiler, pgcollect, would work for you? pgcollect does not require the code to instrumented and is capable of profiling all parts of your program, including shared libraries.

Best Regards,
Mat