public inbox for libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Adhemerval Zanella <adhemerval.zanella@linaro.org>
To: libc-alpha@sourceware.org, Siddhesh Poyarekar <siddhesh@sourceware.org>
Subject: Re: [PATCH 2/2] Avoid adding duplicated symbols into static libraries
Date: Tue, 30 Mar 2021 16:47:45 -0300	[thread overview]
Message-ID: <693c9b6a-d3b8-5ce5-16a9-322ff0cfb2f5@linaro.org> (raw)
In-Reply-To: <20210211101908.2825685-3-siddhesh@sourceware.org>



On 11/02/2021 07:19, Siddhesh Poyarekar via Libc-alpha wrote:
> 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
> 

This broke powerpc64le static math tests:

powerpc64le-linux-gnu]$ make math/tests
[...]
/home/azanella/toolchain/install/compilers/powerpc64le-linux-gnu/bin/powerpc64le-glibc-linux-gnu-gcc -nostdlib -nostartfiles -static -o /home/azanella/glibc/build/powerpc64le-linux-gnu/math/test-signgam-uchar-static     /home/azanella/glibc/build/powerpc64le-linux-gnu/csu/crt1.o /home/azanella/glibc/build/powerpc64le-linux-gnu/csu/crti.o `/home/azanella/toolchain/install/compilers/powerpc64le-linux-gnu/bin/powerpc64le-glibc-linux-gnu-gcc  --print-file-name=crtbeginT.o` /home/azanella/glibc/build/powerpc64le-linux-gnu/math/test-signgam-uchar-static.o /home/azanella/glibc/build/powerpc64le-linux-gnu/support/libsupport_nonshared.a /home/azanella/glibc/build/powerpc64le-linux-gnu/math/libm.a  -Wl,--start-group /home/azanella/glibc/build/powerpc64le-linux-gnu/libc.a -lgcc -lgcc_eh  -Wl,--end-group `/home/azanella/toolchain/install/compilers/powerpc64le-linux-gnu/bin/powerpc64le-glibc-linux-gnu-gcc  --print-file-name=crtend.o` /home/azanella/glibc/build/powerpc64le-linux-gnu/csu/crtn.o
/home/azanella/toolchain/install/compilers/powerpc64le-linux-gnu/lib/gcc/powerpc64le-glibc-linux-gnu/10.2.1/../../../../powerpc64le-glibc-linux-gnu/bin/ld: /home/azanella/glibc/build/powerpc64le-linux-gnu/math/libm.a(e_logf128.o): in function `__ieee754_logf128_power8':
/home/azanella/glibc/glibc-git/math/../sysdeps/ieee754/float128/../ldbl-128/e_logl.c:217: undefined reference to `__frexpf128_power8'
/home/azanella/toolchain/install/compilers/powerpc64le-linux-gnu/lib/gcc/powerpc64le-glibc-linux-gnu/10.2.1/../../../../powerpc64le-glibc-linux-gnu/bin/ld: /home/azanella/glibc/build/powerpc64le-linux-gnu/math/libm.a(s_log1pf128.o): in function `__log1pf128_power8':
/home/azanella/glibc/glibc-git/math/../sysdeps/ieee754/float128/../ldbl-128/s_log1pl.c:166: undefined reference to `__frexpf128_power8'
collect2: error: ld returned 1 exit status
make[2]: *** [../Rules:264: /home/azanella/glibc/build/powerpc64le-linux-gnu/math/test-signgam-uchar-static] Error 1



  reply	other threads:[~2021-03-30 19:47 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 ` [PATCH 2/2] Avoid adding duplicated symbols into static libraries Siddhesh Poyarekar
2021-03-30 19:47   ` Adhemerval Zanella [this message]
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=693c9b6a-d3b8-5ce5-16a9-322ff0cfb2f5@linaro.org \
    --to=adhemerval.zanella@linaro.org \
    --cc=libc-alpha@sourceware.org \
    --cc=siddhesh@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).