From 6dc85e0386a6f497c9a44367f670f3ec1e6d1517 Mon Sep 17 00:00:00 2001 From: Lingkai Dong Date: Tue, 9 Mar 2021 17:35:48 +0000 Subject: [PATCH] Workaround for Cortex-M33 Arm toochain linking Binaries generated for Cortex-M33 targets (e.g. Musca S1/B1) using the Arm toolchain + CMake is unable to run, unless we instruct the linker to not use floating points. Note: This is a temporary workaround, because * Ideally, the Arm linker should be able to auto detect the architecture support from the input object files, but it's not always the case. We already have a similar workaround for Cortex-M4. * The full option to use should be `--cpu=Cortex-M33.no_dsp.no_fp` but `no_dsp` currently conflicts with CMake's compilation tests (no option to disable DSP in the test objects before linking). --- tools/cmake/cores/Cortex-M33-NS.cmake | 7 +++++++ tools/cmake/cores/Cortex-M33.cmake | 7 +++++++ 2 files changed, 14 insertions(+) diff --git a/tools/cmake/cores/Cortex-M33-NS.cmake b/tools/cmake/cores/Cortex-M33-NS.cmake index 2bbc19c4a75..40a074b0c1d 100644 --- a/tools/cmake/cores/Cortex-M33-NS.cmake +++ b/tools/cmake/cores/Cortex-M33-NS.cmake @@ -12,6 +12,13 @@ elseif(${MBED_TOOLCHAIN} STREQUAL "ARM") "-mcpu=cortex-m33+nodsp" "-mfpu=none" ) + list(APPEND link_options + # Necessary as the linker does not always detect + # the architecture from the objectfiles correctly. + # Also, the complete flag should be "--cpu=Cortex-M33.no_dsp.no_fp" + # but this currently conflicts with CMake's compiler test until fixed + "--cpu=Cortex-M33.no_fp" + ) endif() function(mbed_set_cpu_core_definitions target) diff --git a/tools/cmake/cores/Cortex-M33.cmake b/tools/cmake/cores/Cortex-M33.cmake index b9245eb09db..2a369276d82 100644 --- a/tools/cmake/cores/Cortex-M33.cmake +++ b/tools/cmake/cores/Cortex-M33.cmake @@ -12,6 +12,13 @@ elseif(${MBED_TOOLCHAIN} STREQUAL "ARM") "-mcpu=cortex-m33+nodsp" "-mfpu=none" ) + list(APPEND link_options + # Necessary as the linker does not always detect + # the architecture from the objectfiles correctly. + # Also, the complete flag should be "--cpu=Cortex-M33.no_dsp.no_fp" + # but this currently conflicts with CMake's compiler test until fixed + "--cpu=Cortex-M33.no_fp" + ) endif() function(mbed_set_cpu_core_definitions target)