From 813216be9a8840122c93d10a6d27908aa8c0cfa2 Mon Sep 17 00:00:00 2001 From: Jonathan Arnett Date: Sat, 1 Oct 2022 13:03:23 -0400 Subject: [PATCH 1/5] Configure compiled WASM grammars to not catch rejections --- cli/src/wasm.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cli/src/wasm.rs b/cli/src/wasm.rs index 9689245d..f31ac2d2 100644 --- a/cli/src/wasm.rs +++ b/cli/src/wasm.rs @@ -83,6 +83,8 @@ pub fn compile_language_to_wasm(language_dir: &Path, force_docker: bool) -> Resu "-s", "NODEJS_CATCH_EXIT=0", "-s", + "NODEJS_CATCH_REJECTION=0", + "-s", &format!("EXPORTED_FUNCTIONS=[\"_tree_sitter_{}\"]", grammar_name), "-fno-exceptions", "-I", From a8988339c386a452720b181154c5d342919262b0 Mon Sep 17 00:00:00 2001 From: Jonathan Arnett Date: Sat, 1 Oct 2022 13:03:52 -0400 Subject: [PATCH 2/5] Add 'stringToUTF16' and 'AsciiToString' to exported method --- script/build-wasm | 3 +++ 1 file changed, 3 insertions(+) diff --git a/script/build-wasm b/script/build-wasm index 12852583..f95c3f15 100755 --- a/script/build-wasm +++ b/script/build-wasm @@ -77,6 +77,8 @@ fi mkdir -p target/scratch +runtime_methods='stringToUTF16','AsciiToString' + # Use emscripten to generate `tree-sitter.js` and `tree-sitter.wasm` # in the `target/scratch` directory $emcc \ @@ -88,6 +90,7 @@ $emcc \ -s NODEJS_CATCH_EXIT=0 \ -s NODEJS_CATCH_REJECTION=0 \ -s EXPORTED_FUNCTIONS=@${web_dir}/exports.json \ + -s EXPORTED_RUNTIME_METHODS=$runtime_methods \ $emscripten_flags \ -fno-exceptions \ -std=c99 \ From 56e9753b5f404d2d47e4cf699d0db6574fa43149 Mon Sep 17 00:00:00 2001 From: Jonathan Arnett Date: Mon, 17 Oct 2022 12:37:09 -0400 Subject: [PATCH 3/5] Add `memset` to exports --- lib/binding_web/exports.json | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/binding_web/exports.json b/lib/binding_web/exports.json index 55f52e96..e2518ea1 100644 --- a/lib/binding_web/exports.json +++ b/lib/binding_web/exports.json @@ -24,6 +24,7 @@ "_memcmp", "_memcpy", "_memmove", + "_memset", "_strlen", "_towupper", From e4fc6653eedc0c446d64403f80ef22335b41f290 Mon Sep 17 00:00:00 2001 From: Jonathan Arnett Date: Sun, 30 Oct 2022 23:31:44 -0400 Subject: [PATCH 4/5] Add __cxa_atexit to exports --- lib/binding_web/exports.json | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/binding_web/exports.json b/lib/binding_web/exports.json index e2518ea1..3fe11cdf 100644 --- a/lib/binding_web/exports.json +++ b/lib/binding_web/exports.json @@ -14,6 +14,7 @@ "__ZNSt3__212basic_stringIwNS_11char_traitsIwEENS_9allocatorIwEEED2Ev", "__ZdlPv", "__Znwm", + "___cxa_atexit", "_abort", "_iswalnum", "_iswalpha", From 1f36bf091e1faaec5d9282f47c9dab00f7435e06 Mon Sep 17 00:00:00 2001 From: Max Brunsfeld Date: Tue, 15 Nov 2022 16:38:04 -0800 Subject: [PATCH 5/5] Upgrade to emscripten 3.1.25 --- cli/emscripten-version | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cli/emscripten-version b/cli/emscripten-version index 8f4c02d6..199eda56 100644 --- a/cli/emscripten-version +++ b/cli/emscripten-version @@ -1 +1 @@ -2.0.24 +3.1.25