[pkg-golang-devel] Bug#828982: golang-1.6: fix cross build and add mips64/mips64el support

YunQiang Su wzssyqa at gmail.com
Wed Jun 29 14:23:03 UTC 2016


Package: src:golang-1.6

With the attached patch, and installing gcc-6-<triplet>,
we can cross build golang-1.6 with
    dpkg-buildpackage -a<arch> -d

Thus, we can bootstrap golang for mips64 and mips64el.

There are 2 tests fails on mips64el, I will try to fix them.

Note: you will need to link <triplet>-gcc-6 to <triplet>-gcc manually.

-- 
YunQiang Su
-------------- next part --------------
diff -ur golang-1.6-1.6.2/debian/control xxx/debian/control
--- golang-1.6-1.6.2/debian/control	2016-06-24 03:00:54.000000000 +0000
+++ xxx/debian/control	2016-06-29 13:58:30.330252866 +0000
@@ -19,7 +19,7 @@
 Homepage: https://golang.org
 
 Package: golang-1.6-go
-Architecture: amd64 arm64 armel armhf i386 ppc64 ppc64el
+Architecture: amd64 arm64 armel armhf i386 ppc64 ppc64el mips64 mips64el
 Depends: golang-1.6-src (>= ${source:Version}),
          ${misc:Depends},
          ${perl:Depends},
@@ -43,7 +43,7 @@
  pre-compile the standard library inside GOROOT for cross-compilation to work.
 
 Package: golang-1.6-src
-Architecture: amd64 arm64 armel armhf i386 ppc64 ppc64el
+Architecture: amd64 arm64 armel armhf i386 ppc64 ppc64el mips64 mips64el
 Depends: ${misc:Depends}, ${shlibs:Depends}
 Description: Go programming language - source files
  The Go programming language is an open source project to make programmers more
diff -ur golang-1.6-1.6.2/debian/control.in xxx/debian/control.in
--- golang-1.6-1.6.2/debian/control.in	2016-06-24 03:00:54.000000000 +0000
+++ xxx/debian/control.in	2016-06-29 11:59:18.301996282 +0000
@@ -15,7 +15,7 @@
 Homepage: https://golang.org
 
 Package: golang-X.Y-go
-Architecture: amd64 arm64 armel armhf i386 ppc64 ppc64el
+Architecture: amd64 arm64 armel armhf i386 ppc64 ppc64el mips64 mips64el
 Depends: golang-X.Y-src (>= ${source:Version}),
          ${misc:Depends},
          ${perl:Depends},
@@ -39,7 +39,7 @@
  pre-compile the standard library inside GOROOT for cross-compilation to work.
 
 Package: golang-X.Y-src
-Architecture: amd64 arm64 armel armhf i386 ppc64 ppc64el
+Architecture: amd64 arm64 armel armhf i386 ppc64 ppc64el mips64 mips64el
 Depends: ${misc:Depends}, ${shlibs:Depends}
 Description: Go programming language - source files
  The Go programming language is an open source project to make programmers more
diff -ur golang-1.6-1.6.2/debian/golang-X.Y-go.install xxx/debian/golang-X.Y-go.install
--- golang-1.6-1.6.2/debian/golang-X.Y-go.install	2016-06-01 14:07:31.000000000 +0000
+++ xxx/debian/golang-X.Y-go.install	2016-06-29 13:03:52.253257140 +0000
@@ -1,7 +1,7 @@
 VERSION /usr/lib/go-X.Y/
-bin/go /usr/lib/go-X.Y/bin/
-bin/gofmt /usr/lib/go-X.Y/bin/
-pkg/*_* /usr/lib/go-X.Y/pkg/
+bin/@OS_ARCH_BIN@/go /usr/lib/go-X.Y/bin/
+bin/@OS_ARCH_BIN@/gofmt /usr/lib/go-X.Y/bin/
+pkg/@OS_ARCH@ /usr/lib/go-X.Y/pkg/
 pkg/include /usr/share/go-X.Y/pkg/
 pkg/obj /usr/lib/go-X.Y/pkg/
-pkg/tool /usr/lib/go-X.Y/pkg/
+pkg/tool/@OS_ARCH@ /usr/lib/go-X.Y/pkg/tool/
diff -ur golang-1.6-1.6.2/debian/helpers/goenv.sh xxx/debian/helpers/goenv.sh
--- golang-1.6-1.6.2/debian/helpers/goenv.sh	2016-02-24 06:06:05.000000000 +0000
+++ xxx/debian/helpers/goenv.sh	2016-06-29 11:59:18.311996406 +0000
@@ -31,6 +31,9 @@
 export GOHOSTARCH="$(__goarch__deb_arch_cpu "$(dpkg-architecture -qDEB_BUILD_ARCH_CPU 2>/dev/null)")"
 export GOARCH="$(__goarch__deb_arch_cpu "$(dpkg-architecture -qDEB_HOST_ARCH_CPU 2>/dev/null)")"
 
+export CC_FOR_TARGET=$(dpkg-architecture -qDEB_HOST_GNU_TYPE 2>/dev/null)-gcc
+
+
 if [ -z "$GOHOSTOS" -o -z "$GOOS" -o -z "$GOHOSTARCH" -o -z "$GOARCH" ]; then
 	exit 1
 fi
diff -ur golang-1.6-1.6.2/debian/rules xxx/debian/rules
--- golang-1.6-1.6.2/debian/rules	2016-06-01 14:07:31.000000000 +0000
+++ xxx/debian/rules	2016-06-29 13:28:20.567148998 +0000
@@ -8,8 +8,10 @@
 export GOROOT_FINAL := /usr/lib/go-$(GOVER)
 
 DEB_HOST_ARCH_CPU := $(shell dpkg-architecture -qDEB_HOST_ARCH_CPU 2>/dev/null)
+DEB_HOST_GNU_TYPE := $(shell dpkg-architecture -qDEB_HOST_GNU_TYPE 2>/dev/null)
+DEB_BUILD_GNU_TYPE := $(shell dpkg-architecture -qDEB_BUILD_GNU_TYPE 2>/dev/null)
 RUN_TESTS := true
-ifeq (ppc64, $(DEB_HOST_ARCH_CPU))
+ifneq (,$(filter ppc64 mips64 mips64el, $(DEB_HOST_ARCH_CPU)))
 	RUN_TESTS := false
 endif
 ifneq (,$(findstring nocheck,$(DEB_BUILD_OPTIONS)))
@@ -41,13 +43,22 @@
 		rm -f -v golang-$(GOVER)-$${x##golang-X.Y-}; \
 	done
 
+
+ifneq ($(DEB_HOST_GNU_TYPE), $(DEB_BUILD_GNU_TYPE))
+  OS_ARCH_BIN=$${GOOS}_$${GOARCH}
+else
+  OS_ARCH_BIN=
+endif
 override_dh_prep:
 	dh_prep
-	@set -e; cd debian; for x in golang-X.Y-*; do \
-		sed -e 's/X.Y/$(GOVER)/g' $$x > golang-$(GOVER)-$${x##golang-X.Y-}; \
+	set -e; cd debian; for x in golang-X.Y-*; do \
+		echo 'sed -e "s/X.Y/$(GOVER)/g" -e "s/@OS_ARCH@/$${GOOS}_$${GOARCH}/g" -e "s/@OS_ARCH_BIN@/$(OS_ARCH_BIN)/g"' $$x > sed-version.sh; \
+		chmod +x sed-version.sh; \
+		$(CURDIR)/debian/helpers/goenv.sh \
+		./sed-version.sh > golang-$(GOVER)-$${x##golang-X.Y-}; \
+		rm -f sed-version.sh; \
 	done
 
-
 override_dh_auto_test-arch:
 ifeq (true, $(RUN_TESTS))
 	set -ex; \


More information about the pkg-golang-devel mailing list