This libgo patch by Cherry Zhang works around some escaping code in runtime/export_test.go. When compiling the runtime, local variables and closures may not be heap allocated. In one test, there is a go statement with a closure. In the gc compiler, it distinguishes capturing variable by value vs. by address, and rewrites it to passing the captured values as arguments. Currently we don't have this in gccgo, and the escape analysis decides to heap allocate the closure and also the captured variables, which is not allowed. Work around it by passing the variables explicitly.
This is in preparation of turning on escape analysis for the runtime. Bootstrapped and ran Go testsuite on x86_64-pc-linux-gnu. Committed to mainline. Ian
Index: gcc/go/gofrontend/MERGE =================================================================== --- gcc/go/gofrontend/MERGE (revision 256418) +++ gcc/go/gofrontend/MERGE (working copy) @@ -1,4 +1,4 @@ -5cae6a4e0849a3586ee7ce9c915c1520a17db982 +c18c6bd80e0995827ad3396eb1c2401451de88fd The first line of this file holds the git revision number of the last merge done from the gofrontend repository. Index: libgo/go/runtime/export_test.go =================================================================== --- libgo/go/runtime/export_test.go (revision 256366) +++ libgo/go/runtime/export_test.go (working copy) @@ -123,15 +123,15 @@ func RunSchedLocalQueueEmptyTest(iters i // can lead to underutilization (both runnable Gs and idle Ps coexist // for arbitrary long time). done := make(chan bool, 1) - p := new(p) + _p_ := new(p) gs := make([]g, 2) ready := new(uint32) for i := 0; i < iters; i++ { *ready = 0 next0 := (i & 1) == 0 next1 := (i & 2) == 0 - runqput(p, &gs[0], next0) - go func() { + runqput(_p_, &gs[0], next0) + go func(done chan bool, p *p, ready *uint32, next0, next1 bool) { for atomic.Xadd(ready, 1); atomic.Load(ready) != 2; { } if runqempty(p) { @@ -139,13 +139,13 @@ func RunSchedLocalQueueEmptyTest(iters i throw("queue is empty") } done <- true - }() + }(done, _p_, ready, next0, next1) for atomic.Xadd(ready, 1); atomic.Load(ready) != 2; { } - runqput(p, &gs[1], next1) - runqget(p) + runqput(_p_, &gs[1], next1) + runqget(_p_) <-done - runqget(p) + runqget(_p_) } }