From ab4d72756ec4b2c37ec303fae98ec814d3305be6 Mon Sep 17 00:00:00 2001 From: chenrun1 Date: Wed, 18 Sep 2024 14:51:11 +0800 Subject: [PATCH] arch/samd2l2:Ignore atomic warning when using clang compiler When the toolchain does not support atomic, it will use the version implemented by NuttX (low performance version). This scenario is consistent with the original design, so we can ignore it. see bug here: https://bugs.llvm.org/show_bug.cgi?id=43603 Error: inode/fs_inodeaddref.c:50:7: error: large atomic operation may incur significant performance penalty; the access size (4 bytes) exceeds the max lock-free size (0 bytes) [-Werror,-Watomic-alignment] 50 | atomic_fetch_add(&inode->i_crefs, 1); | ^ /tools/clang-arm-none-eabi/lib/clang/17/include/stdatomic.h:152:43: note: expanded from macro 'atomic_fetch_add' 152 | #define atomic_fetch_add(object, operand) __c11_atomic_fetch_add(object, operand, __ATOMIC_SEQ_CST) | ^ 1 error generated. make[1]: *** [Makefile:83: fs_inodeaddref.o] Error 1 Error: inode/fs_inodefind.c:74:7: error: large atomic operation may incur significant performance penalty; the access size (4 bytes) exceeds the max lock-free size (0 bytes) [-Werror,-Watomic-alignment] 74 | atomic_fetch_add(&node->i_crefs, 1); Signed-off-by: chenrun1 --- arch/arm/src/cmake/Toolchain.cmake | 2 ++ arch/arm/src/common/Toolchain.defs | 2 ++ 2 files changed, 4 insertions(+) diff --git a/arch/arm/src/cmake/Toolchain.cmake b/arch/arm/src/cmake/Toolchain.cmake index 1c6deb6f1dcb2..34c61c58ac74d 100644 --- a/arch/arm/src/cmake/Toolchain.cmake +++ b/arch/arm/src/cmake/Toolchain.cmake @@ -61,6 +61,8 @@ if(CONFIG_ARCH_TOOLCHAIN_CLANG) # https://github.com/apache/incubator-nuttx/pull/5971 add_compile_options(-fno-builtin) + add_compile_options(-Wno-atomic-alignment) + add_compile_options(-Wno-atomic-alignment) else() set(TOOLCHAIN_PREFIX arm-none-eabi) set(CMAKE_LIBRARY_ARCHITECTURE ${TOOLCHAIN_PREFIX}) diff --git a/arch/arm/src/common/Toolchain.defs b/arch/arm/src/common/Toolchain.defs index d77c286b4b31c..10950fba7901a 100644 --- a/arch/arm/src/common/Toolchain.defs +++ b/arch/arm/src/common/Toolchain.defs @@ -324,6 +324,8 @@ endif ifeq ($(CONFIG_ARCH_TOOLCHAIN_CLANG),y) ARCHOPTIMIZATION += -fshort-enums + ARCHCFLAGS += -Wno-atomic-alignment + ARCHCXXFLAGS += -Wno-atomic-alignment endif # Architecture flags