From patchwork Tue Aug 30 14:12:06 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Liebler X-Patchwork-Id: 664159 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]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3sNr7t0hznz9ryk for ; Wed, 31 Aug 2016 00:12:41 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=sourceware.org header.i=@sourceware.org header.b=jcZd8qNi; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:subject:to:references:from:date:mime-version :in-reply-to:content-type:message-id; q=dns; s=default; b=Dal67k Loi3Wa0qdCeUWMILZ383DZFRwBuHOfb7I42N55DjV8aY+ftblfo7UQp2BaIMQ/zm foLmIjplZQksByEnCy9K+54YsiLINPeGXvMhnPgaqN7ug7iYKO06C+Q96Qc+ijDZ L9Vsk7IVZSlRGLUgNy7HL8gRcrFQXe/NpAodI= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:subject:to:references:from:date:mime-version :in-reply-to:content-type:message-id; s=default; bh=VLAGHBph8LET DOHfr9Fm448mshg=; b=jcZd8qNiSoQ7fv2LMKSiY9C1wNk3hOuKsoZnfggmQA82 pqccvgU6lwpAqGPTOeQ4+q1dewQzNHsEvN/20EZUeo9wiN28cdCQlw1fbCb1JPQX fh/TdHmUDvBWCiEjea8OMKHngtbcmXsVejxTVTH0jlEr+DLFSqAghYJlj+3Vy38= Received: (qmail 10296 invoked by alias); 30 Aug 2016 14:12:25 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 10196 invoked by uid 89); 30 Aug 2016 14:12:24 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.0 required=5.0 tests=AWL, BAYES_00, KAM_LAZY_DOMAIN_SECURITY, RCVD_IN_DNSWL_LOW, RCVD_IN_SEMBACKSCATTER autolearn=no version=3.3.2 spammy=conftest.c, conftestc, UD:conftest.c, scattered X-HELO: mx0a-001b2d01.pphosted.com X-IBM-Helo: d06dlp03.portsmouth.uk.ibm.com X-IBM-MailFrom: stli@linux.vnet.ibm.com X-IBM-RcptTo: libc-alpha@sourceware.org Subject: Re: [PATCH v3 1/9] Add configure check to test if gcc supports attribute ifunc. To: libc-alpha@sourceware.org References: <1472047472-30307-1-git-send-email-stli@linux.vnet.ibm.com> <0107c9b6-5c33-602b-2b51-c9eb547de208@redhat.com> From: Stefan Liebler Date: Tue, 30 Aug 2016 16:12:06 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.2 MIME-Version: 1.0 In-Reply-To: <0107c9b6-5c33-602b-2b51-c9eb547de208@redhat.com> X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 16083014-0040-0000-0000-0000021C26CA X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 16083014-0041-0000-0000-00002188A246 Message-Id: <0fe1b161-5693-d430-09a2-6a4c8845d578@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2016-08-30_07:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=15 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1604210000 definitions=main-1608300137 On 08/29/2016 11:34 AM, Florian Weimer wrote: > On 08/24/2016 04:04 PM, Stefan Liebler wrote: >> +For multi-arch support it is recommended to use a GCC with >> gnu-indirect-function >> +support as it is used to generate ifunc'ed symbols with correct >> +debug-information. This support can either be enabled by configuring >> GCC with >> +@samp{--enable-gnu-indirect-function} or by enabling it by default by >> setting >> +@samp{default_gnu_indirect_function} variable for a particular >> architecture in >> +gcc source file @file{gcc/config.gcc}. > > Maybe use this text instead? > 6808c16e2d067c8137fa9eae6078dc55c5d355c6 > For multi-arch support it is recommended to use a GCC which has been > built with support for GNU indirect functions. This ensures that > correct debugging information is generated for functions selected by > IFUNC resolvers. This support can either be enabled by configuring GCC > with @samp{--enable-gnu-indirect-function}, or by enabling it by default > by setting @samp{default_gnu_indirect_function} variable for a > particular architecture in the GCC source file @file{gcc/config.gcc}. > Okay. I've updated install-files and I'll use this updated text also for the NEWS entry. > > The configure check looks okay to me. Some existing checks use > AC_TRY_COMPILE, others use the manual expansion you provided. > > Thanks, > Florian > commit 3cfc378ca6f95feaa35b99b4b5897fa35dbff68f Author: Stefan Liebler Date: Wed Aug 24 10:18:14 2016 +0200 Add configure check to test if gcc supports attribute ifunc. This patch adds a configure check to test if gcc supports attribute ifunc. The support can either be enabled in /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, the old approach for generating ifunc'ed symbols is used. Then the debug-information is false. Thus it is recommended to use a gcc with indirect function support (See notes in INSTALL). After this patch-series these inline assemblies for ifunc-handling are not scattered in multiple files but are used only indirect via ifunc-macros and can simply removed in libc-symbols.h in future. If glibc is configured with --enable-multi-arch and gcc does not support attribute ifunc, a configure warning is dumped! This NEWS entry will be added: * For multi-arch support it is recommended to use a GCC which has been built with support for GNU indirect functions. This ensures that correct debugging information is generated for functions selected by IFUNC resolvers. This support can either be enabled by configuring GCC with '--enable-gnu-indirect-function', or by enabling it by default by setting 'default_gnu_indirect_function' variable for a particular architecture in the GCC source file 'gcc/config.gcc'. ChangeLog: * config.h.in (HAVE_GCC_IFUNC): New undef. * configure.ac: Add check if gcc supports attribute ifunc feature. * configure: Regenerated. * manual/install.texi: Add recommendation for gcc with indirect-function support. * INSTALL: Regenerated. diff --git a/INSTALL b/INSTALL index ec3445f..66be341 100644 --- a/INSTALL +++ b/INSTALL @@ -359,6 +359,15 @@ build the GNU C Library: better code. As of release time, GCC 5.3 is the newest compiler verified to work to build the GNU C Library. + For multi-arch support it is recommended to use a GCC which has + been built with support for GNU indirect functions. This ensures + that correct debugging information is generated for functions + selected by IFUNC resolvers. This support can either be enabled by + configuring GCC with '--enable-gnu-indirect-function', or by + enabling it by default by setting 'default_gnu_indirect_function' + variable for a particular architecture in the GCC source file + 'gcc/config.gcc'. + You can use whatever compiler you like to compile programs that use the GNU C Library. diff --git a/config.h.in b/config.h.in index 856ef6a..9f5c5ff 100644 --- a/config.h.in +++ b/config.h.in @@ -171,6 +171,9 @@ /* Define to 1 if STT_GNU_IFUNC support actually works. */ #define HAVE_IFUNC 0 +/* Define if gcc supports attribute ifunc. */ +#undef HAVE_GCC_IFUNC + /* Define if the linker defines __ehdr_start. */ #undef HAVE_EHDR_START diff --git a/configure b/configure index 17625e1..8ffc2b5 100755 --- a/configure +++ b/configure @@ -3914,6 +3914,36 @@ 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; } +# 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 <&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; then if test x"$multi_arch" = xyes; then as_fn_error $? "--enable-multi-arch support requires assembler and linker support" "$LINENO" 5 @@ -3921,6 +3951,13 @@ if test x"$libc_cv_ld_gnu_indirect_function" != xyes; then multi_arch=no fi fi +if test x"$libc_cv_gcc_indirect_function" != xyes && + test x"$multi_arch" = xyes; then + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: --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" >&5 +$as_echo "$as_me: WARNING: --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" >&2;} +fi multi_arch_d= if test x"$multi_arch" != xno; then multi_arch_d=/multiarch @@ -6504,6 +6541,11 @@ if test x"$libc_cv_ld_gnu_indirect_function" = xyes; then fi +if test x"$libc_cv_gcc_indirect_function" = xyes; then + $as_echo "#define HAVE_GCC_IFUNC 1" >>confdefs.h + +fi + # This is far from the AC_ARG_ENABLE that sets it so that a sysdeps # configure fragment can override the value to prevent this AC_DEFINE. diff --git a/configure.ac b/configure.ac index 33bcd62..643002f 100644 --- a/configure.ac +++ b/configure.ac @@ -634,6 +634,30 @@ if ${CC-cc} $CFLAGS $CPPFLAGS $LDFLAGS \ fi rm -f conftest*]) +# 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 <&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; then if test x"$multi_arch" = xyes; then AC_MSG_ERROR([--enable-multi-arch support requires assembler and linker support]) @@ -641,6 +665,11 @@ if test x"$libc_cv_ld_gnu_indirect_function" != xyes; then multi_arch=no fi fi +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]) +fi multi_arch_d= if test x"$multi_arch" != xno; then multi_arch_d=/multiarch @@ -1770,6 +1799,10 @@ if test x"$libc_cv_ld_gnu_indirect_function" = xyes; then AC_DEFINE(HAVE_IFUNC) fi +if test x"$libc_cv_gcc_indirect_function" = xyes; then + AC_DEFINE(HAVE_GCC_IFUNC) +fi + # This is far from the AC_ARG_ENABLE that sets it so that a sysdeps # configure fragment can override the value to prevent this AC_DEFINE. AC_SUBST(use_nscd) diff --git a/manual/install.texi b/manual/install.texi index 79ee45f..5f5705e 100644 --- a/manual/install.texi +++ b/manual/install.texi @@ -402,6 +402,14 @@ the newest version of the compiler that is known to work for building release time, GCC 5.3 is the newest compiler verified to work to build @theglibc{}. +For multi-arch support it is recommended to use a GCC which has been built with +support for GNU indirect functions. This ensures that correct debugging +information is generated for functions selected by IFUNC resolvers. This +support can either be enabled by configuring GCC with +@samp{--enable-gnu-indirect-function}, or by enabling it by default by setting +@samp{default_gnu_indirect_function} variable for a particular architecture in +the GCC source file @file{gcc/config.gcc}. + You can use whatever compiler you like to compile programs that use @theglibc{}.