################################################################################
################################################################################
GO_SITE = https://storage.googleapis.com/golang
GO_SOURCE = go$(GO_VERSION).src.tar.gz
GO_LICENSE_FILES = LICENSE
ifeq ($(BR2_ARM_CPU_ARMV5),y)
else ifeq ($(BR2_ARM_CPU_ARMV6),y)
else ifeq ($(BR2_ARM_CPU_ARMV7A),y)
else ifeq ($(BR2_aarch64),y)
else ifeq ($(BR2_i386),y)
else ifeq ($(BR2_x86_64),y)
else ifeq ($(BR2_powerpc64),y)
else ifeq ($(BR2_powerpc64le),y)
else ifeq ($(BR2_mips64),y)
else ifeq ($(BR2_mips64el),y)
HOST_GO_DEPENDENCIES = host-go-bootstrap
HOST_GO_ROOT = $(HOST_DIR)/usr/lib/go
# For the convienience of target packages.
HOST_GO_TOOLDIR = $(HOST_GO_ROOT)/pkg/tool/linux_$(GO_GOARCH)
GOROOT="$(HOST_GO_ROOT)" \
GOTOOLDIR="$(HOST_GO_TOOLDIR)"
# The go compiler's cgo support uses threads. If BR2_TOOLCHAIN_HAS_THREADS is
# set, build in cgo support for any go programs that may need it. Note that
# any target package needing cgo support must include
# 'depends on BR2_TOOLCHAIN_HAS_THREADS' in its config file.
ifeq (BR2_TOOLCHAIN_HAS_THREADS,y)
# The go build system doesn't have the notion of cross compiling, but just the
# notion of architecture. When the host and target architectures are different
# it expects to be given a target cross compiler in CC_FOR_TARGET. When the
# architectures are the same it will use CC_FOR_TARGET for both host and target
# compilation. To work around this limitation build and install a set of
# compiler and tool binaries built with CC_FOR_TARGET set to the host compiler.
# Also, the go build system is not compatible with ccache, so use
# HOSTCC_NOCCACHE. See https://github.com/golang/go/issues/11685.
GOROOT_BOOTSTRAP=$(HOST_GO_BOOTSTRAP_ROOT) \
GOROOT_FINAL=$(HOST_GO_ROOT) \
$(if $(GO_GOARM),GOARM=$(GO_GOARM)) \
CGO_ENABLED=$(HOST_GO_CGO_ENABLED) \
CC_FOR_TARGET="$(TARGET_CC)" \
CXX_FOR_TARGET="$(TARGET_CXX)"
CC_FOR_TARGET=$(HOSTCC_NOCCACHE) \
CXX_FOR_TARGET=$(HOSTCC_NOCCACHE)
HOST_GO_TMP = $(@D)/host-go-tmp
define HOST_GO_BUILD_CMDS
cd $(@D)/src && $(HOST_GO_MAKE_ENV) $(HOST_GO_HOST_CC) ./make.bash