From 949ae8cced70fdd06cdd220e1e06467bb332d91c Mon Sep 17 00:00:00 2001 From: Dave Cheney Date: Wed, 3 Apr 2013 19:13:37 +1100 Subject: [PATCH] go/build: disable cgo when cross compiling Fixes #5141. R=golang-dev, minux.ma, ality, bradfitz CC=golang-dev https://golang.org/cl/8134043 --- src/pkg/go/build/build.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/pkg/go/build/build.go b/src/pkg/go/build/build.go index dc3669c1df..cc89afb218 100644 --- a/src/pkg/go/build/build.go +++ b/src/pkg/go/build/build.go @@ -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