[PATCH 07/59] posix: Suppress -Wignored-attributes when building for confstr.c with clang

Adhemerval Zanella Netto adhemerval.zanella@linaro.org
Tue Oct 21 18:06:12 GMT 2025



On 17/10/25 16:50, Florian Weimer wrote:
> * Adhemerval Zanella:
> 
>> confstr.c:293:1: error: alias will always resolve to __GI___confstr even if weak definition of __GI_confstr is overridden [-Werror,-Wignored-attributes]
>>   293 | libc_hidden_def (confstr)
>>       | ^
> 
> We could introduce static_weak_alias to avoid generating weak
> definitions for shared builds.  I think it might even catch some
> multiple-definition bugs.
>
The problem clang warns is when we have a double weak alias indirection:

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

If we make the alias to same internal symbol clang does not trigger
warnings:

  #if SOMETHING
  weak_alias (__external_impl, another_external_impl)
  #endif

It is also an issue with some libc_hidden_def usage, where it has:

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

For this case using a strong_alias is suffice.

However I don't have a easy solution for 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)

I can avoid the warning by using a strong_alias to the internal
alias, but I think we will need add a new macro as you suggested
(static_weak_alias).

I think we these changes we can remove all of 
$(config-cflags-wno-ignored-attributes) usage.





More information about the Libc-alpha mailing list