1
0
Fork 0
mirror of https://github.com/Ysurac/openmptcprouter-feeds.git synced 2025-02-15 03:51:51 +00:00

Update golang

This commit is contained in:
Ycarus (Yannick Chabanois) 2023-04-06 21:01:09 +02:00
parent e992652783
commit d322ac87b8
4 changed files with 130 additions and 31 deletions

View file

@ -27,7 +27,10 @@ define GoCompiler/Default/Make
cd "$(1)/src" ; \ cd "$(1)/src" ; \
$(if $(2),GOROOT_FINAL="$(2)/lib/go-$(3)") \ $(if $(2),GOROOT_FINAL="$(2)/lib/go-$(3)") \
$(4) \ $(4) \
$(BASH) make.bash --no-banner ; \ $(BASH) make.bash \
$(if $(findstring s,$(OPENWRT_VERBOSE)),-v) \
--no-banner \
; \
) )
endef endef
@ -73,8 +76,10 @@ define GoCompiler/Default/Install/Bin
$(INSTALL_BIN) -p "$(1)/bin/$(4)"/* "$(2)/lib/go-$(3)/bin/" $(INSTALL_BIN) -p "$(1)/bin/$(4)"/* "$(2)/lib/go-$(3)/bin/"
endif endif
$(INSTALL_DIR) "$(2)/lib/go-$(3)/pkg" if [ -d "$(1)/pkg/$(4)$(if $(5),_$(5))" ]; then \
$(CP) "$(1)/pkg/$(4)$(if $(5),_$(5))" "$(2)/lib/go-$(3)/pkg/" $(INSTALL_DIR) "$(2)/lib/go-$(3)/pkg" ; \
$(CP) "$(1)/pkg/$(4)$(if $(5),_$(5))" "$(2)/lib/go-$(3)/pkg/" ; \
fi
$(INSTALL_DIR) "$(2)/lib/go-$(3)/pkg/tool/$(4)" $(INSTALL_DIR) "$(2)/lib/go-$(3)/pkg/tool/$(4)"
$(INSTALL_BIN) -p "$(1)/pkg/tool/$(4)"/* "$(2)/lib/go-$(3)/pkg/tool/$(4)/" $(INSTALL_BIN) -p "$(1)/pkg/tool/$(4)"/* "$(2)/lib/go-$(3)/pkg/tool/$(4)/"
@ -95,8 +100,6 @@ define GoCompiler/Default/Install/Doc
$(call GoCompiler/Default/Install/make-dirs,$(2),$(3)) $(call GoCompiler/Default/Install/make-dirs,$(2),$(3))
$(call GoCompiler/Default/Install/install-share-data,$(1),$(2),$(3),doc) $(call GoCompiler/Default/Install/install-share-data,$(1),$(2),$(3),doc)
$(call GoCompiler/Default/Install/install-share-data,$(1),$(2),$(3),favicon.ico)
$(call GoCompiler/Default/Install/install-share-data,$(1),$(2),$(3),robots.txt)
endef endef
# $(1) source go root # $(1) source go root

View file

@ -29,7 +29,8 @@ unexport \
GOOS \ GOOS \
GOPATH \ GOPATH \
GOROOT \ GOROOT \
GOTMPDIR GOTMPDIR \
GOWORK
# Unmodified: # Unmodified:
# GOINSECURE # GOINSECURE
# GOPRIVATE # GOPRIVATE
@ -58,10 +59,16 @@ unexport \
unexport \ unexport \
GOARM \ GOARM \
GO386 \ GO386 \
GOAMD64 \
GOMIPS \ GOMIPS \
GOMIPS64 \ GOMIPS64 \
GOPPC64 \
GOWASM GOWASM
# Environment variables for use with code coverage:
unexport \
GOCOVERDIR
# Special-purpose environment variables: # Special-purpose environment variables:
unexport \ unexport \
GCCGOTOOLDIR \ GCCGOTOOLDIR \
@ -74,6 +81,7 @@ unexport \
# From https://pkg.go.dev/runtime#hdr-Environment_Variables # From https://pkg.go.dev/runtime#hdr-Environment_Variables
unexport \ unexport \
GOGC \ GOGC \
GOMEMLIMIT \
GOMAXPROCS \ GOMAXPROCS \
GORACE \ GORACE \
GOTRACEBACK GOTRACEBACK
@ -86,13 +94,12 @@ unexport \
# CC_FOR_${GOOS}_${GOARCH} # CC_FOR_${GOOS}_${GOARCH}
# CXX_FOR_${GOOS}_${GOARCH} # CXX_FOR_${GOOS}_${GOARCH}
# From https://golang.org/doc/install/source#environment # From https://go.dev/doc/install/source#environment
unexport \ unexport \
GOHOSTOS \ GOHOSTOS \
GOHOSTARCH \ GOHOSTARCH
GOPPC64
# From https://golang.org/src/make.bash # From https://go.dev/src/make.bash
unexport \ unexport \
GO_GCFLAGS \ GO_GCFLAGS \
GO_LDFLAGS \ GO_LDFLAGS \
@ -101,16 +108,16 @@ unexport \
GOBUILDTIMELOGFILE \ GOBUILDTIMELOGFILE \
GOROOT_BOOTSTRAP GOROOT_BOOTSTRAP
# From https://golang.org/doc/go1.9#parallel-compile # From https://go.dev/doc/go1.9#parallel-compile
unexport \ unexport \
GO19CONCURRENTCOMPILATION GO19CONCURRENTCOMPILATION
# From https://golang.org/src/cmd/dist/build.go # From https://go.dev/src/cmd/dist/build.go
unexport \ unexport \
BOOT_GO_GCFLAGS \ BOOT_GO_GCFLAGS \
BOOT_GO_LDFLAGS BOOT_GO_LDFLAGS
# From https://golang.org/src/cmd/dist/buildtool.go # From https://go.dev/src/cmd/dist/buildtool.go
unexport \ unexport \
GOBOOTSTRAP_TOOLEXEC GOBOOTSTRAP_TOOLEXEC
@ -152,6 +159,9 @@ ifeq ($(GO_ARCH),386)
# -fno-plt: causes "unexpected GOT reloc for non-dynamic symbol" errors # -fno-plt: causes "unexpected GOT reloc for non-dynamic symbol" errors
GO_CFLAGS_TO_REMOVE:=-fno-plt GO_CFLAGS_TO_REMOVE:=-fno-plt
else ifeq ($(GO_ARCH),amd64)
GO_AMD64:=v1
else ifeq ($(GO_ARCH),arm) else ifeq ($(GO_ARCH),arm)
GO_TARGET_FPU:=$(word 2,$(subst +,$(space),$(call qstrip,$(CONFIG_CPU_TYPE)))) GO_TARGET_FPU:=$(word 2,$(subst +,$(space),$(call qstrip,$(CONFIG_CPU_TYPE))))
@ -183,6 +193,9 @@ else ifneq ($(filter $(GO_ARCH),mips64 mips64le),)
GO_MIPS64:=softfloat GO_MIPS64:=softfloat
endif endif
else ifeq ($(GO_ARCH),ppc64)
GO_PPC64:=power8
endif endif
@ -193,12 +206,11 @@ GO_ARCH_DEPENDS:=@(aarch64||arm||i386||i686||mips||mips64||mips64el||mipsel||pow
# ASLR/PIE # ASLR/PIE
# From https://golang.org/src/cmd/internal/sys/supported.go # From https://go.dev/src/internal/platform/supported.go
GO_PIE_SUPPORTED_OS_ARCH:= \ GO_PIE_SUPPORTED_OS_ARCH:= \
android_386 android_amd64 android_arm android_arm64 \ android_386 android_amd64 android_arm android_arm64 \
linux_386 linux_amd64 linux_arm linux_arm64 \ linux_386 linux_amd64 linux_arm linux_arm64 \
\ windows_386 windows_amd64 windows_arm windows_arm64 \
windows_386 windows_amd64 windows_arm \
\ \
darwin_amd64 darwin_arm64 \ darwin_amd64 darwin_arm64 \
ios_amd64 ios_arm64 \ ios_amd64 ios_arm64 \
@ -209,8 +221,8 @@ GO_PIE_SUPPORTED_OS_ARCH:= \
\ \
linux_ppc64le linux_riscv64 linux_s390x 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) go_pie_install_suffix=$(if $(filter $(1),aix_ppc64 windows_386 windows_amd64 windows_arm windows_arm64),,shared)
ifneq ($(filter $(GO_HOST_OS_ARCH),$(GO_PIE_SUPPORTED_OS_ARCH)),) ifneq ($(filter $(GO_HOST_OS_ARCH),$(GO_PIE_SUPPORTED_OS_ARCH)),)
GO_HOST_PIE_SUPPORTED:=1 GO_HOST_PIE_SUPPORTED:=1

View file

@ -7,7 +7,7 @@
include $(TOPDIR)/rules.mk include $(TOPDIR)/rules.mk
GO_VERSION_MAJOR_MINOR:=1.17 GO_VERSION_MAJOR_MINOR:=1.20
GO_VERSION_PATCH:=3 GO_VERSION_PATCH:=3
PKG_NAME:=golang PKG_NAME:=golang
@ -20,7 +20,7 @@ GO_SOURCE_URLS:=https://dl.google.com/go/ \
PKG_SOURCE:=go$(PKG_VERSION).src.tar.gz PKG_SOURCE:=go$(PKG_VERSION).src.tar.gz
PKG_SOURCE_URL:=$(GO_SOURCE_URLS) PKG_SOURCE_URL:=$(GO_SOURCE_URLS)
PKG_HASH:=705c64251e5b25d5d55ede1039c6aa22bea40a7a931d14c370339853643c3df0 PKG_HASH:=e447b498cde50215c4f7619e5124b0fc4e25fb5d16ea47271c47f278e7aa763a
PKG_MAINTAINER:=Jeffery To <jeffery.to@gmail.com> PKG_MAINTAINER:=Jeffery To <jeffery.to@gmail.com>
PKG_LICENSE:=BSD-3-Clause PKG_LICENSE:=BSD-3-Clause
@ -63,9 +63,11 @@ HOST_GO_VALID_OS_ARCH:= \
aix_ppc64 \ aix_ppc64 \
js_wasm \ js_wasm \
\ \
freebsd_riscv64 \
\
linux_ppc64 linux_ppc64le \ linux_ppc64 linux_ppc64le \
linux_mips linux_mipsle linux_mips64 linux_mips64le \ linux_mips linux_mipsle linux_mips64 linux_mips64le \
linux_riscv64 linux_s390x \ linux_loong64 linux_riscv64 linux_s390x \
\ \
openbsd_mips64 openbsd_mips64
@ -86,6 +88,12 @@ BOOTSTRAP_GO_VALID_OS_ARCH:= \
solaris_amd64 \ solaris_amd64 \
windows_386 windows_amd64 windows_386 windows_amd64
BOOTSTRAP_1_17_SOURCE:=go1.17.13.src.tar.gz
BOOTSTRAP_1_17_SOURCE_URL:=$(GO_SOURCE_URLS)
BOOTSTRAP_1_17_HASH:=a1a48b23afb206f95e7bbaa9b898d965f90826f6f1d1fc0c1d784ada0cd300fd
BOOTSTRAP_1_17_BUILD_DIR:=$(HOST_BUILD_DIR)/.go_bootstrap_1.17
include $(INCLUDE_DIR)/host-build.mk include $(INCLUDE_DIR)/host-build.mk
include $(INCLUDE_DIR)/package.mk include $(INCLUDE_DIR)/package.mk
include ../golang-compiler.mk include ../golang-compiler.mk
@ -94,6 +102,7 @@ include ../golang-package.mk
PKG_UNPACK:=$(HOST_TAR) -C "$(PKG_BUILD_DIR)" --strip-components=1 -xzf "$(DL_DIR)/$(PKG_SOURCE)" PKG_UNPACK:=$(HOST_TAR) -C "$(PKG_BUILD_DIR)" --strip-components=1 -xzf "$(DL_DIR)/$(PKG_SOURCE)"
HOST_UNPACK:=$(HOST_TAR) -C "$(HOST_BUILD_DIR)" --strip-components=1 -xzf "$(DL_DIR)/$(PKG_SOURCE)" HOST_UNPACK:=$(HOST_TAR) -C "$(HOST_BUILD_DIR)" --strip-components=1 -xzf "$(DL_DIR)/$(PKG_SOURCE)"
BOOTSTRAP_UNPACK:=$(HOST_TAR) -C "$(BOOTSTRAP_BUILD_DIR)" --strip-components=1 -xzf "$(DL_DIR)/$(BOOTSTRAP_SOURCE)" BOOTSTRAP_UNPACK:=$(HOST_TAR) -C "$(BOOTSTRAP_BUILD_DIR)" --strip-components=1 -xzf "$(DL_DIR)/$(BOOTSTRAP_SOURCE)"
BOOTSTRAP_1_17_UNPACK:=$(HOST_TAR) -C "$(BOOTSTRAP_1_17_BUILD_DIR)" --strip-components=1 -xzf "$(DL_DIR)/$(BOOTSTRAP_1_17_SOURCE)"
# don't strip ELF executables in test data # don't strip ELF executables in test data
RSTRIP:=: RSTRIP:=:
@ -106,7 +115,7 @@ endif
define Package/golang/Default define Package/golang/Default
$(call GoPackage/GoSubMenu) $(call GoPackage/GoSubMenu)
TITLE:=Go programming language TITLE:=Go programming language
URL:=https://golang.org/ URL:=https://go.dev/
DEPENDS:=$(GO_ARCH_DEPENDS) DEPENDS:=$(GO_ARCH_DEPENDS)
endef endef
@ -181,8 +190,7 @@ ifeq ($(BOOTSTRAP_ROOT_DIR),)
$(eval $(call Download,golang-bootstrap)) $(eval $(call Download,golang-bootstrap))
define Bootstrap/Prepare define Bootstrap/Prepare
mkdir -p "$(BOOTSTRAP_BUILD_DIR)" mkdir -p "$(BOOTSTRAP_BUILD_DIR)" && $(BOOTSTRAP_UNPACK) ;
$(BOOTSTRAP_UNPACK)
endef endef
Hooks/HostPrepare/Post+=Bootstrap/Prepare Hooks/HostPrepare/Post+=Bootstrap/Prepare
@ -190,6 +198,23 @@ ifeq ($(BOOTSTRAP_ROOT_DIR),)
endif endif
# Bootstrap 1.17
define Download/golang-bootstrap-1.17
FILE:=$(BOOTSTRAP_1_17_SOURCE)
URL:=$(BOOTSTRAP_1_17_SOURCE_URL)
HASH:=$(BOOTSTRAP_1_17_HASH)
endef
$(eval $(call Download,golang-bootstrap-1.17))
define Bootstrap-1.17/Prepare
mkdir -p "$(BOOTSTRAP_1_17_BUILD_DIR)" && $(BOOTSTRAP_1_17_UNPACK) ;
endef
Hooks/HostPrepare/Post+=Bootstrap-1.17/Prepare
$(eval $(call GoCompiler/AddProfile,Bootstrap-1.17,$(BOOTSTRAP_1_17_BUILD_DIR),,bootstrap-1.17,$(GO_HOST_OS_ARCH)))
# Host # Host
ifeq ($(GO_HOST_PIE_SUPPORTED),1) ifeq ($(GO_HOST_PIE_SUPPORTED),1)
@ -202,23 +227,31 @@ endif
$(eval $(call GoCompiler/AddProfile,Host,$(HOST_BUILD_DIR),$(HOST_GO_PREFIX),$(HOST_GO_VERSION_ID),$(GO_HOST_OS_ARCH),$(HOST_GO_INSTALL_SUFFIX))) $(eval $(call GoCompiler/AddProfile,Host,$(HOST_BUILD_DIR),$(HOST_GO_PREFIX),$(HOST_GO_VERSION_ID),$(GO_HOST_OS_ARCH),$(HOST_GO_INSTALL_SUFFIX)))
HOST_GO_VARS= \ HOST_GO_VARS= \
GOHOSTARCH="$(GO_HOST_ARCH)" \
GOCACHE="$(GO_BUILD_CACHE_DIR)" \ GOCACHE="$(GO_BUILD_CACHE_DIR)" \
GOENV=off \ GOENV=off \
CC="$(HOSTCC_NOCACHE)" \ CC="$(HOSTCC_NOCACHE)" \
CXX="$(HOSTCXX_NOCACHE)" CXX="$(HOSTCXX_NOCACHE)"
define Host/Compile define Host/Configure
$(call GoCompiler/Bootstrap/CheckHost,$(BOOTSTRAP_GO_VALID_OS_ARCH)) $(call GoCompiler/Bootstrap/CheckHost,$(BOOTSTRAP_GO_VALID_OS_ARCH))
$(call GoCompiler/Host/CheckHost,$(HOST_GO_VALID_OS_ARCH)) $(call GoCompiler/Host/CheckHost,$(HOST_GO_VALID_OS_ARCH))
mkdir -p "$(GO_BUILD_CACHE_DIR)" mkdir -p "$(GO_BUILD_CACHE_DIR)"
endef
define Host/Compile
$(call GoCompiler/Bootstrap/Make, \ $(call GoCompiler/Bootstrap/Make, \
$(HOST_GO_VARS) \ $(HOST_GO_VARS) \
) )
$(call GoCompiler/Host/Make, \ $(call GoCompiler/Bootstrap-1.17/Make, \
GOROOT_BOOTSTRAP="$(BOOTSTRAP_ROOT_DIR)" \ GOROOT_BOOTSTRAP="$(BOOTSTRAP_ROOT_DIR)" \
$(HOST_GO_VARS) \
)
$(call GoCompiler/Host/Make, \
GOROOT_BOOTSTRAP="$(BOOTSTRAP_1_17_BUILD_DIR)" \
$(if $(HOST_GO_ENABLE_PIE),GO_LDFLAGS="-buildmode pie") \ $(if $(HOST_GO_ENABLE_PIE),GO_LDFLAGS="-buildmode pie") \
$(HOST_GO_VARS) \ $(HOST_GO_VARS) \
) )
@ -262,14 +295,16 @@ $(eval $(call GoCompiler/AddProfile,Package,$(PKG_BUILD_DIR),$(PKG_GO_PREFIX),$(
PKG_GO_ZBOOTSTRAP_MODS:= \ PKG_GO_ZBOOTSTRAP_MODS:= \
s/defaultGO386 = `[^`]*`/defaultGO386 = `$(or $(GO_386),sse2)`/; \ s/defaultGO386 = `[^`]*`/defaultGO386 = `$(or $(GO_386),sse2)`/; \
s/defaultGOAMD64 = `[^`]*`/defaultGOAMD64 = `$(or $(GO_AMD64),v1)`/; \
s/defaultGOARM = `[^`]*`/defaultGOARM = `$(or $(GO_ARM),5)`/; \ s/defaultGOARM = `[^`]*`/defaultGOARM = `$(or $(GO_ARM),5)`/; \
s/defaultGOMIPS = `[^`]*`/defaultGOMIPS = `$(or $(GO_MIPS),hardfloat)`/; \ s/defaultGOMIPS = `[^`]*`/defaultGOMIPS = `$(or $(GO_MIPS),hardfloat)`/; \
s/defaultGOMIPS64 = `[^`]*`/defaultGOMIPS64 = `$(or $(GO_MIPS64),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 PKG_GO_ZBOOTSTRAP_PATH:=$(PKG_BUILD_DIR)/src/internal/buildcfg/zbootstrap.go
PKG_GO_VARS= \ PKG_GO_VARS= \
GOHOSTARCH="$(GO_HOST_ARCH)" \
GOCACHE="$(GO_BUILD_CACHE_DIR)" \ GOCACHE="$(GO_BUILD_CACHE_DIR)" \
GOENV=off \ GOENV=off \
GO_GCC_HELPER_PATH="$$$$PATH" \ GO_GCC_HELPER_PATH="$$$$PATH" \
@ -290,18 +325,19 @@ PKG_GO_LDFLAGS= \
-extldflags '$(patsubst -z%,-Wl$(comma)-z$(comma)%,$(TARGET_LDFLAGS))' \ -extldflags '$(patsubst -z%,-Wl$(comma)-z$(comma)%,$(TARGET_LDFLAGS))' \
$(if $(CONFIG_NO_STRIP)$(CONFIG_DEBUG),,-s -w) $(if $(CONFIG_NO_STRIP)$(CONFIG_DEBUG),,-s -w)
# setting -trimpath is not necessary here because the paths inside the
# compiler binary are relative to GOROOT_FINAL (PKG_GO_ROOT), which is
# static / not dependent on the build environment
PKG_GO_INSTALL_ARGS= \ PKG_GO_INSTALL_ARGS= \
-buildvcs=false \
-trimpath \
-ldflags "all=$(PKG_GO_LDFLAGS)" \ -ldflags "all=$(PKG_GO_LDFLAGS)" \
$(if $(PKG_GO_GCFLAGS),-gcflags "all=$(PKG_GO_GCFLAGS)") \ $(if $(PKG_GO_GCFLAGS),-gcflags "all=$(PKG_GO_GCFLAGS)") \
$(if $(PKG_GO_ASMFLAGS),-asmflags "all=$(PKG_GO_ASMFLAGS)") \ $(if $(PKG_GO_ASMFLAGS),-asmflags "all=$(PKG_GO_ASMFLAGS)") \
$(if $(filter $(GO_PKG_ENABLE_PIE),1),-buildmode pie) $(if $(filter $(GO_PKG_ENABLE_PIE),1),-buildmode pie)
define Build/Compile define Build/Configure
mkdir -p "$(GO_BUILD_CACHE_DIR)" mkdir -p "$(GO_BUILD_CACHE_DIR)"
endef
define Build/Compile
@echo "Building target Go first stage" @echo "Building target Go first stage"
$(call GoCompiler/Package/Make, \ $(call GoCompiler/Package/Make, \

View file

@ -0,0 +1,48 @@
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
@@ -1535,25 +1535,20 @@ func (ctxt *Link) hostlink() {
}
if ctxt.Arch.InFamily(sys.ARM, sys.ARM64) && buildcfg.GOOS == "linux" {
- // On ARM, the GNU linker will generate COPY relocations
- // even with -znocopyreloc set.
+ // On ARM, older versions of the GNU linker will generate
+ // COPY relocations even with -znocopyreloc set.
// https://sourceware.org/bugzilla/show_bug.cgi?id=19962
//
- // On ARM64, the GNU linker will fail instead of
- // generating COPY relocations.
+ // On ARM64, older versions of the GNU linker will fail
+ // instead of generating COPY relocations.
//
- // In both cases, switch to gold.
- altLinker = "gold"
-
- // If gold is not installed, gcc will silently switch
- // 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.
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)
+ if bytes.Contains(out, []byte("GNU gold")) {
+ altLinker = "gold"
}
}
}