[PATCH 39/59] elf: Suppress unused function clang warning for __ifunc_resolver

Adhemerval Zanella Netto adhemerval.zanella@linaro.org
Tue Oct 21 11:47:27 GMT 2025



On 20/10/25 16:51, Sam James wrote:
> Adhemerval Zanella <adhemerval.zanella@linaro.org> writes:
> 
>> The __ifunc_resolver macro expands to:
>>
>>    extern __typeof (__redirect_name) name __attribute__ ((ifunc ("iname_ifunc")));
>>    static __typeof (__redirect_name) *name_ifunc (void) { [...] };
>>
>> And although NAME_IFUNC is and alias for NAME, clang still emits
>> an 'unused function 'name_ifunc' [-Werror,-Wunused-function]'
>> warning.  The static is used to avoid name pollution on static
>> linkage.
> 
> A bug report for LLVM would be appreciated. See also
> https://github.com/llvm/llvm-project/issues/63957 (lol).

Right, I will open one.

> 
> Reviewed-by: Sam James <sam@gentoo.org>
> 
>> ---
>>  include/libc-symbols.h | 6 +++++-
>>  1 file changed, 5 insertions(+), 1 deletion(-)
>>
>> diff --git a/include/libc-symbols.h b/include/libc-symbols.h
>> index b407fa8f7d..2f9453e0d7 100644
>> --- a/include/libc-symbols.h
>> +++ b/include/libc-symbols.h
>> @@ -86,6 +86,7 @@
>>  
>>  /* Obtain the definition of symbol_version_reference.  */
>>  #include <libc-symver.h>
>> +#include <libc-diag.h>
>>  
>>  /* When PIC is defined and SHARED isn't defined, we are building PIE
>>     by default.  */
>> @@ -671,7 +672,10 @@ for linking")
>>  # define __ifunc_args(type_name, name, expr, init, ...)			\
>>    extern __typeof (type_name) name __attribute__			\
>>  			      ((ifunc (#name "_ifunc")));		\
>> -  __ifunc_resolver (type_name, name, expr, init, static, __VA_ARGS__)
>> +  DIAG_PUSH_NEEDS_COMMENT_CLANG;					\
>> +  DIAG_IGNORE_NEEDS_COMMENT_CLANG (13, "-Wunused-function");		\
>> +  __ifunc_resolver (type_name, name, expr, init, static, __VA_ARGS__);	\
>> +  DIAG_POP_NEEDS_COMMENT_CLANG;
>>  
>>  # define __ifunc_args_hidden(type_name, name, expr, init, ...)		\
>>    __ifunc_args (type_name, name, expr, init, __VA_ARGS__)



More information about the Libc-alpha mailing list