8

How to build a GCC 4.7 toolchain for cross-compiling? explains how to build a cross-compiling GCC and advises choosing softfp, but I understand that hardfp would be much faster.

Will software compiled for hardfp work on a softfp kernel or is the ABI different?

7

No, software compiled for hardfp will not work on a softfp system, as the calling conventions are different - the soft float conventions involve passing floats through integer registers (though technically, the kernel isn't the real issue - the problem is the linker and all of the standard libraries). This is why the Raspbian project was such a big undertaking, as everything needs to be hardfp from the ground up. However, now that we have an official Raspbian image with full hardfp support, there doesn't seem to be any reason to develop for softfp systems any more. I would suggest changing your toolchain to generate hardfp, using gcc options like:

gcc -O2 -march=armv6 -mfpu=vfp -mfloat-abi=hard

as this should generate code suitable for use with the new Raspbian image. The march flag specifies the processor family, and the mfpu and mfloat flags specify that hard float instructions and calling conventions can and should be used.

As an alternative to the -march flag, you could instead use "-mcpu=arm1176jzf-s", which specifies the actual chip used in the Pi.

  • Or use the toolchain that the Foundation provides on GitHub. – Jivings Jul 18 '12 at 10:00
  • @Jivings If you download their gcc, do you still have to specify march etc? – Alex Chamberlain Jul 18 '12 at 10:37
  • @AlexChamberlain I wouldn't think so. – Jivings Jul 18 '12 at 10:38
  • So, is -march=armv6 etc built into every gcc? – Alex Chamberlain Jul 18 '12 at 10:49
  • So, does gcc -march=armv6 exec another binary? How does it work? – Alex Chamberlain Jul 18 '12 at 11:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.