golang: Update to 1.18, update patch
authorJeffery To <jeffery.to@gmail.com>
Fri, 25 Mar 2022 19:46:25 +0000 (03:46 +0800)
committerRosen Penev <rosenp@gmail.com>
Tue, 29 Mar 2022 02:42:59 +0000 (19:42 -0700)
Signed-off-by: Jeffery To <jeffery.to@gmail.com>
lang/golang/golang-build.sh
lang/golang/golang-package.mk
lang/golang/golang-values.mk
lang/golang/golang/Makefile
lang/golang/golang/patches/001-cmd-link-use-gold-on-ARM-ARM64-only-if-gold-is-available.patch

index 5e40436bbe2bc1b205840906c21a246dc0f89c0e..e0e4ea637f1a3b1ca8031361011c222419392963 100644 (file)
@@ -56,7 +56,7 @@ configure() {
        if [ "$GO_INSTALL_ALL" != 1 ]; then
                code="$(printf '%s\n' "$files" | grep '\.\(c\|cc\|cpp\|go\|h\|hh\|hpp\|proto\|s\)$')"
                testdata="$(printf '%s\n' "$files" | grep '/testdata/')"
-               gomod="$(printf '%s\n' "$files" | grep '/go\.\(mod\|sum\)$')"
+               gomod="$(printf '%s\n' "$files" | grep '/go\.\(mod\|sum\|work\)$')"
 
                for pattern in $GO_INSTALL_EXTRA; do
                        extra="$(printf '%s\n' "$extra"; printf '%s\n' "$files" | grep -e "$pattern")"
index c4f4206834e4470917928fddeb33afa2ad89fec4..0fe3793f0911d0b681fdb06b80293165aa3de4f9 100644 (file)
@@ -32,7 +32,7 @@ include $(GO_INCLUDE_DIR)/golang-values.mk
 #
 #   * Files in any 'testdata' directory
 #
-#   * go.mod and go.sum, in any directory
+#   * go.mod, go.sum and go.work, in any directory
 #
 #   e.g. GO_PKG_INSTALL_EXTRA:=example.toml marshal_test.toml
 #
@@ -198,9 +198,11 @@ GO_PKG_TARGET_VARS= \
        GOOS="$(GO_OS)" \
        GOARCH="$(GO_ARCH)" \
        GO386="$(GO_386)" \
+       GOAMD64="$(GO_AMD64)" \
        GOARM="$(GO_ARM)" \
        GOMIPS="$(GO_MIPS)" \
        GOMIPS64="$(GO_MIPS64)" \
+       GOPPC64="$(GO_PPC64)" \
        CGO_ENABLED=1 \
        CC="$(TARGET_CC)" \
        CXX="$(TARGET_CXX)" \
index 34c9c1c654a30791661c0c31803fcf310911edf5..ef77c8d80e6c3a09edd8362675ff6bd49d531e4e 100644 (file)
@@ -29,7 +29,8 @@ unexport \
   GOOS \
   GOPATH \
   GOROOT \
-  GOTMPDIR
+  GOTMPDIR \
+  GOWORK
 # Unmodified:
 #   GOINSECURE
 #   GOPRIVATE
@@ -58,8 +59,10 @@ unexport \
 unexport \
   GOARM \
   GO386 \
+  GOAMD64 \
   GOMIPS \
   GOMIPS64 \
+  GOPPC64 \
   GOWASM
 
 # Special-purpose environment variables:
@@ -86,13 +89,12 @@ unexport \
 #   CC_FOR_${GOOS}_${GOARCH}
 #   CXX_FOR_${GOOS}_${GOARCH}
 
-# From https://golang.org/doc/install/source#environment
+# From https://go.dev/doc/install/source#environment
 unexport \
   GOHOSTOS \
-  GOHOSTARCH \
-  GOPPC64
+  GOHOSTARCH
 
-# From https://golang.org/src/make.bash
+# From https://go.dev/src/make.bash
 unexport \
   GO_GCFLAGS \
   GO_LDFLAGS \
@@ -101,16 +103,16 @@ unexport \
   GOBUILDTIMELOGFILE \
   GOROOT_BOOTSTRAP
 
-# From https://golang.org/doc/go1.9#parallel-compile
+# From https://go.dev/doc/go1.9#parallel-compile
 unexport \
   GO19CONCURRENTCOMPILATION
 
-# From https://golang.org/src/cmd/dist/build.go
+# From https://go.dev/src/cmd/dist/build.go
 unexport \
   BOOT_GO_GCFLAGS \
   BOOT_GO_LDFLAGS
 
-# From https://golang.org/src/cmd/dist/buildtool.go
+# From https://go.dev/src/cmd/dist/buildtool.go
 unexport \
   GOBOOTSTRAP_TOOLEXEC
 
@@ -152,6 +154,9 @@ ifeq ($(GO_ARCH),386)
   # -fno-plt: causes "unexpected GOT reloc for non-dynamic symbol" errors
   GO_CFLAGS_TO_REMOVE:=-fno-plt
 
+else ifeq ($(GO_ARCH),amd64)
+  GO_AMD64:=v1
+
 else ifeq ($(GO_ARCH),arm)
   GO_TARGET_FPU:=$(word 2,$(subst +,$(space),$(call qstrip,$(CONFIG_CPU_TYPE))))
 
@@ -183,6 +188,9 @@ else ifneq ($(filter $(GO_ARCH),mips64 mips64le),)
     GO_MIPS64:=softfloat
   endif
 
+else ifeq ($(GO_ARCH),ppc64)
+  GO_PPC64:=power8
+
 endif
 
 
@@ -193,7 +201,7 @@ GO_ARCH_DEPENDS:=@(aarch64||arm||i386||i686||mips||mips64||mips64el||mipsel||pow
 
 # ASLR/PIE
 
-# From https://golang.org/src/cmd/internal/sys/supported.go
+# From https://go.dev/src/cmd/internal/sys/supported.go
 GO_PIE_SUPPORTED_OS_ARCH:= \
   android_386  android_amd64  android_arm  android_arm64 \
   linux_386    linux_amd64    linux_arm    linux_arm64 \
@@ -209,7 +217,7 @@ GO_PIE_SUPPORTED_OS_ARCH:= \
   \
   linux_ppc64le linux_riscv64 linux_s390x
 
-# From https://golang.org/src/cmd/go/internal/work/init.go
+# From https://go.dev/src/cmd/go/internal/work/init.go
 go_pie_install_suffix=$(if $(filter $(1),aix_ppc64 windows_386 windows_amd64 windows_arm),,shared)
 
 ifneq ($(filter $(GO_HOST_OS_ARCH),$(GO_PIE_SUPPORTED_OS_ARCH)),)
index f3d1b1e76bcd10001c0cb27631337fad2e02f3d3..8bbe49cb8259d24cef16f97a17c616ba1f09d7af 100644 (file)
@@ -7,8 +7,8 @@
 
 include $(TOPDIR)/rules.mk
 
-GO_VERSION_MAJOR_MINOR:=1.17
-GO_VERSION_PATCH:=8
+GO_VERSION_MAJOR_MINOR:=1.18
+GO_VERSION_PATCH:=
 
 PKG_NAME:=golang
 PKG_VERSION:=$(GO_VERSION_MAJOR_MINOR)$(if $(GO_VERSION_PATCH),.$(GO_VERSION_PATCH))
@@ -20,7 +20,7 @@ GO_SOURCE_URLS:=https://dl.google.com/go/ \
 
 PKG_SOURCE:=go$(PKG_VERSION).src.tar.gz
 PKG_SOURCE_URL:=$(GO_SOURCE_URLS)
-PKG_HASH:=2effcd898140da79a061f3784ca4f8d8b13d811fb2abe9dad2404442dabbdf7a
+PKG_HASH:=38f423db4cc834883f2b52344282fa7a39fbb93650dc62a11fdf0be6409bdad6
 
 PKG_MAINTAINER:=Jeffery To <jeffery.to@gmail.com>
 PKG_LICENSE:=BSD-3-Clause
@@ -262,10 +262,11 @@ $(eval $(call GoCompiler/AddProfile,Package,$(PKG_BUILD_DIR),$(PKG_GO_PREFIX),$(
 
 PKG_GO_ZBOOTSTRAP_MODS:= \
        s/defaultGO386 = `[^`]*`/defaultGO386 = `$(or $(GO_386),sse2)`/; \
+       s/defaultGOAMD64 = `[^`]*`/defaultGOAMD64 = `$(or $(GO_AMD64),v1)`/; \
        s/defaultGOARM = `[^`]*`/defaultGOARM = `$(or $(GO_ARM),5)`/; \
        s/defaultGOMIPS = `[^`]*`/defaultGOMIPS = `$(or $(GO_MIPS),hardfloat)`/; \
        s/defaultGOMIPS64 = `[^`]*`/defaultGOMIPS64 = `$(or $(GO_MIPS64),hardfloat)`/; \
-       s/defaultGOPPC64 = `[^`]*`/defaultGOPPC64 = `power8`/;
+       s/defaultGOPPC64 = `[^`]*`/defaultGOPPC64 = `$(or $(GO_PPC64),power8)`/;
 
 PKG_GO_ZBOOTSTRAP_PATH:=$(PKG_BUILD_DIR)/src/internal/buildcfg/zbootstrap.go
 
index 4d93ad2e452fbafb8deeaa9061e0b111ed1831af..e8ea13c3c06f0b370c26d4f357589fa915f3a8d8 100644 (file)
@@ -1,8 +1,19 @@
-This is https://github.com/golang/go/pull/49748 backported for Go 1.17.
+From 5ccf9f47bf4f5ba53e0ab7338a7fd4626714cfb2 Mon Sep 17 00:00:00 2001
+From: Jeffery To <jeffery.to@gmail.com>
+Date: Tue, 23 Nov 2021 15:05:37 +0800
+Subject: [PATCH] cmd/link: use gold on ARM/ARM64 only if gold is available
+
+COPY relocation handling on ARM/ARM64 has been fixed in recent versions
+of the GNU linker. This switches to gold only if gold is available.
+
+Fixes #22040.
+---
+ src/cmd/link/internal/ld/lib.go | 19 +++++++------------
+ 1 file changed, 7 insertions(+), 12 deletions(-)
 
 --- a/src/cmd/link/internal/ld/lib.go
 +++ b/src/cmd/link/internal/ld/lib.go
-@@ -1391,23 +1391,18 @@ func (ctxt *Link) hostlink() {
+@@ -1393,25 +1393,20 @@ func (ctxt *Link) hostlink() {
                }
  
                if ctxt.Arch.InFamily(sys.ARM, sys.ARM64) && buildcfg.GOOS == "linux" {
@@ -24,7 +35,9 @@ This is https://github.com/golang/go/pull/49748 backported for Go 1.17.
 -                      // back to ld.bfd. So we parse the version information
 -                      // and provide a useful error if gold is missing.
 +                      // In both cases, switch to gold if gold is available.
-                       cmd := exec.Command(*flagExtld, "-fuse-ld=gold", "-Wl,--version")
+                       name, args := flagExtld[0], flagExtld[1:]
+                       args = append(args, "-fuse-ld=gold", "-Wl,--version")
+                       cmd := exec.Command(name, args...)
                        if out, err := cmd.CombinedOutput(); err == nil {
 -                              if !bytes.Contains(out, []byte("GNU gold")) {
 -                                      log.Fatalf("ARM external linker must be gold (issue #15696), but is not: %s", out)