CMake: Fix Mbed TLS compilation for Cortex-M0/0+/1/M23

Due to a known issue in Mbed TLS's architecture determination
(ARMmbed/mbedtls#1077), we get the error

    error: inline assembly requires more registers than available

when compiling `bignum.c` for Cortex-M0/0+/1/M23 which do not have
the macro `__thumb2__` set by the compiler.

The workaround is to define the macro `MULADDC_CANNOT_USE_R7` which
is already defined by Mbed CLI 1 but missing in our CMake support.

Fixes ARMmbed/mbed-os-example-lorawan#220
pull/14529/head
Lingkai Dong 2021-04-09 12:37:38 +01:00
parent b5652a45c9
commit 86e7bc559b
2 changed files with 17 additions and 1 deletions

View File

@ -102,3 +102,20 @@ target_compile_definitions(mbed-mbedtls
INTERFACE
MBED_CONF_MBEDTLS_PRESENT=1
)
# Workaround for https://github.com/ARMmbed/mbedtls/issues/1077
# which affects cores without __thumb2__ set by the compiler
# due to the lack of full Thumb-2 support
set(partial-thumb2-cores
Cortex-M0
Cortex-M0+
Cortex-M1
Cortex-M23
Cortex-M23-NS
)
if(MBED_CPU_CORE IN_LIST partial-thumb2-cores)
target_compile_definitions(mbed-mbedtls
INTERFACE
MULADDC_CANNOT_USE_R7
)
endif()

View File

@ -78,7 +78,6 @@ function(mbed_set_profile_options target mbed_toolchain)
target_compile_definitions(${target}
INTERFACE
__ASSERT_MSG
MULADDC_CANNOT_USE_R7
)
endif()