From 4a16e81fef929db91acf353dde8b87c3aa0d9c0c Mon Sep 17 00:00:00 2001 From: Mark Haines Date: Wed, 28 Jun 2017 17:58:36 +0100 Subject: [PATCH] Treat CGO_ENABLED="0" the same as cross-compiling. This means that explicitly disabling cgo using CGO_ENABLED="0" in order to get a static binary will work even when the libraries in GOROOT have been compiled with cgo enabled. Otherwise it looks like gb will use the packages built with cgo in GOROOT even when cgo has been disabled. --- context.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/context.go b/context.go index e62ca99..b3ad475 100644 --- a/context.go +++ b/context.go @@ -364,7 +364,7 @@ func (s *Statistics) String() string { } func (c *Context) isCrossCompile() bool { - return c.gohostos != c.gotargetos || c.gohostarch != c.gotargetarch + return c.gohostos != c.gotargetos || c.gohostarch != c.gotargetarch || os.Getenv("CGO_ENABLED") == "0" } // envForDir returns a copy of the environment