public inbox for glibc-cvs@sourceware.org
help / color / mirror / Atom feed
From: Adhemerval Zanella <azanella@sourceware.org>
To: glibc-cvs@sourceware.org
Subject: [glibc/azanella/clang] configure: Use -Wno-ignored-attributes if compiler warns about multiple aliases
Date: Thu,  9 Feb 2023 19:47:58 +0000 (GMT)	[thread overview]
Message-ID: <20230209194758.ACD9C3857B98@sourceware.org> (raw)

https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=ba390dd1a58a1414cc7ae0571286d8f4f085f0f0

commit ba390dd1a58a1414cc7ae0571286d8f4f085f0f0
Author: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date:   Fri Mar 11 10:40:44 2022 -0300

    configure: Use -Wno-ignored-attributes if compiler warns about multiple aliases
    
    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.

Diff:
---
 configure                             | 29 +++++++++++++++++++++++++++++
 configure.ac                          | 22 ++++++++++++++++++++++
 math/Makefile                         |  8 ++++++++
 sysdeps/x86_64/fpu/multiarch/Makefile |  2 ++
 4 files changed, 61 insertions(+)

diff --git a/configure b/configure
index f1fddbfeb6..073d474fcc 100755
--- a/configure
+++ b/configure
@@ -5992,6 +5992,35 @@ $as_echo "$libc_cv_wno_ignored_attributes" >&6; }
 config_vars="$config_vars
 config-cflags-wno-ignored-attributes = $libc_cv_wno_ignored_attributes"
 
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if -Wno-ignored-attributes is required for aliases" >&5
+$as_echo_n "checking if -Wno-ignored-attributes is required for aliases... " >&6; }
+if ${libc_cv_wno_ignored_attributes+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat > conftest.c <<EOF
+void __foo (void)
+{
+}
+extern __typeof (__foo) foo __attribute__ ((weak, alias ("__foo")));
+extern __typeof (__foo) bar __attribute__ ((weak, alias ("foo")));
+EOF
+libc_cv_wno_ignored_attributes=""
+if ! { ac_try='${CC-cc} $CFLAGS $CPPFLAGS -Werror -c conftest.c'
+  { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5
+  (eval $ac_try) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; }
+then
+  libc_cv_wno_ignored_attributes="-Wno-ignored-attributes"
+fi
+rm -f conftest*
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libc_cv_wno_ignored_attributes" >&5
+$as_echo "$libc_cv_wno_ignored_attributes" >&6; }
+config_vars="$config_vars
+config-cflags-wno-ignored-attributes = $libc_cv_wno_ignored_attributes"
+
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether cc puts quotes around section names" >&5
 $as_echo_n "checking whether cc puts quotes around section names... " >&6; }
 if ${libc_cv_have_section_quotes+:} false; then :
diff --git a/configure.ac b/configure.ac
index 1b39d19735..c2a90c070d 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1410,6 +1410,28 @@ rm -f conftest*])
 LIBC_CONFIG_VAR([config-cflags-wno-ignored-attributes],
 		[$libc_cv_wno_ignored_attributes])
 
+dnl clang emits an warning when a double alias redirection is used, to warn
+dnl the the original symbol will be used even when weak definition is overridden.
+dnl This is a common pattern for weak_alias, where multiple alias are set to
+dnl same symbol.
+AC_CACHE_CHECK([if -Wno-ignored-attributes is required for aliases],
+	       libc_cv_wno_ignored_attributes, [dnl
+cat > conftest.c <<EOF
+void __foo (void)
+{
+}
+extern __typeof (__foo) foo __attribute__ ((weak, alias ("__foo")));
+extern __typeof (__foo) bar __attribute__ ((weak, alias ("foo")));
+EOF
+libc_cv_wno_ignored_attributes=""
+if ! AC_TRY_COMMAND([${CC-cc} $CFLAGS $CPPFLAGS -Werror -c conftest.c])
+then
+  libc_cv_wno_ignored_attributes="-Wno-ignored-attributes"
+fi
+rm -f conftest*])
+LIBC_CONFIG_VAR([config-cflags-wno-ignored-attributes],
+		[$libc_cv_wno_ignored_attributes])
+
 AC_CACHE_CHECK(whether cc puts quotes around section names,
 	       libc_cv_have_section_quotes,
 	       [cat > conftest.c <<EOF
diff --git a/math/Makefile b/math/Makefile
index a9daae09de..bf0393b7a7 100644
--- a/math/Makefile
+++ b/math/Makefile
@@ -1002,6 +1002,14 @@ CFLAGS-s_y0f.c += -fno-builtin-y0f32
 CFLAGS-s_y1f.c += -fno-builtin-y1f32
 CFLAGS-s_ynf.c += -fno-builtin-ynf32
 
+CFLAGS-s_fabsf128.c += $(config-cflags-wno-ignored-attributes)
+CFLAGS-fraiseexcpt.c += $(config-cflags-wno-ignored-attributes)
+CFLAGS-fegetround.c += $(config-cflags-wno-ignored-attributes)
+CFLAGS-fesetround.c += $(config-cflags-wno-ignored-attributes)
+CFLAGS-fegetenv.c += $(config-cflags-wno-ignored-attributes)
+CFLAGS-fesetenv.c += $(config-cflags-wno-ignored-attributes)
+CFLAGS-feholdexcpt.c += $(config-cflags-wno-ignored-attributes)
+
 # These files quiet sNaNs in a way that is optimized away without
 # -fsignaling-nans.
 CFLAGS-s_modf.c += $(config-cflags-signaling-nans)
diff --git a/sysdeps/x86_64/fpu/multiarch/Makefile b/sysdeps/x86_64/fpu/multiarch/Makefile
index 248162525b..caa1ec82fb 100644
--- a/sysdeps/x86_64/fpu/multiarch/Makefile
+++ b/sysdeps/x86_64/fpu/multiarch/Makefile
@@ -13,6 +13,8 @@ libm-sysdep_routines += e_exp-fma e_log-fma e_pow-fma s_atan-fma \
 			e_asin-fma e_atan2-fma s_sin-fma s_tan-fma \
 			s_sincos-fma
 
+CFLAGS-s_sincos.c += $(config-cflags-wno-ignored-attributes)
+
 CFLAGS-e_asin-fma.c = -mfma -mavx2
 CFLAGS-e_atan2-fma.c = -mfma -mavx2
 CFLAGS-e_exp-fma.c = -mfma -mavx2

             reply	other threads:[~2023-02-09 19:47 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-02-09 19:47 Adhemerval Zanella [this message]
  -- strict thread matches above, loose matches on Subject: below --
2024-04-17 20:06 Adhemerval Zanella
2024-04-02 15:52 Adhemerval Zanella
2024-02-09 17:30 Adhemerval Zanella
2024-02-07 14:06 Adhemerval Zanella
2024-01-29 17:56 Adhemerval Zanella
2023-12-21 18:53 Adhemerval Zanella
2023-09-28 17:51 Adhemerval Zanella
2023-08-30 12:36 Adhemerval Zanella
2022-10-28 17:40 Adhemerval Zanella
2022-10-28 17:38 Adhemerval Zanella
2022-10-04 12:58 Adhemerval Zanella
2022-10-04 12:56 Adhemerval Zanella
2022-06-09 21:19 Adhemerval Zanella
2022-06-09 13:16 Adhemerval Zanella
2022-06-03 14:05 Adhemerval Zanella
2022-05-13 14:19 Adhemerval Zanella
2022-05-12 19:33 Adhemerval Zanella
2022-05-10 18:23 Adhemerval Zanella
2022-04-29 14:03 Adhemerval Zanella
2022-04-04 12:54 Adhemerval Zanella
2022-03-31 19:06 Adhemerval Zanella
2022-03-29 20:29 Adhemerval Zanella
2022-03-16 18:03 Adhemerval Zanella
2022-03-15 18:41 Adhemerval Zanella
2022-03-11 17:25 Adhemerval Zanella

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230209194758.ACD9C3857B98@sourceware.org \
    --to=azanella@sourceware.org \
    --cc=glibc-cvs@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).