From patchwork Mon Sep 20 09:47:26 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Nathan Sidwell X-Patchwork-Id: 65191 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id 37F75B70AB for ; Mon, 20 Sep 2010 19:47:47 +1000 (EST) Received: (qmail 31864 invoked by alias); 20 Sep 2010 09:47:45 -0000 Received: (qmail 31855 invoked by uid 22791); 20 Sep 2010 09:47:43 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL, BAYES_00, T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mail.codesourcery.com (HELO mail.codesourcery.com) (38.113.113.100) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 20 Sep 2010 09:47:38 +0000 Received: (qmail 3529 invoked from network); 20 Sep 2010 09:47:36 -0000 Received: from unknown (HELO ?192.168.44.101?) (nathan@127.0.0.2) by mail.codesourcery.com with ESMTPA; 20 Sep 2010 09:47:36 -0000 Message-ID: <4C972DAE.9080101@codesourcery.com> Date: Mon, 20 Sep 2010 10:47:26 +0100 From: Nathan Sidwell User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.12) Gecko/20100915 Thunderbird/3.0.8 MIME-Version: 1.0 To: GCC Patches Subject: add --enable-gnu-indirect-function configure switch Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org 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 2010-09-20 Nathan Sidwell * 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`