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]

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


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(-)

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


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