Reputation: 111
I have a x86 core which does not support floating point unit (FPU), and i am writing a micro kernel for floating point calculations such as add, div, mul, pow, log etc. As per need i must use static library for doing float calculations. I found to use glibc (from GNU) which has math library. It means I will have to compile glibc with “-msoft-float” compiler switch or ‘without-fp’. After doing search in stackoverflow.com I found glibc can be compiled by sequence of command like given below (from link - How to compile glibc 32bit on an x86_64 machine) :
NOTE- I have Ubuntu12.04 version running VMware on win7 desktop.
$Mkdir build-glib
$Cd build-glib
$../glibc-2.17/configure --prefix=$HOME/glibc-2.17 --host=i686-linux-gnu \
--build=i686-linux- gnu \
CC="gcc -m32" CXX="g++ -m32" CFLAGS="-O2 -march=i686" \
CXXFLAGS="-O2 -march=i686"
$make
$.....
Above build is Successful. Now I tried to compile “with_fp=’no’ ” configure option, but I got below errors.
$../glibc-2.17/configure --prefix=$HOME/glibc-2.17 --host=i686-linux-gnu \
--build=i686-linux-gnu \
CC="gcc -m32" CXX="g++ -m32" CFLAGS="-O2 -march=i686" \
CXXFLAGS="-O2 -march=i686" with_fp=”no”
$make
$.....
gcc -m32 ../sysdeps/ieee754/dbl-64/e_exp.c -c -std=gnu99 -fgnu89-inline -fno-stack-protector -
O2 -Wall -Winline -Wwrite-strings -fmerge-all-constants -frounding-math -march=i686 -Wstrict-
prototypes -mpreferred-stack-boundary=4 -Wa,-mtune=i686 -Wno-uninitialized -
U_FORTIFY_SOURCE -D__NO_MATH_INLINES -D__LIBC_INTERNAL_MATH_INLINES -I../include -
I/home/rajiv/Downloads/build-glib/math -I/home/rajiv/Downloads/build-glib -
I../nptl/sysdeps/unix/sysv/linux/i386/i686 -I../sysdeps/unix/sysv/linux/i386/i686 -
I../nptl/sysdeps/unix/sysv/linux/i386 -I../nptl/sysdeps/unix/sysv/linux/x86
-I../sysdeps/unix/sysv/linux/x86 -I../sysdeps/unix/sysv/linux/i386/nptl -
I../sysdeps/unix/sysv/linux/i386 -I../nptl/sysdeps/unix/sysv/linux -I../nptl/sysdeps/pthread -
I../sysdeps/pthread -I../ports/sysdeps/unix/sysv/linux -I../sysdeps/unix/sysv/linux -
I../sysdeps/gnu -I../sysdeps/unix/inet -I../nptl/sysdeps/unix/sysv -
I../ports/sysdeps/unix/sysv -I../sysdeps/unix/sysv -I../sysdeps/unix/i386 -
I../nptl/sysdeps/unix -I../ports/sysdeps/unix -I../sysdeps/unix -I../sysdeps/posix -
I../sysdeps/i386/i686/multiarch -I../nptl/sysdeps/i386/i686 -I../sysdeps/i386/i686 -
I../sysdeps/i386/i486 -I../nptl/sysdeps/i386/i486 -I../nptl/sysdeps/i386 -I../sysdeps/i386 -
I../sysdeps/x86 -I../sysdeps/wordsize-32 -I../sysdeps/ieee754/ldbl-96 -I../sysdeps/ieee754/dbl-
64 -I../sysdeps/ieee754/flt-32 -I../sysdeps/ieee754 -I../sysdeps/generic -I../nptl -I../ports -
I.. -I../libio -I. -D_LIBC_REENTRANT -include ../include/libc-symbols.h -DNOT_IN_libc=1 -
DIS_IN_libm=1 -DIN_LIB=libm -o /home/rajiv/Downloads/build-glib/math/e_exp.o -MD -MP -
MF /home/rajiv/Downloads/build-glib/math/e_exp.o.dt -MT /home/rajiv/Downloads/build-
glib/math/e_exp.o
../sysdeps/ieee754/dbl-64/e_exp.c: In function ‘__ieee754_exp’:
../sysdeps/ieee754/dbl-64/e_exp.c:64:3: error: ‘FE_TONEAREST’ undeclared (first use in this
function)
../sysdeps/ieee754/dbl-64/e_exp.c:64:3: note: each undeclared identifier is reported only once
for each function it appears in
make[2]: *** [/home/rajiv/Downloads/build-glib/math/e_exp.o] Error 1
make[2]: Leaving directory `/home/rajiv/Downloads/glibc-2.17/math'
make[1]: *** [math/others] Error 2
make[1]: Leaving directory `/home/rajiv/Downloads/glibc-2.17'
make: *** [all] Error 2
Then I tried to compile glibc with “-msoft-float” switch. I used below commands but got error again.
$../glibc-2.17/configure --prefix=$HOME/glibc-2.17 --host=i686-linux-gnu \
--build=i686-linux-gnu \
CC="gcc -m32 –msoft-float" CXX="g++ -m32 –msoft-float" CFLAGS="-O2 -march=i686 –msoft-float" \
CXXFLAGS="-O2 -march=i686 –msoft-float"
$make
$.....
/home/rajiv/Downloads/build-glib/shlib.lds /home/rajiv/Downloads/build-glib/csu/abi-
note.o /home/rajiv/Downloads/build-glib/elf/soinit.os /home/rajiv/Downloads/build-
glib/libc_pic.os /home/rajiv/Downloads/build-glib/elf/sofini.os /home/rajiv/Downloads/build-
glib/elf/interp.os /home/rajiv/Downloads/build-glib/elf/ld.so -lgcc
/home/rajiv/Downloads/build-glib/libc_pic.os: In function `__modf':
(.text+0x144d0): undefined reference to `__subdf3'
/home/rajiv/Downloads/build-glib/libc_pic.os: In function `ldexp':
(.text+0x1463f): undefined reference to `__eqdf2'
(.text+0x14f34): undefined reference to `__eqxf2'
/home/rajiv/Downloads/build-glib/libc_pic.os: In function `__erand48_r':
(.text+0x1963b): undefined reference to `__subdf3'
/home/rajiv/Downloads/build-glib/libc_pic.os: In function `round_and_return':
strtof_l.c:(.text+0x1ba9d): undefined reference to `__mulsf3'
strtof_l.c:(.text+0x1bd43): undefined reference to `__mulsf3'
/home/rajiv/Downloads/build-glib/libc_pic.os:(.text+0x1c36b): more undefined references to
`__mulsf3' follow
/home/rajiv/Downloads/build-glib/libc_pic.os: In function `round_and_return':
strtod_l.c:(.text+0x1ef5e): undefined reference to `__muldf3'
strtod_l.c:(.text+0x1f12c): undefined reference to `__muldf3'
/home/rajiv/Downloads/build-glib/libc_pic.os: In function `__GI_____strtod_l_internal':
(.text+0x1f91c): undefined reference to `__muldf3'
/home/rajiv/Downloads/build-glib/libc_pic.os:(.text+0x1fc7f): more undefined references to
`__muldf3' follow
wcstod_l.c:(.text+0x84a28): undefined reference to `__muldf3'
wcstod_l.c:(.text+0x84a9e): undefined reference to `__muldf3'
wcstod_l.c:(.text+0x84c6c): undefined reference to `__muldf3'
/home/rajiv/Downloads/build-glib/libc_pic.os: In function `____wcstod_l_internal':
(.text+0x85285): undefined reference to `__muldf3'
/home/rajiv/Downloads/build-glib/libc_pic.os:(.text+0x8578d): more undefined references to
`__muldf3' follow
/home/rajiv/Downloads/build-glib/libc_pic.os: In function `round_and_return':
wcstold_l.c:(.text+0x87e48): undefined reference to `__mulxf3'
wcstold_l.c:(.text+0x880a9): undefined reference to `__mulxf3'
/home/rajiv/Downloads/build-glib/libc_pic.os:(.text+0x886e1): more undefined references to
`__mulxf3' follow
/home/rajiv/Downloads/build-glib/libc_pic.os: In function `round_and_return':
wcstof_l.c:(.text+0x8b278): undefined reference to `__mulsf3'
wcstof_l.c:(.text+0x8b3e3): undefined reference to `__mulsf3'
/home/rajiv/Downloads/build-glib/libc_pic.os:(.text+0x8b8f1): more undefined references to
`__mulsf3' follow
/home/rajiv/Downloads/build-glib/libc_pic.os: In function `difftime':
(.text+0x91e37): undefined reference to `__floatsidf'
/home/rajiv/Downloads/build-glib/libc_pic.os: In function `difftime':
/home/rajiv/Downloads/build-glib/libc_pic.os: In function `ecvt_r':
(.text+0xd64f6): undefined reference to `__muldf3'
/home/rajiv/Downloads/build-glib/libc_pic.os: In function `qfcvt_r':
(.text+0xd6934): undefined reference to `__mulxf3'
/home/rajiv/Downloads/build-glib/libc_pic.os: In function `__qecvt_r':
(.text+0xd6fd7): undefined reference to `__ltxf2'
/home/rajiv/Downloads/build-glib/libc_pic.os: In function `__qecvt_r':
(.text+0xd7007): undefined reference to `__mulxf3'
/home/rajiv/Downloads/build-glib/libc_pic.os: In function `__monstartup':
(.text+0xdd792): undefined reference to `__fixsfsi'
collect2: ld returned 1 exit status
make[2]: *** [/home/rajiv/Downloads/build-glib/libc.so] Error 1
make[2]: Leaving directory `/home/rajiv/Downloads/glibc-2.17/elf'
make[1]: *** [elf/subdir_lib] Error 2
make[1]: Leaving directory `/home/rajiv/Downloads/glibc-2.17'
make: *** [all] Error 2
Please help and let me know that how can I compile or build the GNU glibc to use it on non FPU x86 core. Basically I need libm.a compiled with ‘-msoft-float’ or ‘without-fp’ , so that I can link libm statically to create kernel BIN.
As you can see non of my trials are working :(. I tried to link gcc soft-fp lib also, but could not do.
Upvotes: 2
Views: 3195
Reputation: 1784
Did you try "configure" with "--with-float=soft" ?
And consider using "--host=i386-linux-gnu" (instead of i686), because intel processors have math co-processor since i486.
Upvotes: 0