https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100912
Bug ID: 100912
Summary: powerpc64le: ieee128 long double incorrectly printed
when using shared libstdc++
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: libstdc++
Assignee: unassigned at gcc dot gnu.org
Reporter: msc at linux dot ibm.com
Target Milestone: ---
Steps to reproduce:
- Build gcc with IEEE128 as the default long double format (using GCC source
revision cb6e6d5faa3f817435b6f203226fa5969d7a7264).
~/build/gcc> ~/src/gcc/configure --prefix=/home/mscastanho/usr
--with-long-double-128 --with-long-double-format=ieee
--build=powerpc64le-linux-gnu --host=powerpc64le-linux-gnu
--target=powerpc64le-linux-gnu --enable-languages=c++ --with-glibc-version=2.33
--disable-bootstrap CC=gcc-11 CXX=g++-11
~/build/gcc> make && make install
~/build/gcc> /home/mscastanho/usr/bin/g++ -v
Using built-in specs.
COLLECT_GCC=/home/mscastanho/usr/bin/g++
COLLECT_LTO_WRAPPER=/home/mscastanho/usr/libexec/gcc/powerpc64le-linux-gnu/12.0.0/lto-wrapper
Target: powerpc64le-linux-gnu
Configured with: /home/mscastanho/src/gcc/configure
--prefix=/home/mscastanho/usr --with-long-double-128
--with-long-double-format=ieee --build=powerpc64le-linux-gnu
--host=powerpc64le-linux-gnu --target=powerpc64le-linux-gnu
--enable-languages=c++ --with-glibc-version=2.33 --disable-bootstrap CC=gcc-11
CXX=g++-11
Thread model: posix
Supported LTO compression algorithms: zlib
gcc version 12.0.0 20210604 (experimental) (GCC)
- Build and run simple test program with the new compiler and libstdc++
~/build/gcc> cat ~/test-ieee128.cpp
#include <iostream>
using namespace std;
int main () {
long double n = 1.0L;
cout << n << endl;
return 0;
}
~/build/gcc> /home/mscastanho/usr/bin/g++ -g ~/test-ieee128.cpp -o test-shared
~/build/gcc> LD_PRELOAD=~/usr/lib64/libstdc++.so.6 ./test-shared
6.95326e-310
Here I'd expect "1" to be printed.
If the same program is statically linked to libstdc++, it works as expected:
mscastanho@yanny4:~/build/gcc> /home/mscastanho/usr/bin/g++ -g
-static-libstdc++ ~/test-ieee128.cpp -o test-static
mscastanho@yanny4:~/build/gcc> ./test-static
1
After running the two programs side-by-side under gdb, I found out they are
actually calling two different symbols for vsnprintf on std::__convert_from_v.
Dynamically linked binary:
>>> disas _ZSt16__convert_from_vRKP15__locale_structPciPKcz
Dump of assembler code for function
_ZSt16__convert_from_vRKP15__locale_structPciPKcz:
0x00007ffff7d19340 <+0>: addis r2,r12,37
0x00007ffff7d19344 <+4>: addi r2,r2,-14912
=> 0x00007ffff7d19348 <+8>: mflr r0
0x00007ffff7d1934c <+12>: std r29,-24(r1)
0x00007ffff7d19350 <+16>: std r30,-16(r1)
0x00007ffff7d19354 <+20>: mr r29,r6
0x00007ffff7d19358 <+24>: std r31,-8(r1)
0x00007ffff7d1935c <+28>: mr r30,r5
0x00007ffff7d19360 <+32>: mr r31,r4
0x00007ffff7d19364 <+36>: std r0,16(r1)
0x00007ffff7d19368 <+40>: stdu r1,-64(r1)
0x00007ffff7d1936c <+44>: std r7,128(r1)
0x00007ffff7d19370 <+48>: std r8,136(r1)
0x00007ffff7d19374 <+52>: std r10,152(r1)
0x00007ffff7d19378 <+56>: std r9,144(r1)
0x00007ffff7d1937c <+60>: ld r3,0(r3)
0x00007ffff7d19380 <+64>: bl 0x7ffff7d09b60
<000006bf.plt_call.__uselocale@@GLIBC_2.17>
0x00007ffff7d19384 <+68>: ld r2,24(r1)
0x00007ffff7d19388 <+72>: mr r5,r29
0x00007ffff7d1938c <+76>: mr r4,r30
0x00007ffff7d19390 <+80>: addi r6,r1,128
0x00007ffff7d19394 <+84>: mr r9,r3
0x00007ffff7d19398 <+88>: mr r3,r31
0x00007ffff7d1939c <+92>: mr r30,r9
0x00007ffff7d193a0 <+96>: bl 0x7ffff7d112a0
<000006bf.plt_call.vsnprintf@@GLIBC_2.17> <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
0x00007ffff7d193a4 <+100>: ld r2,24(r1)
0x00007ffff7d193a8 <+104>: mr r31,r3
0x00007ffff7d193ac <+108>: mr r3,r30
0x00007ffff7d193b0 <+112>: bl 0x7ffff7d09b60
<000006bf.plt_call.__uselocale@@GLIBC_2.17>
0x00007ffff7d193b4 <+116>: ld r2,24(r1)
0x00007ffff7d193b8 <+120>: addi r1,r1,64
0x00007ffff7d193bc <+124>: mr r3,r31
0x00007ffff7d193c0 <+128>: ld r0,16(r1)
0x00007ffff7d193c4 <+132>: ld r29,-24(r1)
0x00007ffff7d193c8 <+136>: ld r30,-16(r1)
0x00007ffff7d193cc <+140>: ld r31,-8(r1)
0x00007ffff7d193d0 <+144>: mtlr r0
0x00007ffff7d193d4 <+148>: blr
0x00007ffff7d193d8 <+152>: .long 0x0
0x00007ffff7d193dc <+156>: .long 0x1000900
0x00007ffff7d193e0 <+160>: .long 0x380
End of assembler dump.
Statically linked binary:
>>> disas _ZSt16__convert_from_vRKP15__locale_structPciPKcz
Dump of assembler code for function
_ZSt16__convert_from_vRKP15__locale_structPciPKcz:
0x000000001002e470 <+0>: lis r2,4122
0x000000001002e474 <+4>: addi r2,r2,31744
=> 0x000000001002e478 <+8>: mflr r0
0x000000001002e47c <+12>: std r29,-24(r1)
0x000000001002e480 <+16>: std r30,-16(r1)
0x000000001002e484 <+20>: mr r29,r6
0x000000001002e488 <+24>: std r31,-8(r1)
0x000000001002e48c <+28>: mr r30,r5
0x000000001002e490 <+32>: mr r31,r4
0x000000001002e494 <+36>: std r0,16(r1)
0x000000001002e498 <+40>: stdu r1,-64(r1)
0x000000001002e49c <+44>: std r7,128(r1)
0x000000001002e4a0 <+48>: std r8,136(r1)
0x000000001002e4a4 <+52>: std r10,152(r1)
0x000000001002e4a8 <+56>: std r9,144(r1)
0x000000001002e4ac <+60>: ld r3,0(r3)
0x000000001002e4b0 <+64>: bl 0x10003720
<0000011a.plt_call.__uselocale@@GLIBC_2.17>
0x000000001002e4b4 <+68>: ld r2,24(r1)
0x000000001002e4b8 <+72>: mr r5,r29
0x000000001002e4bc <+76>: mr r4,r30
0x000000001002e4c0 <+80>: addi r6,r1,128
0x000000001002e4c4 <+84>: mr r9,r3
0x000000001002e4c8 <+88>: mr r3,r31
0x000000001002e4cc <+92>: mr r30,r9
0x000000001002e4d0 <+96>: bl 0x10003280
<0000011a.plt_call.__vsnprintfieee128@@GLIBC_2.32> <<<<<<<<<<<<<<<<<<<<<
0x000000001002e4d4 <+100>: ld r2,24(r1)
0x000000001002e4d8 <+104>: mr r31,r3
0x000000001002e4dc <+108>: mr r3,r30
0x000000001002e4e0 <+112>: bl 0x10003720
<0000011a.plt_call.__uselocale@@GLIBC_2.17>
0x000000001002e4e4 <+116>: ld r2,24(r1)
0x000000001002e4e8 <+120>: addi r1,r1,64
0x000000001002e4ec <+124>: mr r3,r31
0x000000001002e4f0 <+128>: ld r0,16(r1)
0x000000001002e4f4 <+132>: ld r29,-24(r1)
0x000000001002e4f8 <+136>: ld r30,-16(r1)
0x000000001002e4fc <+140>: ld r31,-8(r1)
0x000000001002e500 <+144>: mtlr r0
0x000000001002e504 <+148>: blr
0x000000001002e508 <+152>: .long 0x0
0x000000001002e50c <+156>: .long 0x1000900
0x000000001002e510 <+160>: .long 0x380
End of assembler dump.
Software versions used:
Distro:
~/build/gcc> cat /etc/os-release
NAME="openSUSE Tumbleweed"
# VERSION="20210105"
ID="opensuse-tumbleweed"
ID_LIKE="opensuse suse"
VERSION_ID="20210105"
PRETTY_NAME="openSUSE Tumbleweed"
ANSI_COLOR="0;32"
CPE_NAME="cpe:/o:opensuse:tumbleweed:20210105"
BUG_REPORT_URL="https://bugs.opensuse.org"
HOME_URL="https://www.opensuse.org/"
DOCUMENTATION_URL="https://en.opensuse.org/Portal:Tumbleweed"
LOGO="distributor-logo"
GCC used to build the new compiler:
~/build/gcc> g++-11 -v
Using built-in specs.
COLLECT_GCC=g++-11
COLLECT_LTO_WRAPPER=/usr/lib64/gcc/powerpc64le-suse-linux/11/lto-wrapper
Target: powerpc64le-suse-linux
Configured with: ../configure --prefix=/usr --infodir=/usr/share/info
--mandir=/usr/share/man --libdir=/usr/lib64 --libexecdir=/usr/lib64
--enable-languages=c,c++,objc,fortran,obj-c++,ada,go,jit --enable-host-shared
--enable-checking=release --disable-werror
--with-gxx-include-dir=/usr/include/c++/11 --enable-ssp --disable-libssp
--disable-libvtv --enable-cet=auto --disable-libcc1 --enable-plugin
--with-bugurl=https://bugs.opensuse.org/ --with-pkgversion='SUSE Linux'
--with-slibdir=/lib64 --with-system-zlib --enable-libstdcxx-allocator=new
--disable-libstdcxx-pch --enable-version-specific-runtime-libs
--with-gcc-major-version-only --enable-linker-build-id --enable-linux-futex
--enable-gnu-indirect-function --program-suffix=-11 --without-system-libunwind
--with-cpu=power8 --with-tune=power9 --enable-secureplt --with-long-double-128
--enable-targets=powerpcle-linux --disable-multilib
--with-build-config=bootstrap-lto-lean --enable-link-mutex
--build=powerpc64le-suse-linux --host=powerpc64le-suse-linux
Thread model: posix
Supported LTO compression algorithms: zlib zstd
gcc version 11.0.0 20210118 (experimental) [revision
76c1dd15e4a056a59a13b2208af23a6bd67c2682] (SUSE Linux)
glibc:
~/build/gcc> /lib64/libc.so.6
GNU C Library (GNU libc) release release version 2.33 (git 9826b03b74).
[...]
binutils:
~/build/gcc> rpm -qa binutils
binutils-2.35.1-1.1.ppc64le