views:

411

answers:

2

Is it (easily) possible to use software floating point on i386 linux without incurring the expense of trapping into the kernel on each call? I've tried -msoft-float, but it seems the normal (ubuntu) C libraries don't have a FP library included:

$ gcc -m32 -msoft-float -lm -o test test.c
/tmp/cc8RXn8F.o: In function `main':
test.c:(.text+0x39): undefined reference to `__muldf3'
collect2: ld returned 1 exit status
+2  A: 

Unless you want to bootstrap your entire toolchain by hand, you could start with uclibc toolchain (the i386 version, I imagine) -- soft float is (AFAIK) not directly supported for "native" compilation on debian and derivatives, but it can be used via the "embedded" approach of the uclibc toolchain.

Alex Martelli
Thanks for the response. I tried bootstrapping uclibc using buildroot but it seems to be ignoring the .config I provided it under BR2_UCLIBC_CONFIG, at least for the UCLIBC_HAS_FPU option :/
bdonlan
A: 

G'day,

Unless you're targetting a platform that doesn't have inbuilt FP support, I can't think of a reason why you'd want to emulate FP support.

Doesn't your x386 platform have external FPU support? Pity it's not a x486 with the FPU built in!

In my experience, any soft emulation is bound to be much slower than its hardware equivalent.

That's why I finished up writing a package in Ada to taget the onboard 68k FPU instead of using the soft emulation provided by the compiler manufacturer at the time. They finished up bundling it in their compiler as a matter of fact.

Edit: Just seen your comment below. Hmmm, if you don't need a full suite of FP support is it possible to roll your own for the few math functions you do need? That how the Ada package I mentioned got started.

HTH

cheers,

Rob Wells
We're looking at porting a product to an embedded x86 CPU, and a number of them do not have a FPU. We're currently running on a platform without a FPU, but we don't incur penalties for trapping to the kernel either :)
bdonlan