https://github.com/Prabhuk created 
https://github.com/llvm/llvm-project/pull/175677

Add `-fstack-size-section` and `-fexperimental-call-graph-section` flags
for all baremetal runtime libraries built by Fuchsia toolchain.


>From 191973d8e645be06845561067db4e1c9b3e38803 Mon Sep 17 00:00:00 2001
From: prabhukr <[email protected]>
Date: Mon, 12 Jan 2026 23:47:17 +0000
Subject: [PATCH] [Fuchsia] Stack analysis flags for baremetal runtimes

Add `-fstack-size-section` and `-fexperimental-call-graph-section` flags
for all baremetal runtime libraries built by Fuchsia toolchain.
---
 clang/cmake/caches/Fuchsia-stage2.cmake | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/clang/cmake/caches/Fuchsia-stage2.cmake 
b/clang/cmake/caches/Fuchsia-stage2.cmake
index de14bde2007a4..07f9558eaa8d9 100644
--- a/clang/cmake/caches/Fuchsia-stage2.cmake
+++ b/clang/cmake/caches/Fuchsia-stage2.cmake
@@ -325,7 +325,7 @@ foreach(target 
armv6m-none-eabi;armv7m-none-eabi;armv7em-none-eabi;armv8m.main-n
     if(${target} STREQUAL "armv8.1m.main-none-eabi")
       set(BUILTINS_${target}_CMAKE_${lang}_local_flags 
"${BUILTINS_${target}_CMAKE_${lang}_local_flags} -mfloat-abi=hard 
-march=armv8.1-m.main+mve.fp+fp.dp -mcpu=cortex-m55")
     endif()
-    set(BUILTINS_${target}_CMAKE_${lang}_FLAGS 
"${BUILTINS_${target}_CMAKE_${lang}_local_flags}" CACHE STRING "")
+    set(BUILTINS_${target}_CMAKE_${lang}_FLAGS 
"${BUILTINS_${target}_CMAKE_${lang}_local_flags} -fstack-size-section 
-fexperimental-call-graph-section" CACHE STRING "")
   endforeach()
   foreach(type SHARED;MODULE;EXE)
     set(BUILTINS_${target}_CMAKE_${type}_LINKER_FLAGS "-fuse-ld=lld" CACHE 
STRING "")
@@ -351,7 +351,7 @@ foreach(target 
armv6m-none-eabi;armv7m-none-eabi;armv7em-none-eabi;armv8m.main-n
     if(${target} STREQUAL "armv8.1m.main-none-eabi")
       set(RUNTIMES_${target}_CMAKE_${lang}_local_flags 
"${RUNTIMES_${target}_CMAKE_${lang}_local_flags} -mfloat-abi=hard 
-march=armv8.1-m.main+mve.fp+fp.dp -mcpu=cortex-m55")
     endif()
-    set(RUNTIMES_${target}_CMAKE_${lang}_FLAGS 
"${RUNTIMES_${target}_CMAKE_${lang}_local_flags}" CACHE STRING "")
+    set(RUNTIMES_${target}_CMAKE_${lang}_FLAGS 
"${RUNTIMES_${target}_CMAKE_${lang}_local_flags} -fstack-size-section 
-fexperimental-call-graph-section" CACHE STRING "")
   endforeach()
   foreach(type SHARED;MODULE;EXE)
     set(RUNTIMES_${target}_CMAKE_${type}_LINKER_FLAGS "-fuse-ld=lld" CACHE 
STRING "")
@@ -393,7 +393,7 @@ foreach(target riscv32-unknown-elf)
   set(BUILTINS_${target}_CMAKE_SYSROOT "" CACHE STRING "")
   set(BUILTINS_${target}_CMAKE_BUILD_TYPE MinSizeRel CACHE STRING "")
   foreach(lang C;CXX;ASM)
-    set(BUILTINS_${target}_CMAKE_${lang}_FLAGS "--target=${target} 
-march=rv32imafc -mabi=ilp32f" CACHE STRING "")
+    set(BUILTINS_${target}_CMAKE_${lang}_FLAGS "--target=${target} 
-march=rv32imafc -mabi=ilp32f -fstack-size-section 
-fexperimental-call-graph-section" CACHE STRING "")
   endforeach()
   foreach(type SHARED;MODULE;EXE)
     set(BUILTINS_${target}_CMAKE_${type}_LINKER_FLAGS "-fuse-ld=lld" CACHE 
STRING "")
@@ -409,7 +409,7 @@ foreach(target riscv32-unknown-elf)
   foreach(lang C;CXX;ASM)
     # TODO: The preprocessor defines workaround various issues in libc and 
libc++ integration.
     # These should be addressed and removed over time.
-    set(RUNTIMES_${target}_CMAKE_${lang}_FLAGS "--target=${target} 
-march=rv32imafc -mabi=ilp32f -Wno-atomic-alignment" CACHE STRING "")
+    set(RUNTIMES_${target}_CMAKE_${lang}_FLAGS "--target=${target} 
-march=rv32imafc -mabi=ilp32f -Wno-atomic-alignment -fstack-size-section 
-fexperimental-call-graph-section" CACHE STRING "")
   endforeach()
   foreach(type SHARED;MODULE;EXE)
     set(RUNTIMES_${target}_CMAKE_${type}_LINKER_FLAGS "-fuse-ld=lld" CACHE 
STRING "")

_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to