Long time ago Rust used segmented stack (split stack), but switched to continuous stack around 2013. I am now working on ARM Cortex-M baremetal targets and trying to use segmented stack to prevent stack overflow. I would like to know how to let the current Rust compiler compile functions with segmented stack.
rustcneeds to emit the LLVM attribute
split-stackto the compiled functions.
- Currently we have no
rustcoption that controls this behavior. Related discussion here.
- I will need to modify the compiler source code to add the
split-stackattribute to the generated LLVM IR.
What I have done:
- Patched LLVM to emit the segmented stack function prologue for my embedded baremetal target.
- Wrote a runtime to support
- Tested the LLVM patch and the runtime implementation by some test code written in C compiled with Clang (with
-fsplit-stackoption turned on).
rustcfrom source with my patched LLVM and linked it to
It seems that the only missing piece in the puzzle is to let
rustc emit the
split-stack attribute. Could someone please point me to the source file that is responsible for picking LLVM attributes for functions? Thanks!