-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Link the Wasm EH runtime under -fwasm-exceptions without requiring C++ #27496
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
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8833,9 +8833,10 @@ def test_exceptions_c_linker(self): | |
| self.assert_fail([EMCC, '-sSTRICT', test_file('other/test_exceptions_c_linker.c')], 'error: undefined symbol: __cxa_find_matching_catch_1') | ||
|
|
||
| @parameterized({ | ||
| # TODO: Add wasm_eh modes once the libunwind Wasm EH followup PR lands | ||
| '': ([],), | ||
| 'exceptions': (['-fexceptions'],), | ||
| 'wasm_eh': (['-fwasm-exceptions'],), | ||
| 'wasm_legacy_eh': (['-fwasm-exceptions', '-sWASM_LEGACY_EXCEPTIONS'],), | ||
|
Comment on lines
8837
to
+8839
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. Can we use
Collaborator
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. IIUC that does not include the empty case (i.e. no exception handling)? |
||
| }) | ||
| def test_libunwind(self, cflags): | ||
| src = r''' | ||
|
|
@@ -14621,10 +14622,36 @@ def test_wasi_with_sjlj(self): | |
|
|
||
| # When using Wasm exception, SUPPORT_LONGJMP defaults to 'wasm', which does | ||
| # not use the JS-based support. This should succeed. | ||
| # -fwasm-exceptions exports __cpp_exception, so this is necessary | ||
| self.set_setting('DEFAULT_TO_CXX') | ||
| self.do_runf('core/test_longjmp.c', cflags=['-fwasm-exceptions']) | ||
|
|
||
| def test_cpp_exception_tag(self): | ||
| # Wasm EH throw/catch sites reference the `__cpp_exception` tag directly, | ||
| # regardless of source language (e.g. rustc objects), so an object whose | ||
| # only undefined symbol is the tag must still pull in its libunwind definition. | ||
| create_file('throw.S', ''' | ||
| .tagtype __cpp_exception i32 | ||
|
guybedford marked this conversation as resolved.
|
||
| .text | ||
| .globl throw_tag | ||
| throw_tag: | ||
| .functype throw_tag (i32) -> () | ||
| local.get 0 | ||
| throw __cpp_exception | ||
| end_function | ||
| ''') | ||
| create_file('main.c', r''' | ||
| #include <stdio.h> | ||
| void throw_tag(int); | ||
| int main(int argc, char* argv[]) { | ||
| if (argc > 100) { | ||
| throw_tag(argc); | ||
| } | ||
| printf("done\n"); | ||
| return 0; | ||
| } | ||
| ''') | ||
| # -mexception-handling is needed for the assembler to accept `throw`. | ||
| self.do_runf('main.c', 'done\n', cflags=['throw.S', '-fwasm-exceptions', '-mexception-handling']) | ||
|
guybedford marked this conversation as resolved.
|
||
|
|
||
| def test_memory_init_file_unsupported(self): | ||
| self.assert_fail([EMCC, test_file('hello_world.c'), '-Werror', '--memory-init-file=1'], 'error: --memory-init-file is no longer supported') | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1686,7 +1686,6 @@ def get_files(self): | |
| 'stdlib_typeinfo.cpp', | ||
| 'private_typeinfo.cpp', | ||
| 'cxa_exception_js_utils.cpp', | ||
| '__cpp_exception.S', | ||
| ] | ||
| match self.eh_mode: | ||
| case Exceptions.NONE: | ||
|
|
@@ -2484,8 +2483,13 @@ def add_sanitizer_libs(): | |
| add_library('libc++') | ||
| if settings.LINK_AS_CXX or sanitize: | ||
| add_library('libc++abi') | ||
| if settings.WASM_EXCEPTIONS: | ||
| add_library('libunwind') | ||
| if settings.WASM_EXCEPTIONS: | ||
| # Wasm EH objects can come from any language frontend (e.g. rust), so the | ||
| # unwinding runtime and the `__cpp_exception` tag it defines are linked | ||
| # independently of C++. When WASM_EXCEPTIONS is not enabled, `_Unwind_*` | ||
| # symbols are instead provided by JS stubs in libcore.js (under | ||
| # LINK_AS_CXX). | ||
|
Comment on lines
+2489
to
+2491
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. Does this mean we need
Collaborator
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 think this full comment is no longer needed. libunwind should always be linked into all programs one or another. I should have known that before. How about just: |
||
| add_library('libunwind') | ||
|
|
||
| if settings.PROXY_POSIX_SOCKETS: | ||
| add_library('libsockets_proxy') | ||
|
|
||
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.
Add PR number here.