16lyt
(Yahya Tawil)
November 15, 2021, 12:02pm
1
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.
boraozgen
(Bora Özgen)
November 16, 2021, 7:59am
2
Which version of Mbed OS is this? I don’t see the mentioned flags in the master branch.
# Copyright (c) 2020 ARM Limited. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
# Sets cpu core options
if(${MBED_TOOLCHAIN} STREQUAL "GCC_ARM")
list(APPEND common_options
"-mthumb"
"-mcpu=cortex-m4"
)
elseif(${MBED_TOOLCHAIN} STREQUAL "ARM")
list(APPEND common_options
"-mcpu=cortex-m4"
"-mfpu=none"
)
if(deprecated_system_processor)
# Normally `--cpu` is not needed, because `armlink` can infer
# features from object files. But CMake versions below 3.21
# automatically add `--cpu=${CMAKE_SYSTEM_PROCESSOR}` which is
# incorrect, so as a workaround we need to add `no_fp`.
list(APPEND link_options
This file has been truncated. show original
Still, an interesting topic, why is FPU disabled in master anyway?
16lyt
(Yahya Tawil)
November 16, 2021, 8:39am
3
I’m sorry. It is not Cortex-M4.cmake it is Cortex-M4F.cmake
Should not be a configurable flag ?
boraozgen
(Bora Özgen)
November 16, 2021, 9:54am
4
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.
16lyt
(Yahya Tawil)
November 21, 2021, 10:09am
5
I created an issue for that.
opened 09:58AM - 21 Nov 21 UTC
closed 11:13AM - 22 Nov 21 UTC
priority: untriaged
component: untriaged
<!--
************************************** WARNING **********************… ****************
The ciarcom bot parses this header automatically. Any deviation from the
template may cause the bot to automatically correct this header or may result in a
warning message, requesting updates.
Please ensure all sections of the template below are filled in and no changes
are made to the template format. Only bugs should be raised here as issues.
Questions or enhancements should instead be raised on our forums:
https://forums.mbed.com/ .
*************************************************************************************
-->
### Description of defect
The compiler and linker flag `float-abi` to select the float engine option seems can't be configured from application. It is fixes with `soft` for GCC and `hard` for ARM compilers in the following file: `mbed-os/tools/cmake/cores/Cortex-M4F.cmake`. Howevere, In my application, I had to select the `-mfloat-abi:hard` option and the only way was to modify the file `mbed-os/tools/cmake/cores/Cortex-M4F.cmake` and change the GCC option to `hard`. This workaround is not portable as it changes a file shipped with Mbed-os. This issue is a result of the [discussion went in the forum](https://forums.mbed.com/t/mbed-tools-uses-different-compiler-float-abi-flag-than-mbed-studio-build/15266).
<!--
Add detailed description of what you are reporting.
Good example: https://os.mbed.com/docs/mbed-os/latest/contributing/workflow.html
-->
#### Target(s) affected by this defect ?
Issue does not seem to be target specific. I tried with an Ambiq target.
#### Toolchain(s) (name and version) displaying this defect ?
gcc-arm-none-eabi-9-2020-q2-update
#### What version of Mbed-os are you using (tag or sha) ?
<!--
For a released version please provide the release tag (this can be found as per the instructions below)
mbed-os version can be found in /platform/mbed_version.h. The tag can be reconstructed as follows:
mbed-os-MBED_MAJOR_VERSION.MBED_MINOR_VERSION.MBED_PATCH_VERSION
Master branch is indicated by 'mbed-os-99.99.99
For an issue found on Master please provide the sha being used.
-->
mbed-os-6.14.0
#### What version(s) of tools are you using. List all that apply (E.g. mbed-cli)
mbed-tools 7.31.1, Mbed Studio 1.4.3
#### How is this defect reproduced ?
Try to build using `mbed-tools` any example/demo code with library compiled with `-mfloat-abi:hard`.
<!--
For connectivity issues it is recommended to enable mbed trace and attach the traces
generated by the logger to the issue.
-->