Re: [PATCH] Silence clang -Wignored-attributes when building with clang
Adhemerval Zanella Netto <[email protected]> Wed, 29 Jul 2026 14:04:21 -0300
| Newsgroups | gmane.comp.lib.glibc.alpha |
|---|---|
| Organization | Linaro |
| Message-ID | <[email protected]> |
On 27/07/26 11:54, Matt Turner wrote:
> Building glibc with clang trips -Wignored-attributes on the alias
> redirections glibc uses intentionally, e.g. the long_double_symbol
> machinery where a public name aliases a weak alias of an internal
> symbol.
>
> These warnings are harmless: the alias attribute still generates
> the correct ELF symbol table entries, and the GNU linker resolves
> indirect alias chains at link time. Clang warns that attributes
> on the intermediate alias target won't be inherited by the outer
> alias, but that attribute propagation is neither expected nor
> needed here -- the aliasing semantics themselves are unaffected.
>
> Detect whether CC is clang (cc-clang) and add -Wno-ignored-attributes
> to the warning flags.
I could avoid add this flag by reworking how the weak alias were done
for some routines (check 6b7067460f0ad8eb591735d21c60bcf3b52023df). It
does work for x86_64 and aarch64 for clang 18 through 22 (I haven't
tested 23 yet).
Which ABI are you targeting?
> ---
> Makeconfig | 4 ++++
> configure | 29 +++++++++++++++++++++++++++++
> configure.ac | 9 +++++++++
> 3 files changed, 42 insertions(+)
>
> diff --git ./Makeconfig ./Makeconfig
> index 8fe7217dd7..4c34e59aed 100644
> --- ./Makeconfig
> +++ ./Makeconfig
> @@ -908,6 +908,10 @@ endif
> ifeq ($(enable-werror),yes)
> +gccwarn += -Werror
> endif
> +# Clang warns on the intentional alias redirections (e.g. long_double_symbol).
> +ifeq ($(cc-clang),yes)
> ++gccwarn += -Wno-ignored-attributes
> +endif
> +gccwarn-c = -Wstrict-prototypes -Wold-style-definition \
> $(cc-option-wfree-labels) $(cc-option-wmissing-parameter-name)
>
> diff --git ./configure ./configure
> index 90c4b4f858..fbe8e4ac30 100755
> --- ./configure
> +++ ./configure
> @@ -6031,6 +6031,35 @@ config_vars="$config_vars
> have-test-clang = $libc_cv_test_clang"
>
>
> +cat > conftest.c <<EOF
> +$conftest_code
> +EOF
> +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: checking whether CC is clang" >&5
> +printf %s "checking whether CC is clang... " >&6; }
> +if test ${libc_cv_cc_clang+y}
> +then :
> + printf %s "(cached) " >&6
> +else case e in #(
> + e) if { ac_try='${CC-cc} $CFLAGS $CPPFLAGS -c conftest.c -o conftest 1>&5'
> + { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5
> + (eval $ac_try) 2>&5
> + ac_status=$?
> + printf "%s\n" "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
> + test $ac_status = 0; }; }
> + then
> + libc_cv_cc_clang=yes
> + else
> + libc_cv_cc_clang=no
> + fi ;;
> +esac
> +fi
> +{ printf "%s\n" "$as_me:${as_lineno-$LINENO}: result: $libc_cv_cc_clang" >&5
> +printf "%s\n" "$libc_cv_cc_clang" >&6; }
> +rm -f conftest*
> +config_vars="$config_vars
> +cc-clang = $libc_cv_cc_clang"
> +
> +
> cat > conftest.cc <<EOF
> $conftest_code
> EOF
> diff --git ./configure.ac ./configure.ac
> index 2a788c13b7..0d81a6e7a0 100644
> --- ./configure.ac
> +++ ./configure.ac
> @@ -651,6 +651,15 @@ LIBC_TRY_TEST_CC_COMMAND([for clang],
> )
> LIBC_CONFIG_VAR([have-test-clang], [$libc_cv_test_clang])
>
> +dnl Check whether the library itself is built with clang (CC).
> +LIBC_TRY_CC_COMMAND([whether CC is clang],
> + [$conftest_code],
> + [-c],
> + libc_cv_cc_clang,
> + [libc_cv_cc_clang=yes], [libc_cv_cc_clang=no],
> +)
> +LIBC_CONFIG_VAR([cc-clang], [$libc_cv_cc_clang])
> +
> dnl Check if clang++ is used to test glibc.
> LIBC_TRY_TEST_CXX_COMMAND([for clang++],
> [$conftest_code],