Re: It's time to kill statistical profiling

Ed Maste <[email protected]>
Newsgroups gmane.os.freebsd.architechture
Message-ID <CAPyFy2AqFgya66PiyjFB2Xkbck3rMqVNEtTgEYDnNhw7P8EXpQ@mail.gmail.com>
On Sun, 20 Jun 2021 at 17:08, Steve Kargl
<[email protected]> wrote:
>
> Are there plans to replace the _p.a with something
> that allows profiling code?  If not, are you upstreaming
> patches to GCC to disable -pg?  AFAIK, 'gcc10 -pg ... -lm'
> causes gcc to look for at least libc_p.a and libm_p.a.

I believe this is how GCC operates indeed, but I'm not aware of the
implementation or specific details. Clang behaves as you describe --
here is all behaviour change based on OPT_pg, from
lib/Driver/ToolChains/FreeBSD.cpp:

    if (!Args.hasArg(options::OPT_shared)) {
      if (Args.hasArg(options::OPT_pg))
        crt1 = "gcrt1.o";
      else if (IsPIE)
        crt1 = "Scrt1.o";
      else
        crt1 = "crt1.o";
    }
...
      if (Args.hasArg(options::OPT_pg))
        CmdArgs.push_back("-lm_p");
      else
        CmdArgs.push_back("-lm");

and similar for -lgcc_p, -lgcc_eh_p, -lpthread_p, -lc_p, -lc++_p, -lstdc++_p.

This support was initially introduced upstream in:

commit 66f2276aee67738d116d26494d8a78fc6528586b
Author: Roman Divacky <[email protected]>
Date:   Thu Feb 10 16:59:40 2011 +0000

    Adjust the object files to be linked in when mcount profiling
    is specified in the FreeBSD linker driver.

    llvm-svn: 125285

and was implemented for OpenBSD later that year, but no other OS does
this. I'm not sure exactly what happens elsewhere - my guess is that
the runtime support exists in libc but it is built without -pg so
coverage will not include libc itself.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.