[PATCH 08/11] configure: Use -Wno-ignored-attributes if compiler warns about multiple aliases

Fangrui Song maskray@google.com
Sat Oct 29 05:59:36 GMT 2022


On 2022-10-28, Adhemerval Zanella via Libc-alpha wrote:
>clang emits an warning when a double alias redirection is used, to warn
>the the original symbol will be used even when weak definition is
>overridden.  Howerver, this is a common pattern for weak_alias, where
>multiple alias are set to same symbol.

Confirmed that the pattern is common.  

% rg -U 'libc_hidden_def.*\nweak_alias.*\nlibc_hidden_weak' -l
login/getlogin_r.c
libio/iofgets_u.c
libio/iofflush.c
libio/iofputs_u.c
libio/iofflush_u.c
libio/iofgets.c
libio/fileno.c
string/memmem.c
resource/getrlimit64.c
string/argz-next.c
inet/if_index.c
io/open.c
string/basename.c
wcsmbs/wmemset.c
wcsmbs/wcschr.c
wcsmbs/wmemchr.c
wctype/wcfuncs.c
resolv/inet_pton.c
sysdeps/x86_64/wmemchr.S
sysdeps/x86_64/memset.S
sysdeps/unix/getlogin_r.c
sysdeps/x86_64/wcschr.S
sysdeps/mach/hurd/getpid.c
sysdeps/mach/hurd/read.c
sysdeps/mach/hurd/write.c
sysdeps/mach/hurd/getlogin_r.c
sysdeps/mach/hurd/if_index.c
sysdeps/mach/hurd/fcntl.c
sysdeps/mach/hurd/open.c
sysdeps/unix/sysv/linux/getlogin_r.c
sysdeps/unix/sysv/linux/fcntl64.c
sysdeps/unix/sysv/linux/if_index.c

The three macros can be reordered and there may be more results.

I just took some notes here https://maskray.me/blog/2021-10-10-when-can-glibc-be-built-with-clang#alias-to-a-weak-alias
I feel that the pattern is ugly but I cannot figure out a better way. Clang has a reasonable diagnostic. It is fine to 
ignore it as the Clang symbol codegen matches GCC.

```
26: 0000000000000000   596 FUNC    GLOBAL HIDDEN     1 __GI___mbrtowc
33: 0000000000000000   596 FUNC    GLOBAL DEFAULT    1 __mbrtowc
34: 0000000000000000   596 FUNC    WEAK   HIDDEN     1 __GI_mbrtowc
35: 0000000000000000   596 FUNC    WEAK   DEFAULT    1 mbrtowc
```

So here is a Reviewed-by tag: but I really hope that we can come up with a better way.

Reviewed-by: Fangrui Song <maskray@google.com>


More information about the Libc-alpha mailing list