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


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