-
Notifications
You must be signed in to change notification settings - Fork 12.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use unwinding
crate for unwinding on Xous platform
#117072
Conversation
r? @cuviper (rustbot has picked a reviewer for you, use r? to override) |
These commits modify compiler targets. These commits modify the If this was unintentional then you should revert the changes before this PR is merged. |
This comment has been minimized.
This comment has been minimized.
These commits modify the If this was unintentional then you should revert the changes before this PR is merged. These commits modify compiler targets. Third-party dependency whitelist may have been modified! You must ensure that any new dependencies have compatible licenses before merging. |
This comment has been minimized.
This comment has been minimized.
87f857a
to
f2d3fed
Compare
I'm nominating this for libs team discussion, both because |
☔ The latest upstream changes (presumably #117504) made this pull request unmergeable. Please resolve the merge conflicts. |
f2d3fed
to
d91d1dc
Compare
rebased to follow the removal of |
☔ The latest upstream changes (presumably #117716) made this pull request unmergeable. Please resolve the merge conflicts. |
d91d1dc
to
ca43176
Compare
ca43176
to
c419805
Compare
Forced push changes that:
|
@@ -0,0 +1,102 @@ | |||
#![allow(nonstandard_style)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Most of these are available from unwinding::abi
, can this be used instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem is that the callee uses raw pointers, so most of the functions here are casting pointers to references. The calling code could be modified to use references rather than pointers, but I didn't want to touch such fundamental structures.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's fine then. But at least change the pub fn
to pub unsafe fn
since they accept raw pointers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Alright, I've changed the signatures and verified that it still works.
c419805
to
40bbd13
Compare
This comment has been minimized.
This comment has been minimized.
The `unwinding` crate supports processing unwinding data, and is written entirely in Rust. This allows it to be ported to new platforms more easily than using the llvm-based `libunwind`. While `libunwind` is very well supported on major targets, it is difficult to use on other targets. SGX is an example of this where Rust carries custom patches in order to enable backtrace support. This adds an alternative for supported architectures. Rather than providing a custom target, `unwinding` allows for a solution that is completely written in Rust. This adds `xous` as the first consumer, and forthcoming patches will modify libstd to take advantage of this. Signed-off-by: Sean Cross <[email protected]>
Now that `unwind` supports Xous, enable unwinding panics on Xous. Signed-off-by: Sean Cross <[email protected]>
Xous as an operating system is compiled with gcc-type personalities when it comes to unwinding. This enables unwinding inside panics on Xous, which enables Rust tests. Signed-off-by: Sean Cross <[email protected]>
Now that everything is in place to support unwinding on Xous, enable this for that target. Signed-off-by: Sean Cross <[email protected]>
Add `unwinding` as a dependency. This is required on platforms where unwinding isn't provided by llvm. Signed-off-by: Sean Cross <[email protected]>
40bbd13
to
7c7bc5f
Compare
The main() function takes an argument that contains the eh_frame address. Implement `unwinding` support by looking for unwinding data at this address. Signed-off-by: Sean Cross <[email protected]>
Add `unwinding` as a permitted dependency of rustc, as it is now used as part of panic unwinding within platforms such as Xous. Signed-off-by: Sean Cross <[email protected]>
7c7bc5f
to
0773afc
Compare
@bors r+ |
☀️ Test successful - checks-actions |
Finished benchmarking commit (84a554c): comparison URL. Overall result: ✅ improvements - no action needed@rustbot label: -perf-regression Instruction countThis is a highly reliable metric that was used to determine the overall result at the top of this comment.
Max RSS (memory usage)ResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
CyclesResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 675.395s -> 673.722s (-0.25%) |
This patch adds support for using unwinding on platforms where libunwinding isn't viable. An example of such a platform is
riscv32imac-unknown-xous-elf
.Background
The Rust project maintains a fork of llvm at llvm-project where it applies patches on top of the llvm project. This mostly seems to be to get unwinding support for the SGX project, and there may be other patches that I'm unaware of.
There is a lot of machinery in the build system to support compiling
libunwind
on other platforms, and I needed to add additional patches to llvm in order to add support for Xous.Rather than continuing down this path, it seemed much easier to use a Rust-based library. The
unwinding
crate by @nbdd0121 fits this description perfectly.Future work
This could potentially replace the custom patches for
libunwind
on other platforms such as SGX, and could enable unwinding support on many more exotic platforms.Anti-goals
This is not designed to replace
libunwind
on tier-one platforms or those where unwinding support already exists. There is already a well-established approach for unwinding there. Instead, this aims to enable unwinding on new platforms where C++ code may be difficult to compile.