Build: Disable IAR release builds for v8.1m arch cpus.

IAR has a compilation bug on the highest optimization level.

Signed-off-by: Dávid Házi <david.hazi@arm.com>
Change-Id: I3ab5e6872b82634457f8050f9fe8c6261b6972f6
diff --git a/toolchain_IARARM.cmake b/toolchain_IARARM.cmake
index bf4a7f7..41e8502 100644
--- a/toolchain_IARARM.cmake
+++ b/toolchain_IARARM.cmake
@@ -94,6 +94,18 @@
 
     set(CMAKE_C_FLAGS ${CMAKE_C_FLAGS_INIT})
     set(CMAKE_ASM_FLAGS ${CMAKE_ASM_FLAGS_INIT})
+
+    # Can't use the highest optimization with IAR on v8.1m arch because of the
+    # compilation bug in mbedcrypto
+    if ((CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL "9.20") AND
+        (CMAKE_C_COMPILER_VERSION VERSION_LESS_EQUAL "9.32") AND
+        ((TFM_SYSTEM_PROCESSOR STREQUAL "cortex-m85") OR
+         (TFM_SYSTEM_PROCESSOR STREQUAL "cortex-m55")) AND
+        (CMAKE_BUILD_TYPE STREQUAL "Release"))
+        message(FATAL_ERROR "Release build isn't available for M55 and M85"
+                " cores with IAR version between 9.20 and 9.32.")
+    endif()
+
 endmacro()
 
 # Configure environment for the compiler setup run by cmake at the first