cmd/cgo: improve gccgo support

Use wrapper functions to tell scheduler what we are doing.

With this patch, and a separate patch to the go tool, all the
cgo tests pass with gccgo.

R=golang-dev, rsc
CC=golang-dev
https://golang.org/cl/6812058
This commit is contained in:
Ian Lance Taylor 2012-11-01 11:21:30 -07:00
parent f284a3ff4d
commit 3b04d23cbf
2 changed files with 198 additions and 68 deletions

View file

@ -644,7 +644,14 @@ func (p *Package) rewriteRef(f *File) {
n.Kind = "var"
}
if n.Mangle == "" {
n.Mangle = "_C" + n.Kind + "_" + n.Go
// When using gccgo variables have to be
// exported so that they become global symbols
// that the C code can refer to.
prefix := "_C"
if *gccgo && n.Kind == "var" {
prefix = "C"
}
n.Mangle = prefix + n.Kind + "_" + n.Go
}
}