MIPS cross compiler soft float problem
Michael Meissner
gcc-help@the-meissners.org
Mon Jun 16 11:38:00 GMT 2003
On Mon, Jun 16, 2003 at 10:14:34AM +0200, Stefan Fagerström wrote:
> Hi,
>
> I have a stange problem with my cross compiler for mips.
> It returns NaN when calling function with float arguments.
>
> Example:
> #include <stdio.h>
>
> float a(float a, float b, float c, float d)
> {
> return a*b*c*d;
> }
>
> int main()
> {
>
> float b = a(1.0, 0.3, 0.4, 0.5);
>
> printf("b = %f\n", b);
>
>
> printf("mul 2.4*4.5 = %f\n", 2.4*4.5);
> return 0;
> }
>
> Comipled with:
> /usr/local/devenv/bin/mipsel-linux-gnu-gcc -o testfloatcall -O2 -mips2
> -mcpu=r4600 -msoft-float -msoft-float testfloatcall.c
>
>
> Results:
> b = nan
> mul 2.4*4.5 = 10.800000
My guess is your glibc was not compiled with -msoft-float. Glibc's under Linux
typically don't have multilib support. I believe the MIPS calling sequence
passes floating point values to variable argument functions in floating point
registers, rather than integer registers.
--
Michael Meissner
email: gnu@the-meissners.org
http://www.the-meissners.org
More information about the Gcc-help
mailing list