summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/wasm/wasm-emscripten.cpp36
1 files changed, 21 insertions, 15 deletions
diff --git a/src/wasm/wasm-emscripten.cpp b/src/wasm/wasm-emscripten.cpp
index c2cace488..a57573254 100644
--- a/src/wasm/wasm-emscripten.cpp
+++ b/src/wasm/wasm-emscripten.cpp
@@ -1224,25 +1224,31 @@ std::string EmscriptenGlueGenerator::generateEmscriptenMetadata(
});
meta << "\n ],\n";
- auto mainReadsParams = false;
- auto* exp = wasm.getExportOrNull("main");
- if (!exp) {
- exp = wasm.getExportOrNull("__main_argc_argv");
- }
- if (exp) {
- 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;
+ // In normal mode we attempt to determine if main takes argumnts or not
+ // In standalone mode we export _start instead and rely on the presence
+ // of the __wasi_args_get and __wasi_args_sizes_get syscalls allow us to
+ // DCE to the argument handling JS code instead.
+ if (!standalone) {
+ auto mainReadsParams = false;
+ auto* exp = wasm.getExportOrNull("main");
+ if (!exp) {
+ exp = wasm.getExportOrNull("__main_argc_argv");
+ }
+ if (exp) {
+ 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 << " \"mainReadsParams\": " << int(mainReadsParams) << '\n';
meta << "}\n";