mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-13 15:33:40 +00:00
compiler: remove unnecessary main.main call workaround
Since https://github.com/tinygo-org/tinygo/pull/1571 (in particular, the first commit that sets the main package path), the main package is always named "main". This makes the callMain() workaround in the runtime unnecessary and allows directly calling the main.main function with a //go:linkname pragma.
This commit is contained in:
committed by
Ron Evans
parent
32a5d46c57
commit
92ed645a11
@@ -297,14 +297,6 @@ func CompileProgram(pkgName string, lprogram *loader.Program, machine llvm.Targe
|
||||
}
|
||||
irbuilder.CreateRetVoid()
|
||||
|
||||
// Conserve for goroutine lowering. Without marking these as external, they
|
||||
// would be optimized away.
|
||||
realMain := c.mod.NamedFunction(lprogram.MainPkg().Pkg.Path() + ".main")
|
||||
realMain.SetLinkage(llvm.ExternalLinkage) // keep alive until goroutine lowering
|
||||
|
||||
// Replace callMain placeholder with actual main function.
|
||||
c.mod.NamedFunction("runtime.callMain").ReplaceAllUsesWith(realMain)
|
||||
|
||||
// Load some attributes
|
||||
getAttr := func(attrName string) llvm.Attribute {
|
||||
attrKind := llvm.AttributeKindID(attrName)
|
||||
|
||||
Reference in New Issue
Block a user