all: allow -O0 optimization level

This commit is contained in:
Ayke van Laethem
2018-09-24 16:17:42 +02:00
parent 6191d4e1ac
commit c9ae72a105
2 changed files with 25 additions and 32 deletions
+17 -20
View File
@@ -10,14 +10,18 @@ const Compiler = "tgo"
// package.
func initAll()
// These signatures are used to call the correct main function: with scheduling
// or without scheduling.
func main_main()
func main_mainAsync(parent *coroutine) *coroutine
// The compiler will change this to true if there are 'go' statements in the
// compiled program and turn it into a const.
var hasScheduler bool
// The compiler will insert the call to main.main() here, depending on whether
// the scheduler is necessary.
//
// Without scheduler:
//
// main.main()
//
// With scheduler:
//
// coroutine := main.main(nil)
// scheduler(coroutine)
func mainWrapper()
// Entry point for Go. Initialize all packages and call main.main().
//go:export main
@@ -31,18 +35,11 @@ func main() int {
// Enable interrupts etc.
postinit()
// This branch must be optimized away. Only one of the targets must remain,
// or there will be link errors.
if hasScheduler {
// Initialize main and run the scheduler.
coro := main_mainAsync(nil)
scheduler(coro)
return 0
} else {
// No scheduler is necessary. Call main directly.
main_main()
return 0
}
// Compiler-generated wrapper to main.main().
mainWrapper()
// For libc compatibility.
return 0
}
func GOMAXPROCS(n int) int {