]> git.feebdaed.xyz Git - 0xmirror/glibc.git/commit
Handle clang -Wignored-attributes on weak aliases
authorAdhemerval Zanella <adhemerval.zanella@linaro.org>
Mon, 1 Dec 2025 20:09:46 +0000 (17:09 -0300)
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>
Tue, 9 Dec 2025 11:58:10 +0000 (08:58 -0300)
commit6b7067460f0ad8eb591735d21c60bcf3b52023df
tree91774d1f6b8e478bccdb8e1e61a3657d915cb641
parent2677916d1ccd568951d3b3e29df7076648e157a2
Handle clang -Wignored-attributes on weak aliases

Clang issues a warning for double alias redirection, indicating that thei
original symbol is used even if a weak definition attempts to override it.

For instance, in the construction:

  int __internal_impl (...) {}
  weak_alias (__internal_impl, external_impl);
  #if SOMETHING
  weak_alias (external_impl, another_external_impl)
  #endif

Clang warns that another_external_impl always resolves to __internal_impl,
even if external_impl is a weak reference. Using the internal symbol for
both aliases resolves this warning.

This issue also occurs with certain libc_hidden_def usage:

  int __internal_impl (...) {}
  weak_alias (__internal_impl, __internal_alias)
  libc_hidden_weak (__internal_alias)

In this case, using a strong_alias is sufficient to avoid the warning
(since the alias is internal, there is no need to use a weak alias).

However, for the constructions like:

  int __internal_impl (...) {}
  weak_alias (__internal_impl, __internal_alias)
  libc_hidden_def (__internal_alias)
  weak_alias (__internal_impl, external_alias)
  libc_hidden_def (external_alias)

Clang warns that the internal external_alias will always resolve to
__GI___internal_impl, even if a weak definition of __GI_internal_impl is
overridden.  For this case, a new macro named static_weak_alias is used
to create a strong alias for SHARED, or a weak_alias otherwise.

With these changes, there is no need to check and enable the
-Wno-ignored-attributes suppression when using clang.

Checked with a build on affected ABIs, and a full check on aarch64,
armhf, i686, and x86_64.

Reviewed-by: Sam James <sam@gentoo.org>
118 files changed:
Makefile.in
benchtests/bench-memset.c
configure
configure.ac
dirent/Makefile
include/libc-symbols.h
inet/Makefile
inet/in6_addr.c
io/Makefile
io/Versions
io/lockf64.c
libio/Makefile
libio/feof_u.c
libio/ferror_u.c
libio/fileno.c
libio/getc_u.c
libio/iofflush.c
libio/iofflush_u.c
libio/iofgets_u.c
libio/iofputs.c
libio/iofputs_u.c
libio/iofwrite.c
libio/ioputs.c
libio/putc_u.c
login/Makefile
misc/Makefile
misc/makedev.c
posix/Makefile
posix/confstr.c
posix/fork.c
resolv/Makefile
resolv/inet_pton.c
resource/Makefile
socket/Makefile
stdio-common/Makefile
stdlib/Makefile
stdlib/secure-getenv.c
stdlib/strtod_l.c
stdlib/strtof_l.c
stdlib/strtol.c
string/Makefile
string/argz-next.c
string/basename.c
string/ffs.c
string/ffsll.c
string/memmem.c
string/mempcpy.c
string/test-memchr.c
string/test-strchr.c
string/test-strlen.c
string/test-strnlen.c
sysdeps/aarch64/Makefile
sysdeps/aarch64/fpu/fclrexcpt.c
sysdeps/aarch64/fpu/fegetenv.c
sysdeps/aarch64/fpu/fegetround.c
sysdeps/aarch64/fpu/feholdexcpt.c
sysdeps/aarch64/fpu/fesetenv.c
sysdeps/aarch64/fpu/fesetround.c
sysdeps/aarch64/fpu/feupdateenv.c
sysdeps/aarch64/fpu/fraiseexcpt.c
sysdeps/aarch64/fpu/ftestexcept.c
sysdeps/arm/Makefile
sysdeps/generic/math_ldbl_opt.h
sysdeps/i386/i686/multiarch/wcschr-c.c
sysdeps/ieee754/float128/s_fabsf128.c
sysdeps/ieee754/ldbl-128/strtold_l.c
sysdeps/ieee754/ldbl-96/strtold_l.c
sysdeps/powerpc/powerpc32/power4/multiarch/mempcpy-ppc32.c
sysdeps/s390/wcschr-c.c
sysdeps/unix/sysv/linux/accept.c
sysdeps/unix/sysv/linux/connect.c
sysdeps/unix/sysv/linux/dirfd.c
sysdeps/unix/sysv/linux/fcntl64.c
sysdeps/unix/sysv/linux/getlogin_r.c
sysdeps/unix/sysv/linux/getrlimit64.c
sysdeps/unix/sysv/linux/if_index.c
sysdeps/unix/sysv/linux/ifaddrs.c
sysdeps/unix/sysv/linux/lseek64.c
sysdeps/unix/sysv/linux/mmap64.c
sysdeps/unix/sysv/linux/pread64.c
sysdeps/unix/sysv/linux/pwrite64.c
sysdeps/unix/sysv/linux/read.c
sysdeps/unix/sysv/linux/recv.c
sysdeps/unix/sysv/linux/send.c
sysdeps/unix/sysv/linux/write.c
sysdeps/wordsize-64/Makefile
sysdeps/wordsize-64/strtol.c
sysdeps/wordsize-64/strtoul.c
sysdeps/wordsize-64/wcstol.c
sysdeps/wordsize-64/wcstoul.c
sysdeps/x86_64/fpu/fclrexcpt.c
sysdeps/x86_64/fpu/fegetenv.c
sysdeps/x86_64/fpu/fegetround.c
sysdeps/x86_64/fpu/feholdexcpt.c
sysdeps/x86_64/fpu/fesetenv.c
sysdeps/x86_64/fpu/fesetround.c
sysdeps/x86_64/fpu/fraiseexcpt.c
sysdeps/x86_64/fpu/ftestexcept.c
sysdeps/x86_64/fpu/multiarch/s_exp10m1f.c
sysdeps/x86_64/fpu/multiarch/s_exp2m1f.c
sysdeps/x86_64/fpu/multiarch/s_sincos.c
sysdeps/x86_64/multiarch/mempcpy.c
sysdeps/x86_64/multiarch/stpcpy.c
sysdeps/x86_64/multiarch/strnlen.c
sysdeps/x86_64/multiarch/wcschr.c
sysdeps/x86_64/multiarch/wmemchr.c
sysdeps/x86_64/multiarch/wmemset.c
termios/Makefile
time/Makefile
time/mktime.c
wcsmbs/Makefile
wcsmbs/mbrtowc.c
wcsmbs/wcrtomb.c
wcsmbs/wcschr.c
wcsmbs/wmemchr.c
wcsmbs/wmemset.c
wctype/Makefile
wctype/wcfuncs.c