Trying to use gprof profiler, but linking keeps failing

mailinglists--- via fpc-pascal <[email protected]> Tue, 17 Mar 2026 13:21:03 +0000
Newsgroups gmane.comp.compilers.free-pascal.general
Message-ID <[email protected]>
Hi. I wanted to use gprof to profile a binary of mine that has 
performance problems. I'm trying to recompiled the fpgui framework and 
the program with -O- and -pg but the framework fails at the linking 
stage.

Linking target/fpgui-framework
bootstrap_program.pas(126,1) Warning: "crtbegin.o" not found, this will 
probably cause a linking failure
bootstrap_program.pas(126,1) Warning: "crtend.o" not found, this will 
probably cause a linking failure
/usr/bin/ld: /usr/lib/x86_64-linux-gnu/libc_nonshared.a(atexit.oS): in 
function `atexit':
(.text+0x7): undefined reference to `__dso_handle'
/usr/bin/ld: target/fpgui-framework: hidden symbol `__dso_handle' isn't 
defined
/usr/bin/ld: final link failed: bad value
bootstrap_program.pas(126,1) Error: Error while linking
bootstrap_program.pas(126,1) Fatal: There were 1 errors compiling 
module, stopping
Fatal: Compilation aborted
Error: /data/devel/fpc-3.2.2/x86_64-linux/bin/ppcx64 returned an error 
exitcode


Any ideas? I then did a google search and Gemini came back with this:

The -pg (gprof) flag doesn't work well with Free Pascal — it tries to 
link against C runtime profiling infrastructure (crtbegin.o, 
__dso_handle) that FPC's linker setup doesn't support.


Is this true?

Regards,
   Graeme


_______________________________________________
fpc-pascal maillist  -  [email protected]
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal