From 0f593ed6f5b3fe8ac0aa9d4611452d23cbc0e70e Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Thu, 17 Nov 2022 12:44:26 -0800 Subject: [PATCH] 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 https://github.com/emscripten-core/emscripten/pull/18228 --- src/passes/PostEmscripten.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/passes/PostEmscripten.cpp b/src/passes/PostEmscripten.cpp index 86b7b8bc3ad..ea4922e3a1b 100644 --- a/src/passes/PostEmscripten.cpp +++ b/src/passes/PostEmscripten.cpp @@ -214,12 +214,19 @@ struct PostEmscripten : public Pass { std::vector
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");