Possible Duplicate:
Using software floating point on x86 linux
Just for educational reasons I'd like to compile some programmes using the -msoft-float
option of gcc
, i.e. doing floating point arithmetic without using the x87/sse fpu unit. Take a simple example:
#include <cstdio>
int main(int argc, char** argv) {
double x=3.14;
double y=2.71;
double z=x+y;
printf("z=%f\n",z);
return 0;
}
Compile with either (need to disable sse otherwise -msoft-float
has no effect)
g++ -msoft-float -mfpmath=387 float.cpp
g++ -msoft-float -m32 float.cpp
and I get
float.cpp:(.text+0x36): undefined reference to `__adddf3'
Now the man page warns me that I might need to provide my own soft-float library. However, since I'm not doing cross-compilation, does this still apply?
-msoft-float
Generate output containing library calls for floating point.
Warning: the requisite libraries are not part of GCC. Normally the
facilities of the machine's usual C compiler are used, but this
can't be done directly in cross-compilation. You must make your own
arrangements to provide suitable library functions for cross-
compilation.
I checked libgcc_s.so
as well as other libraries and __adddf3
is indeed nowhere to be found. I also looked into the gcc-4.6.2
source code and there's a directory
./gcc/config/soft-fp/
with all the soft-float routines, but I failed to compile them by hand.
So is there a way to just compile a soft-float library (or do I have to compile a whole new gcc) or have I overseen something more simple?