Menu

#342 Build fails for Cortex-M3 or -M4+nofp due to undefined compiler flag __ARM_FP

QP
closed
None
1
2024-08-01
2023-08-16
Anonymous
No

qpc/ports/arm-cm-qk/gnu/qk_port.h:85:
#if (__ARM_FP != 0) /* if VFP available... */
along with the same define in qk_port.c, lines 108, 155, 217, 280.

Will error on build if C compiler flags contains:
-mcpu=cortex-m3
-mcpu=cortex-m4+nofp
-mcpu=cortex-m4 when -mfloat-abi=soft or lacking -mfloat-abi altogether.
(as opposed to eg cortex-m4)

__ARM_FP is undefined when there is no hardware floating-point, according to ARM C Language extensions, §5.5 Floating-point and vector hardware:
https://arm-software.github.io/acle/main/acle.html#markdown-toc-floating-point-and-vector-hardware

Changing all the above #if checks to:
#if defined(__ARM_FP) && (__ARM_FP != 0) /* if VFP available... */
instead, ie checking it is defined before the value check, fixed it for me.

Discussion

  • Anonymous

    Anonymous - 2023-08-16

    oops, forgot the error message:

    [  1%] Building C object [redacted]/CMakeFiles/[redacted]
    In file included from qpc/ports/arm-cm/qk/gnu/qf_port.h:102,
                     from qpc/include/qpc.h:53,
                     [... snipped ...]
                     qpc/ports/arm-cm/qk/gnu/qk_port.h:85:6: 
                error: "__ARM_FP" is not defined, evaluates to 0 [-Werror=undef]
       85 | #if (__ARM_FP != 0) /* if VFP available... */
          |      ^~~~~~~~
    cc1: all warnings being treated as errors
    
     
  • Anonymous

    Anonymous - 2023-08-16

    Thanks for reporting.

    I've never encountered that problem, but probably because the -mfloat-abi compilation option was always specified.

    But anyway, all QP ports to ARM Cortex-M will be modified to use:

    #ifdef __ARM_FP
    . . .
    

    instead of:

    #if (__ARM_FP != 0)
    . . .
    

    --MMS

     
  • Anonymous

    Anonymous - 2023-08-21

    I found -mfloat-abi=soft to give the error as well. But thank you!

    Our context is that it's easy for floating point to sneak in via library inclusions if not careful.

    Once your change is in, (and as long as src/qs/qs_fp.c is excluded, for obvious reasons) the -mgeneral-regs-only ARM compiler flag that bans all floating point register use works as well.

     
  • Quantum Leaps

    Quantum Leaps - 2023-09-27

    Fixed in QP/C/C++ 7.3.0.
    --MMS

     

Anonymous
Anonymous

Add attachments
Cancel