summaryrefslogtreecommitdiff
path: root/src/passes/PostEmscripten.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/passes/PostEmscripten.cpp')
-rw-r--r--src/passes/PostEmscripten.cpp14
1 files changed, 10 insertions, 4 deletions
diff --git a/src/passes/PostEmscripten.cpp b/src/passes/PostEmscripten.cpp
index b569cd0e0..39bc3e889 100644
--- a/src/passes/PostEmscripten.cpp
+++ b/src/passes/PostEmscripten.cpp
@@ -186,10 +186,13 @@ IString EM_JS_PREFIX("__em_js__");
IString EM_JS_DEPS_PREFIX("__em_lib_deps_");
struct EmJsWalker : public PostWalker<EmJsWalker> {
+ bool sideModule;
std::vector<Export> toRemove;
+ EmJsWalker(bool sideModule) : sideModule(sideModule) {}
+
void visitExport(Export* curr) {
- if (curr->name.startsWith(EM_JS_PREFIX)) {
+ if (!sideModule && curr->name.startsWith(EM_JS_PREFIX)) {
toRemove.push_back(*curr);
}
if (curr->name.startsWith(EM_JS_DEPS_PREFIX)) {
@@ -215,14 +218,15 @@ struct PostEmscripten : public Pass {
auto& options = getPassOptions();
auto sideModule = options.hasArgument("post-emscripten-side-module");
if (!sideModule) {
+ removeData(module, segmentOffsets, "__start_em_asm", "__stop_em_asm");
+ removeData(module, segmentOffsets, "__start_em_js", "__stop_em_js");
+
// 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_js");
@@ -232,7 +236,9 @@ struct PostEmscripten : public Pass {
}
void removeEmJsExports(Module& module) {
- EmJsWalker walker;
+ auto& options = getPassOptions();
+ auto sideModule = options.hasArgument("post-emscripten-side-module");
+ EmJsWalker walker(sideModule);
walker.walkModule(&module);
for (const Export& exp : walker.toRemove) {
if (exp.kind == ExternalKind::Function) {