From patchwork Mon Nov 8 11:33:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adhemerval Zanella Netto X-Patchwork-Id: 47211 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id E5C62385843B for ; Mon, 8 Nov 2021 11:33:45 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E5C62385843B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1636371225; bh=kDnxQTmTXbSoWTJ7UBvEiPqTUjhntaFpOzfJ8cOVk8I=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=K0gmw6JkHguE7MduY9uFkn/rWo0K4Jv7ueFiNiPOhlDcduFAJbsSSn+F4ZZAlDvOO zQaGK6Z3Mj/vPBFObbBdyMvp1kDeteMDrL5z7CmUGp4eWGA9lIjs1uoYdGuLLFXbne k8ItcVfCuwG9cqUNh53tws6DRIxlDa4HmXmWLY3A= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from mail-oi1-x22a.google.com (mail-oi1-x22a.google.com [IPv6:2607:f8b0:4864:20::22a]) by sourceware.org (Postfix) with ESMTPS id D3AA53858401 for ; Mon, 8 Nov 2021 11:33:21 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org D3AA53858401 Received: by mail-oi1-x22a.google.com with SMTP id bl27so24165361oib.0 for ; Mon, 08 Nov 2021 03:33:21 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=kDnxQTmTXbSoWTJ7UBvEiPqTUjhntaFpOzfJ8cOVk8I=; b=uZ8kmYqIAghm8o5BTqOtP4hnuFB/b/NFMd4cC6SC1kELWZgmFKrxL1qYwUovTDvt8B vcActDiL+EFVvNnPORPe4NQKYtugQW6jzTdRPSVS77sxotoZI4l3hadDKTjCxTziq9Qy xIeQGBPHIPuwFrK/dmcVP0D+TNJJzoEJOTnpJRCkQW4yfpjOotUdm1nNk6iR1np0i2Xf itnoeKSNYQudTaX/fUA5HbQRPnfYTitgAgFfq+E3jSgEeKQvvKPTIOMXbqClGJNch1yt XSk1d9SP5jiH7cK7SBWBntT1kzpvXCT2sCrdTBwRb0VwRV97NlMSN9vNNEE4FIgFtsEd ZHFw== X-Gm-Message-State: AOAM531nXwlLN4ZMO1S8K38dV1Xh4CYmD93C5kzREMJLtQJ1/zZSFuzf EnzGbZutuncxNzyEMDvZZyU9vjqrK0owIQ== X-Google-Smtp-Source: ABdhPJztltWGbD2uMq1Y4eAv7ocnmXbo0i4jPUjdckAnTwDazuCXThOFijfGFr8AlDlx28BFFZLHIw== X-Received: by 2002:aca:2408:: with SMTP id n8mr406484oic.124.1636371200642; Mon, 08 Nov 2021 03:33:20 -0800 (PST) Received: from birita.. ([2804:431:c7cb:55a:c067:29b:4c08:be99]) by smtp.gmail.com with ESMTPSA id r26sm1676832otn.15.2021.11.08.03.33.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Nov 2021 03:33:20 -0800 (PST) To: libc-alpha@sourceware.org, Tulio Magno Quites Machado Filho Subject: [PATCH] powerpc: Define USE_PPC64_NOTOC iff compiler and linker also supports it Date: Mon, 8 Nov 2021 08:33:16 -0300 Message-Id: <20211108113316.8867-1-adhemerval.zanella@linaro.org> X-Mailer: git-send-email 2.32.0 MIME-Version: 1.0 X-Spam-Status: No, score=-12.9 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Adhemerval Zanella via Libc-alpha From: Adhemerval Zanella Netto Reply-To: Adhemerval Zanella Errors-To: libc-alpha-bounces+patchwork=sourceware.org@sourceware.org Sender: "Libc-alpha" The @ntoc usage only yields any advantage on ISA 3.1+ machine (power10) and for ld.bfd also when it see pcrel relocations used on the code (generated if compiler targets ISA 3.1+). On bfd case ISA 3.1+ instruction on stubs are used iff linker also sees the new pc-relative relocations (for instance R_PPC64_D34), otherwise it generates default stubs (ppc64_elf_check_relocs:4700). This patch also help on linkers that do not implement this optimization, since building for older ISA (such as 3.0 / power9) will also trigger power10 stubs generation in the assembly code uses the NOTOC imacro. Checked on powerpc64le-linux-gnu. Reviewed-by: Fangrui Song Reviewed-by: Tulio Magno Quites Machado Filho --- sysdeps/powerpc/powerpc64/configure | 42 ++++++++++++++++---------- sysdeps/powerpc/powerpc64/configure.ac | 25 ++++++++++----- 2 files changed, 43 insertions(+), 24 deletions(-) diff --git a/sysdeps/powerpc/powerpc64/configure b/sysdeps/powerpc/powerpc64/configure index 5ce77af631..db18791a55 100644 --- a/sysdeps/powerpc/powerpc64/configure +++ b/sysdeps/powerpc/powerpc64/configure @@ -32,26 +32,36 @@ if test x$libc_cv_overlapping_opd = xyes; then fi -# @notoc started to be supported in GNU Binutils 2.31. - -{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if the assembler supports @notoc" >&5 -$as_echo_n "checking if the assembler supports @notoc... " >&6; } +# We check if compiler supports @notoc generation since there is no +# gain by enabling it if it will be optimized away by the linker. +# It also helps linkers that might not optimize it and end up +# generating stubs with ISA 3.1 instruction even targetting older ISA. +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if the compiler supports @notoc" >&5 +$as_echo_n "checking if the compiler supports @notoc... " >&6; } if ${libc_cv_ppc64_notoc+:} false; then : $as_echo_n "(cached) " >&6 else - - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -void foo (void) {asm("b foo@notoc");} - -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - libc_cv_ppc64_notoc=yes -else + cat > conftest.c <&5 + (eval $ac_try) 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; } \ + && { ac_try='grep -q -E 'bar@notoc' conftest.s' + { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_try\""; } >&5 + (eval $ac_try) 2>&5 + ac_status=$? + $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5 + test $ac_status = 0; }; } + then + libc_cv_ppc64_notoc=yes + fi + rm -rf conftest.* fi { $as_echo "$as_me:${as_lineno-$LINENO}: result: $libc_cv_ppc64_notoc" >&5 $as_echo "$libc_cv_ppc64_notoc" >&6; } diff --git a/sysdeps/powerpc/powerpc64/configure.ac b/sysdeps/powerpc/powerpc64/configure.ac index b77156f696..05f0000807 100644 --- a/sysdeps/powerpc/powerpc64/configure.ac +++ b/sysdeps/powerpc/powerpc64/configure.ac @@ -22,13 +22,22 @@ if test x$libc_cv_overlapping_opd = xyes; then AC_DEFINE(USE_PPC64_OVERLAPPING_OPD) fi -# @notoc started to be supported in GNU Binutils 2.31. -AC_CACHE_CHECK([if the assembler supports @notoc], - libc_cv_ppc64_notoc, [ - AC_COMPILE_IFELSE([AC_LANG_SOURCE([ -void foo (void) {asm("b foo@notoc");} - ])], - [libc_cv_ppc64_notoc=yes], - [libc_cv_ppc64_notoc=no])]) +# We check if compiler supports @notoc generation since there is no +# gain by enabling it if it will be optimized away by the linker. +# It also helps linkers that might not optimize it and end up +# generating stubs with ISA 3.1 instruction even targetting older ISA. +AC_CACHE_CHECK([if the compiler supports @notoc], + libc_cv_ppc64_notoc, [dnl + cat > conftest.c <