diff --git a/llvm/lib/CheerpUtils/CallConstructors.cpp b/llvm/lib/CheerpUtils/CallConstructors.cpp index d8dc52da93d6..373689a77892 100644 --- a/llvm/lib/CheerpUtils/CallConstructors.cpp +++ b/llvm/lib/CheerpUtils/CallConstructors.cpp @@ -43,8 +43,13 @@ PreservedAnalyses CallConstructorsPass::run(llvm::Module &M, llvm::ModuleAnalysi Function* memoryInit = cast(M.getOrInsertFunction("__memory_init", Ty).getCallee()); memoryInit->setSection("asmjs"); Builder.CreateCall(Ty, memoryInit); + } + Function* GetEnviron = M.getFunction("__syscall_main_environ"); + if (GetEnviron) + Builder.CreateCall(GetEnviron->getFunctionType(), GetEnviron); + for (Constant* C: cheerp::getGlobalConstructors(M)) { Builder.CreateCall(Ty, cast(C->getAggregateElement(1)));