-
Notifications
You must be signed in to change notification settings - Fork 10.4k
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
Runtime: define get_return_address for WebAssembly #31693
Conversation
#else | ||
#error missing implementation for get_return_address | ||
#define get_return_address() ((void*) 0) | ||
#endif | ||
|
||
using namespace swift; | ||
|
||
#if defined(__wasm__) |
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.
Should this not be __wasi__
, because this is not related to the object file format?
Id like to get @gottesmm's opinion on this as well |
@swift-ci please test |
@swift-ci please test Windows platform |
What does exclusivity checking have to do with threads? Other than the implementation needing to be thread-safe, which is trivial if there are no threads. |
Great point, sorry I missed that. I've re-enabled it, now the only thing left in this PR is defining |
@compnerd could you have another look please? |
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.
Does this not break other things as you cannot get the return address? This may let it compile but can cause correctness issues.
Just looking in to this. It seems that WASI does not support getting the return address right now (see also: WebAssemblyTargetLowering::LowerRETURNADDR). AFAICT this is only used for diagnostics, so it shouldn’t be a big deal to leave it out. The other option (besides returning a null pointer), would be to omit the “PC” field from the “Access” type on WASI. Would you prefer that approach? |
@compnerd |
@swift-ci please test |
@swift-ci please smoke test |
I think that it may be better to disable the larger portions of Swift for WASM until the get return address can be implemented. Note that the else path would still prevent you from progressing, which this is undoing. |
Close due to the merge of #42097 |
WebAssembly/WASI doesn't support stack traces and return addresses. To make it possible to compile exclusivity code for this platform, it seems to make the most sense for the
get_return_address()
to return a zero value. Since it's only used for diagnostics, this shouldn't cause any issues when targeting WASI.Related to SR-9307.
(cc @compnerd)