Help with hard versus soft float on PPC
Till Straumann
strauman at slac.stanford.edu
Fri Nov 20 11:06:47 UTC 2009
At least for classic PPC (I'm not familiar with the SPE ABI) the
hard- and soft-float ABIs are *not* binary compatible.
Luckily later gcc toolchains set and check object file
attributes to detect such situations.
E.g., when using -hard-float the classic PPC ABI requires
the compiler to set a CRC bit-6 when floating-point
arguments are (or clear the bit if this is not the case) passed in
registers to functions with variable arguments.
Code compiled with -soft-float never uses FP registers and thus
does not maintain the bit in question.
Hence, if a function compiled with -msoft-float calls a
vararg function compiled with -mhard-float then the
state of CRC[6] is undefined and may be wrong.
This then may crash a FP-only task because the
-mhard-float compiled function may find CRC[6]==1
and try to save some FP registers on the stack...
Another incompatibility is that -hard-float compiled
code passes FP args in registers whereas -soft-float
compiled code obviously does not. Hence, passing of
FP args is not possible between code with this ABI
incompatibility.
Again, that all was about classic PPC but I strongly
recommend to take these warnings seriously and
not try to mix incompatible compiler flags.
HTH
-- Till
Peter Dufault wrote:
> I've been building my application for my new MPC5554 BSP using the MPC5554 hard-float (single precision SPE hard-float, I added the context switch hooks) while the BSP has been built using soft float. This has been working OK for about a month. I tried to rebuild the BSP with the same set of flags as my application, but now I get warnings, though I didn't before even though there was a mismatch then too.
>
> /opt/rtems-4.10/lib/gcc/powerpc-rtems4.10/4.4.2/../../../../powerpc-rtems4.10/bin/ld: Warning: /home/dufault/work/scratch/Andrea_Doria/powerpcmpc5566evbrtems4.10/lib/libmotobank.a(servo.o) uses hard float, o-optimize/motobank.exe uses soft float
>
> All the application and bsp .o files are now built using:
> -meabi \
> -mfloat-gprs=single \
> -mspe
>
> and the final link looks like this:
>
> powerpc-rtems4.10-g++ \
> -B/opt/rtems-4.10/powerpc-rtems4.10/mpc5566evb/lib/ \
> -specs bsp_specs \
> -qrtems \
> -g \
> -Wall \
> -mcpu=8540 \
> -meabi \
> -msdata \
> -fno-common \
> -mfloat-gprs=single \
> -mspe \
> -D__ppc_generic \
> -mstrict-align \
> -o o-optimize/motobank.exe \
> o-optimize/_init.o \
> o-optimize/flash.o \
> -L/home/dufault/work/scratch/Andrea_Doria/powerpcmpc5566evbrtems4.10/lib \
> -lmotobank \
> -letpu \
> -ltelnetd \
> -lnfs
>
> I haven't done anything about rebuilding newlib.
>
> What's the right way to go about properly building for -float-gprs=single -mspe?
>
> Peter
> _______________________________________________
> rtems-users mailing list
> rtems-users at rtems.org
> http://www.rtems.org/mailman/listinfo/rtems-users
>
More information about the users
mailing list