Skip to content

compiler: remove unnecessary main.main call workaround #1592

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jan 24, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions compiler/compiler.go
Original file line number Diff line number Diff line change
@@ -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)
3 changes: 1 addition & 2 deletions src/runtime/runtime.go
Original file line number Diff line number Diff line change
@@ -10,8 +10,7 @@ const Compiler = "tinygo"
// package.
func initAll()

// callMain is a placeholder for the program main function.
// All references to this are replaced with references to the program main function by the compiler.
//go:linkname callMain main.main
func callMain()

func GOMAXPROCS(n int) int {