Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion src/wasm/wasm-emscripten.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down
3 changes: 2 additions & 1 deletion test/lld/duplicate_imports.wast.out
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,8 @@
"invoke_ffd"
],
"features": [
]
],
"mainReadsParams": 1
}
-- END METADATA --
;)
3 changes: 2 additions & 1 deletion test/lld/em_asm.wast.mem.out
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,8 @@
"invokeFuncs": [
],
"features": [
]
],
"mainReadsParams": 0
}
-- END METADATA --
;)
3 changes: 2 additions & 1 deletion test/lld/em_asm.wast.out
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,8 @@
"invokeFuncs": [
],
"features": [
]
],
"mainReadsParams": 0
}
-- END METADATA --
;)
3 changes: 2 additions & 1 deletion test/lld/em_asm_O0.wast.out
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,8 @@
"invokeFuncs": [
],
"features": [
]
],
"mainReadsParams": 1
}
-- END METADATA --
;)
3 changes: 2 additions & 1 deletion test/lld/em_asm_shared.wast.out
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,8 @@
"invokeFuncs": [
],
"features": [
]
],
"mainReadsParams": 0
}
-- END METADATA --
;)
3 changes: 2 additions & 1 deletion test/lld/em_asm_table.wast.out
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@
"invokeFuncs": [
],
"features": [
]
],
"mainReadsParams": 0
}
-- END METADATA --
;)
3 changes: 2 additions & 1 deletion test/lld/em_js_O0.wast.out
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,8 @@
"invokeFuncs": [
],
"features": [
]
],
"mainReadsParams": 0
}
-- END METADATA --
;)
3 changes: 2 additions & 1 deletion test/lld/hello_world.passive.wast.out
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,8 @@
"invokeFuncs": [
],
"features": [
]
],
"mainReadsParams": 0
}
-- END METADATA --
;)
3 changes: 2 additions & 1 deletion test/lld/hello_world.wast.mem.out
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@
"invokeFuncs": [
],
"features": [
]
],
"mainReadsParams": 0
}
-- END METADATA --
;)
3 changes: 2 additions & 1 deletion test/lld/hello_world.wast.out
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,8 @@
"invokeFuncs": [
],
"features": [
]
],
"mainReadsParams": 0
}
-- END METADATA --
;)
3 changes: 2 additions & 1 deletion test/lld/init.wast.out
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,8 @@
"invokeFuncs": [
],
"features": [
]
],
"mainReadsParams": 0
}
-- END METADATA --
;)
3 changes: 2 additions & 1 deletion test/lld/recursive.wast.out
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,8 @@
"invokeFuncs": [
],
"features": [
]
],
"mainReadsParams": 0
}
-- END METADATA --
;)
3 changes: 2 additions & 1 deletion test/lld/reserved_func_ptr.wast.out
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,8 @@
"invokeFuncs": [
],
"features": [
]
],
"mainReadsParams": 1
}
-- END METADATA --
;)
3 changes: 2 additions & 1 deletion test/lld/shared.wast.out
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,8 @@
"invokeFuncs": [
],
"features": [
]
],
"mainReadsParams": 0
}
-- END METADATA --
;)