Tell me more ×
Raspberry Pi Stack Exchange is a question and answer site for users and developers of hardware and software for Raspberry Pi. It's 100% free, no registration required.

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?

share|improve this question

1 Answer

up vote 5 down vote accepted

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.

share|improve this answer
Or use the toolchain that the Foundation provides on GitHub. – Jivings Jul 18 '12 at 10:00
Fantastic, thank you! – Alex Chamberlain Jul 18 '12 at 10:14
@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
show 6 more comments

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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