From 763c8b96ccda8ad210b8cbc971e23d130146e1fc Mon Sep 17 00:00:00 2001 From: Dave Rodgman Date: Mon, 5 Jun 2023 21:24:57 -0400 Subject: [PATCH] Fix armclang compile fail Signed-off-by: Dave Rodgman --- ChangeLog.d/armclang-compile-fix.txt | 5 +++++ include/mbedtls/bn_mul.h | 11 +++++++++++ 2 files changed, 16 insertions(+) create mode 100644 ChangeLog.d/armclang-compile-fix.txt diff --git a/ChangeLog.d/armclang-compile-fix.txt b/ChangeLog.d/armclang-compile-fix.txt new file mode 100644 index 000000000000..93ad6af88969 --- /dev/null +++ b/ChangeLog.d/armclang-compile-fix.txt @@ -0,0 +1,5 @@ +Bugfix + * Fix clang and armclang compilation error when targeting certain Arm + M-class CPUs (Cortex-M0, Cortex-M0+, Cortex-M1, Cortex-M23, + SecurCore SC000). Fixes #1077. + diff --git a/include/mbedtls/bn_mul.h b/include/mbedtls/bn_mul.h index a0bc4d061d3f..6414e54291fa 100644 --- a/include/mbedtls/bn_mul.h +++ b/include/mbedtls/bn_mul.h @@ -677,6 +677,15 @@ #if defined(__arm__) && !defined(MULADDC_CANNOT_USE_R7) #if defined(__thumb__) && !defined(__thumb2__) +#if !defined(__ARMCC_VERSION) && !defined(__clang__) \ + && !defined(__llvm__) && !defined(__INTEL_COMPILER) +/* + * Thumb 1 ISA. This code path has only been tested successfully on gcc; + * it does not compile on clang or armclang. + * + * Other compilers which define __GNUC__ may not work. The above macro + * attempts to exclude these untested compilers. + */ #define MULADDC_INIT \ asm( \ @@ -731,6 +740,8 @@ "r6", "r7", "r8", "r9", "cc" \ ); +#endif /* Compiler is gcc */ + #elif (__ARM_ARCH >= 6) && \ defined (__ARM_FEATURE_DSP) && (__ARM_FEATURE_DSP == 1)