summaryrefslogtreecommitdiff
path: root/test/lit/wasm-emscripten-finalize/em_js.wat
diff options
context:
space:
mode:
authorSam Clegg <sbc@chromium.org>2021-02-08 11:48:35 -0800
committerGitHub <noreply@github.com>2021-02-08 11:48:35 -0800
commit7bff209e0da1ea335cccfa9874fe830c49480eba (patch)
tree5f2ee61a07055202a7390858a9fbd705e1c94f69 /test/lit/wasm-emscripten-finalize/em_js.wat
parentd4e31719c6609e121d5bb6758e1b9d3335113755 (diff)
downloadbinaryen-7bff209e0da1ea335cccfa9874fe830c49480eba.tar.gz
binaryen-7bff209e0da1ea335cccfa9874fe830c49480eba.tar.bz2
binaryen-7bff209e0da1ea335cccfa9874fe830c49480eba.zip
Fix removal of EM_JS functions (#3552)
The algorithm was trying to remove all __em_js functions but it was using the names of functions rather than export names so it was failing to remove these functions unless the internal function names happened to match (this turns out of the true for build with debug names).
Diffstat (limited to 'test/lit/wasm-emscripten-finalize/em_js.wat')
-rw-r--r--test/lit/wasm-emscripten-finalize/em_js.wat28
1 files changed, 28 insertions, 0 deletions
diff --git a/test/lit/wasm-emscripten-finalize/em_js.wat b/test/lit/wasm-emscripten-finalize/em_js.wat
new file mode 100644
index 000000000..c2dd4c17d
--- /dev/null
+++ b/test/lit/wasm-emscripten-finalize/em_js.wat
@@ -0,0 +1,28 @@
+;; Test that funcions exported with __em_js are correctly removed
+;; once they strings they return are extracted.
+
+;; RUN: wasm-emscripten-finalize %s -S | filecheck %s
+
+;; Both functions should be stripped from the binary
+;; CHECK-NOT: (func
+
+;; CHECK: "emJsFuncs": {
+;; CHECK-NEXT: "bar": "more JS string dara",
+;; CHECK-NEXT: "foo": "some JS string"
+;; CHECK-NEXT: },
+
+(module
+ (memory 1 1)
+ (data (i32.const 1024) "some JS string\00")
+ (data (i32.const 2048) "more JS string dara\00")
+ (export "__em_js__foo" (func $__em_js__foo))
+ (export "__em_js__bar" (func $bar))
+ ;; Name matches export name
+ (func $__em_js__foo (result i32)
+ (i32.const 1024)
+ )
+ ;; Name does not match export name
+ (func $bar (result i32)
+ (i32.const 2048)
+ )
+)