__nldbl_fprintf and __gtdf2 on PowerPC no-fpu

classic Classic list List threaded Threaded
15 messages Options
Reply | Threaded
Open this post in threaded view
|

__nldbl_fprintf and __gtdf2 on PowerPC no-fpu

Hiroki Kaminaga
Hi,

I'm using gcc-4.1.1, glibc-2.5, binutils-2.17.50.0.6 to cross compile
for PowerPC architecture, without fp.

Below is sample problem I met:

$ cat ldbl.c
#include <stdio.h>
int main(void){
  long double ld1, ld2;
  if (ld1>ld2)
    fprintf(stderr, "hello, %Lf\n", ld1);
  return 0;
}

$ powerpc-unknown-linux-gcc -static ldbl.c
/usr/local/powerpc-unknown-linux-newtool/devel/bin/../target/usr/lib/libc.a(gedf2.o): In function `__gtdf2':
gedf2.c:(.text+0x0): multiple definition of `__gtdf2'
/usr/local/powerpc-unknown-linux-newtool/devel/bin/../lib/gcc/powerpc-unknown-linux/4.1.1/libgcc.a(_gt_df.o):/var/rpm/BUILD/gcc-4.1.1/objdir/gcc/dp-bit.c:1223: first defined here
/usr/local/powerpc-unknown-linux-newtool/devel/bin/../lib/gcc/powerpc-unknown-linux/4.1.1/../../../../powerpc-unknown-linux/bin/ld: Warning: size of symbol `__gtdf2' changed from 152 in /usr/local/powerpc-unknown-linux-newtool/devel/bin/../lib/gcc/powerpc-unknown-linux/4.1.1/libgcc.a(_gt_df.o) to 440 in /usr/local/powerpc-unknown-linux-newtool/devel/bin/../target/usr/lib/libc.a(gedf2.o)
collect2: ld returned 1 exit status

Without specifying -static, or removing `if' statement, or change `long
double' to `float' from sample program would not reproduce the problem.

Any hint to solve this?


(Hiroki Kaminaga)
t
--
Reply | Threaded
Open this post in threaded view
|

Re: __nldbl_fprintf and __gtdf2 on PowerPC no-fpu

Hiroki Kaminaga
 Hi,

Hiroki Kaminaga wrote:

> I'm using gcc-4.1.1, glibc-2.5, binutils-2.17.50.0.6 to cross compile
> for PowerPC architecture, without fp.
>
> Below is sample problem I met:
>
> $ cat ldbl.c
> #include <stdio.h>
> int main(void){
>   long double ld1, ld2;
>   if (ld1>ld2)
>     fprintf(stderr, "hello, %Lf\n", ld1);
>   return 0;
> }
>
> $ powerpc-unknown-linux-gcc -static ldbl.c
> /usr/local/powerpc-unknown-linux-newtool/devel/bin/../target/usr/lib/libc.a(gedf2.o): In function `__gtdf2':
> gedf2.c:(.text+0x0): multiple definition of `__gtdf2'
> /usr/local/powerpc-unknown-linux-newtool/devel/bin/../lib/gcc/powerpc-unknown-linux/4.1.1/libgcc.a(_gt_df.o):/var/rpm/BUILD/gcc-4.1.1/objdir/gcc/dp-bit.c:1223: first defined here
> /usr/local/powerpc-unknown-linux-newtool/devel/bin/../lib/gcc/powerpc-unknown-linux/4.1.1/../../../../powerpc-unknown-linux/bin/ld: Warning: size of symbol `__gtdf2' changed from 152 in /usr/local/powerpc-unknown-linux-newtool/devel/bin/../lib/gcc/powerpc-unknown-linux/4.1.1/libgcc.a(_gt_df.o) to 440 in /usr/local/powerpc-unknown-linux-newtool/devel/bin/../target/usr/lib/libc.a(gedf2.o)
> collect2: ld returned 1 exit status
>
> Without specifying -static, or removing `if' statement, or change `long
> double' to `float' from sample program would not reproduce the problem.

in addition, changing the if statement to
 '>=' or '<' or '<=' or '=='or '!='
(thus __gedf2, __l[te]df2, __eqdf2, __nedf2) did not show up the
problem. It seems to appear only on __gtdf2.


(Hiroki Kaminaga)
t
--
Reply | Threaded
Open this post in threaded view
|

Re: __nldbl_fprintf and __gtdf2 on PowerPC no-fpu

Hiroki Kaminaga
Hi,

Hiroki Kaminaga wrote:

> > I'm using gcc-4.1.1, glibc-2.5, binutils-2.17.50.0.6 to cross compile
> > for PowerPC architecture, without fp.
> >
> > Below is sample problem I met:
> >
> > $ cat ldbl.c
> > #include <stdio.h>
> > int main(void){
> >   long double ld1, ld2;
> >   if (ld1>ld2)
> >     fprintf(stderr, "hello, %Lf\n", ld1);
> >   return 0;
> > }
> >
> > $ powerpc-unknown-linux-gcc -static ldbl.c
> > /usr/local/powerpc-unknown-linux-newtool/devel/bin/../target/usr/lib/libc.a(gedf2.o): In function `__gtdf2':
> > gedf2.c:(.text+0x0): multiple definition of `__gtdf2'
> > /usr/local/powerpc-unknown-linux-newtool/devel/bin/../lib/gcc/powerpc-unknown-linux/4.1.1/libgcc.a(_gt_df.o):/var/rpm/BUILD/gcc-4.1.1/objdir/gcc/dp-bit.c:1223: first defined here
> > /usr/local/powerpc-unknown-linux-newtool/devel/bin/../lib/gcc/powerpc-unknown-linux/4.1.1/../../../../powerpc-unknown-linux/bin/ld: Warning: size of symbol `__gtdf2' changed from 152 in /usr/local/powerpc-unknown-linux-newtool/devel/bin/../lib/gcc/powerpc-unknown-linux/4.1.1/libgcc.a(_gt_df.o) to 440 in /usr/local/powerpc-unknown-linux-newtool/devel/bin/../target/usr/lib/libc.a(gedf2.o)
> > collect2: ld returned 1 exit status
> >
> > Without specifying -static, or removing `if' statement, or change `long
> > double' to `float' from sample program would not reproduce the problem.
>
> in addition, changing the if statement to
>  '>=' or '<' or '<=' or '=='or '!='
> (thus __gedf2, __l[te]df2, __eqdf2, __nedf2) did not show up the
> problem. It seems to appear only on __gtdf2.

another addition, changing fprintf to fscanf did not reproduce the problem.
it seems only the combination of *printf and __gtdf2 and -static would
cause this problem.


(Hiroki Kaminaga)
t
--
Reply | Threaded
Open this post in threaded view
|

Re: __nldbl_fprintf and __gtdf2 on PowerPC no-fpu

Hiroki Kaminaga
Hi,

Hiroki Kaminaga wrote:

> > > I'm using gcc-4.1.1, glibc-2.5, binutils-2.17.50.0.6 to cross compile
> > > for PowerPC architecture, without fp.
> > >
> > > Below is sample problem I met:
> > >
> > > $ cat ldbl.c
> > > #include <stdio.h>
> > > int main(void){
> > >   long double ld1, ld2;
> > >   if (ld1>ld2)
> > >     fprintf(stderr, "hello, %Lf\n", ld1);
> > >   return 0;
> > > }
> > >
> > > $ powerpc-unknown-linux-gcc -static ldbl.c
> > > /usr/local/powerpc-unknown-linux-newtool/devel/bin/../target/usr/lib/libc.a(gedf2.o): In function `__gtdf2':
> > > gedf2.c:(.text+0x0): multiple definition of `__gtdf2'
> > > /usr/local/powerpc-unknown-linux-newtool/devel/bin/../lib/gcc/powerpc-unknown-linux/4.1.1/libgcc.a(_gt_df.o):/var/rpm/BUILD/gcc-4.1.1/objdir/gcc/dp-bit.c:1223: first defined here
> > > /usr/local/powerpc-unknown-linux-newtool/devel/bin/../lib/gcc/powerpc-unknown-linux/4.1.1/../../../../powerpc-unknown-linux/bin/ld: Warning: size of symbol `__gtdf2' changed from 152 in /usr/local/powerpc-unknown-linux-newtool/devel/bin/../lib/gcc/powerpc-unknown-linux/4.1.1/libgcc.a(_gt_df.o) to 440 in /usr/local/powerpc-unknown-linux-newtool/devel/bin/../target/usr/lib/libc.a(gedf2.o)
> > > collect2: ld returned 1 exit status
> > >
> > > Without specifying -static, or removing `if' statement, or change `long
> > > double' to `float' from sample program would not reproduce the problem.
> >
> > in addition, changing the if statement to
> >  '>=' or '<' or '<=' or '=='or '!='
> > (thus __gedf2, __l[te]df2, __eqdf2, __nedf2) did not show up the
> > problem. It seems to appear only on __gtdf2.
>
> another addition, changing fprintf to fscanf did not reproduce the problem.
> it seems only the combination of *printf and __gtdf2 and -static would
> cause this problem.

Opps, false information, sorry...
*scanf and __gtdf2 DID reproduce the problem.
also, __ledf2 and {*printf,*scanf} DID reproduce the problem.

Summary:
                | __gtdf2 __gedf2 __ltdf2 __ledf2
----------------+-------- ------- ------- -------
__nldbl_fprintf |    NG      OK      OK      NG
__nldbl_fscanf  |    NG      OK      OK      NG


(Hiroki Kaminaga)
t
--
Reply | Threaded
Open this post in threaded view
|

Re: __nldbl_fprintf and __gtdf2 on PowerPC no-fpu

Hiroki Kaminaga
Hi,

Hiroki Kaminaga wrote:

> > > > I'm using gcc-4.1.1, glibc-2.5, binutils-2.17.50.0.6 to cross compile
> > > > for PowerPC architecture, without fp.
> > > >
> > > > Below is sample problem I met:
> > > >
> > > > $ cat ldbl.c
> > > > #include <stdio.h>
> > > > int main(void){
> > > >   long double ld1, ld2;
> > > >   if (ld1>ld2)
> > > >     fprintf(stderr, "hello, %Lf\n", ld1);
> > > >   return 0;
> > > > }
> > > >
> > > > $ powerpc-unknown-linux-gcc -static ldbl.c
> > > > /usr/local/powerpc-unknown-linux-newtool/devel/bin/../target/usr/lib/libc.a(gedf2.o): In function `__gtdf2':
> > > > gedf2.c:(.text+0x0): multiple definition of `__gtdf2'
> > > > /usr/local/powerpc-unknown-linux-newtool/devel/bin/../lib/gcc/powerpc-unknown-linux/4.1.1/libgcc.a(_gt_df.o):/var/rpm/BUILD/gcc-4.1.1/objdir/gcc/dp-bit.c:1223: first defined here
> > > > /usr/local/powerpc-unknown-linux-newtool/devel/bin/../lib/gcc/powerpc-unknown-linux/4.1.1/../../../../powerpc-unknown-linux/bin/ld: Warning: size of symbol `__gtdf2' changed from 152 in /usr/local/powerpc-unknown-linux-newtool/devel/bin/../lib/gcc/powerpc-unknown-linux/4.1.1/libgcc.a(_gt_df.o) to 440 in /usr/local/powerpc-unknown-linux-newtool/devel/bin/../target/usr/lib/libc.a(gedf2.o)
> > > > collect2: ld returned 1 exit status
> > > >
> > > > Without specifying -static, or removing `if' statement, or change `long
> > > > double' to `float' from sample program would not reproduce the problem.
> > >
> > > in addition, changing the if statement to
> > >  '>=' or '<' or '<=' or '=='or '!='
> > > (thus __gedf2, __l[te]df2, __eqdf2, __nedf2) did not show up the
> > > problem. It seems to appear only on __gtdf2.
> >
> > another addition, changing fprintf to fscanf did not reproduce the problem.
> > it seems only the combination of *printf and __gtdf2 and -static would
> > cause this problem.
>
> Opps, false information, sorry...
> *scanf and __gtdf2 DID reproduce the problem.
> also, __ledf2 and {*printf,*scanf} DID reproduce the problem.
>
> Summary:
>                 | __gtdf2 __gedf2 __ltdf2 __ledf2
> ----------------+-------- ------- ------- -------
> __nldbl_fprintf |    NG      OK      OK      NG
> __nldbl_fscanf  |    NG      OK      OK      NG


I think I found the cause.

__gtdf2 was *NOT* in glibc-2.5-ports/sysdeps/powerpc/nofpu/Versions
but __gedf2 *WAS* in this file.

I think I posted to the wrong list.
Sorry for the noise.


Best Regards,

(Hiroki Kaminaga)
nil
--
Reply | Threaded
Open this post in threaded view
|

Re: __nldbl_fprintf and __gtdf2 on PowerPC no-fpu

Steven Munroe
In reply to this post by Hiroki Kaminaga
You need the patches attached to
http://sources.redhat.com/bugzilla/show_bug.cgi?id=2749 and
http://sources.redhat.com/bugzilla/show_bug.cgi?id=3268.

The ports patched where commited to the ports add-on but libc patches
are not. You will need to -mlong-double-128 in you gcc and build libc
with the ports add-on.
Reply | Threaded
Open this post in threaded view
|

Re: __nldbl_fprintf and __gtdf2 on PowerPC no-fpu

Hiroki Kaminaga
Steven Munroe wrote:
> You need the patches attached to
> http://sources.redhat.com/bugzilla/show_bug.cgi?id=2749 and
> http://sources.redhat.com/bugzilla/show_bug.cgi?id=3268.
>
> The ports patched where commited to the ports add-on but libc patches
> are not. You will need to -mlong-double-128 in you gcc and build libc
> with the ports add-on.

Thanks!

I've applied pateches in above link to gcc-4.1.1 and glibc-2.5, but
the problem still appears... Could you give it a try with your
toolchain?

$ cat ldbl.c
#include <stdio.h>
int main(void){
  long double ld1, ld2;
  if (ld1>ld2)
    fprintf(stderr, "hello, %f\n", ld1);
  return 0;
}

$ powerpc-unknown-linux-gcc -static ldbl.c


Best Regards,

(Hiroki Kaminaga)
t
--
Reply | Threaded
Open this post in threaded view
|

Re: __nldbl_fprintf and __gtdf2 on PowerPC no-fpu

Steven Munroe
Hiroki Kaminaga wrote:

>Steven Munroe wrote:
>  
>>You need the patches attached to
>>http://sources.redhat.com/bugzilla/show_bug.cgi?id=2749 and
>>http://sources.redhat.com/bugzilla/show_bug.cgi?id=3268.
>>
>>The ports patched where commited to the ports add-on but libc patches
>>are not. You will need to -mlong-double-128 in you gcc and build libc
>>with the ports add-on.
>>    
>
>Thanks!
>
>I've applied pateches in above link to gcc-4.1.1 and glibc-2.5, but
>the problem still appears... Could you give it a try with your
>toolchain?
>
>$ cat ldbl.c
>#include <stdio.h>
>int main(void){
>  long double ld1, ld2;
>  if (ld1>ld2)
>    fprintf(stderr, "hello, %f\n", ld1);
>  return 0;
>}
>
>$ powerpc-unknown-linux-gcc -static ldbl.c
>
>  

works for me.

Did you apply all the patches? did you configure --enable-add-ons=ports,nptl

Reply | Threaded
Open this post in threaded view
|

Re: __nldbl_fprintf and __gtdf2 on PowerPC no-fpu

Hiroki Kaminaga
Steven Munroe wrote:

> works for me.
>
> Did you apply all the patches? did you configure --enable-add-ons=ports,nptl

Thank you!

my configure was --enable-addons=ports,linuxthreads.
I'll investigate some more.

Sorry for late rely.


(Hiroki Kaminaga)
t
--
Reply | Threaded
Open this post in threaded view
|

Re: __nldbl_fprintf and __gtdf2 on PowerPC no-fpu

Steven Munroe
Hiroki Kaminaga wrote:

>Steven Munroe wrote:
>
>  
>>works for me.
>>
>>Did you apply all the patches? did you configure --enable-add-ons=ports,nptl
>>    
>
>Thank you!
>
>my configure was --enable-addons=ports,linuxthreads.
>I'll investigate some more.
>
>  
linuxthreads is deprecated in glibc-2.4 and I have not been testing
linuxthreads at all. I have tested all the soft-fp patches with nptl.

Reply | Threaded
Open this post in threaded view
|

Re: __nldbl_fprintf and __gtdf2 on PowerPC no-fpu

Hiroki Kaminaga
In reply to this post by Steven Munroe
Hi,

> Did you apply all the patches? did you configure --enable-add-ons=ports,nptl

In the patch: gcc-41-20060515.patch in
http://sources.redhat.com/bugzilla/show_bug.cgi?id=2749

I found following:

a) $target matching

--- gcc-41-20060515.orig/gcc/configure  2006-05-15 11:14:19.000000000 -0500
+++ gcc-41-20060515/gcc/configure       2006-05-15 13:47:27.594268652 -0500
...
+# Check if TFmode long double should be used by default or not.
+# Some glibc targets used DFmode long double, but with glibc 2.4
+# and later they can use TFmode.
+case "$target" in
+  powerpc*-*-*gnu* | \

but my target was configured with --target=powerpc-unknown-linux ...
with *OUT* the string `gnu'...
Ok to change as below?
+  powerpc*-*-* | \


b) grep pattern matching

--- gcc-41-20060515.orig/gcc/configure  2006-05-15 11:14:19.000000000 -0500
+++ gcc-41-20060515/gcc/configure       2006-05-15 13:47:27.594268652 -0500
...
+   grep '^ *#[ ]*define[ ][ ]*__LONG_DOUBLE_MATH_OPTIONAL' \
+     $glibc_header_dir/bits/wordsize.h > /dev/null 2>&1 \

--- gcc-41-20060515.orig/gcc/configure.ac 2006-05-15 11:14:20.000000000 -0500
+++ gcc-41-20060515/gcc/configure.ac      2006-05-15 13:47:27.597400000 -0500
...
+   grep '^[ ]*#[ ]*define[ ][ ]*__LONG_DOUBLE_MATH_OPTIONAL' \
+     $glibc_header_dir/bits/wordsize.h > /dev/null 2>&1 \


configure.ac grep has: `hat' `open bracket' `space' `tab' `close bracket'
but configure file did *NOT* have open and close bracket.
This lead to fail grep pattern match, and didn't define
TARGET_DEFAULT_LONG_DOUBLE_128.

I tried to regenerate configure from configure.ac with autoconf, but I also
got the misgenerated configure. My autoconf was 2.59 (in FC3). Maybe you
also have buggy autoconf?


(Hiroki Kaminaga)
t
--
Reply | Threaded
Open this post in threaded view
|

Re: __nldbl_fprintf and __gtdf2 on PowerPC no-fpu

Daniel Jacobowitz-2
On Tue, Dec 12, 2006 at 03:12:53PM +0900, Hiroki Kaminaga wrote:
> but my target was configured with --target=powerpc-unknown-linux ...
> with *OUT* the string `gnu'...
> Ok to change as below?
> +  powerpc*-*-* | \

That shouldn't matter.  $target has been through config.sub, which will
canonicalize it.  Are you sure?

> configure.ac grep has: `hat' `open bracket' `space' `tab' `close bracket'
> but configure file did *NOT* have open and close bracket.
> This lead to fail grep pattern match, and didn't define
> TARGET_DEFAULT_LONG_DOUBLE_128.
>
> I tried to regenerate configure from configure.ac with autoconf, but I also
> got the misgenerated configure. My autoconf was 2.59 (in FC3). Maybe you
> also have buggy autoconf?

Autoconf is working as designed: the braces need to be doubled because
they are also the m4 quote characters.

--
Daniel Jacobowitz
CodeSourcery
Reply | Threaded
Open this post in threaded view
|

Re: __nldbl_fprintf and __gtdf2 on PowerPC no-fpu

Hiroki Kaminaga
Daniel Jacobowitz <[hidden email]> wrote:

> That shouldn't matter.  $target has been through config.sub, which will
> canonicalize it.  Are you sure?

Ah, sorry, gnu was appended, so no change was needed.

> Autoconf is working as designed: the braces need to be doubled because
> they are also the m4 quote characters.

when I changed gcc-41-20060515.patch (from PR2749) as below, it was ok.

--- gcc-41-20060515.orig/gcc/configure.ac
+++ gcc-41-20060515/gcc/configure.ac
...
-+      grep '^[ ]*#[ ]*define[ ][ ]*__LONG_DOUBLE_MATH_OPTIONAL' \
++      grep '^[[ ]]*#[ ]*define[ ][ ]*__LONG_DOUBLE_MATH_OPTIONAL' \


thanks.

(Hiroki Kaminaga)
t
--
Reply | Threaded
Open this post in threaded view
|

Re: __nldbl_fprintf and __gtdf2 on PowerPC no-fpu

Hiroki Kaminaga
In reply to this post by Hiroki Kaminaga
Hiroki Kaminaga <[hidden email]> wrote:
> I'll investigate some more.

The problem was due to libc.a(gedf2.o) defining both __gedf2 and __gtdf2.

ldbl.o had:
UND __gtdf2
UND __nldbl_fprintf

__gtdf2 was found in libgcc.a(_gt_df.o).
When finding __nldbl_fprintf, it also looks for __printf_size, where
__gedf2 is UND, and finds it in libc.a(gedf2.o). But gedf2.o also defines
__gtdf2, and thus the error:  multiple definition of `__gtdf2'


For -mlong-double-128 case, it is similar:

ldbl.o had:
UND __gcc_qgt
UND fprintf

__gcc_qgt was found in libgcc.a(darwin-ldouble.o). In darwin-ldouble.o, it
has UND __ledf2, and finds it in libgcc.a(_le_df.o).
When finding fprintf, it looks for vfprintf, where __printf_fp is UND.
__printf_fp is found in libc.a(printf_fp.o) where __ltdf2 is UND and
finds it in libc.a(ledf2.o). But ledf2.o also defines __ledf2, and thus
the error: multiple definition of `__ledf2'

The problem here is that libc.a(ledf2.o) defining both __ledf2 and __ltdf2.

So, the solution I could think is:

a) stop using strong_alias() in soft-fp/{eq,ge,le}[sdt]f2.c
   (and make one definition per one *.o)
b) stop defining *df in libgcc

a) is temporal fixup. So I should do b)?


(Hiroki Kaminaga)
t
--
Reply | Threaded
Open this post in threaded view
|

Re: __nldbl_fprintf and __gtdf2 on PowerPC no-fpu

Joseph Myers
On Wed, 13 Dec 2006, Hiroki Kaminaga wrote:

> a) stop using strong_alias() in soft-fp/{eq,ge,le}[sdt]f2.c
>    (and make one definition per one *.o)
> b) stop defining *df in libgcc
>
> a) is temporal fixup. So I should do b)?

Yes.  See the todo list at
<http://gcc.gnu.org/wiki/Software_floating_point> (this is in the context
of GCC 4.2 or later which includes soft-fp); you need to add the GCC
configure option to disable libgcc defining soft-fp functions defined in
glibc.

--
Joseph S. Myers
[hidden email]