From 15009945aca9b81d7c57d797bbafa58dfaa4c891 Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Fri, 18 Nov 2022 10:48:59 -0800 Subject: [PATCH] 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 --- 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");