Message ID | 20210211101908.2825685-3-siddhesh@sourceware.org |
---|---|
State | New |
Headers | show |
Series | math symbols cleanup | expand |
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
On 3/31/21 1:17 AM, Adhemerval Zanella wrote: > 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 Sorry about that. I'll revert the patch if I'm unable to post a fix by the end of the day. Siddhesh
Siddhesh Poyarekar via Libc-alpha <libc-alpha@sourceware.org> writes: > On 3/31/21 1:17 AM, Adhemerval Zanella wrote: >> 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 > > Sorry about that. I'll revert the patch if I'm unable to post a fix by > the end of the day. I don't think we need to hurry and revert this. I'm also looking at this. It has to do with multiarch builds. I'm sorry for not taking a look at patch 2/2. :-(
On 3/31/21 7:24 PM, Tulio Magno Quites Machado Filho via Libc-alpha wrote: > I don't think we need to hurry and revert this. > I'm also looking at this. It has to do with multiarch builds. > > I'm sorry for not taking a look at patch 2/2. :-( Sorry I rushed to push this :) I posted a fix to patch this up but I think Andreas may have a more complete fix. Could you please review that one? https://sourceware.org/pipermail/libc-alpha/2021-March/124602.html Thanks, Siddhesh
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