This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git


The following commit(s) were added to refs/heads/master by this push:
     new e57cfc3778 arm64/toolchain: Add -fstack-usage for stack analysis
e57cfc3778 is described below

commit e57cfc3778224f5c00af061aae88120d1c027ea7
Author: wangjianyu3 <wangjian...@xiaomi.com>
AuthorDate: Tue May 27 20:18:08 2025 +0800

    arm64/toolchain: Add -fstack-usage for stack analysis
    
    After `CONFIG_STACK_USAGE` enabled, no "*.su" file was generated, 
tools/showstack.sh output nothing.
    
    Signed-off-by: wangjianyu3 <wangjian...@xiaomi.com>
---
 arch/arm64/src/Toolchain.defs        | 8 ++++++++
 arch/arm64/src/cmake/Toolchain.cmake | 8 ++++++++
 2 files changed, 16 insertions(+)

diff --git a/arch/arm64/src/Toolchain.defs b/arch/arm64/src/Toolchain.defs
index 4086257541..0db36aa011 100644
--- a/arch/arm64/src/Toolchain.defs
+++ b/arch/arm64/src/Toolchain.defs
@@ -76,6 +76,14 @@ ifeq ($(CONFIG_STACK_CANARIES),y)
   ARCHOPTIMIZATION += -fstack-protector-all
 endif
 
+ifeq ($(CONFIG_STACK_USAGE),y)
+  ARCHOPTIMIZATION += -fstack-usage
+endif
+
+ifneq ($(CONFIG_STACK_USAGE_WARNING),0)
+  ARCHOPTIMIZATION += -Wstack-usage=$(CONFIG_STACK_USAGE_WARNING)
+endif
+
 ifeq ($(CONFIG_MM_UBSAN_ALL),y)
   ARCHOPTIMIZATION += $(CONFIG_MM_UBSAN_OPTION)
 endif
diff --git a/arch/arm64/src/cmake/Toolchain.cmake 
b/arch/arm64/src/cmake/Toolchain.cmake
index 973f8c8897..e02f6f3bd8 100644
--- a/arch/arm64/src/cmake/Toolchain.cmake
+++ b/arch/arm64/src/cmake/Toolchain.cmake
@@ -105,6 +105,14 @@ if(CONFIG_STACK_CANARIES)
   add_compile_options(-fstack-protector-all)
 endif()
 
+if(CONFIG_STACK_USAGE)
+  add_compile_options(-fstack-usage)
+endif()
+
+if(CONFIG_STACK_USAGE_WARNING)
+  add_compile_options(-Wstack-usage=${CONFIG_STACK_USAGE_WARNING})
+endif()
+
 if(CONFIG_MM_UBSAN_ALL)
   add_compile_options(${CONFIG_MM_UBSAN_OPTION})
 endif()

Reply via email to