diff mbox

add --enable-gnu-indirect-function configure switch

Message ID 4C972DAE.9080101@codesourcery.com
State New
Headers show

Commit Message

Nathan Sidwell Sept. 20, 2010, 9:47 a.m. UTC
This patch adds an explicit  --enable-gnu-indirect-function configure switch, 
which allows the builder to override any autodetection of indirect function 
support.   If the switch is not explicitly set, autodection occurs which now 
also checks the version of glibc being used.  I've cleaned up the test harness 
bits, which had kept rather too much of the alias checking bits.

built & test on i686-pc-linux-gnu, ok?

nathan

Comments

Andreas Schwab Sept. 20, 2010, 10:09 a.m. UTC | #1
Nathan Sidwell <nathan@codesourcery.com> writes:

> +AC_ARG_ENABLE(gnu-indirect-function,
> + [  --enable-gnu-indirect-function	enable the use of the @gnu_indirect_function to
> +				glibc systems],

Please use AS_HELP_STRING.

Andreas.
Joseph Myers Sept. 21, 2010, 10:32 p.m. UTC | #2
On Mon, 20 Sep 2010, Nathan Sidwell wrote:

> This patch adds an explicit  --enable-gnu-indirect-function configure switch,

Patches adding configure options need to update install.texi.
diff mbox

Patch

2010-09-20  Nathan Sidwell  <nathan@codesourcery.com>

	* configure.ac (enable-gnu-indirect-function): New configure
	option.  Verify glibc version.
	* configure: Rebuilt.

	testsuite/
	* lib/target-supports-dg.exp (dg-require_ifunc): Remove remnants
	of dg-require-alias.
	* lib/target-supports.exp (check_ifunc_available): Check known
	good GLIBC version.  Remove check_alias_available remnants.

Index: configure
===================================================================
--- configure	(revision 164430)
+++ configure	(working copy)
@@ -905,6 +905,7 @@ 
 enable_fast_install
 enable_libtool_lock
 with_plugin_ld
+enable_gnu_indirect_function
 enable_comdat
 enable_gnu_unique_object
 enable_linker_build_id
@@ -1611,6 +1612,8 @@ 
   --enable-fast-install[=PKGS]
                           optimize for fast installation [default=yes]
   --disable-libtool-lock  avoid locking (might break parallel builds)
+  --enable-gnu-indirect-function	enable the use of the @gnu_indirect_function to
+				glibc systems
   --enable-comdat         enable COMDAT group support
   --enable-gnu-unique-object	enable the use of the @gnu_unique_object ELF extension on
 				glibc systems
@@ -17139,7 +17142,7 @@ 
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 17142 "configure"
+#line 17145 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -17245,7 +17248,7 @@ 
   lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
   lt_status=$lt_dlunknown
   cat > conftest.$ac_ext <<_LT_EOF
-#line 17248 "configure"
+#line 17251 "configure"
 #include "confdefs.h"
 
 #if HAVE_DLFCN_H
@@ -21332,19 +21335,27 @@ 
 # gnu_indirect_function type is an extension proposed at
 # http://groups.google/com/group/generic-abi/files. It allows dynamic runtime
 # selection of function implementation
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking assembler for gnu_indirect_function" >&5
+# Check whether --enable-gnu-indirect-function was given.
+if test "${enable_gnu_indirect_function+set}" = set; then :
+  enableval=$enable_gnu_indirect_function; case $enable_gnu_indirect_function in
+    yes | no) ;;
+    *) as_fn_error "'$enable_gnu_indirect_function' is an invalid value for --enable-gnu-indirect-function.
+Valid choices are 'yes' and 'no'." "$LINENO" 5 ;;
+  esac
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking assembler for gnu_indirect_function" >&5
 $as_echo_n "checking assembler for gnu_indirect_function... " >&6; }
-if test "${gcc_cv_as_indirect_function+set}" = set; then :
+if test "${gcc_cv_as_gnu_indirect_function+set}" = set; then :
   $as_echo_n "(cached) " >&6
 else
-  gcc_cv_as_indirect_function=no
+  gcc_cv_as_gnu_indirect_function=no
     if test $in_tree_gas = yes; then
     if test $in_tree_gas_is_elf = yes \
-  && test $gcc_cv_gas_vers -ge `expr \( \( 2 \* 1000 \) + 20 \) \* 1000 + 1`
-  then gcc_cv_as_indirect_function=yes
+  && test $gcc_cv_gas_vers -ge `expr \( \( 2 \* 1000 \) + 20.1 \) \* 1000 + gcc_cv_as_gnu_indirect_function=yes`
+  then :
 fi
   elif test x$gcc_cv_as != x; then
-    echo '	.type  Foo, @gnu_indirect_function
+    echo '.type foo, @gnu_indirect_function
 Foo:' > conftest.s
     if { ac_try='$gcc_cv_as $gcc_cv_as_flags  -o conftest.o conftest.s >&5'
   { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5
@@ -21353,7 +21364,7 @@ 
   $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
   test $ac_status = 0; }; }
     then
-	gcc_cv_as_indirect_function=yes
+	gcc_cv_as_gnu_indirect_function=yes
     else
       echo "configure: failed program was" >&5
       cat conftest.s >&5
@@ -21361,16 +21372,29 @@ 
     rm -f conftest.o conftest.s
   fi
 fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_as_indirect_function" >&5
-$as_echo "$gcc_cv_as_indirect_function" >&6; }
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $gcc_cv_as_gnu_indirect_function" >&5
+$as_echo "$gcc_cv_as_gnu_indirect_function" >&6; }
+if test $gcc_cv_as_gnu_indirect_function = yes; then
+  # Also check for ld.so support, i.e. glibc 2.11 or higher.
+   if test x$host = x$build -a x$host = x$target &&
+       glibcver=`ldd --version 2>/dev/null | sed 's/.* //;q'`; then
+      glibcmajor=`expr "$glibcver" : "\([0-9]*\)"`
+      glibcminor=`expr "$glibcver" : "[2-9]*\.\([0-9]*\)"`
+      glibcnum=`expr $glibcmajor \* 1000 + $glibcminor`
+      if test "$glibcnum" -ge 2011 ; then
+        enable_gnu_indirect_function=yes
+      fi
+    fi
+fi
+fi
 
+if test x$enable_gnu_indirect_function = xyes; then
 
-if test $gcc_cv_as_indirect_function = yes ; then
+$as_echo "#define HAVE_GAS_GNU_INDIRECT_FUNCTION 1" >>confdefs.h
 
-$as_echo "#define HAVE_GAS_INDIRECT_FUNCTION 1" >>confdefs.h
-
 fi
 
+
 if test $in_tree_ld != yes ; then
   ld_ver=`$gcc_cv_ld --version 2>/dev/null | sed 1q`
   if test x"$ld_is_gold" = xyes; then
Index: testsuite/lib/target-supports-dg.exp
===================================================================
--- testsuite/lib/target-supports-dg.exp	(revision 164430)
+++ testsuite/lib/target-supports-dg.exp	(working copy)
@@ -94,12 +94,7 @@ 
 # test.
 
 proc dg-require-ifunc { args } {
-    set ifunc_available [ check_ifunc_available ]
-    if { $ifunc_available == -1 } {
-	upvar name name
-	unresolved "$name"
-    }
-    if { $ifunc_available < 2 } {
+    if { ![ check_ifunc_available ] } {
 	upvar dg-do-what dg-do-what
 	set dg-do-what [list [lindex ${dg-do-what} 0] "N" "P"]
     }
Index: testsuite/lib/target-supports.exp
===================================================================
--- testsuite/lib/target-supports.exp	(revision 164430)
+++ testsuite/lib/target-supports.exp	(working copy)
@@ -372,12 +372,10 @@ 
 # proc check_ifunc_available { }
 ###############################
 
-# Determine if the target toolchain supports the alias attribute.
+# Determine if the target toolchain supports the ifunc attribute.
 
-# Returns 2 if the target supports aliases.  Returns 1 if the target
-# only supports weak aliased.  Returns 0 if the target does not
-# support aliases at all.  Returns -1 if support for aliases could not
-# be determined.
+# Returns 1 if the target supports ifunc.  Returns 0 if the target
+# does not support ifunc.
 
 proc check_ifunc_available { } {
     global ifunc_available_saved
@@ -390,26 +388,19 @@ 
 	set obj ifunc[pid].o
         verbose "check_ifunc_available  compiling testfile $src" 2
 	set f [open $src "w"]
-	# Compile a small test program.  The definition of "g" is
-	# necessary to keep the Solaris assembler from complaining
-	# about the program.
-	puts $f "#ifdef __cplusplus\nextern \"C\"\n#endif\n"
-	puts $f "void g() {} void f() __attribute__((ifunc(\"g\")));"
+	puts $f "#endif"
+	puts $f "#ifdef __cplusplus\nextern \"C\"\n#endif"
+	puts $f "void g() {}"
+	puts $f "void f() __attribute__((ifunc(\"g\")));"
 	close $f
 	set lines [${tool}_target_compile $src $obj object ""]
 	file delete $src
 	remote_file build delete $obj
 
 	if [string match "" $lines] then {
-	    # No error messages, everything is OK.
-	    set ifunc_available_saved 2
+	    set ifunc_available_saved 1
 	} else {
-	    if [regexp "ifunc is not supported" $lines] {
-		verbose "check_ifunc_available  target does not support ifunc" 2
-		set ifunc_available_saved 0
-	    } else {
-		set ifunc_available_saved -1
-	    }
+	    set ifunc_available_saved 0
 	}
 
 	verbose "check_ifunc_available  returning $ifunc_available_saved" 2
Index: configure.ac
===================================================================
--- configure.ac	(revision 164430)
+++ configure.ac	(working copy)
@@ -2161,16 +2161,34 @@ 
 # gnu_indirect_function type is an extension proposed at
 # http://groups.google/com/group/generic-abi/files. It allows dynamic runtime
 # selection of function implementation
-gcc_GAS_CHECK_FEATURE(gnu_indirect_function, gcc_cv_as_indirect_function,
- [elf,2,20,1],,
-[	.type  Foo, @gnu_indirect_function
-Foo:])
-GCC_TARGET_TEMPLATE([HAVE_GAS_INDIRECT_FUNCTION])
-if test $gcc_cv_as_indirect_function = yes ; then
-  AC_DEFINE(HAVE_GAS_INDIRECT_FUNCTION, 1,
-  [Define if your assembler supports indirect function type.])
+AC_ARG_ENABLE(gnu-indirect-function,
+ [  --enable-gnu-indirect-function	enable the use of the @gnu_indirect_function to
+				glibc systems],
+ [case $enable_gnu_indirect_function in
+    yes | no) ;;
+    *) AC_MSG_ERROR(['$enable_gnu_indirect_function' is an invalid value for --enable-gnu-indirect-function.
+Valid choices are 'yes' and 'no'.]) ;;
+  esac],
+ [gcc_GAS_CHECK_FEATURE([gnu_indirect_function], gcc_cv_as_gnu_indirect_function,
+   [elf,2,20.1],,
+   [.type foo, @gnu_indirect_function
+Foo:],,
+# Also check for ld.so support, i.e. glibc 2.11 or higher.
+   [[if test x$host = x$build -a x$host = x$target &&
+       glibcver=`ldd --version 2>/dev/null | sed 's/.* //;q'`; then
+      glibcmajor=`expr "$glibcver" : "\([0-9]*\)"`
+      glibcminor=`expr "$glibcver" : "[2-9]*\.\([0-9]*\)"`
+      glibcnum=`expr $glibcmajor \* 1000 + $glibcminor`
+      if test "$glibcnum" -ge 2011 ; then
+        enable_gnu_indirect_function=yes
+      fi
+    fi]])])
+if test x$enable_gnu_indirect_function = xyes; then
+  AC_DEFINE(HAVE_GAS_GNU_INDIRECT_FUNCTION, 1,
+   [Define if your assembler supports @gnu_indirect_function.])
 fi
 
+
 changequote(,)dnl
 if test $in_tree_ld != yes ; then
   ld_ver=`$gcc_cv_ld --version 2>/dev/null | sed 1q`