Static analysis examines program properties without executing the program. For embedded Rust, it can estimate worst-case stack usage before firmware runs—a useful first defense against stack overflow, which can silently corrupt nearby memory. section 7.4 section 7.4.2
A practical estimation workflow:
- Build with stack-size metadata and release link-time optimization, then use cargo-call-stack to estimate per-function usage and the deepest call path. section 7.4.2
- Compare the reported worst case with the stack region in memory.x. Treat the estimate as a lower bound: indirect calls may be unknown, and interrupt depths must be added to the paths they preempt. section 7.4.2
- Allow a 25–50% safety margin; combine estimation with link-time layout choices, runtime checks, or hardware enforcement rather than relying on the estimate alone. section 7.4 section 7.4.2
Estimate a call path
Install cargo-call-stack with stable Cargo, add rust-src to nightly, enable fat LTO for release, then run the analysis on the nightly-built target binary. The output can be rendered as an SVG call graph with Graphviz. section 7.4.2
Figure 7.4 Example call-graph output from cargo-call-stack, rendered to SVG via Graphviz
Inspect an example call-graph visualization to see how the analysis reports deepest call paths. section 7.4.2










