Description
Downstream issue: rust-embedded/cortex-m-rt#139
It looks like LLVM is extremely eager to overwrite the Link Register without saving it as soon as noreturn
is put on a function. Since rustc does that for any -> !
function, which includes many parts of the panic machinery, this effectively makes obtaining a backtrace on panic on embedded systems impossible.
This is somewhat analogous to omission of frame pointers on x86, so maybe -Cforce-frame-pointers
can be repurposed to prevent this behavior on Thumb/ARM targets? I'm not sure there's even an LLVM feature to control this specifically, but I suppose rustc could always omit the noreturn
.
Since this is only important in debug builds (that may be optimized, however), it might make sense to couple this behavior to whether debug assertions are enabled, but I'm not sure about that. What do you think? Would a patch doing something of this sort be accepted?