Skip to content

Commit d63b8a4

Browse files
authored
Don't add __wasm_call_ctors to startup function list in wasm standalone mode (#2384)
In this mode crt1 takes care of calling it.
1 parent 66cb7b3 commit d63b8a4

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

src/tools/wasm-emscripten-finalize.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -241,8 +241,12 @@ int main(int argc, const char* argv[]) {
241241
wasm.addExport(ex);
242242
initializerFunctions.push_back(F->name);
243243
}
244-
if (auto* e = wasm.getExportOrNull(WASM_CALL_CTORS)) {
245-
initializerFunctions.push_back(e->name);
244+
// Costructors get called from crt1 in wasm standalone mode.
245+
// Unless there is no entry point.
246+
if (!standaloneWasm || !wasm.getExportOrNull("_start")) {
247+
if (auto* e = wasm.getExportOrNull(WASM_CALL_CTORS)) {
248+
initializerFunctions.push_back(e->name);
249+
}
246250
}
247251
}
248252

0 commit comments

Comments
 (0)