Re: -ffunction-sections and profiling

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Tim Abbott wrote:
I'd like to be able to compile the Linux kernel with both -ffunction-sections and profiling (-pg). Using gcc with both -ffunction-sections and -pg causes the following warning to be printed:

"warning: -ffunction-sections disabled; it makes profiling impossible"

and indeed -ffunction-sections is disabled. I've not been able to find any documentation or mailing list threads that explain this conflict, though the discussion starting at [1] speculates it is related to the labels emitted for profiling support, and notes that the code for disabling -ffunction-sections was written when -ffunction-sections was introduced back in 1996.

However, I've compiled gcc 4.3.2 on i386 after removing the code that disables -ffunction-sections when profiling is enabled. It does generate working -ffunction-sections code that has mcount calls at the start of each function. I've also tried gprof with a simple program compiled with -ffunction-sections -pg, and it gave similar (though definitely not identical) results to those from using gprof with the same program compiled with just -pg.

So, why does gcc disable -ffunction-sections when compiling with -pg?
Because it didn't work way back when the code was originally written. If you wanted to do some testing, test function-sections with -pg on the PA (HP-UX) or Sparc (Solaris) targets. That's where the problem is most likely to manifest itself. If I had to hazard a guess I'd suspect something along the lines of not being able to ensure that one or more marker labels are in the same section as the function itself.
Jeff

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux