This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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



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
-- 
2.7.4


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]