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

Message ID bee78e74-3553-e049-89aa-01b66a8ae531@linaro.org
State Dropped
Headers

Commit Message

Adhemerval Zanella Oct. 19, 2017, 5:17 p.m. UTC
  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.

---
  

Comments

Joseph Myers Oct. 20, 2017, 5:04 p.m. UTC | #1
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..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