-
Notifications
You must be signed in to change notification settings - Fork 102
Open
Description
Several source files in CMSIS-NN use GCC-specific optimization hints that are not properly guarded against non-GCC compilers. Building with Clang/LLVM Embedded Toolchain for Arm produces warnings, and one case also affects IAR.
Case 1 - attribute((optimize(...))) missing Clang and IAR guards
| #if !defined(__ARMCC_VERSION) |
Problem:
The guard only excludes Arm Compiler (__ARMCC_VERSION). Clang
(clang) and IAR (ICCARM) are not excluded, so both compilers
receive the GCC-specific attribute.
Compilers affected:
- Clang/LLVM Embedded Toolchain for Arm 19.1.5 - warning:
warning: unknown attribute 'optimize' ignored [-Wunknown-attributes] - IAR C/C++ Compiler for Arm 9.70.1 - warning:
Warning[Pe1097]: unknown attribute 'optimize'
Suggested fix:
#if !defined(__ARMCC_VERSION) && !defined(__ICCARM__) && !defined(__clang__)
__attribute__((optimize("no-unroll-loops")))
#endifCase 2 - #pragma GCC optimize(...) missing Clang guard
Files:
| #if !defined(ARM_MATH_MVEI) && defined(ARM_MATH_DSP) && !defined(__ARMCC_VERSION) && !defined(__ICCARM__) |
| #if !defined(ARM_MATH_MVEI) && defined(ARM_MATH_DSP) && !defined(__ARMCC_VERSION) && !defined(__ICCARM__) |
Problem:
The guard correctly excludes ARMCC and IAR, but does not exclude Clang,
which does not implement #pragma GCC optimize.
Compilers affected:
- Clang/LLVM Embedded Toolchain for Arm 19.1.5 - warning:
warning: unknown pragma ignored [-Wunknown-pragmas]
Suggested fix:
#if !defined(ARM_MATH_MVEI) && defined(ARM_MATH_DSP) && !defined(__ARMCC_VERSION) && !defined(__ICCARM__) && !defined(__clang__)
#pragma GCC optimize("unroll-loops")
#endifEnvironment
- Toolchain: LLVM Embedded Toolchain for Arm 19.1.5, IAR C/C++ Compiler for Arm: 9.70.1
- Target: Cortex-M33, Cortex-M55
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels