From 3babdfdc009dbd3bdc2077137f17b299b5428aca Mon Sep 17 00:00:00 2001 From: Ayke van Laethem Date: Fri, 19 Oct 2018 17:39:41 +0200 Subject: [PATCH] compiler: fix runtime.mainWrapper linkage and debug info --- compiler/compiler.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/compiler/compiler.go b/compiler/compiler.go index 1216d6cf..7000d0dd 100644 --- a/compiler/compiler.go +++ b/compiler/compiler.go @@ -378,8 +378,15 @@ func (c *Compiler) Compile(mainPath string) error { } c.builder.CreateRetVoid() - mainWrapper := c.mod.NamedFunction("runtime.mainWrapper") - block = c.ctx.AddBasicBlock(mainWrapper, "entry") + mainWrapper := c.ir.GetFunction(c.ir.Program.ImportedPackage("runtime").Members["mainWrapper"].(*ssa.Function)) + mainWrapper.LLVMFn.SetLinkage(llvm.InternalLinkage) + difunc, err = c.attachDebugInfo(mainWrapper) + if err != nil { + return err + } + pos = c.ir.Program.Fset.Position(mainWrapper.Pos()) + c.builder.SetCurrentDebugLocation(uint(pos.Line), uint(pos.Column), difunc, llvm.Metadata{}) + block = c.ctx.AddBasicBlock(mainWrapper.LLVMFn, "entry") c.builder.SetInsertPointAtEnd(block) realMain := c.mod.NamedFunction(c.ir.MainPkg().Pkg.Path() + ".main") if c.ir.NeedsScheduler() {