[packages/golang] up to 1.6

glen glen at pld-linux.org
Tue Apr 5 15:38:11 CEST 2016


commit c1200160820dc6fdc3015e12eba3b7064ce1923c
Author: Elan Ruusamäe <glen at delfi.ee>
Date:   Tue Apr 5 15:13:09 2016 +0300

    up to 1.6
    
    builds, and resulting package is able to build this package again
    
    compiler rewritten in go, requires go 1.4+ to compile
    added patches from fedora

 ca-certs.patch                         |  20 +++---
 go1.5-zoneinfo_testing_only.patch      |  23 +++++++
 go1.5beta1-disable-TestGdbPython.patch |  15 +++++
 golang-1.2-verbose-build.patch         |  19 ++++++
 golang.spec                            | 108 ++++++++++++++++++++++++++-------
 mmap-cgo-stackalign.patch              |  45 ++++++++++++++
 6 files changed, 197 insertions(+), 33 deletions(-)
---
diff --git a/golang.spec b/golang.spec
index 30d1b3c..05baed0 100644
--- a/golang.spec
+++ b/golang.spec
@@ -6,28 +6,49 @@
 # - check if hg use at build time can be dropped
 # - build all target archs, subpackage them: http://golang.org/doc/install/source#environment
 # - subpackage -src files?
+# - subpackage for "shared"?
 
 # Conditional build:
-%bcond_without	tests	# build without tests [nop actually]
-%bcond_without	verbose	# verbose build (V=1)
+%bcond_without	verbose		# verbose build (V=1)
+%bcond_without	tests		# build without tests [nop actually]
+%bcond_without	shared		# Build golang shared objects for stdlib
+%bcond_without	ext_linker	# Build golang using external/internal(close to cgo disabled) linking.
+
+%ifnarch %{ix86} %{x8664} %{arm} ppc64le aarch64
+%undefine	with_shared
+%undefine	with_ext_linker
+%endif
 
 Summary:	Go compiler and tools
 Summary(pl.UTF-8):	Kompilator języka Go i narzędzia
 Name:		golang
-Version:	1.4.3
-Release:	1
-License:	BSD
+Version:	1.6
+Release:	0.2
+# source tree includes several copies of Mark.Twain-Tom.Sawyer.txt under Public Domain
+License:	BSD and Public Domain
 Group:		Development/Languages
 # Source0Download: https://golang.org/dl/
 Source0:	https://storage.googleapis.com/golang/go%{version}.src.tar.gz
-# Source0-md5:	dfb604511115dd402a77a553a5923a04
+# Source0-md5:	e67833ea37fbc002fbe38efe6c1bcd98
 Patch0:		ca-certs.patch
 Patch1:		%{name}-binutils.patch
+Patch2:		%{name}-1.2-verbose-build.patch
+Patch3:		mmap-cgo-stackalign.patch
+Patch4:		go1.5beta1-disable-TestGdbPython.patch
+Patch5:		go1.5-zoneinfo_testing_only.patch
 URL:		http://golang.org/
 BuildRequires:	bash
 BuildRequires:	rpm-pythonprov
+# The compiler is written in Go. Needs go(1.4+) compiler for build.
+%if %{with bootstrap}
+BuildRequires:	gcc-go >= 6:5
+%else
+BuildRequires:	golang >= 1.4
+%endif
 %if %{with tests}
+BuildRequires:	glibc-static
 BuildRequires:	hostname
+BuildRequires:	pcre-devel
 BuildRequires:	tzdata
 %endif
 Requires:	ca-certificates
@@ -40,6 +61,8 @@ BuildRoot:	%{tmpdir}/%{name}-%{version}-root-%(id -u -n)
 %define		_enable_debug_packages	0
 %define		_noautoreqfiles		%{_libdir}/%{name}/src
 
+%define	goroot %{_libdir}/%{name}
+
 %ifarch %{ix86}
 %define	GOARCH 386
 %endif
@@ -81,48 +104,79 @@ Dokumentacja do go.
 %setup -qc
 mv go/* .
 %patch0 -p1
-%patch1 -p1
+#%patch1 -p1 seems outdated, compiler rewritten in .go instead of .c
+%patch2 -p1
+%patch3 -p1
+%patch4 -p1
+%patch5 -p1
 
 cat > env.sh <<'EOF'
-export GOROOT=$(pwd)
-export GOROOT_FINAL=%{_libdir}/%{name}
+# bootstrap compiler GOROOT
+%if %{with bootstrap}
+export GOROOT_BOOTSTRAP=%{_prefix}
+%else
+export GOROOT_BOOTSTRAP=%{goroot}
+%endif
+export GOROOT_FINAL=%{goroot}
+
+export GOHOSTOS=linux
+export GOHOSTARCH=%{GOARCH}
 
 export GOOS=linux
-export GOBIN=$GOROOT/bin
 export GOARCH=%{GOARCH}
-export GOROOT_FINAL
-export MAKE="%{__make}"
+%if %{without external_linker}
+export GO_LDFLAGS="-linkmode internal"
+%endif
+%if %{without cgo_enabled}
+export CGO_ENABLED=0
+%endif
+
+# use our gcc options for this build, but store gcc as default for compiler
+export CFLAGS="%{rpmcflags}"
+export LDFLAGS="%{rpmldflags}"
+
 CC="%{__cc}"
 export CC="${CC#ccache }"
-
-export PATH="$PATH:$GOBIN"
+export CC_FOR_TARGET="$CC"
 EOF
 
-install -d bin
-
+%if 0
 # optflags for go tools build
 nflags="\"$(echo '%{rpmcflags}' | sed -e 's/^[ 	]*//;s/[ 	]*$//;s/[ 	]\+/ /g' -e 's/ /\",\"/g')\""
 %{__sed} -i -e "s/\"-O2\"/$nflags/" src/cmd/dist/build.c
 # NOTE: optflags used in gcc calls from go compiler are in src/cmd/go/build.go
+%endif
 
 %build
 . ./env.sh
-
 cd src
-./all.bash
+./make.bash --no-clean
+cd ..
+
+# build shared std lib
+%if %{with shared}
+GOROOT=$(pwd) PATH=$(pwd)/bin:$PATH go install -buildmode=shared std
+%endif
 
 %install
 rm -rf $RPM_BUILD_ROOT
-GOROOT=$RPM_BUILD_ROOT%{_libdir}/%{name}
+GOROOT=$RPM_BUILD_ROOT%{goroot}
 
 install -d $GOROOT/{misc,lib,src}
 install -d $RPM_BUILD_ROOT%{_bindir}
 
-cp -a pkg include lib bin src $GOROOT
+cp -a pkg lib bin src VERSION $GOROOT
 cp -a misc/cgo $GOROOT/misc
+
 # kill Win32 and Plan9 scripts
 find $GOROOT -name '*.bat' -o -name '*.rc' | xargs %{__rm}
 
+# https://github.com/golang/go/issues/4749
+find $GOROOT/src | xargs touch -r $GOROOT/VERSION
+# and level out all the built archives
+touch $GOROOT/pkg
+find $GOROOT/pkg | xargs touch -r $GOROOT/pkg
+
 ln -sf %{_libdir}/%{name}/bin/go $RPM_BUILD_ROOT%{_bindir}/go
 ln -sf %{_libdir}/%{name}/bin/godoc $RPM_BUILD_ROOT%{_bindir}/godoc
 ln -sf %{_libdir}/%{name}/bin/gofmt $RPM_BUILD_ROOT%{_bindir}/gofmt
@@ -148,7 +202,7 @@ rm -rf $RPM_BUILD_ROOT
 
 %files
 %defattr(644,root,root,755)
-%doc AUTHORS CONTRIBUTORS LICENSE README
+%doc AUTHORS CONTRIBUTORS LICENSE
 %ifarch %{arm}
 %attr(755,root,root) %{_bindir}/5a
 %attr(755,root,root) %{_bindir}/5c
@@ -173,10 +227,10 @@ rm -rf $RPM_BUILD_ROOT
 %attr(755,root,root) %{_bindir}/godoc
 %attr(755,root,root) %{_bindir}/gofmt
 %dir %{_libdir}/%{name}
+%{_libdir}/%{name}/VERSION
 %dir %{_libdir}/%{name}/bin
 %attr(755,root,root) %{_libdir}/%{name}/bin/*
 
-%{_libdir}/%{name}/include
 %{_libdir}/%{name}/lib
 %{_libdir}/%{name}/misc
 %{_libdir}/%{name}/src
@@ -187,7 +241,15 @@ rm -rf $RPM_BUILD_ROOT
 %dir %{_libdir}/%{name}/pkg/tool/linux_%{GOARCH}
 %attr(755,root,root) %{_libdir}/%{name}/pkg/tool/linux_%{GOARCH}/*
 
-%ifarch %{x8664}
+%{_libdir}/%{name}/pkg/bootstrap
+%{_libdir}/%{name}/pkg/include
+
+%if %{with shared}
+%{_libdir}/%{name}/pkg/linux_%{GOARCH}_dynlink
+%endif
+
+%if 0
+#ifarch %{x8664}
 %dir %{_libdir}/%{name}/pkg/linux_%{GOARCH}_race
 %{_libdir}/%{name}/pkg/linux_%{GOARCH}_race/*.a
 %{_libdir}/%{name}/pkg/linux_%{GOARCH}_race/compress
diff --git a/ca-certs.patch b/ca-certs.patch
index f17393c..78ddd54 100644
--- a/ca-certs.patch
+++ b/ca-certs.patch
@@ -1,10 +1,10 @@
---- golang-1.4.2/src/crypto/x509/root_unix.go~	2015-05-21 11:15:20.000000000 +0300
-+++ golang-1.4.2/src/crypto/x509/root_unix.go	2015-05-21 11:15:26.427510756 +0300
-@@ -10,6 +10,7 @@
- 
- // Possible certificate files; stop after finding one.
- var certFiles = []string{
-+	"/etc/certs/ca-certificates.crt",         // PLD Linux
- 	"/etc/ssl/certs/ca-certificates.crt",     // Debian/Ubuntu/Gentoo etc.
- 	"/etc/pki/tls/certs/ca-bundle.crt",       // Fedora/RHEL
- 	"/etc/ssl/ca-bundle.pem",                 // OpenSUSE
+--- golang-1.6/src/crypto/x509/root_unix.go~	2016-02-17 22:35:21.000000000 +0200
++++ golang-1.6/src/crypto/x509/root_unix.go	2016-04-05 13:04:44.231441583 +0300
+@@ -11,6 +11,7 @@
+ // Possible directories with certificate files; stop after successfully
+ // reading at least one file from a directory.
+ var certDirectories = []string{
++	"/etc/openssl/certs",           // PLD Linux
+ 	"/etc/ssl/certs",               // SLES10/SLES11, https://golang.org/issue/12139
+ 	"/system/etc/security/cacerts", // Android
+ }
diff --git a/go1.5-zoneinfo_testing_only.patch b/go1.5-zoneinfo_testing_only.patch
new file mode 100644
index 0000000..35c7d08
--- /dev/null
+++ b/go1.5-zoneinfo_testing_only.patch
@@ -0,0 +1,23 @@
+# we had been just removing the zoneinfo.zip, but that caused tests to fail for users that
+# later run `go test -a std`. This makes it only use the zoneinfo.zip where needed in tests.
+diff --git a/src/time/zoneinfo_unix.go b/src/time/zoneinfo_unix.go
+index ed9502d..c2569e7 100644
+--- a/src/time/zoneinfo_unix.go
++++ b/src/time/zoneinfo_unix.go
+@@ -32,14 +32,14 @@ var zoneDirs = []string{
+ 	"/usr/share/zoneinfo/",
+ 	"/usr/share/lib/zoneinfo/",
+ 	"/usr/lib/locale/TZ/",
+-	runtime.GOROOT() + "/lib/time/zoneinfo.zip",
+ }
+ 
+ var origZoneDirs = zoneDirs
+ 
+ func forceZipFileForTesting(zipOnly bool) {
+-	zoneDirs = make([]string, len(origZoneDirs))
++	zoneDirs = make([]string, len(origZoneDirs)+1)
+ 	copy(zoneDirs, origZoneDirs)
++	zoneDirs = append(zoneDirs, runtime.GOROOT()+"/lib/time/zoneinfo.zip")
+ 	if zipOnly {
+ 		for i := 0; i < len(zoneDirs)-1; i++ {
+ 			zoneDirs[i] = "/XXXNOEXIST"
diff --git a/go1.5beta1-disable-TestGdbPython.patch b/go1.5beta1-disable-TestGdbPython.patch
new file mode 100644
index 0000000..29f3ea8
--- /dev/null
+++ b/go1.5beta1-disable-TestGdbPython.patch
@@ -0,0 +1,15 @@
+# disable TestGdbPython
+# https://github.com/golang/go/issues/11214
+diff --git a/src/runtime/runtime-gdb_test.go b/src/runtime/runtime-gdb_test.go
+index f4014b2..2c09441 100644
+--- a/src/runtime/runtime-gdb_test.go
++++ b/src/runtime/runtime-gdb_test.go
+@@ -38,7 +38,7 @@ func main() {
+ }
+ `
+ 
+-func TestGdbPython(t *testing.T) {
++func testGdbPython(t *testing.T) {
+ 	if runtime.GOOS == "darwin" {
+ 		t.Skip("gdb does not work on darwin")
+ 	}
diff --git a/golang-1.2-verbose-build.patch b/golang-1.2-verbose-build.patch
new file mode 100644
index 0000000..e9c5edf
--- /dev/null
+++ b/golang-1.2-verbose-build.patch
@@ -0,0 +1,19 @@
+Index: go/src/make.bash
+===================================================================
+--- go.orig/src/make.bash
++++ go/src/make.bash
+@@ -153,12 +153,12 @@ if [ "$GOHOSTARCH" != "$GOARCH" -o "$GOHOSTOS" != "$GOOS" ]; then
+ 	# CC_FOR_TARGET is recorded as the default compiler for the go tool. When building for the host, however,
+ 	# use the host compiler, CC, from `cmd/dist/dist env` instead.
+ 	CC=$CC GOOS=$GOHOSTOS GOARCH=$GOHOSTARCH \
+-		"$GOTOOLDIR"/go_bootstrap install -gcflags "$GO_GCFLAGS" -ldflags "$GO_LDFLAGS" -v std cmd
++		"$GOTOOLDIR"/go_bootstrap install -gcflags "$GO_GCFLAGS" -ldflags "$GO_LDFLAGS" -v -x std cmd
+ 	echo
+ fi
+ 
+ echo "##### Building packages and commands for $GOOS/$GOARCH."
+-CC=$CC_FOR_TARGET "$GOTOOLDIR"/go_bootstrap install $GO_FLAGS -gcflags "$GO_GCFLAGS" -ldflags "$GO_LDFLAGS" -v std cmd
++CC=$CC_FOR_TARGET "$GOTOOLDIR"/go_bootstrap install $GO_FLAGS -gcflags "$GO_GCFLAGS" -ldflags "$GO_LDFLAGS" -v -x std cmd
+ echo
+ 
+ rm -f "$GOTOOLDIR"/go_bootstrap
diff --git a/mmap-cgo-stackalign.patch b/mmap-cgo-stackalign.patch
new file mode 100644
index 0000000..4f7f263
--- /dev/null
+++ b/mmap-cgo-stackalign.patch
@@ -0,0 +1,45 @@
+# Resolves https://bugzilla.redhat.com/show_bug.cgi?id=1304591
+# https://github.com/golang/go/issues/14384
+From 315f4c70f123cfbf061d097543af555547acd9c7 Mon Sep 17 00:00:00 2001
+From: Shenghou Ma <minux at golang.org>
+Date: Thu, 18 Feb 2016 16:29:39 -0500
+Subject: [PATCH] runtime: use correct psABI SP alignment before calling libc
+ mmap
+
+Fixes #14384.
+
+Change-Id: Ib025cf2d20754b4c2db52f0a8a4717fd303371d6
+Reviewed-on: https://go-review.googlesource.com/19660
+Run-TryBot: Minux Ma <minux at golang.org>
+TryBot-Result: Gobot Gobot <gobot at golang.org>
+Reviewed-by: Ian Lance Taylor <iant at golang.org>
+Reviewed-by: Austin Clements <austin at google.com>
+---
+ src/runtime/sys_linux_amd64.s | 6 +++++-
+ 1 file changed, 5 insertions(+), 1 deletion(-)
+
+diff --git a/src/runtime/sys_linux_amd64.s b/src/runtime/sys_linux_amd64.s
+index aed85cb..f407078 100644
+--- a/src/runtime/sys_linux_amd64.s
++++ b/src/runtime/sys_linux_amd64.s
+@@ -258,7 +258,7 @@ TEXT runtime·sysMmap(SB),NOSPLIT,$0
+ 
+ // Call the function stored in _cgo_mmap using the GCC calling convention.
+ // This must be called on the system stack.
+-TEXT runtime·callCgoMmap(SB),NOSPLIT,$0
++TEXT runtime·callCgoMmap(SB),NOSPLIT,$16
+ 	MOVQ	addr+0(FP), DI
+ 	MOVQ	n+8(FP), SI
+ 	MOVL	prot+16(FP), DX
+@@ -266,7 +266,11 @@ TEXT runtime·callCgoMmap(SB),NOSPLIT,$0
+ 	MOVL	fd+24(FP), R8
+ 	MOVL	off+28(FP), R9
+ 	MOVQ	_cgo_mmap(SB), AX
++	MOVQ	SP, BX
++	ANDQ	$~15, SP	// alignment as per amd64 psABI
++	MOVQ	BX, 0(SP)
+ 	CALL	AX
++	MOVQ	0(SP), SP
+ 	MOVQ	AX, ret+32(FP)
+ 	RET
+ 
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/packages/golang.git/commitdiff/c1200160820dc6fdc3015e12eba3b7064ce1923c



More information about the pld-cvs-commit mailing list