summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSam Clegg <sbc@chromium.org>2022-11-18 10:48:59 -0800
committerGitHub <noreply@github.com>2022-11-18 10:48:59 -0800
commit15009945aca9b81d7c57d797bbafa58dfaa4c891 (patch)
tree029103b29b9e6dee1694fcf07074390a16e019f3 /src
parent66214bcaf00aecb4bb00af3fec3b59e717ad7927 (diff)
downloadbinaryen-15009945aca9b81d7c57d797bbafa58dfaa4c891.tar.gz
binaryen-15009945aca9b81d7c57d797bbafa58dfaa4c891.tar.bz2
binaryen-15009945aca9b81d7c57d797bbafa58dfaa4c891.zip
Add post-emscripten-side-module pass argument (#5274)
In this mode we don't remove the start/stop_em_asm symbols or data. This is because with side modules we read this information directly from the wasm binaryen at runtime. See https://github.com/emscripten-core/emscripten/pull/18228
Diffstat (limited to 'src')
-rw-r--r--src/passes/PostEmscripten.cpp13
1 files changed, 10 insertions, 3 deletions
diff --git a/src/passes/PostEmscripten.cpp b/src/passes/PostEmscripten.cpp
index 86b7b8bc3..ea4922e3a 100644
--- a/src/passes/PostEmscripten.cpp
+++ b/src/passes/PostEmscripten.cpp
@@ -214,12 +214,19 @@ struct PostEmscripten : public Pass {
std::vector<Address> segmentOffsets; // segment index => address offset
calcSegmentOffsets(module, segmentOffsets);
- removeData(module, segmentOffsets, "__start_em_asm", "__stop_em_asm");
+ auto& options = getPassOptions();
+ auto sideModule = options.hasArgument("post-emscripten-side-module");
+ if (!sideModule) {
+ // Side modules read EM_ASM data from the module based on these exports
+ // so we need to keep them around in that case.
+ removeData(module, segmentOffsets, "__start_em_asm", "__stop_em_asm");
+ module.removeExport("__start_em_asm");
+ module.removeExport("__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");