public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
* [PATCH v2 1/9] Add configure check to test if gcc supports attribute ifunc.
@ 2016-08-08 14:40 Stefan Liebler
  2016-08-08 14:40 ` [PATCH v2 2/9] Use gcc attribute ifunc in libc_ifunc macro instead of inline assembly due to false debuginfo Stefan Liebler
                   ` (10 more replies)
  0 siblings, 11 replies; 21+ messages in thread
From: Stefan Liebler @ 2016-08-08 14:40 UTC (permalink / raw)
  To: libc-alpha; +Cc: stli, fweimer, murphyp, schwab, joseph_myers

This patch adds a configure check to test if gcc supports attribute ifunc.
The support can either be enabled in <gcc-src>/gcc/config.gcc for one
architecture in general by setting default_gnu_indirect_function variable to yes
or by configuring gcc with --enable-gnu-indirect-function.

The next patch rewrites libc_ifunc macro to use gcc attribute ifunc instead
of inline assembly to generate the IFUNC symbols due to false debuginfo.

If gcc does not support attribute ifunc and glibc is configured with
--enable-multi-arch then configure will abort with an error message.
If --enable-multi-arch is not given then configure will silently
disable multi-arch support.

ChangeLog:

	* configure.ac: Add check if gcc supports attribute ifunc feature.
	* configure: Regenerated.
---
 configure    | 38 +++++++++++++++++++++++++++++++++++---
 configure.ac | 32 +++++++++++++++++++++++++++++---
 2 files changed, 64 insertions(+), 6 deletions(-)

diff --git a/configure b/configure
index 17625e1..aedada3 100755
--- a/configure
+++ b/configure
@@ -3914,9 +3914,40 @@ fi
 { $as_echo "$as_me:${as_lineno-$LINENO}: result: $libc_cv_ld_gnu_indirect_function" >&5
 $as_echo "$libc_cv_ld_gnu_indirect_function" >&6; }
 
-if test x"$libc_cv_ld_gnu_indirect_function" != xyes; then
+# Check if gcc supports attribute ifunc as it is used in libc_ifunc macro.
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for gcc attribute ifunc support" >&5
+$as_echo_n "checking for gcc attribute ifunc support... " >&6; }
+if ${libc_cv_gcc_indirect_function+:} false; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat > conftest.c <<EOF
+extern int func (int);
+int used_func (int a)
+{
+  return a;
+}
+static void *resolver ()
+{
+  return &used_func;
+}
+extern __typeof (func) func __attribute__ ((ifunc ("resolver")));
+EOF
+libc_cv_gcc_indirect_function=no
+if ${CC-cc} -c conftest.c -o conftest.o 1>&5 \
+   2>&5 ; then
+  if $READELF -s conftest.o | grep IFUNC >/dev/null 2>&5; then
+    libc_cv_gcc_indirect_function=yes
+  fi
+fi
+rm -f conftest*
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libc_cv_gcc_indirect_function" >&5
+$as_echo "$libc_cv_gcc_indirect_function" >&6; }
+
+if test x"$libc_cv_ld_gnu_indirect_function" != xyes \
+   || test x"$libc_cv_gcc_indirect_function" != xyes; then
   if test x"$multi_arch" = xyes; then
-    as_fn_error $? "--enable-multi-arch support requires assembler and linker support" "$LINENO" 5
+    as_fn_error $? "--enable-multi-arch support require gcc, assembler and linker indirect-function support" "$LINENO" 5
   else
     multi_arch=no
   fi
@@ -6499,7 +6530,8 @@ fi
 
 # A sysdeps configure fragment can reset this if IFUNC is not actually
 # usable even though the assembler knows how to generate the symbol type.
-if test x"$libc_cv_ld_gnu_indirect_function" = xyes; then
+if test x"$libc_cv_ld_gnu_indirect_function" = xyes \
+   && test x"$libc_cv_gcc_indirect_function" = xyes; then
   $as_echo "#define HAVE_IFUNC 1" >>confdefs.h
 
 fi
diff --git a/configure.ac b/configure.ac
index 33bcd62..0961151 100644
--- a/configure.ac
+++ b/configure.ac
@@ -634,9 +634,34 @@ if ${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS \
 fi
 rm -f conftest*])
 
-if test x"$libc_cv_ld_gnu_indirect_function" != xyes; then
+# Check if gcc supports attribute ifunc as it is used in libc_ifunc macro.
+AC_CACHE_CHECK([for gcc attribute ifunc support],
+	       libc_cv_gcc_indirect_function, [dnl
+cat > conftest.c <<EOF
+extern int func (int);
+int used_func (int a)
+{
+  return a;
+}
+static void *resolver ()
+{
+  return &used_func;
+}
+extern __typeof (func) func __attribute__ ((ifunc ("resolver")));
+EOF
+libc_cv_gcc_indirect_function=no
+if ${CC-cc} -c conftest.c -o conftest.o 1>&AS_MESSAGE_LOG_FD \
+   2>&AS_MESSAGE_LOG_FD ; then
+  if $READELF -s conftest.o | grep IFUNC >/dev/null 2>&AS_MESSAGE_LOG_FD; then
+    libc_cv_gcc_indirect_function=yes
+  fi
+fi
+rm -f conftest*])
+
+if test x"$libc_cv_ld_gnu_indirect_function" != xyes \
+   || test x"$libc_cv_gcc_indirect_function" != xyes; then
   if test x"$multi_arch" = xyes; then
-    AC_MSG_ERROR([--enable-multi-arch support requires assembler and linker support])
+    AC_MSG_ERROR([--enable-multi-arch support require gcc, assembler and linker indirect-function support])
   else
     multi_arch=no
   fi
@@ -1766,7 +1791,8 @@ AC_SUBST(libc_cv_gcc_unwind_find_fde)
 
 # A sysdeps configure fragment can reset this if IFUNC is not actually
 # usable even though the assembler knows how to generate the symbol type.
-if test x"$libc_cv_ld_gnu_indirect_function" = xyes; then
+if test x"$libc_cv_ld_gnu_indirect_function" = xyes \
+   && test x"$libc_cv_gcc_indirect_function" = xyes; then
   AC_DEFINE(HAVE_IFUNC)
 fi
 
-- 
2.5.5

^ permalink raw reply	[flat|nested] 21+ messages in thread

end of thread, other threads:[~2016-08-24 14:10 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-08-08 14:40 [PATCH v2 1/9] Add configure check to test if gcc supports attribute ifunc Stefan Liebler
2016-08-08 14:40 ` [PATCH v2 2/9] Use gcc attribute ifunc in libc_ifunc macro instead of inline assembly due to false debuginfo Stefan Liebler
2016-08-08 14:40 ` [PATCH v2 3/9] s390: Refactor ifunc resolvers " Stefan Liebler
2016-08-08 14:40 ` [PATCH v2 8/9] Use libc_ifunc macro for vfork in libpthread Stefan Liebler
2016-08-08 14:40 ` [PATCH v2 6/9] Use libc_ifunc macro for clock_* symbols in librt Stefan Liebler
2016-08-08 14:40 ` [PATCH v2 4/9] i386, x86: Use libc_ifunc macro for time, gettimeofday Stefan Liebler
2016-08-08 14:40 ` [PATCH v2 7/9] Use libc_ifunc macro for system in libpthread Stefan Liebler
2016-08-08 14:40 ` [PATCH v2 5/9] ppc: Use libc_ifunc macro for time, gettimeofday Stefan Liebler
2016-08-08 16:08 ` [PATCH v2 1/9] Add configure check to test if gcc supports attribute ifunc Paul E. Murphy
2016-08-08 16:42   ` Joseph Myers
2016-08-08 16:52   ` Andreas Schwab
2016-08-09 15:12   ` Stefan Liebler
2016-08-08 16:40 ` Joseph Myers
2016-08-09 11:56   ` Florian Weimer
2016-08-09 15:12     ` Stefan Liebler
2016-08-09 20:15     ` Joseph Myers
2016-08-08 17:58 ` [PATCH v2 9/9] Use libc_ifunc macro for siglongjmp, longjmp in libpthread Stefan Liebler
2016-08-17 10:37 ` [PATCH v2 1/9] Add configure check to test if gcc supports attribute ifunc Stefan Liebler
2016-08-17 11:04   ` Florian Weimer
2016-08-17 12:21     ` Joseph Myers
2016-08-24 14:10   ` Stefan Liebler

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).