[1/5] Avoid build multiarch if compiler warns about mismatched alias

Message ID 1507842584-28674-1-git-send-email-adhemerval.zanella@linaro.org
State New
Headers show
Series
  • [1/5] Avoid build multiarch if compiler warns about mismatched alias
Related show

Commit Message

Adhemerval Zanella Oct. 12, 2017, 9:09 p.m.
GCC 8 emits a warning for alias for functions with incompatible types
and it is used extensivelly for ifunc resolvers implementations in C
(for instance on weak_alias with the internal symbol name to the
external one or with the libc_hidden_def to set ifunc for internal
usage).

This breaks the build when the ifunc resolver is not defined using
gcc attribute extensions (HAVE_GCC_IFUNC being 0).  Although for
all currently architectures that have multiarch support this compiler
options is enabled for default, there is still the option where the
user might try build glibc with a compiler without support for such
extension.  In this case this patch just disable the multiarch folder
in sysdeps selections.

GCC 7 and before still builds IFUNCs regardless of compiler support
(although for the lack of attribute support debug information would
be optimal).

The patch also fixes the default value of the multiarch support in
configure.ac (the correct value which is tested later in the script
assumes 'yes' instead of 'default').

Checked with a build on multiarch support architectures (aarch64,a
arm, sparc, s390, powerpc, x86_64, i386) with multiarch enable
and disable and with GCC 7 and GCC 8.

	* configure.ac (multi_arch): Use 'yes' as default value.
	(libc_cv_gcc_incompatbile_alias): New define: indicates whether
	compiler emits an warning for alias for functions with
	incompatible types.
---
 ChangeLog    |  7 +++++++
 configure    | 39 ++++++++++++++++++++++++++++++++++++++-
 configure.ac | 31 ++++++++++++++++++++++++++++++-
 3 files changed, 75 insertions(+), 2 deletions(-)

Comments

Joseph Myers Oct. 12, 2017, 9:52 p.m. | #1
On Thu, 12 Oct 2017, Adhemerval Zanella wrote:

> +  if test x"$libc_cv_gcc_incompatible_alias" == xyes &&
> +     test x"$enable_werror" == xyes; then
> +    AC_MSG_WARN([gcc emits a warning for alias between functions of incompatible types
> +and -Werror is enabled.  Multi-arch is disabled. ])
> +    multi_arch=no

I don't think --disable-werror should ever affect how or whether glibc 
builds as multi-arch.
Adhemerval Zanella Oct. 17, 2017, 1:49 p.m. | #2
On 12/10/2017 18:52, Joseph Myers wrote:
> On Thu, 12 Oct 2017, Adhemerval Zanella wrote:
> 
>> +  if test x"$libc_cv_gcc_incompatible_alias" == xyes &&
>> +     test x"$enable_werror" == xyes; then
>> +    AC_MSG_WARN([gcc emits a warning for alias between functions of incompatible types
>> +and -Werror is enabled.  Multi-arch is disabled. ])
>> +    multi_arch=no
> 
> I don't think --disable-werror should ever affect how or whether glibc 
> builds as multi-arch.
> 

Right, I will remove the 'enable_werror' condition to disable multi-arch.
Are you ok with the rest of the patch?
Joseph Myers Oct. 17, 2017, 4:28 p.m. | #3
On Tue, 17 Oct 2017, Adhemerval Zanella wrote:

> On 12/10/2017 18:52, Joseph Myers wrote:
> > On Thu, 12 Oct 2017, Adhemerval Zanella wrote:
> > 
> >> +  if test x"$libc_cv_gcc_incompatible_alias" == xyes &&
> >> +     test x"$enable_werror" == xyes; then
> >> +    AC_MSG_WARN([gcc emits a warning for alias between functions of incompatible types
> >> +and -Werror is enabled.  Multi-arch is disabled. ])
> >> +    multi_arch=no
> > 
> > I don't think --disable-werror should ever affect how or whether glibc 
> > builds as multi-arch.
> > 
> 
> Right, I will remove the 'enable_werror' condition to disable multi-arch.
> Are you ok with the rest of the patch?

Please send the revised patch series based on current master for review.
Adhemerval Zanella Oct. 19, 2017, 1:06 p.m. | #4
On 17/10/2017 14:28, Joseph Myers wrote:
> On Tue, 17 Oct 2017, Adhemerval Zanella wrote:
> 
>> On 12/10/2017 18:52, Joseph Myers wrote:
>>> On Thu, 12 Oct 2017, Adhemerval Zanella wrote:
>>>
>>>> +  if test x"$libc_cv_gcc_incompatible_alias" == xyes &&
>>>> +     test x"$enable_werror" == xyes; then
>>>> +    AC_MSG_WARN([gcc emits a warning for alias between functions of incompatible types
>>>> +and -Werror is enabled.  Multi-arch is disabled. ])
>>>> +    multi_arch=no
>>>
>>> I don't think --disable-werror should ever affect how or whether glibc 
>>> builds as multi-arch.
>>>
>>
>> Right, I will remove the 'enable_werror' condition to disable multi-arch.
>> Are you ok with the rest of the patch?
> 
> Please send the revised patch series based on current master for review.
> 

Updated patch below:

---

From a9444ab21867e57b3d771c808d322a736bccf0c3 Mon Sep 17 00:00:00 2001
From: Adhemerval Zanella <adhemerval.zanella@linaro.org>
Date: Tue, 10 Oct 2017 11:12:50 -0300
Subject: [PATCH 01/32] Avoid build multiarch if compiler warns about
 mismatched alias

GCC 8 emits an warning for alias for functions with incompatible types
and it is used extensivelly for ifunc resolvers implementations in C
(for instance on weak_alias with the internal symbol name to the
external one or with the libc_hidden_def to set ifunc for internal
usage).

This breaks the build when the ifunc resolver is not defined using
gcc attribute extensions (HAVE_GCC_IFUNC being 0).  Although for
all currently architectures that have multiarch support this compiler
options is enabled for default, there is still the option where the
user might try build glibc with a compiler without support for such
extension.  In this case this patch just disable the multiarch folder
in sysdeps selections.

GCC 7 and before still builds IFUNCs regardless of compiler support
(although for the lack of attribute support debug information would
be optimal).

The patch also fixes the default value of the multiarch support in
configure.ac (the correct value which is tested later in the script
assumer 'yes' instead of 'default').

Checked with a build on multiarch support architectures (aarch64,a
arm, sparc, s390, powerpc, x86_64, i386) with multiarch enable
and disable and with GCC 7 and GCC 8.

	* configure.ac (multi_arch): Use 'yes' as default value.
	(libc_cv_gcc_incompatbile_alias): New define: indicates whether
	compiler emits an warning for alias for functions with
	incompatible types.
---

diff --git a/configure.ac b/configure.ac
index 195e81a..a1387ae 100644
--- a/configure.ac
+++ b/configure.ac
@@ -304,7 +304,7 @@ AC_ARG_ENABLE([multi-arch],
 	      AC_HELP_STRING([--enable-multi-arch],
 			     [enable single DSO with optimizations for multiple architectures]),
 	      [multi_arch=$enableval],
-	      [multi_arch=default])
+	      [multi_arch=yes])
 
 AC_ARG_ENABLE([experimental-malloc],
 	      AC_HELP_STRING([--disable-experimental-malloc],
@@ -634,6 +634,26 @@ if ${CC-cc} -c conftest.c -o conftest.o 1>&AS_MESSAGE_LOG_FD \
 fi
 rm -f conftest*])
 
+# Check if gcc warns about alias for function with incompatible types.
+AC_CACHE_CHECK([if compiler warns about alias for function with incompatible types],
+	       libc_cv_gcc_incompatible_alias, [dnl
+cat > conftest.c <<EOF
+int __redirect_foo (const void *s, int c);
+
+__typeof (__redirect_foo) *foo_impl (void) __asm__ ("foo");
+__typeof (__redirect_foo) *foo_impl (void)
+{
+  return 0;
+}
+
+extern __typeof (__redirect_foo) foo_alias __attribute__ ((alias ("foo")));
+EOF
+libc_cv_gcc_incompatible_alias=yes
+if ${CC-cc} -Werror -c conftest.c -o conftest.o 1>&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD ; then
+  libc_cv_gcc_incompatible_alias=no
+fi
+rm -f conftest*])
+
 if test x"$libc_cv_ld_gnu_indirect_function" != xyes; then
   if test x"$multi_arch" = xyes; then
     AC_MSG_ERROR([--enable-multi-arch support requires assembler and linker support])
@@ -645,6 +665,14 @@ if test x"$libc_cv_gcc_indirect_function" != xyes &&
    test x"$multi_arch" = xyes; then
   AC_MSG_WARN([--enable-multi-arch support recommends a gcc with gnu-indirect-function support.
 Please use a gcc which supports it by default or configure gcc with --enable-gnu-indirect-function])
+  # GCC 8+ emits and warning for alias with incompatible types and it might
+  # fail to to build ifunc resolvers aliases to either weak or internal
+  # symbols.  Disables multiarch build in this case.
+  if test x"$libc_cv_gcc_incompatible_alias" == xyes; then
+    AC_MSG_WARN([gcc emits a warning for alias between functions of incompatible types.
+Multi-arch is disabled. ])
+    multi_arch=no
+  fi
 fi
 multi_arch_d=
 if test x"$multi_arch" != xno; then
Joseph Myers Oct. 19, 2017, 1:40 p.m. | #5
On Thu, 19 Oct 2017, Adhemerval Zanella wrote:

> The patch also fixes the default value of the multiarch support in
> configure.ac (the correct value which is tested later in the script
> assumer 'yes' instead of 'default').

I'm concerned about this "fix".  Did you test on an architecture where the 
assembler and linker lack IFUNC support?

The default is supposed to be support if assembler and linker support is 
present.  If absent, an explicit --enable-multi-arch should give an error, 
but the default would just disable the feature.

>  if test x"$libc_cv_ld_gnu_indirect_function" != xyes; then
>    if test x"$multi_arch" = xyes; then
>      AC_MSG_ERROR([--enable-multi-arch support requires assembler and linker support])

That is, this is deliberately distinguishing "default" (turned into "no" 
here if assembler and linker support absent) from "yes" (give an error 
here if multi-arch explicitly requested but assembler and linker support 
absent).  This logic should be maintained when adding the requirement for 
ifunc attributes to work with GCC 8 or later: for "default", missing 
support means "no"; for "yes", missing support means error.

Later code in configure.ac also explicitly checks for "default" and turns 
it into "no" when there are no multiarch sysdeps directories.
Adhemerval Zanella Oct. 19, 2017, 4:07 p.m. | #6
On 19/10/2017 11:40, Joseph Myers wrote:
> On Thu, 19 Oct 2017, Adhemerval Zanella wrote:
> 
>> The patch also fixes the default value of the multiarch support in
>> configure.ac (the correct value which is tested later in the script
>> assumer 'yes' instead of 'default').
> 
> I'm concerned about this "fix".  Did you test on an architecture where the 
> assembler and linker lack IFUNC support?
> 
> The default is supposed to be support if assembler and linker support is 
> present.  If absent, an explicit --enable-multi-arch should give an error, 
> but the default would just disable the feature.
> 
>>  if test x"$libc_cv_ld_gnu_indirect_function" != xyes; then
>>    if test x"$multi_arch" = xyes; then
>>      AC_MSG_ERROR([--enable-multi-arch support requires assembler and linker support])
> 
> That is, this is deliberately distinguishing "default" (turned into "no" 
> here if assembler and linker support absent) from "yes" (give an error 
> here if multi-arch explicitly requested but assembler and linker support 
> absent).  This logic should be maintained when adding the requirement for 
> ifunc attributes to work with GCC 8 or later: for "default", missing 
> support means "no"; for "yes", missing support means error.
> 
> Later code in configure.ac also explicitly checks for "default" and turns 
> it into "no" when there are no multiarch sysdeps directories.

My initial proposal is indeed wrong for architectures where assembler
and linker lack IFUNC support.  Below is the fix which does not change
the multi_arch configure.ac default value (which is indeed correct
as you pointed out).


Now for m68k-linux-gnu I see the expected result:

checking for assembler and linker STT_GNU_IFUNC support... no
checking for gcc attribute ifunc support... no
checking if compiler warns about alias for function with incompatible types... no
checking sysdep dirs... sysdeps/unix/sysv/linux/m68k/m680x0 sysdeps/unix/sysv/linux/m68k sysdeps/m68k/nptl sysdeps/unix/sysv/linux sysdeps/nptl sysdeps/pthread sysdeps/gnu sysdeps/unix/inet sysdeps/unix/sysv sysdeps/unix sysdeps/posix sysdeps/m68k/m680x0/m68020 sysdeps/m68k/m680x0/fpu sysdeps/m68k/m680x0 sysdeps/ieee754/ldbl-96 sysdeps/m68k/fpu sysdeps/m68k sysdeps/wordsize-32 sysdeps/ieee754/dbl-64 sysdeps/ieee754/flt-32 sysdeps/ieee754 sysdeps/generic


And for armv7-linux-gnueabihf with GCC6 I see:

checking for assembler and linker STT_GNU_IFUNC support... yes
checking for gcc attribute ifunc support... no
checking if compiler warns about alias for function with incompatible types... no
checking sysdep dirs... sysdeps/unix/sysv/linux/arm sysdeps/arm/nptl sysdeps/unix/sysv/linux sysdeps/nptl sysdeps/pthread sysdeps/gnu sysdeps/unix/inet sysdeps/unix/sysv sysdeps/unix/arm sysdeps/unix sysdeps/posix sysdeps/arm/armv7/multiarch sysdeps/arm/armv7 sysdeps/arm/armv6t2 sysdeps/arm/armv6 sysdeps/arm sysdeps/wordsize-32 sysdeps/ieee754/flt-32 sysdeps/ieee754/dbl-64 sysdeps/ieee754 sysdeps/generic


For armv7-linux-gnueabihf with GCC8 without ifunc support on compiler:

checking for assembler and linker STT_GNU_IFUNC support... yes
checking for gcc attribute ifunc support... no
checking if compiler warns about alias for function with incompatible types... yes
configure: WARNING: gcc emits a warning for alias between functions of incompatible types.
Multi-arch is disabled.
checking sysdep dirs... sysdeps/unix/sysv/linux/arm sysdeps/arm/nptl sysdeps/unix/sysv/linux sysdeps/nptl sysdeps/pthread sysdeps/gnu sysdeps/unix/inet sysdeps/unix/sysv sysdeps/unix/arm sysdeps/unix sysdeps/posix sysdeps/arm/armv7 sysdeps/arm/armv6t2 sysdeps/arm/armv6 sysdeps/arm sysdeps/wordsize-32 sysdeps/ieee754/flt-32 sysdeps/ieee754/dbl-64 sysdeps/ieee754 sysdeps/generic


And finally for armv7-linux-gnueabihf with GCC8 with compiler ifunc support:

checking for assembler and linker STT_GNU_IFUNC support... yes
checking for gcc attribute ifunc support... yes
checking if compiler warns about alias for function with incompatible types... yes
checking sysdep dirs... sysdeps/unix/sysv/linux/arm sysdeps/arm/nptl sysdeps/unix/sysv/linux sysdeps/nptl sysdeps/pthread sysdeps/gnu sysdeps/unix/inet sysdeps/unix/sysv sysdeps/unix/arm sysdeps/unix sysdeps/posix sysdeps/arm/armv7/multiarch sysdeps/arm/armv7 sysdeps/arm/armv6t2 sysdeps/arm/armv6 sysdeps/arm sysdeps/wordsize-32 sysdeps/ieee754/flt-32 sysdeps/ieee754/dbl-64 sysdeps/ieee754 sysdeps/generic

---

GCC 8 emits an warning for alias for functions with incompatible types
and it is used extensivelly for ifunc resolvers implementations in C
(for instance on weak_alias with the internal symbol name to the
external one or with the libc_hidden_def to set ifunc for internal
usage).

This breaks the build when the ifunc resolver is not defined using
gcc attribute extensions (HAVE_GCC_IFUNC being 0).  Although for
all currently architectures that have multiarch support this compiler
options is enabled for default, there is still the option where the
user might try build glibc with a compiler without support for such
extension.  In this case this patch just disable the multiarch folder
in sysdeps selections.

GCC 7 and before still builds IFUNCs regardless of compiler support
(although for the lack of attribute support debug information would
be optimal).

Checked with a build on multiarch support architectures (aarch64,
arm, sparc, s390, powerpc, x86_64, i386) with multiarch enable
and disable and with GCC 7 and GCC 8.

	* configure.ac (libc_cv_gcc_incompatbile_alias): New define:
	indicates whether compiler emits an warning for alias for
	functions with incompatible types.
---
diff --git a/configure.ac b/configure.ac
index 195e81a..99c94f3 100644
--- a/configure.ac
+++ b/configure.ac
@@ -634,6 +634,26 @@ if ${CC-cc} -c conftest.c -o conftest.o 1>&AS_MESSAGE_LOG_FD \
 fi
 rm -f conftest*])
 
+# Check if gcc warns about alias for function with incompatible types.
+AC_CACHE_CHECK([if compiler warns about alias for function with incompatible types],
+	       libc_cv_gcc_incompatible_alias, [dnl
+cat > conftest.c <<EOF
+int __redirect_foo (const void *s, int c);
+
+__typeof (__redirect_foo) *foo_impl (void) __asm__ ("foo");
+__typeof (__redirect_foo) *foo_impl (void)
+{
+  return 0;
+}
+
+extern __typeof (__redirect_foo) foo_alias __attribute__ ((alias ("foo")));
+EOF
+libc_cv_gcc_incompatible_alias=yes
+if ${CC-cc} -Werror -c conftest.c -o conftest.o 1>&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD ; then
+  libc_cv_gcc_incompatible_alias=no
+fi
+rm -f conftest*])
+
 if test x"$libc_cv_ld_gnu_indirect_function" != xyes; then
   if test x"$multi_arch" = xyes; then
     AC_MSG_ERROR([--enable-multi-arch support requires assembler and linker support])
@@ -641,10 +661,19 @@ if test x"$libc_cv_ld_gnu_indirect_function" != xyes; then
     multi_arch=no
   fi
 fi
-if test x"$libc_cv_gcc_indirect_function" != xyes &&
-   test x"$multi_arch" = xyes; then
-  AC_MSG_WARN([--enable-multi-arch support recommends a gcc with gnu-indirect-function support.
+if test x"$libc_cv_gcc_indirect_function" != xyes; then
+  if test x"$multi_arch" = xyes; then
+    AC_MSG_WARN([--enable-multi-arch support recommends a gcc with gnu-indirect-function support.
 Please use a gcc which supports it by default or configure gcc with --enable-gnu-indirect-function])
+  fi
+  # GCC 8+ emits and warning for alias with incompatible types and it might
+  # fail to to build ifunc resolvers aliases to either weak or internal
+  # symbols.  Disables multiarch build in this case.
+  if test x"$libc_cv_gcc_incompatible_alias" == xyes; then
+    AC_MSG_WARN([gcc emits a warning for alias between functions of incompatible types.
+Multi-arch is disabled. ])
+    multi_arch=no
+  fi
 fi
 multi_arch_d=
 if test x"$multi_arch" != xno; then
Joseph Myers Oct. 19, 2017, 4:49 p.m. | #7
On Thu, 19 Oct 2017, Adhemerval Zanella wrote:

> For armv7-linux-gnueabihf with GCC8 without ifunc support on compiler:
> 
> checking for assembler and linker STT_GNU_IFUNC support... yes
> checking for gcc attribute ifunc support... no
> checking if compiler warns about alias for function with incompatible types... yes
> configure: WARNING: gcc emits a warning for alias between functions of incompatible types.
> Multi-arch is disabled.

Note that for this case, with explicit --enable-multi-arch, there should 
be an error, much like that for missing assembler / linker support in that 
case (while for the default case without the configure option, a warning 
plus disabling multi-arch is appropriate).  I don't think this patch 
achieves that.
Adhemerval Zanella Oct. 19, 2017, 5:17 p.m. | #8
On 19/10/2017 14:49, Joseph Myers wrote:
> On Thu, 19 Oct 2017, Adhemerval Zanella wrote:
> 
>> For armv7-linux-gnueabihf with GCC8 without ifunc support on compiler:
>>
>> checking for assembler and linker STT_GNU_IFUNC support... yes
>> checking for gcc attribute ifunc support... no
>> checking if compiler warns about alias for function with incompatible types... yes
>> configure: WARNING: gcc emits a warning for alias between functions of incompatible types.
>> Multi-arch is disabled.
> 
> Note that for this case, with explicit --enable-multi-arch, there should 
> be an error, much like that for missing assembler / linker support in that 
> case (while for the default case without the configure option, a warning 
> plus disabling multi-arch is appropriate).  I don't think this patch 
> achieves that.
> 

Right, current approach disable multiarch in this case.  What about the below
(using arm-linux-gnueabihf as target):

* GCC6:

checking for assembler and linker STT_GNU_IFUNC support... yes
checking for gcc attribute ifunc support... no
checking if compiler warns about alias for function with incompatible types... no
checking sysdep dirs... sysdeps/unix/sysv/linux/arm sysdeps/arm/nptl sysdeps/unix/sysv/linux sysdeps/nptl sysdeps/pthread sysdeps/gnu sysdeps/unix/inet sysdeps/unix/sysv sysdeps/unix/arm sysdeps/unix sysdeps/posix sysdeps/arm/armv7/multiarch sysdeps/arm/armv7 sysdeps/arm/armv6t2 sysdeps/arm/armv6 sysdeps/arm sysdeps/wordsize-32 sysdeps/ieee754/flt-32 sysdeps/ieee754/dbl-64 sysdeps/ieee754 sysdeps/generic

* GCC6 with --enable-multi-arch:

checking for assembler and linker STT_GNU_IFUNC support... yes
checking for gcc attribute ifunc support... no
checking if compiler warns about alias for function with incompatible types... no
configure: WARNING: --enable-multi-arch support recommends a gcc with gnu-indirect-function support.
Please use a gcc which supports it by default or configure gcc with --enable-gnu-indirect-function
checking sysdep dirs... sysdeps/unix/sysv/linux/arm sysdeps/arm/nptl sysdeps/unix/sysv/linux sysdeps/nptl sysdeps/pthread sysdeps/gnu sysdeps/unix/inet sysdeps/unix/sysv sysdeps/unix/arm sysdeps/unix sysdeps/posix sysdeps/arm/armv7/multiarch sysdeps/arm/armv7 sysdeps/arm/armv6t2 sysdeps/arm/armv6 sysdeps/arm sysdeps/wordsize-32 sysdeps/ieee754/flt-32 sysdeps/ieee754/dbl-64 sysdeps/ieee754 sysdeps/generic

* GCC8 without ifunc support and default config options:

checking for assembler and linker STT_GNU_IFUNC support... yes
checking for gcc attribute ifunc support... no
checking if compiler warns about alias for function with incompatible types... yes
configure: WARNING: gcc emits a warning for alias between functions of incompatible types
configure: WARNING: Multi-arch is disabled.
checking sysdep dirs... sysdeps/unix/sysv/linux/arm sysdeps/arm/nptl sysdeps/unix/sysv/linux sysdeps/nptl sysdeps/pthread sysdeps/gnu sysdeps/unix/inet sysdeps/unix/sysv sysdeps/unix/arm sysdeps/unix sysdeps/posix sysdeps/arm/armv7 sysdeps/arm/armv6t2 sysdeps/arm/armv6 sysdeps/arm sysdeps/wordsize-32 sysdeps/ieee754/flt-32 sysdeps/ieee754/dbl-64 sysdeps/ieee754 sysdeps/generic

* GCC8 without ifunc support and with --enable-multi-arch:

checking for assembler and linker STT_GNU_IFUNC support... yes
checking for gcc attribute ifunc support... no
checking if compiler warns about alias for function with incompatible types... yes
configure: WARNING: gcc emits a warning for alias between functions of incompatible types
configure: error: --enable-multi-arch support requires a gcc with gnu-indirect-function support

* GC8 with ifunc support:

checking for assembler and linker STT_GNU_IFUNC support... yes
checking for gcc attribute ifunc support... yes
checking if compiler warns about alias for function with incompatible types... yes
checking sysdep dirs... sysdeps/unix/sysv/linux/arm sysdeps/arm/nptl sysdeps/unix/sysv/linux sysdeps/nptl sysdeps/pthread sysdeps/gnu sysdeps/unix/inet sysdeps/unix/sysv sysdeps/unix/arm sysdeps/unix sysdeps/posix sysdeps/arm/armv7/multiarch sysdeps/arm/armv7 sysdeps/arm/armv6t2 sysdeps/arm/armv6 sysdeps/arm sysdeps/wordsize-32 sysdeps/ieee754/flt-32 sysdeps/ieee754/dbl-64 sysdeps/ieee754 sysdeps/generic


I think it would be better to display the warning message on default
configuration as well (I think that was my initial intention on
changing the multi_arch default), but I think we can address it on
a subsequent patch.

---

diff --git a/configure.ac b/configure.ac
index 195e81a..cde1585 100644
--- a/configure.ac
+++ b/configure.ac
@@ -634,6 +634,26 @@ if ${CC-cc} -c conftest.c -o conftest.o 1>&AS_MESSAGE_LOG_FD \
 fi
 rm -f conftest*])
 
+# Check if gcc warns about alias for function with incompatible types.
+AC_CACHE_CHECK([if compiler warns about alias for function with incompatible types],
+	       libc_cv_gcc_incompatible_alias, [dnl
+cat > conftest.c <<EOF
+int __redirect_foo (const void *s, int c);
+
+__typeof (__redirect_foo) *foo_impl (void) __asm__ ("foo");
+__typeof (__redirect_foo) *foo_impl (void)
+{
+  return 0;
+}
+
+extern __typeof (__redirect_foo) foo_alias __attribute__ ((alias ("foo")));
+EOF
+libc_cv_gcc_incompatible_alias=yes
+if ${CC-cc} -Werror -c conftest.c -o conftest.o 1>&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD ; then
+  libc_cv_gcc_incompatible_alias=no
+fi
+rm -f conftest*])
+
 if test x"$libc_cv_ld_gnu_indirect_function" != xyes; then
   if test x"$multi_arch" = xyes; then
     AC_MSG_ERROR([--enable-multi-arch support requires assembler and linker support])
@@ -641,10 +661,21 @@ if test x"$libc_cv_ld_gnu_indirect_function" != xyes; then
     multi_arch=no
   fi
 fi
-if test x"$libc_cv_gcc_indirect_function" != xyes &&
-   test x"$multi_arch" = xyes; then
-  AC_MSG_WARN([--enable-multi-arch support recommends a gcc with gnu-indirect-function support.
+if test x"$libc_cv_gcc_indirect_function" != xyes; then
+  # GCC 8+ emits and warning for alias with incompatible types and it might
+  # fail to to build ifunc resolvers aliases to either weak or internal
+  # symbols.  Disables multiarch build in this case.
+  if test x"$libc_cv_gcc_incompatible_alias" == xyes; then
+    AC_MSG_WARN([gcc emits a warning for alias between functions of incompatible types])
+    if test x"$multi_arch" = xyes; then
+      AC_MSG_ERROR([--enable-multi-arch support requires a gcc with gnu-indirect-function support])
+    fi
+    AC_MSG_WARN([Multi-arch is disabled.])
+    multi_arch=no
+  elif test x"$multi_arch" = xyes; then
+    AC_MSG_WARN([--enable-multi-arch support recommends a gcc with gnu-indirect-function support.
 Please use a gcc which supports it by default or configure gcc with --enable-gnu-indirect-function])
+  fi
 fi
 multi_arch_d=
 if test x"$multi_arch" != xno; then
Joseph Myers Oct. 20, 2017, 5:04 p.m. | #9
On Thu, 19 Oct 2017, Adhemerval Zanella wrote:

> +if test x"$libc_cv_gcc_indirect_function" != xyes; then
> +  # GCC 8+ emits and warning for alias with incompatible types and it might

s/and warning/a warning/.

> +  # fail to to build ifunc resolvers aliases to either weak or internal

s/to to/to/.

OK with those fixes.

Patch

diff --git a/configure.ac b/configure.ac
index 195e81a..647aaa6 100644
--- a/configure.ac
+++ b/configure.ac
@@ -304,7 +304,7 @@  AC_ARG_ENABLE([multi-arch],
 	      AC_HELP_STRING([--enable-multi-arch],
 			     [enable single DSO with optimizations for multiple architectures]),
 	      [multi_arch=$enableval],
-	      [multi_arch=default])
+	      [multi_arch=yes])
 
 AC_ARG_ENABLE([experimental-malloc],
 	      AC_HELP_STRING([--disable-experimental-malloc],
@@ -634,6 +634,26 @@  if ${CC-cc} -c conftest.c -o conftest.o 1>&AS_MESSAGE_LOG_FD \
 fi
 rm -f conftest*])
 
+# Check if gcc warns about alias for function with incompatible types.
+AC_CACHE_CHECK([if compiler warns about alias for function with incompatible types],
+	       libc_cv_gcc_incompatible_alias, [dnl
+cat > conftest.c <<EOF
+int __redirect_foo (const void *s, int c);
+
+__typeof (__redirect_foo) *foo_impl (void) __asm__ ("foo");
+__typeof (__redirect_foo) *foo_impl (void)
+{
+  return 0;
+}
+
+extern __typeof (__redirect_foo) foo_alias __attribute__ ((alias ("foo")));
+EOF
+libc_cv_gcc_incompatible_alias=yes
+if ${CC-cc} -Werror -c conftest.c -o conftest.o 1>&AS_MESSAGE_LOG_FD 2>&AS_MESSAGE_LOG_FD ; then
+  libc_cv_gcc_incompatible_alias=no
+fi
+rm -f conftest*])
+
 if test x"$libc_cv_ld_gnu_indirect_function" != xyes; then
   if test x"$multi_arch" = xyes; then
     AC_MSG_ERROR([--enable-multi-arch support requires assembler and linker support])
@@ -645,6 +665,15 @@  if test x"$libc_cv_gcc_indirect_function" != xyes &&
    test x"$multi_arch" = xyes; then
   AC_MSG_WARN([--enable-multi-arch support recommends a gcc with gnu-indirect-function support.
 Please use a gcc which supports it by default or configure gcc with --enable-gnu-indirect-function])
+  # GCC 8+ emits and warning for alias with incompatible types and thus fail
+  # to build ifunc resolvers aliases to either weak or internal symbols.
+  # Disables multiarch build in this case.
+  if test x"$libc_cv_gcc_incompatible_alias" == xyes &&
+     test x"$enable_werror" == xyes; then
+    AC_MSG_WARN([gcc emits a warning for alias between functions of incompatible types
+and -Werror is enabled.  Multi-arch is disabled. ])
+    multi_arch=no
+  fi
 fi
 multi_arch_d=
 if test x"$multi_arch" != xno; then