-
Notifications
You must be signed in to change notification settings - Fork 3.3k
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
Rust compilation fails on a trivial input with "undefined symbol: __gxx_personality_v0" #17128
Comments
Do you know where the source code for libpanic_unwind.o lives or how it was compiled? |
Emscripten does not currently define that symbol. @aheejin, is this something we should be defining? What does it mean exactly? Or should we suggest that the rust library needs to be updated/fixed instead? |
It looks like that symbol is maybe present when building with wasm exceptions but not with SjLj (emscripten) exceptions. I removed the dummy version for this reason back in #12820 |
I get exactly the same linking error even with |
Actually that is not true, I get a different error with
|
Well it does seem like just declaring |
This adds CI to build libpython3.11 for wasm32-emscripten and running tests against it. We need to patch instant to work around the emscripten_get_now: sebcrozet/instant#47 We also have to patch emscripten to work aroung the "undefined symbol gxx_personality_v0" error: emscripten-core/emscripten#17128 I set up a nox file to download and install emscripten, download and build cpython, set appropriate environment variables then run cargo test. The workflow just installs python, rust, node, and nox and runs the nox session. I xfailed all the test failures. There are problems with datetime. iter_dict_nosegv and test_filenotfounderror should probably be fixable. The tests that involve threads or asyncio probably can't be fixed.
This adds CI to build libpython3.11 for wasm32-emscripten and running tests against it. We need to patch instant to work around the emscripten_get_now: sebcrozet/instant#47 We also have to patch emscripten to work aroung the "undefined symbol gxx_personality_v0" error: emscripten-core/emscripten#17128 I set up a nox file to download and install emscripten, download and build cpython, set appropriate environment variables then run cargo test. The workflow just installs python, rust, node, and nox and runs the nox session. I xfailed all the test failures. There are problems with datetime. iter_dict_nosegv and test_filenotfounderror should probably be fixable. The tests that involve threads or asyncio probably can't be fixed.
You could define it anywhere you like.. but the real fix is most likely to remove the reference to it in the rust source code. |
Yeah. Patching emscripten is so convenient that it is often the path of least resistance to fixing problems caused elsewhere. |
Per rust-lang/rust#85821 it looks like this should be fixed in Rust, though it is unfortunate the old unwinding personality symbol disappeared. I cannot help though. |
I'm not too familiar with emscripten, but if the function doesn't do anything then we can replace it with a stub in Rust. We do the same for MSVC exceptions here: https://github.com/rust-lang/rust/blob/9d20fd109809f20c049d6895a5be27a1fbd39daa/library/panic_unwind/src/seh.rs#L327 |
I think the function is never called. I stubbed it with a function that logs the input and ran various panic tests and it never got invoked. Though for instance |
This adds CI to build libpython3.11 for wasm32-emscripten and running tests against it. We need to patch instant to work around the emscripten_get_now: sebcrozet/instant#47 We also have to patch emscripten to work aroung the "undefined symbol gxx_personality_v0" error: emscripten-core/emscripten#17128 I set up a nox file to download and install emscripten, download and build cpython, set appropriate environment variables then run cargo test. The workflow just installs python, rust, node, and nox and runs the nox session. I xfailed all the test failures. There are problems with datetime. iter_dict_nosegv and test_filenotfounderror should probably be fixable. The tests that involve threads or asyncio probably can't be fixed.
I don't know much about Rust. Why does Rust need that symbol? It is a name of the personality function in libc++abi. I don't think Rust would use libc++abi internally? Also I'm not very familiar with the status of EH support in Rust. Does it use Emscripten EH or Wasm EH or something else? In case of Wasm EH I think you would need a frontend support that can generate the specific EH IR our LLVM backend expects. Clang has that support but I'm not sure if Rust has it too? By the way neither of Wasm EH and Emscripten EH has that symbol. Emscripten EH doesn't use a personality function at all, and it instead use emscripten/src/library_exceptions.js Lines 330 to 383 in d2f8747
Wasm EH uses a personality function, but we use a different name emscripten/system/lib/libcxxabi/src/cxa_personality.cpp Lines 900 to 901 in d2f8747
|
The personality function is passed to LLVM in the |
Interesting.. I see that symbol in the bitcode but then i gets compiled away at some point: https://godbolt.org/z/WaaaYrfrG I wonder why the rustc usage doesn't also get compiled away? |
Same with emscripten exceptions.. that symbol gets compiled away: https://godbolt.org/z/heasWYdn9 It is interesting that in both cases clang is generating reference to __gxx_wasm_personality_v0 even though with wasm exceptions we apparently use a different personality and with emscripten exceptions we don't define a personality at all. |
The difference is that Rust wraps |
Actually it looks like -fwasm-exceptions causes emscripten/system/lib/libcxxabi/src/cxa_personality.cpp Lines 900 to 901 in d2f8747
It looks like clang chooses which one to use here: https://github.com/llvm/llvm-project/blob/907aedbb3d08a28f00a6a45b0ec82cdc373115c9/clang/lib/CodeGen/CGException.cpp#L173-L189 |
* ci: test on emscripten target This adds CI to build libpython3.11 for wasm32-emscripten and running tests against it. We need to patch instant to work around the emscripten_get_now: sebcrozet/instant#47 We also have to patch emscripten to work aroung the "undefined symbol gxx_personality_v0" error: emscripten-core/emscripten#17128 I set up a nox file to download and install emscripten, download and build cpython, set appropriate environment variables then run cargo test. The workflow just installs python, rust, node, and nox and runs the nox session. I xfailed all the test failures. There are problems with datetime. iter_dict_nosegv and test_filenotfounderror should probably be fixable. The tests that involve threads or asyncio probably can't be fixed. * Some cleanup * Remove instant patch * Add explanations for xfails
I ran I'm not sure |
By the way if you can't compile that empty I tried |
This seems correct in practice. As I mentioned further up the thread, I patched in a version of
@Amanieu suggested this further up in the thread. I think this is the clear consensus from this discussion, I will open a PR on Rust.
People are using the wasm32-unknown-unknown target.
|
This resolves rust-lang#85821. See also the discussion here: emscripten-core/emscripten#17128 The consensus seems to be that rust_eh_personality is never invoked. I patched __gxx_personality_v0 to log invocations and then ran various panic tests and it was never called, so this analysis matches what seems to happen in practice. This replaces the definition with an abort, modeled on the structured exception handling implementation.
… r=Amanieu Don't use __gxx_personality_v0 in panic_unwind on emscripten target This resolves rust-lang#85821. See also the discussion here: emscripten-core/emscripten#17128 The consensus seems to be that rust_eh_personality is never invoked. I patched __gxx_personality_v0 to log invocations and then ran various panic tests and it was never called, so this analysis matches what seems to happen in practice. This replaces the definition with an abort, modeled on the structured exception handling implementation.
… r=Amanieu Don't use __gxx_personality_v0 in panic_unwind on emscripten target This resolves rust-lang#85821. See also the discussion here: emscripten-core/emscripten#17128 The consensus seems to be that rust_eh_personality is never invoked. I patched __gxx_personality_v0 to log invocations and then ran various panic tests and it was never called, so this analysis matches what seems to happen in practice. This replaces the definition with an abort, modeled on the structured exception handling implementation.
Thanks everyone! |
This resolves #85821. See also the discussion here: emscripten-core/emscripten#17128 The consensus seems to be that rust_eh_personality is never invoked. I patched __gxx_personality_v0 to log invocations and then ran various panic tests and it was never called, so this analysis matches what seems to happen in practice. This replaces the definition with an abort, modeled on the structured exception handling implementation.
Don't use __gxx_personality_v0 in panic_unwind on emscripten target This resolves #85821. See also the discussion here: emscripten-core/emscripten#17128 The consensus seems to be that rust_eh_personality is never invoked. I patched __gxx_personality_v0 to log invocations and then ran various panic tests and it was never called, so this analysis matches what seems to happen in practice. This replaces the definition with an abort, modeled on the structured exception handling implementation.
Reproduction
Make a file
main.rs
consisting of:then run:
results in:
My minimized version of the failing link command:
libpanic_unwind
consists of a single object filepanic_unwind<junk>.o
which after disassembling is ~280 lines of wat:Disassembly of panic_unwind.o
The text was updated successfully, but these errors were encountered: