Re: -ffunction-sections and profiling

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

 



Tim Abbott <tabbott@xxxxxxx> writes:

> 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?

I think it is no longer necessary.  In some cases gcc uses a counter
for every function, which it does by switching into the .data section
before the function and declaring the counter.  Back when
-ffunction-sections was introduced, the profiling code would then
switch back to the general .text section rather than to the section
where the function was supposed to go.  That is long fixed.  I suspect
that this limitation can be removed.

Ian

[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