kumquat-buildroot/package/go-bootstrap-stage1/go-bootstrap-stage1.mk
Christian Stewart 6bedfdf691 package/go-bootstrap: split into two stages: go1.4 and go1.19.10
Go 1.20 requires a minimum version of go 1.17.13 to bootstrap.

https://go.dev/doc/go1.20#bootstrap

As Go 1.4 was the previous version that could be compiled with C, there is now
no way to bootstrap go with a C compiler, unless we use a two-stage bootstrap:

 - build host-go-bootstrap-1.4-20170531
 - build host-go-bootstrap-1.19.10 with host-go-bootstrap-1.4-20170531
 - build host-go-1.20 with host-go-bootstrap-1.19.9

This is implemented in this commit first, before upgrading host-go to 1.20.

Note: the .patch files from package/go version 1.19.x are not necessary for
package/go-bootstrap-stage2 and have not been included there.

Previous discussion of possible alternatives:

https://lore.kernel.org/all/CA+h8R2rtcynkCBsz=_9yANOEguyPCOcQDj8_ns+cv8RS8+8t9A@mail.gmail.com/
https://lore.kernel.org/all/20220525234312.643dfc03@windsurf/T/

Signed-off-by: Christian Stewart <christian@aperture.us>
Signed-off-by: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
2023-07-22 22:59:27 +02:00

44 lines
1.5 KiB
Makefile

################################################################################
#
# go-bootstrap-stage1
#
################################################################################
# Use last C-based Go compiler: v1.4.x
# See https://golang.org/doc/install/source#bootstrapFromSource
GO_BOOTSTRAP_STAGE1_VERSION = 1.4-bootstrap-20171003
GO_BOOTSTRAP_STAGE1_SITE = https://dl.google.com/go
GO_BOOTSTRAP_STAGE1_SOURCE = go$(GO_BOOTSTRAP_STAGE1_VERSION).tar.gz
GO_BOOTSTRAP_STAGE1_LICENSE = BSD-3-Clause
GO_BOOTSTRAP_STAGE1_LICENSE_FILES = LICENSE
HOST_GO_BOOTSTRAP_STAGE1_ROOT = $(HOST_DIR)/lib/go-$(GO_BOOTSTRAP_STAGE1_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_STAGE1_MAKE_ENV = \
GOOS=linux \
GOROOT_FINAL="$(HOST_GO_BOOTSTRAP_STAGE1_ROOT)" \
GOROOT="$(@D)" \
GOBIN="$(@D)/bin" \
CC=$(HOSTCC_NOCCACHE) \
CGO_ENABLED=0
define HOST_GO_BOOTSTRAP_STAGE1_BUILD_CMDS
cd $(@D)/src && $(HOST_GO_BOOTSTRAP_STAGE1_MAKE_ENV) ./make.bash
endef
define HOST_GO_BOOTSTRAP_STAGE1_INSTALL_CMDS
$(INSTALL) -D -m 0755 $(@D)/bin/go $(HOST_GO_BOOTSTRAP_STAGE1_ROOT)/bin/go
$(INSTALL) -D -m 0755 $(@D)/bin/gofmt $(HOST_GO_BOOTSTRAP_STAGE1_ROOT)/bin/gofmt
cp -a $(@D)/lib $(HOST_GO_BOOTSTRAP_STAGE1_ROOT)/
cp -a $(@D)/pkg $(HOST_GO_BOOTSTRAP_STAGE1_ROOT)/
# The Go sources must be installed to the host/ tree for the Go stdlib.
cp -a $(@D)/src $(HOST_GO_BOOTSTRAP_STAGE1_ROOT)/
endef
$(eval $(host-generic-package))