public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Siddhesh Poyarekar <siddhesh@sourceware.org>
To: libc-alpha@sourceware.org
Cc: fweimer@redhat.com, carlos@redhat.com
Subject: [PATCH 2/2] Avoid adding duplicated symbols into static libraries
Date: Thu, 11 Feb 2021 15:49:08 +0530	[thread overview]
Message-ID: <20210211101908.2825685-3-siddhesh@sourceware.org> (raw)
In-Reply-To: <20210211101908.2825685-1-siddhesh@sourceware.org>

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.
---
 math/Makefile | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/math/Makefile b/math/Makefile
index 687aa5d510..c4cc1b2068 100644
--- a/math/Makefile
+++ b/math/Makefile
@@ -196,6 +196,9 @@ calls = s_isinfF s_isnanF s_finiteF s_copysignF s_modfF s_scalbnF s_frexpF \
 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_%))
 
 ifeq ($(build-mathvec),yes)
 # We need to install libm.so and libm.a as linker scripts
-- 
2.29.2


  parent reply	other threads:[~2021-02-11 10:22 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-11 10:19 [PATCH 0/2] math symbols cleanup Siddhesh Poyarekar
2021-02-11 10:19 ` [PATCH 1/2] Move __isnanf128 to libc.so Siddhesh Poyarekar
2021-02-11 10:27   ` Florian Weimer
2021-02-11 14:14     ` [PATCH v2 " Siddhesh Poyarekar
2021-02-11 16:03       ` Florian Weimer
2021-03-29 13:57       ` Siddhesh Poyarekar
2021-03-29 22:02         ` Tulio Magno Quites Machado Filho
2021-03-30  9:31           ` [COMMITTED] " Siddhesh Poyarekar
2021-02-11 10:19 ` Siddhesh Poyarekar [this message]
2021-03-30 19:47   ` [PATCH 2/2] Avoid adding duplicated symbols into static libraries Adhemerval Zanella
2021-03-31  2:57     ` Siddhesh Poyarekar
2021-03-31 13:54       ` Tulio Magno Quites Machado Filho
2021-03-31 14:05         ` Siddhesh Poyarekar
2021-03-02  6:09 ` [PING][PATCH 0/2] math symbols cleanup Siddhesh Poyarekar
2021-03-22  4:36 ` Siddhesh Poyarekar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210211101908.2825685-3-siddhesh@sourceware.org \
    --to=siddhesh@sourceware.org \
    --cc=carlos@redhat.com \
    --cc=fweimer@redhat.com \
    --cc=libc-alpha@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).