diff --git a/package/go/Config.in.host b/package/go/Config.in.host index a42e37f90bea..7ba70c984355 100644 --- a/package/go/Config.in.host +++ b/package/go/Config.in.host @@ -2,7 +2,7 @@ config BR2_PACKAGE_HOST_GO_TARGET_ARCH_SUPPORTS bool default y - depends on BR2_PACKAGE_HOST_GO_BOOTSTRAP_STAGE3_ARCH_SUPPORTS || BR2_PACKAGE_HOST_GO_BIN_HOST_ARCH_SUPPORTS + depends on BR2_PACKAGE_HOST_GO_BOOTSTRAP_STAGE4_ARCH_SUPPORTS || BR2_PACKAGE_HOST_GO_BIN_HOST_ARCH_SUPPORTS # See https://go.dev/doc/install/source#environment # See src/go/build/syslist.go for the list of supported architectures depends on (BR2_arm && BR2_TOOLCHAIN_SUPPORTS_PIE) || BR2_aarch64 \ @@ -34,7 +34,7 @@ config BR2_PACKAGE_HOST_GO_TARGET_CGO_LINKING_SUPPORTS config BR2_PACKAGE_HOST_GO_HOST_ARCH_SUPPORTS bool default y - depends on BR2_PACKAGE_HOST_GO_BOOTSTRAP_STAGE3_ARCH_SUPPORTS || BR2_PACKAGE_HOST_GO_BIN_HOST_ARCH_SUPPORTS + depends on BR2_PACKAGE_HOST_GO_BOOTSTRAP_STAGE4_ARCH_SUPPORTS || BR2_PACKAGE_HOST_GO_BIN_HOST_ARCH_SUPPORTS # CGO linking for the host. Since we use the same compiler for target # and host, if the target can't do CGO linking, then the host can't. @@ -57,7 +57,7 @@ if BR2_PACKAGE_HOST_GO choice prompt "Go compiler variant" - default BR2_PACKAGE_HOST_GO_SRC if BR2_PACKAGE_HOST_GO_BOOTSTRAP_STAGE3_ARCH_SUPPORTS + default BR2_PACKAGE_HOST_GO_SRC if BR2_PACKAGE_HOST_GO_BOOTSTRAP_STAGE4_ARCH_SUPPORTS default BR2_PACKAGE_HOST_GO_BIN if BR2_PACKAGE_HOST_GO_BIN_HOST_ARCH_SUPPORTS help Select a Go compiler variant. @@ -66,7 +66,7 @@ choice config BR2_PACKAGE_HOST_GO_SRC bool "host go (source)" - depends on BR2_PACKAGE_HOST_GO_BOOTSTRAP_STAGE3_ARCH_SUPPORTS + depends on BR2_PACKAGE_HOST_GO_BOOTSTRAP_STAGE4_ARCH_SUPPORTS help This package will build the go compiler for the host. @@ -90,3 +90,4 @@ source "package/go/go-bin/Config.in.host" source "package/go/go-bootstrap-stage1/Config.in.host" source "package/go/go-bootstrap-stage2/Config.in.host" source "package/go/go-bootstrap-stage3/Config.in.host" +source "package/go/go-bootstrap-stage4/Config.in.host" diff --git a/package/go/go-bootstrap-stage4/0001-cmd-dist-set-buildvcs-false-when-building-go-bootstr.patch b/package/go/go-bootstrap-stage4/0001-cmd-dist-set-buildvcs-false-when-building-go-bootstr.patch new file mode 100644 index 000000000000..58f4581b02a3 --- /dev/null +++ b/package/go/go-bootstrap-stage4/0001-cmd-dist-set-buildvcs-false-when-building-go-bootstr.patch @@ -0,0 +1,71 @@ +From 6b05378097c6a386ed9912d2471976dc39504e86 Mon Sep 17 00:00:00 2001 +From: Christian Stewart +Date: Thu, 27 Jul 2023 21:28:47 -0700 +Subject: [PATCH] cmd/dist: set buildvcs=false when building go-bootstrap + +When building go-bootstrap as part of the make.bash process, the cmd/dist +invokes the bootstrap Go compiler to build the go_bootstrap tool: + +${GOROOT_BOOTSTRAP}/bin/go install -tags=math_big_pure_go compiler_bootstrap purego bootstrap/cmd/... + +If there is an invalid .git directory in a parent of ${GOROOT_BOOTSTRAP}, +make.bash will fail. Reproduction of the issue: + + mkdir go-issue-61620 + cd ./go-issue-61620 + wget https://go.dev/dl/go1.19.11.src.tar.gz + mkdir go-bootstrap + tar -xf go1.19.11.src.tar.gz -C ./go-bootstrap --strip-components=1 + cd ./go-bootstrap/src/ + bash make.bash + cd ../../ + wget https://go.dev/dl/go1.20.6.src.tar.gz + mkdir go + tar -xf go1.20.6.src.tar.gz -C ./go/ --strip-components=1 + printf "gitdir: ../../does/not/exist/.git" > ./.git + cd ./go/src/ + GOROOT_BOOTSTRAP=$(pwd)/../../go-bootstrap/ bash make.bash + +The build fails with the following error: + + Building Go toolchain1 using [snip]/go-1.19.10. + error obtaining VCS status: exit status 128 + Use -buildvcs=false to disable VCS stamping. + go tool dist: FAILED: [snip]/go-1.19.10/bin/go install -tags=math_big_pure_go \ + compiler_bootstrap purego bootstrap/cmd/...: exit status 1 + +This change unconditionally sets -buildvcs=false when compiling go-bootstrap. We +don't need the revision information in those binaries anyway. Setting this flag +was previously not done as we were unsure if the go-bootstrap compiler would be +new enough to support the buildvcs build flag. Since Go 1.20.x, Go 1.19.x is the +minimum version for go-bootstrap, and supports -buildvcs=false. We can now set +-buildvcs=false without worrying about compatibility. + +Related: https://github.com/golang/go/issues/54852 +Fixes: https://github.com/golang/go/issues/61620 + +Upstream: https://github.com/golang/go/pull/61621 + +Signed-off-by: Christian Stewart +Signed-off-by: Romain Naour +--- + src/cmd/dist/buildtool.go | 3 +++ + 1 file changed, 3 insertions(+) + +diff --git a/src/cmd/dist/buildtool.go b/src/cmd/dist/buildtool.go +index a528d7aa76..3b411d6ebb 100644 +--- a/src/cmd/dist/buildtool.go ++++ b/src/cmd/dist/buildtool.go +@@ -221,6 +221,9 @@ func bootstrapBuildTools() { + cmd := []string{ + pathf("%s/bin/go", goroot_bootstrap), + "install", ++ // Fixes cases where an invalid .git is present in a parent of GOROOT_BOOTSTRAP. ++ // See: https://github.com/golang/go/issues/61620 ++ "-buildvcs=false", + "-tags=math_big_pure_go compiler_bootstrap purego", + } + if vflag > 0 { +-- +2.41.0 + diff --git a/package/go/go-bootstrap-stage4/Config.in.host b/package/go/go-bootstrap-stage4/Config.in.host new file mode 100644 index 000000000000..292486582ccf --- /dev/null +++ b/package/go/go-bootstrap-stage4/Config.in.host @@ -0,0 +1,4 @@ +config BR2_PACKAGE_HOST_GO_BOOTSTRAP_STAGE4_ARCH_SUPPORTS + bool + default y + depends on BR2_PACKAGE_HOST_GO_BOOTSTRAP_STAGE3_ARCH_SUPPORTS diff --git a/package/go/go-bootstrap-stage4/go-bootstrap-stage4.hash b/package/go/go-bootstrap-stage4/go-bootstrap-stage4.hash new file mode 100644 index 000000000000..eb10323ecee2 --- /dev/null +++ b/package/go/go-bootstrap-stage4/go-bootstrap-stage4.hash @@ -0,0 +1,3 @@ +# From https://go.dev/dl +sha256 e1cce9379a24e895714a412c7ddd157d2614d9edbe83a84449b6e1840b4f1226 go1.23.12.src.tar.gz +sha256 2d36597f7117c38b006835ae7f537487207d8ec407aa9d9980794b2030cbc067 LICENSE diff --git a/package/go/go-bootstrap-stage4/go-bootstrap-stage4.mk b/package/go/go-bootstrap-stage4/go-bootstrap-stage4.mk new file mode 100644 index 000000000000..db0c85e3d0c3 --- /dev/null +++ b/package/go/go-bootstrap-stage4/go-bootstrap-stage4.mk @@ -0,0 +1,54 @@ +################################################################################ +# +# go-bootstrap-stage4 +# +################################################################################ + +# Use last Go version that go-bootstrap-stage3 can build: v1.23.x +# See https://go.dev/doc/go1.24#bootstrap +GO_BOOTSTRAP_STAGE4_VERSION = 1.23.12 +GO_BOOTSTRAP_STAGE4_SITE = https://storage.googleapis.com/golang +GO_BOOTSTRAP_STAGE4_SOURCE = go$(GO_BOOTSTRAP_STAGE4_VERSION).src.tar.gz + +GO_BOOTSTRAP_STAGE4_LICENSE = BSD-3-Clause +GO_BOOTSTRAP_STAGE4_LICENSE_FILES = LICENSE + +# Use go-bootstrap-stage3 to bootstrap. +HOST_GO_BOOTSTRAP_STAGE4_DEPENDENCIES = host-go-bootstrap-stage3 + +HOST_GO_BOOTSTRAP_STAGE4_ROOT = $(HOST_DIR)/lib/go-$(GO_BOOTSTRAP_STAGE4_VERSION) + +# The go build system is not compatible with ccache, so use +# HOSTCC_NOCCACHE. See https://github.com/golang/go/issues/11685. +HOST_GO_BOOTSTRAP_STAGE4_MAKE_ENV = \ + GO111MODULE=off \ + GOCACHE=$(HOST_GO_HOST_CACHE) \ + GOROOT_BOOTSTRAP=$(HOST_GO_BOOTSTRAP_STAGE3_ROOT) \ + GOROOT_FINAL=$(HOST_GO_BOOTSTRAP_STAGE4_ROOT) \ + GOROOT="$(@D)" \ + GOBIN="$(@D)/bin" \ + GOOS=linux \ + CC=$(HOSTCC_NOCCACHE) \ + CXX=$(HOSTCXX_NOCCACHE) \ + CGO_ENABLED=0 + +define HOST_GO_BOOTSTRAP_STAGE4_BUILD_CMDS + cd $(@D)/src && \ + $(HOST_GO_BOOTSTRAP_STAGE4_MAKE_ENV) ./make.bash $(if $(VERBOSE),-v) +endef + +define HOST_GO_BOOTSTRAP_STAGE4_INSTALL_CMDS + $(INSTALL) -D -m 0755 $(@D)/bin/go $(HOST_GO_BOOTSTRAP_STAGE4_ROOT)/bin/go + $(INSTALL) -D -m 0755 $(@D)/bin/gofmt $(HOST_GO_BOOTSTRAP_STAGE4_ROOT)/bin/gofmt + + cp -a $(@D)/lib $(HOST_GO_BOOTSTRAP_STAGE4_ROOT)/ + + mkdir -p $(HOST_GO_BOOTSTRAP_STAGE4_ROOT)/pkg + cp -a $(@D)/pkg/include $(HOST_GO_BOOTSTRAP_STAGE4_ROOT)/pkg/ + cp -a $(@D)/pkg/tool $(HOST_GO_BOOTSTRAP_STAGE4_ROOT)/pkg/ + + # The Go sources must be installed to the host/ tree for the Go stdlib. + cp -a $(@D)/src $(HOST_GO_BOOTSTRAP_STAGE4_ROOT)/ +endef + +$(eval $(host-generic-package)) diff --git a/package/go/go-src/go-src.mk b/package/go/go-src/go-src.mk index c1f11a2262ff..9a18b6afe8c4 100644 --- a/package/go/go-src/go-src.mk +++ b/package/go/go-src/go-src.mk @@ -16,7 +16,7 @@ GO_SRC_CPE_ID_PRODUCT = go HOST_GO_SRC_PROVIDES = host-go HOST_GO_SRC_DEPENDENCIES = \ - host-go-bootstrap-stage3 \ + host-go-bootstrap-stage4 \ $(HOST_GO_DEPENDENCIES_CGO) ifeq ($(BR2_PACKAGE_HOST_GO_TARGET_ARCH_SUPPORTS),y) @@ -37,7 +37,7 @@ endif HOST_GO_SRC_MAKE_ENV = \ GO111MODULE=off \ GOCACHE=$(HOST_GO_HOST_CACHE) \ - GOROOT_BOOTSTRAP=$(HOST_GO_BOOTSTRAP_STAGE3_ROOT) \ + GOROOT_BOOTSTRAP=$(HOST_GO_BOOTSTRAP_STAGE4_ROOT) \ GOROOT_FINAL=$(HOST_GO_ROOT) \ GOROOT="$(@D)" \ GOBIN="$(@D)/bin" \ diff --git a/package/go/go.hash b/package/go/go.hash index dc88e9beab61..92e7584769b7 100644 --- a/package/go/go.hash +++ b/package/go/go.hash @@ -1,9 +1,9 @@ # sha256 checksum from https://go.dev/dl/ -sha256 e1cce9379a24e895714a412c7ddd157d2614d9edbe83a84449b6e1840b4f1226 go1.23.12.src.tar.gz -sha256 3b2fd446e26642555d1446a38ccbefb2a30bba3179d3ef132ed64d3c63b0c42a go1.23.12.linux-386.tar.gz -sha256 d3847fef834e9db11bf64e3fb34db9c04db14e068eeb064f49af747010454f90 go1.23.12.linux-amd64.tar.gz -sha256 52ce172f96e21da53b1ae9079808560d49b02ac86cecfa457217597f9bc28ab3 go1.23.12.linux-arm64.tar.gz -sha256 9704eba01401a3793f54fac162164b9c5d8cc6f3cab5cee72684bb72294d9f41 go1.23.12.linux-armv6l.tar.gz -sha256 1a7cc5f7baeaf39125dce5d660a39438e7f0e04d13d3498590d240aae976b565 go1.23.12.linux-ppc64le.tar.gz -sha256 2f43708aa0922d692da0a1fc775475c343907610bec77002de1bbe37601ea338 go1.23.12.linux-s390x.tar.gz -sha256 2d36597f7117c38b006835ae7f537487207d8ec407aa9d9980794b2030cbc067 LICENSE +sha256 d010c109cee94d80efe681eab46bdea491ac906bf46583c32e9f0dbb0bd1a594 go1.25.2.src.tar.gz +sha256 d03cdcbc9bd8baf5cf028de390478e9e2b3e4d0afe5a6582dedc19bfe6a263b2 go1.25.2.linux-386.tar.gz +sha256 d7fa7f8fbd16263aa2501d681b11f972a5fd8e811f7b10cb9b26d031a3d7454b go1.25.2.linux-amd64.tar.gz +sha256 65a3e34fb2126f55b34e1edfc709121660e1be2dee6bdf405fc399a63a95a87d go1.25.2.linux-arm64.tar.gz +sha256 eb949be683e82a99e9861dafd7057e31ea40b161eae6c4cd18fdc0e8c4ae6225 go1.25.2.linux-armv6l.tar.gz +sha256 8b0c8d3ee5b1b5c28b6bd63dc4438792012e01d03b4bf7a61d985c87edab7d1f go1.25.2.linux-ppc64le.tar.gz +sha256 9cfe517ba423f59f3738ca5c3d907c103253cffbbcc2987142f79c5de8c1bf93 go1.25.2.linux-s390x.tar.gz +sha256 911f8f5782931320f5b8d1160a76365b83aea6447ee6c04fa6d5591467db9dad LICENSE diff --git a/package/go/go.mk b/package/go/go.mk index 69ca746783cb..696b2be19e8e 100644 --- a/package/go/go.mk +++ b/package/go/go.mk @@ -4,7 +4,7 @@ # ################################################################################ -GO_VERSION = 1.23.12 +GO_VERSION = 1.25.2 HOST_GO_GOPATH = $(HOST_DIR)/share/go-path HOST_GO_HOST_CACHE = $(HOST_DIR)/share/host-go-cache