Skip to content

Commit

Permalink
Add post-emscripten-side-module pass argument (#5274)
Browse files Browse the repository at this point in the history
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 emscripten-core/emscripten#18228
  • Loading branch information
sbc100 committed Nov 18, 2022
1 parent 66214bc commit 1500994
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions src/passes/PostEmscripten.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down

0 comments on commit 1500994

Please sign in to comment.