Skip to content

Commit 0332ce8

Browse files
committed
rust: Workaround gcc/clang differences with soft fp
GCC automatically defines a `__SOFTFP__` define on targets that are using software floating point. The clang compiler does not do this by default, so check this, and define it. Signed-off-by: David Brown <[email protected]>
1 parent a57ceb7 commit 0332ce8

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

lib/rust/zephyr-sys/wrapper.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,14 @@ extern int errno;
2121
/* First, make sure we have all of our config settings. */
2222
#include <zephyr/autoconf.h>
2323

24+
/* Gcc defines __SOFT_FP__ when the target uses software floating point, and the CMSIS headers get
25+
* confused without this.
26+
*/
27+
#if defined(CONFIG_CPU_CORTEX_M)
28+
#if !defined(CONFIG_FP_HARDABI) && !defined(FORCE_FP_HARDABI) && !defined(__SOFTFP__)
29+
#define __SOFTFP__
30+
#endif
31+
#endif
32+
2433
#include <zephyr/kernel.h>
2534
#include <zephyr/drivers/gpio.h>

0 commit comments

Comments
 (0)