From patchwork Wed Mar 31 05:14:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Siddhesh Poyarekar X-Patchwork-Id: 42815 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 0ABC038618B8; Wed, 31 Mar 2021 05:14:33 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 0ABC038618B8 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1617167673; bh=MeFrS6rxNQ6v/qTL4PZQ5LWtNo1wHwq0lPZ/9w1KIyQ=; h=To:Subject:Date:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=hthmWnDpQq9WnYLWizu3O0uhhKvwR3v4IPYOskKVIsho6f0W9vVYYpbwr0aaFswwY EoukbvZ6Kml69cQDFdXafTE4xrJ0VIdnfhOTfDNmQmWOx9714g+VHyGma5UwLLzNVH Yrpqh/zhC3IwOtQ8XuGKCmvREzRW1amFcHDTl3/U= X-Original-To: libc-alpha@sourceware.org Delivered-To: libc-alpha@sourceware.org Received: from fossa.birch.relay.mailchannels.net (fossa.birch.relay.mailchannels.net [23.83.209.62]) by sourceware.org (Postfix) with ESMTPS id 2373D3861887 for ; Wed, 31 Mar 2021 05:14:28 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 2373D3861887 X-Sender-Id: dreamhost|x-authsender|siddhesh@gotplt.org Received: from relay.mailchannels.net (localhost [127.0.0.1]) by relay.mailchannels.net (Postfix) with ESMTP id 8AF00322674; Wed, 31 Mar 2021 05:14:27 +0000 (UTC) Received: from pdx1-sub0-mail-a80.g.dreamhost.com (100-96-27-144.trex.outbound.svc.cluster.local [100.96.27.144]) (Authenticated sender: dreamhost) by relay.mailchannels.net (Postfix) with ESMTPA id C84ED322727; Wed, 31 Mar 2021 05:14:26 +0000 (UTC) X-Sender-Id: dreamhost|x-authsender|siddhesh@gotplt.org Received: from pdx1-sub0-mail-a80.g.dreamhost.com (pop.dreamhost.com [64.90.62.162]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384) by 100.96.27.144 (trex/6.1.1); Wed, 31 Mar 2021 05:14:27 +0000 X-MC-Relay: Neutral X-MailChannels-SenderId: dreamhost|x-authsender|siddhesh@gotplt.org X-MailChannels-Auth-Id: dreamhost X-Troubled-Robust: 7da24392431693d7_1617167667415_866625934 X-MC-Loop-Signature: 1617167667415:1443070947 X-MC-Ingress-Time: 1617167667414 Received: from pdx1-sub0-mail-a80.g.dreamhost.com (localhost [127.0.0.1]) by pdx1-sub0-mail-a80.g.dreamhost.com (Postfix) with ESMTP id 95A938933E; Tue, 30 Mar 2021 22:14:26 -0700 (PDT) Received: from rhbox.redhat.com (unknown [1.186.101.110]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: siddhesh@gotplt.org) by pdx1-sub0-mail-a80.g.dreamhost.com (Postfix) with ESMTPSA id A84357E39F; Tue, 30 Mar 2021 22:14:24 -0700 (PDT) X-DH-BACKEND: pdx1-sub0-mail-a80 To: libc-alpha@sourceware.org Subject: [PATCH] ppc64le: Make shared libm routines work again for static programs Date: Wed, 31 Mar 2021 10:44:10 +0530 Message-Id: <20210331051410.844754-1-siddhesh@sourceware.org> X-Mailer: git-send-email 2.29.2 MIME-Version: 1.0 X-Spam-Status: No, score=-3494.3 required=5.0 tests=BAYES_00, GIT_PATCH_0, JMQ_SPF_NEUTRAL, KAM_DMARC_NONE, KAM_DMARC_STATUS, RCVD_IN_BARRACUDACENTRAL, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NEUTRAL, TXREP, URIBL_BLACK autolearn=ham autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) 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: Siddhesh Poyarekar via Libc-alpha From: Siddhesh Poyarekar Reply-To: Siddhesh Poyarekar Errors-To: libc-alpha-bounces@sourceware.org Sender: "Libc-alpha" Routines shared between libc and libm were made shared-only for libm (so that libm.a does not have those functions) with this commit: commit 4898d9712bbd85e6fb576442f578d6f3c3e35898 Author: Siddhesh Poyarekar Date: Tue Mar 30 14:58:37 2021 +0530 Avoid adding duplicated symbols into static libraries Some math functions (such as __isnan*) are built into both libm and libc because they are needed in libc. The symbol gets exported from libc.so and not libm.so, because of which dynamic linking works fine; the symbols are always resolved from libc.so and libm.so uses its internal copy of the same function if needed. When linking statically though, the libm variants get used throughout because the symbols are exported in both archives and libm.a is searched first. This patch removes these duplicate objects from the libm.a archive so that programs always link to libc in both, the static and dynamic case. The difference this will cause is that libm uses of these functions will start using the libc versions in the !SHARED case. This is harmless at the moment because the objects are identical except for their names. Some of these duplicates could be removed from libm.so too, but I avoided that in the interest of retaining an internal reference if at all those functions get used within libm in future. This broke ppc64le, which implements some of these shared routines as ifuncs in libm. To allow the ppc64le case to continue to work, use a new make variable exclude-libm-shared-only-routines to list the routines that should be excluded from the shared-only list so that those routines continue to be built in both libc.a and libm.a on ppc64le. I have verified on ppc64le that the libm tests now run to completion. I also verified on x86_64 that the shared functions continue to appear only in libc.a and not in libm.a. Perhaps a long term fix is for ppc64le to move those ifuncs into libc. As things stand now, libc use of the shared functions will use the non-ifunc versions in libc.so, which may not be desirable. Maybe an even better longer term fi would be to merge libm into libc. --- math/Makefile | 6 ++++-- sysdeps/powerpc/powerpc64/le/fpu/multiarch/Makefile | 6 +++++- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/math/Makefile b/math/Makefile index ceb1eb2085..e37bc594d7 100644 --- a/math/Makefile +++ b/math/Makefile @@ -194,10 +194,12 @@ calls = s_isinfF s_isnanF s_finiteF s_copysignF s_modfF s_scalbnF s_frexpF \ s_signbitF $(gen-calls) gen-calls = s_ldexpF generated += $(foreach s,.c .S,$(call type-foreach, $(calls:s_%=m_%$(s)))) -routines = $(call type-foreach, $(calls)) # The $(calls) that are shared between libm and libc are not included in static # libm so the symbols end up in exactly one place. -libm-shared-only-routines = $(call type-foreach, $(calls:s_%=m_%)) +shared-only = $(filter-out \ + $(exclude-libm-shared-only-routines),$(calls:s_%=m_%)) +libm-shared-only-routines = $(call type-foreach, $(shared-only)) +routines = $(libm-shared-only-routines:m_%=s_%) ifeq ($(build-mathvec),yes) # We need to install libm.so and libm.a as linker scripts diff --git a/sysdeps/powerpc/powerpc64/le/fpu/multiarch/Makefile b/sysdeps/powerpc/powerpc64/le/fpu/multiarch/Makefile index 767805b510..3c0603fa02 100644 --- a/sysdeps/powerpc/powerpc64/le/fpu/multiarch/Makefile +++ b/sysdeps/powerpc/powerpc64/le/fpu/multiarch/Makefile @@ -85,6 +85,9 @@ endif # ifeq ($(do_f128_multiarch),yes) +exclude-libm-shared-only-routines = s_modfF s_scalbnF s_frexpF \ + s_ldexpF + gen-libm-f128-ifunc-routines = \ e_acosf128 e_acoshf128 e_asinf128 e_atan2f128 e_atanhf128 e_coshf128 \ e_expf128 e_fmodf128 e_hypotf128 e_j0f128 e_j1f128 e_jnf128 \ @@ -96,7 +99,8 @@ gen-libm-f128-ifunc-routines = \ s_tanhf128 s_truncf128 s_remquof128 e_log2f128 \ s_roundf128 s_nearbyintf128 s_sincosf128 s_fmaf128 s_lrintf128 \ s_llrintf128 s_lroundf128 s_llroundf128 e_exp10f128 \ - m_modff128 m_scalbnf128 m_frexpf128 m_ldexpf128 x2y2m1f128 \ + $(patsubst s_%F,m_%f128,$(exclude-libm-shared-only-routines)) \ + x2y2m1f128 \ gamma_productf128 lgamma_negf128 lgamma_productf128 s_roundevenf128 \ cargf128 conjf128 cimagf128 crealf128 cabsf128 e_scalbf128 s_cacosf128 \ s_cacoshf128 s_ccosf128 s_ccoshf128 s_casinf128 s_csinf128 \