summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSam Clegg <sbc@chromium.org>2022-10-04 22:19:35 -0700
committerGitHub <noreply@github.com>2022-10-04 22:19:35 -0700
commitd9ce340fb17a24dca28e0018f5537846841368ab (patch)
tree071126dd26d5657908eecf1ba1abc8a80ae14bea
parent5b0977d564ef7f20f066a3082720b5b7327642c2 (diff)
downloadbinaryen-d9ce340fb17a24dca28e0018f5537846841368ab.tar.gz
binaryen-d9ce340fb17a24dca28e0018f5537846841368ab.tar.bz2
binaryen-d9ce340fb17a24dca28e0018f5537846841368ab.zip
Strip em_js_deps exports (#5109)
These are only needed for the metadata extraction in emcc.
-rw-r--r--src/passes/PostEmscripten.cpp8
-rw-r--r--src/wasm/wasm-emscripten.cpp2
-rw-r--r--test/lit/passes/post-emscripten.wast40
3 files changed, 36 insertions, 14 deletions
diff --git a/src/passes/PostEmscripten.cpp b/src/passes/PostEmscripten.cpp
index e17c529bb..ded949859 100644
--- a/src/passes/PostEmscripten.cpp
+++ b/src/passes/PostEmscripten.cpp
@@ -185,6 +185,7 @@ static void removeData(Module& wasm,
}
cashew::IString EM_JS_PREFIX("__em_js__");
+cashew::IString EM_JS_DEPS_PREFIX("__em_lib_deps_");
struct EmJsWalker : public PostWalker<EmJsWalker> {
std::vector<Export> toRemove;
@@ -193,6 +194,9 @@ struct EmJsWalker : public PostWalker<EmJsWalker> {
if (curr->name.startsWith(EM_JS_PREFIX.str)) {
toRemove.push_back(*curr);
}
+ if (curr->name.startsWith(EM_JS_DEPS_PREFIX.str)) {
+ toRemove.push_back(*curr);
+ }
}
};
@@ -212,10 +216,14 @@ struct PostEmscripten : public Pass {
removeData(module, segmentOffsets, "__start_em_asm", "__stop_em_asm");
removeData(module, segmentOffsets, "__start_em_js", "__stop_em_js");
+ removeData(
+ module, segmentOffsets, "__start_em_lib_deps", "__stop_em_lib_deps");
module.removeExport("__start_em_asm");
module.removeExport("__stop_em_asm");
module.removeExport("__start_em_js");
module.removeExport("__stop_em_js");
+ module.removeExport("__start_em_lib_deps");
+ module.removeExport("__stop_em_lib_deps");
}
void removeEmJsExports(Module& module) {
diff --git a/src/wasm/wasm-emscripten.cpp b/src/wasm/wasm-emscripten.cpp
index 0bc74580d..9cc8b29f0 100644
--- a/src/wasm/wasm-emscripten.cpp
+++ b/src/wasm/wasm-emscripten.cpp
@@ -33,8 +33,6 @@
namespace wasm {
-cashew::IString EM_JS_PREFIX("__em_js__");
-
void addExportedFunction(Module& wasm, Function* function) {
wasm.addFunction(function);
auto export_ = new Export;
diff --git a/test/lit/passes/post-emscripten.wast b/test/lit/passes/post-emscripten.wast
index 259a16729..fc61e8845 100644
--- a/test/lit/passes/post-emscripten.wast
+++ b/test/lit/passes/post-emscripten.wast
@@ -5,14 +5,22 @@
;; refer to is either zero'd out, or the segment emptied.
(module
- ;; CHECK: (global $g1 i32 (i32.const 1000))
- (global $g1 i32 (i32.const 1000))
- ;; CHECK: (global $g2 i32 (i32.const 1011))
- (global $g2 i32 (i32.const 1011))
- ;; CHECK: (global $g3 i32 (i32.const 2006))
- (global $g3 i32 (i32.const 2006))
- ;; CHECK: (global $g4 i32 (i32.const 2015))
- (global $g4 i32 (i32.const 2015))
+ ;; CHECK: (global $em_asm_start i32 (i32.const 1000))
+ (global $em_asm_start i32 (i32.const 1000))
+ ;; CHECK: (global $em_asm_stop i32 (i32.const 1011))
+ (global $em_asm_stop i32 (i32.const 1011))
+ ;; CHECK: (global $em_js_start i32 (i32.const 2006))
+ (global $em_js_start i32 (i32.const 2006))
+ ;; CHECK: (global $em_js_stop i32 (i32.const 2015))
+ (global $em_js_stop i32 (i32.const 2015))
+ ;; CHECK: (global $em_lib_deps_start i32 (i32.const 3000))
+ (global $em_lib_deps_start i32 (i32.const 3000))
+ ;; CHECK: (global $em_lib_deps_stop i32 (i32.const 3009))
+ (global $em_lib_deps_stop i32 (i32.const 3009))
+ ;; CHECK: (global $foo_start i32 (i32.const 4000))
+ (global $foo_start i32 (i32.const 4000))
+ ;; CHECK: (global $foo_stop i32 (i32.const 4015))
+ (global $foo_stop i32 (i32.const 4015))
(memory 10 10)
;; CHECK: (memory $0 10 10)
@@ -20,9 +28,17 @@
(data $data1 (i32.const 1000) "hello world")
;; CHECK: (data $data2 (i32.const 2000) "hello \00\00\00\00\00\00\00\00\00 world")
(data $data2 (i32.const 2000) "hello DELETE ME world")
- (export "__start_em_asm" (global $g1))
- (export "__stop_em_asm" (global $g2))
- (export "__start_em_js" (global $g3))
- (export "__stop_em_js" (global $g4))
+ ;; CHECK: (data $data3 (i32.const 3000) "")
+ (data $data3 (i32.const 3000) "some deps")
+ (export "__start_em_asm" (global $em_asm_start))
+ (export "__stop_em_asm" (global $em_asm_stop))
+ (export "__start_em_js" (global $em_js_start))
+ (export "__stop_em_js" (global $em_js_stop))
+ (export "__start_em_lib_deps" (global $em_lib_deps_start))
+ (export "__stop_em_lib_deps" (global $em_lib_deps_stop))
+ ;; CHECK: (export "__start_foo" (global $foo_start))
+ (export "__start_foo" (global $foo_start))
+ ;; CHECK: (export "__stop_foo" (global $foo_stop))
+ (export "__stop_foo" (global $foo_stop))
)