Arm Mbed OS support forum

Mbed-tools uses different compiler float-abi flag than mbed studio build

Hi

I’m building a project using Mbed studio without any issue. When I build with mbed-tools I get an error like bellow. I’m using the -t GCC_ARM option.

/lib/gcc/arm-none-eabi/9.3.1/…/…/…/…/arm-none-eabi/bin/ld: error: …/…/…/…/mbed-os/targets/TARGET_Ambiq_Micro/TARGET_Apollo3/sdk/CMSIS/ARM/Lib/ARM/libarm_cortexM4lf_math.a(arm_min_f32.o) uses VFP register arguments, ozon-2021-fw.elf does not

After googling I found the problem because libarm_cortexM4lf_math.a is built with option float-abi: hard while in mbed-tools I found a file mbed-os/tools/cmake/cores/Cortex-M4.cmake with the following:

# Sets cpu core options
if(${MBED_TOOLCHAIN} STREQUAL "GCC_ARM")
    list(APPEND common_options
        "-mthumb"
        "-mcpu=cortex-m4"
        "-mfpu=fpv4-sp-d16"
        "-mfloat-abi=soft"
    )
elseif(${MBED_TOOLCHAIN} STREQUAL "ARM")
    list(APPEND common_options
        "-mcpu=cortex-m4"
        "-mfpu=fpv4-sp-d16"
        "-mfloat-abi=hard"
    )

So why there is this difference between the mbed-tools and Mbed studio builds ?

Changing the value to hard solves the problem. But is there a portable solution as the mentioned file is shipped with the Mbed-os.

Which version of Mbed OS is this? I don’t see the mentioned flags in the master branch.

Still, an interesting topic, why is FPU disabled in master anyway?

I’m sorry. It is not Cortex-M4.cmake it is Cortex-M4F.cmake

Should not be a configurable flag ?

Right, that explains the lack of the flags in the M4 config.

I could not find any information in the git history about these lines. I wonder if there are other libraries/components used by Mbed which are compiled for the soft ABI. This definitely needs some explanation.

I created an issue for that.