go/build: disable cgo when cross compiling

Fixes #5141.

R=golang-dev, minux.ma, ality, bradfitz
CC=golang-dev
https://golang.org/cl/8134043
This commit is contained in:
Dave Cheney 2013-04-03 19:13:37 +11:00
parent 4b6ca21271
commit 949ae8cced

View File

@ -301,7 +301,13 @@ func defaultContext() Context {
case "0":
c.CgoEnabled = false
default:
c.CgoEnabled = cgoEnabled[c.GOOS+"/"+c.GOARCH]
// golang.org/issue/5141
// cgo should be disabled for cross compilation builds
if runtime.GOARCH == c.GOARCH && runtime.GOOS == c.GOOS {
c.CgoEnabled = cgoEnabled[c.GOOS+"/"+c.GOARCH]
break
}
c.CgoEnabled = false
}
return c