From ed8964d1fedeb51a63232736f237dec9edf472a1 Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Sat, 12 Oct 2019 08:31:46 -0700 Subject: [PATCH] Don't add __wasm_call_ctors to startup function list in wasm standalone mode In this mode crt1 takes care of calling it. --- src/tools/wasm-emscripten-finalize.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/tools/wasm-emscripten-finalize.cpp b/src/tools/wasm-emscripten-finalize.cpp index 75744a8227f..234438460d6 100644 --- a/src/tools/wasm-emscripten-finalize.cpp +++ b/src/tools/wasm-emscripten-finalize.cpp @@ -241,8 +241,12 @@ int main(int argc, const char* argv[]) { wasm.addExport(ex); initializerFunctions.push_back(F->name); } - if (auto* e = wasm.getExportOrNull(WASM_CALL_CTORS)) { - initializerFunctions.push_back(e->name); + // Costructors get called from crt1 in wasm standalone mode. + // Unless there is no entry point. + if (!standaloneWasm || !wasm.getExportOrNull("_start")) { + if (auto* e = wasm.getExportOrNull(WASM_CALL_CTORS)) { + initializerFunctions.push_back(e->name); + } } }