I was hunting down a stack overflow recently, and during investigation I added EXTRA_CFLAGS += -fstack-usage
to my projects build.mk
, but I couldn't find the expected .su
files containing the estimated per-function stack usage estimates.
I looked in both the binary output dir: ${workspace}/target/6.2.0/boron/
and where the intermediate .o and .d files get stored: ~/.particle/toolchains/deviceOS/6.2.0/build/target/user/platform-13-m/my_proj/src
. Neither contained the expected .su
files.
It appears there was a bug in GCC a while back [1] that prevented the .su
output if LTO (Link Time Optimization) is enabled. So this is possibly the issue?
Is there some cleanup by the build script that's deleting the .su files, or another setting that the Particle build is setting that's preventing gcc from outputting these files? Has anybody else successfully used -fstack-usage
I'm confidant my build.mk
is getting processed correctly, because I fixed my overflow by setting EXTRA_CFLAGS += -Wstack-usage=XXX
and compiling and walking XXX down to find the offending function.
I have avoided delving into the Particle build system as I'm admittedly not well-versed with Make and my eyes quickly gloss over when trying to track how it works from the chain of included files.
Related: Is it possible to call FreeRTOS kernel utilities from within my application thread? Specifically, I'd like to call uxTaskGetStackHighWaterMark
[2] so I can decide how much effort I should allocate to walking my application away from the stack overflow cliff.
[1] c - ARM-gcc stack usage files empty - Stack Overflow
[2] uxTaskGetStackHighWaterMark, uxTaskGetStackHighWaterMark2 - FreeRTOS™