On Thu, Aug 17, 2023 at 01:36:32AM +0200, Bruno Haible wrote: > 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.
Thank you for your response and explanation! > 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? I was analyzing the FTBFS of the grep package in ALT after the upgrade to the glibc 2.38. The -flto flag is enabled for all packages by default, and the grep package is compiled with the --enable-gcc-warnings configuration option, which includes the -Wsuggest-attribute=cold flag. I was certain that this issue should be addressed in gnulib (since the warning is triggered by the gnulib code and the warning flag itself comes from the gnulib), but I've come to realize that certain warnings that are disabled by grep are actually related to gnulib code. -- glebfm