-
-
Notifications
You must be signed in to change notification settings - Fork 15.3k
Simplify exception handling on wasm #160067
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -18,6 +18,11 @@ cfg_select! { | |
| target_env = "msvc" => { | ||
| // Windows MSVC no extra unwinder support needed | ||
| } | ||
| target_family = "wasm" => { | ||
| mod types; | ||
| mod wasm; | ||
| pub use wasm::*; | ||
| } | ||
| any( | ||
| target_os = "l4re", | ||
| target_os = "none", | ||
|
|
@@ -32,18 +37,12 @@ cfg_select! { | |
| target_os = "psp", | ||
| target_os = "solid_asp3", | ||
| all(target_vendor = "fortanix", target_env = "sgx"), | ||
| all(target_os = "wasi", panic = "unwind"), | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Personally I feel it'll work best to "pretend like you're native" on WASI as opposed to having wasm-specific code here. You've already got concerns about possible future LLVM changes/evolutions, for example, and presumably libunwind would be kept in sync which means Rust wouldn't have to explicitly keep in sync. Have you tested this on WASI targets to see if it works? I remember dealing with
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. WASI is already not native in that we don't have a personality function on wasm and consequently all functions that the personality function would normally need to call are entirely missing on wasm.
We already would need to adapt to LLVM changes on wasm32-unknown-unknown. This PR merely makes that code used on all wasm targets.
Not yet.
It should still be using __cpp_exception from libunwind.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd recommend testing this change. "Should work" I have found often means "there's some subtle reason that this doesn't actually work", especially when it comes to things like this. For WASI libunwind is already linked, so I think it's best to use it directly instead of going behind it to throw an exception. |
||
| target_os = "xous", | ||
| ) => { | ||
| mod libunwind; | ||
| pub use libunwind::*; | ||
| mod types; | ||
| } | ||
| target_family = "wasm" => { | ||
| mod types; | ||
| mod wasm; | ||
| pub use wasm::*; | ||
| } | ||
| _ => { | ||
| // no unwinder on the system! | ||
| // - os=none ("bare metal" targets) | ||
|
|
@@ -215,6 +214,10 @@ cfg_select! { | |
| #[link(name = "gcc_s")] | ||
| unsafe extern "C" {} | ||
|
|
||
| #[cfg(all(target_os = "wasi", panic = "unwind"))] | ||
| #[link(name = "unwind")] | ||
| unsafe extern "C" {} | ||
|
|
||
| #[cfg(all(target_os = "windows", target_env = "gnu", target_abi = "llvm"))] | ||
| #[link(name = "unwind", kind = "static", modifiers = "-bundle", cfg(target_feature = "crt-static"))] | ||
| #[link(name = "unwind", cfg(not(target_feature = "crt-static")))] | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.
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.
Given the breadth of libunwind implementations, how confident are you that all implementations basically look like this? I'd expect some libunwind somewhere to do something weird for example which means that this might be a regression.
View changes since the review