Skip to content

Commit

Permalink
callconstructors: call environ init function if present
Browse files Browse the repository at this point in the history
  • Loading branch information
Hyxogen committed Jan 10, 2024
1 parent 0caba68 commit da47f30
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions llvm/lib/CheerpUtils/CallConstructors.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,13 @@ PreservedAnalyses CallConstructorsPass::run(llvm::Module &M, llvm::ModuleAnalysi
Function* memoryInit = cast<Function>(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<Function>(C->getAggregateElement(1)));
Expand Down

0 comments on commit da47f30

Please sign in to comment.