]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
elf: Suppress unused function clang warning for __ifunc_resolver
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>
Fri, 17 Oct 2025 19:13:14 +0000 (16:13 -0300)
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>
Tue, 21 Oct 2025 12:26:04 +0000 (09:26 -0300)
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.

Reviewed-by: Sam James <sam@gentoo.org>
include/libc-symbols.h

index b407fa8f7d08e76d66730e4f8f9e6db2bc326faf..2f9453e0d7be52eb05d5591d5af03a773ef016be 100644 (file)
@@ -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__)