-
Notifications
You must be signed in to change notification settings - Fork 89
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Building apps with gcc flag '-mhard-float' ? #97
Comments
I was lazy one upon a lifetime. The newlib in libtock-c is built to support all cortex M's, which do not all have hard floating point support. The fix for this is to build multiple copies of newlib with varying features enabled and choose the one that matches the capabilities of the board. The libtock-c build system just doesn't have that intelligence implemented presently. The I think the newlib build actually does this to an extent out of the box; if you build newlib locally you should get a version in I'm happy to add more newlib builds to Tock (we maybe should bump versions of newlib too.. we're using one from 2017 presently), but the logic to choose the right newlib is a bit trickier. Maybe less painful now with some of the logic @bradjc had to implement for Risc-V... |
This is a build for |
Thank you so much for the files! I replaced
lonelyjoe@lonelyjoe-desktop:~/workspace/libtock-c/examples/n-body$ make
DIR ../../libtock/build/cortex-m0
CC ../../libtock/internal/alarm_internal.c
In file included from ./../../support/warning_header.h:6:0,
from <command-line>:0:
/usr/include/newlib/stdio.h: In function '__sputc_r':
/usr/include/newlib/stdio.h:671:39: sorry, unimplemented: Thumb-1 hard-float VFP ABI
_ELIDABLE_INLINE int __sputc_r(struct _reent *_ptr, int _c, FILE *_p) {
^~~~~~
../../TockLibrary.mk:147: recipe for target '../../libtock/build/cortex-m0/alarm_internal.o' failed
make: *** [../../libtock/build/cortex-m0/alarm_internal.o] Error 1 |
try |
That worked! Thank you!
|
You shouldn't need to cross-compile all of gcc, you just need to rebuild libgcc (these are mostly compiler intrinsics, e.g. the calls to memset and such that gcc can emit). To a first order, should just be updating this line: https://github.com/tock/libtock-c/blob/master/libc%2B%2B/build.sh#L45 |
Thank you for your help!! I was able to rebuild libgcc and successfully build & flash the |
Unfortunately, I think there are several more steps that are necessary to get hard floating point working in Tock. There was a start once here ( tock/tock#1010 ), but getting this working is actually a fairly substantial change because of the way that ARM implements things. Specifically:
The best path forward for this is likely what @bradjc suggested in the prior Tock issue: implementing a new Sorry for not thinking this through so much before and not giving you a heads-up about the additional missing pieces earlier :/ |
Hello 🦀,
I measured the execution time of the same C
nbody
benchmark program on top of FreeRTOS & Tock.(I only modified variable
n
in the main function to beconst volatile int n = 50000;
)(Both cases were tested on
NucleoF429ZI
board)nbody
on FreeRTOS : 13.037325 secondsnbody
on Tock : 360.536 secondsI found that Tock apps are currently built with gcc flag
-mfloat-abi=soft
libtock-c/Configuration.mk
Line 138 in 3d96d35
I tried replacing the flag with
-mfloat-abi=hard
,but I received the following error.
On
Stm32CubeIDE
which providesnewlib-nano
as the default runtime library,I had no errors while building the same C program on top of FreeRTOS with the
-mfloat-abi=hard
configuration.One thing I see is that the instruction set I used in
stm32cubeide
wasThumb-2
,while the error from building Tock tells me
Thumb-1 hard-float VFP ABI
is not implemented.(below is an image of the build configuration I used for building
nbody
on FreeRTOS)Is there a way to work around this error to build apps with flag
-mfloat-abi=soft
?Or is it currently possible to use
Thumb-2
instruction set instead ofThumb-1
?Thank you for checking out this issue 👍 👍
The text was updated successfully, but these errors were encountered: