@@ -186,10 +186,13 @@ IString EM_JS_PREFIX("__em_js__");
186
186
IString EM_JS_DEPS_PREFIX (" __em_lib_deps_" );
187
187
188
188
struct EmJsWalker : public PostWalker <EmJsWalker> {
189
+ bool sideModule;
189
190
std::vector<Export> toRemove;
190
191
192
+ EmJsWalker (bool sideModule) : sideModule(sideModule) {}
193
+
191
194
void visitExport (Export* curr) {
192
- if (curr->name .startsWith (EM_JS_PREFIX)) {
195
+ if (!sideModule && curr->name .startsWith (EM_JS_PREFIX)) {
193
196
toRemove.push_back (*curr);
194
197
}
195
198
if (curr->name .startsWith (EM_JS_DEPS_PREFIX)) {
@@ -215,14 +218,15 @@ struct PostEmscripten : public Pass {
215
218
auto & options = getPassOptions ();
216
219
auto sideModule = options.hasArgument (" post-emscripten-side-module" );
217
220
if (!sideModule) {
221
+ removeData (module , segmentOffsets, " __start_em_asm" , " __stop_em_asm" );
222
+ removeData (module , segmentOffsets, " __start_em_js" , " __stop_em_js" );
223
+
218
224
// Side modules read EM_ASM data from the module based on these exports
219
225
// so we need to keep them around in that case.
220
- removeData (module , segmentOffsets, " __start_em_asm" , " __stop_em_asm" );
221
226
module .removeExport (" __start_em_asm" );
222
227
module .removeExport (" __stop_em_asm" );
223
228
}
224
229
225
- removeData (module , segmentOffsets, " __start_em_js" , " __stop_em_js" );
226
230
removeData (
227
231
module , segmentOffsets, " __start_em_lib_deps" , " __stop_em_lib_deps" );
228
232
module .removeExport (" __start_em_js" );
@@ -232,7 +236,9 @@ struct PostEmscripten : public Pass {
232
236
}
233
237
234
238
void removeEmJsExports (Module& module ) {
235
- EmJsWalker walker;
239
+ auto & options = getPassOptions ();
240
+ auto sideModule = options.hasArgument (" post-emscripten-side-module" );
241
+ EmJsWalker walker (sideModule);
236
242
walker.walkModule (&module );
237
243
for (const Export& exp : walker.toRemove ) {
238
244
if (exp.kind == ExternalKind::Function) {
0 commit comments