[Docker-maint] Bug#776401: src:golang: Set CGO_ENABLED for all platforms

Hilko Bengen bengen at debian.org
Tue Jan 27 16:51:40 UTC 2015


Package: src:golang
Severity: wishlist
Version: 2:1.3.3-1
Tags: patch

Apparently, it is possible to build a CGO-enabled Golang cross compiler
on all platforms if CGO_ENABLED=1 is set at build-time. I have
successfully built Windows executables that use fopen(), fread()
functions from the C standard library using something like:

$ CC=i686-w64-mingw32-gcc CGO_ENABLED=1 GOOS=windows GOARCH=i386 go build ...

Please consider adding the simple patch attached below.

(I am still trying to figure out if there's a way to set a
GOARCH/GOOS-specific sensible default for CC, CXX.)

Cheers,
-Hilko

diff --git a/debian/rules b/debian/rules
index d73e90f..642b9c0 100755
--- a/debian/rules
+++ b/debian/rules
@@ -116,6 +116,7 @@ debian/build.stamp:
	-${FOR_GO_ARCH} \
		export GOARCH=$$arch; \
		export GOOS=$$os; \
+	       export CGO_ENABLED=1; \
		cd src && bash ./make.bash --no-clean; \
		[ "$$arch" = "amd64" ] && [ "$$os" = "linux" ] && $(GOBIN)/go install -race std; \
		cd ..; \




More information about the Docker-maint mailing list