-
-
Notifications
You must be signed in to change notification settings - Fork 21.6k
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
[3.x] Build javascript+GDNative export template with -s WASM_BIGINT #62397
Conversation
This tells emscripten to pass i64 values from WebAssembly to JavaScript as BigInt instead of as two i32s, which could lead to crashes when GDNative modules are used.
Sorry, I don't fully understand this part. Where is the function defined then?
I feel that's kind of a problem for now, at least in the 3.x branch which tries to have wide browser support. |
Sorry, it's explained better in the blogpost I linked:
The function is defined in (and called by) the GDNative module itself, but for exception-handling-purposes is wrapped in a JavaScript try-block, so the call makes a roundtrip from wasm to js. That's where the wrapper function comes in.
Well, that applies only to exports with GDNative enabled, which without this patch are broken anyway it seems. |
Minimum browser versions for webassembly are:
Minimum browser versions for
So you see the issue is mostly Safari. Current tip of tree Emscripten only supports Safari 15 with |
It would be possible to fix Emscripten dynamic linking without |
To enable the Safari 14 compatibility when it comes along you should also pass |
That's not the case, given I do test GDNative side modules, and they do work, maybe it's broken for your case, but not "generally broken".
From the post, this seem an issue specific to C++ exception, which are disabled for the main module to reduce size so I'm actually surprised would work in the side modules at all. |
It's a problem with panics. If you disable exception support, ideally it should abort at runtime when an exception is thrown. Currently there are linker errors. It might be worth trying to compile with |
But then I don't see how |
The link error is caused by a three-way interaction between stack unwinding, 64 bit integer handling, and dynamic linking. |
Okay I am pretty sure that setting You can test whether a library is going to cause a problem with:
if you see any output, it is probably broken. |
Sorry for the delay following up on this. It's not clear to me what's a reproducer for this issue so we could confirm the need for I do see however that we added CC @adamscott |
I found that this was superseded by #88594, which should be cherry-picked for |
This tells emscripten to pass i64 values from WebAssembly to JavaScript as BigInt instead of as two i32s, which could lead to crashes when GDNative modules are used.
@hoodmane wrote about it here. The gist of it (as I understand it) is that without this patch, emscripten generates custom wrapper functions per function signature to do the (i32, i32) -> i64 conversion, and if a GDNative module has to call a function with a signature not present in the Godot main module, an error is thrown. For my godot-rust project, this patch fixes an immediate crash on launch.
Note that this does reduce browser compatibility a bit for GDNative exports (to browsers supporting BigInt64Array, although emscripten-core/emscripten#17103 if merged would relax that requirement to just BigInt).