Skip to content

Commit 0f593ed

Browse files
committed
Add post-emscripten-side-module pass argument
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
1 parent ff32193 commit 0f593ed

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

src/passes/PostEmscripten.cpp

+10-3
Original file line numberDiff line numberDiff line change
@@ -214,12 +214,19 @@ struct PostEmscripten : public Pass {
214214
std::vector<Address> segmentOffsets; // segment index => address offset
215215
calcSegmentOffsets(module, segmentOffsets);
216216

217-
removeData(module, segmentOffsets, "__start_em_asm", "__stop_em_asm");
217+
auto& options = getPassOptions();
218+
auto sideModule = options.hasArgument("post-emscripten-side-module");
219+
if (!sideModule) {
220+
// Side modules read EM_ASM data from the module based on these exports
221+
// so we need to keep them around in that case.
222+
removeData(module, segmentOffsets, "__start_em_asm", "__stop_em_asm");
223+
module.removeExport("__start_em_asm");
224+
module.removeExport("__stop_em_asm");
225+
}
226+
218227
removeData(module, segmentOffsets, "__start_em_js", "__stop_em_js");
219228
removeData(
220229
module, segmentOffsets, "__start_em_lib_deps", "__stop_em_lib_deps");
221-
module.removeExport("__start_em_asm");
222-
module.removeExport("__stop_em_asm");
223230
module.removeExport("__start_em_js");
224231
module.removeExport("__stop_em_js");
225232
module.removeExport("__start_em_lib_deps");

0 commit comments

Comments
 (0)