diff options
Diffstat (limited to 'src/wasm/wasm-emscripten.cpp')
-rw-r--r-- | src/wasm/wasm-emscripten.cpp | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/src/wasm/wasm-emscripten.cpp b/src/wasm/wasm-emscripten.cpp index a3433bf9f..3ee3e4424 100644 --- a/src/wasm/wasm-emscripten.cpp +++ b/src/wasm/wasm-emscripten.cpp @@ -1042,7 +1042,23 @@ std::string EmscriptenGlueGenerator::generateEmscriptenMetadata( wasm.features.iterFeatures([&](FeatureSet::Feature f) { meta << nextElement() << "\"--enable-" << FeatureSet::toString(f) << '"'; }); - meta << "\n ]\n"; + meta << "\n ],\n"; + + auto mainReadsParams = false; + if (auto* exp = wasm.getExportOrNull("main")) { + if (exp->kind == ExternalKind::Function) { + auto* main = wasm.getFunction(exp->value); + mainReadsParams = true; + // If main does not read its parameters, it will just be a stub that + // calls __original_main (which has no parameters). + if (auto* call = main->body->dynCast<Call>()) { + if (call->operands.empty()) { + mainReadsParams = false; + } + } + } + } + meta << " \"mainReadsParams\": " << int(mainReadsParams) << '\n'; meta << "}\n"; |