Gleb Fotengauer-Malinovskiy wrote:
> Following the glibc commit glibc-2.38~298 ("Mark various cold functions
> as __COLD"), the compilation of projects employing the manywarnings
> module (such as GNU grep) with with the -flto flag triggers a GCC
> warning:
> 
> sigsegv.c: In function ‘stackoverflow_deinstall_handler.part.0’:
> sigsegv.c:1441:1: error: function might be candidate for attribute ‘cold’ 
> [-Werror=suggest-attribute=cold]

Thanks for the suggestion, but it is wrong to use _GL_ATTRIBUTE_COLD
in this case.

By the definition of the 'cold' attribute [1], whether it makes sense to use
this attribute or not depends on the call graph of this function. But the
function 'stackoverflow_deinstall_handler' is a global function. Therefore
its call graph includes the program that's going to invoke it. Gnulib being
a library used to build dozens of packages with hundreds of programs, no one
can make valid statements about such call graphs.

Btw, what's your purpose of using -Wsuggest-attribute=cold ? If you are
using -flto, then the compiler should already be able to make the optimizations,
having just found out that the function is rarely used. Or are you making
1 compilation with -flto, in order to get back to compilations without -flto
later?

Bruno

[1] 
https://gcc.gnu.org/onlinedocs/gcc-13.2.0/gcc/Common-Function-Attributes.html




Reply via email to