Use generic __ifunc for SPARC

Message ID alpine.DEB.2.20.1709261815560.21154@digraph.polyomino.org.uk
State New, archived
Headers

Commit Message

Joseph Myers Sept. 26, 2017, 6:17 p.m. UTC
  glibc fails to build with GCC mainline for SPARC because of the use of
manually-created IFUNCs, which fail the tests of compatibility of
function alias types.  This patch changes sparc-ifunc.h to use the
generic __ifunc in defining sparc_libm_ifunc.  The generic __ifunc can
use the GCC ifunc attribute when available, so ensuring
type-correctness as well as better debug info than when setting symbol
types in asm statements.

Note that for this to fix the build with GCC mainline the GCC patch
<https://gcc.gnu.org/ml/gcc-patches/2017-09/msg01779.html>, or
building GCC with --enable-gnu-indirect-function, is also needed.

Tested (compilation only) with build-many-glibcs.py (sparc64-linux-gnu
and sparcv9-linux-gnu, with GCC 8 with the above patch, and also with
GCC 7).

2017-09-26  Joseph Myers  <joseph@codesourcery.com>

	* sysdeps/sparc/sparc-ifunc.h [!__ASSEMBLER__] (sparc_libm_ifunc):
	Define using __ifunc.
  

Comments

David Miller Sept. 26, 2017, 6:20 p.m. UTC | #1
From: Joseph Myers <joseph@codesourcery.com>
Date: Tue, 26 Sep 2017 18:17:06 +0000

> glibc fails to build with GCC mainline for SPARC because of the use of
> manually-created IFUNCs, which fail the tests of compatibility of
> function alias types.  This patch changes sparc-ifunc.h to use the
> generic __ifunc in defining sparc_libm_ifunc.  The generic __ifunc can
> use the GCC ifunc attribute when available, so ensuring
> type-correctness as well as better debug info than when setting symbol
> types in asm statements.
> 
> Note that for this to fix the build with GCC mainline the GCC patch
> <https://gcc.gnu.org/ml/gcc-patches/2017-09/msg01779.html>, or
> building GCC with --enable-gnu-indirect-function, is also needed.
> 
> Tested (compilation only) with build-many-glibcs.py (sparc64-linux-gnu
> and sparcv9-linux-gnu, with GCC 8 with the above patch, and also with
> GCC 7).
> 
> 2017-09-26  Joseph Myers  <joseph@codesourcery.com>
> 
> 	* sysdeps/sparc/sparc-ifunc.h [!__ASSEMBLER__] (sparc_libm_ifunc):
> 	Define using __ifunc.

Looks good.
  

Patch

diff --git a/sysdeps/sparc/sparc-ifunc.h b/sysdeps/sparc/sparc-ifunc.h
index 8cc86ff..4b1ea00 100644
--- a/sysdeps/sparc/sparc-ifunc.h
+++ b/sysdeps/sparc/sparc-ifunc.h
@@ -162,14 +162,8 @@  END (__##name)
 
 #else	/* __ASSEMBLER__ */
 
-# define sparc_libm_ifunc(name, expr)					\
-  extern void *name##_ifunc (int) __asm__ (#name);			\
-  void *name##_ifunc (int hwcap)					\
-  {									\
-    __typeof (name) *res = expr;					\
-    return res;								\
-  }									\
-  __asm__ (".type " #name ", %gnu_indirect_function");
+# define sparc_libm_ifunc(name, expr)				\
+  __ifunc (name, name, expr, int hwcap, libm_ifunc_init)
 
 # define sparc_libc_ifunc(name, expr) sparc_libm_ifunc (name, expr)