fix(wasm): enable C++ exception catching in the Emscripten build - #2
Closed
charlieh0tel wants to merge 2 commits into
Closed
charlieh0tel wants to merge 2 commits into
charlieh0tel wants to merge 2 commits into
Conversation
Emscripten disables exception catching by default, so throws abort and catch blocks are elided. nec_context uses `throw 1` to unwind a finished solve, and nec_process_input relies on catching nec_exception to report errors. Pass -fexceptions at both compile and link time. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The CI wasm job only checked that nec2pp.js/nec2pp.wasm were produced. Load the module under Node, feed nec_process_input a deck that makes the geometry parser throw, and require rc -2 with the error in the output. Without exception catching the throw escapes into JS and the test fails. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
charlieh0tel
force-pushed
the
fix-wasm-exceptions
branch
from
October 2, 2026 02:57
9575170 to
5b74cdc
Compare
Owner
Author
|
Closing: not sending WASM-target fixes upstream (tmolteno#136 closed). nec2-js builds WASM with its own emcc script, which already passes -fexceptions. Branch kept for the smoke test. |
charlieh0tel
force-pushed
the
fix-wasm-exceptions
branch
from
October 2, 2026 03:03
5b74cdc to
9575170
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Emscripten disables C++ exception catching by default:
throwaborts the module andcatchblocks are elided. This adds-fexceptionsto both compile and link options for thenec2pp_wasmtarget.nec_context::simulateusesthrow 1/catch (int)to unwind a finished solve (src/nec_context.cpp:1126,:1142,:1153).nec_process_input(src/nec_wasm.cpp) catchesnec_exceptionto return-2with an error message.Note: the WASM entry point is still a stub and doesn't call
simulate()yet, so today the error-handling path is the one that matters; the solve path will once it's wired up.Also adds
tests/wasm_smoke.js, run in the CIwasmjob: it loads the module under Node, feedsnec_process_inputa deck that makes the geometry parser throw, and requires rc-2with the error message in the output.Test plan
node tests/wasm_smoke.js nec2pp.jspasses against a build of this branchmaster(the exception escapes into JS as a raw pointer)wasmjob passes🤖 Generated with Claude Code