Skip to content

Commit

Permalink
update go to buildroot master and incorporate patch for using binary …
Browse files Browse the repository at this point in the history
…golang
  • Loading branch information
bryanforbes committed Oct 2, 2024
1 parent 3890f07 commit 89ba349
Show file tree
Hide file tree
Showing 46 changed files with 216 additions and 55 deletions.
2 changes: 1 addition & 1 deletion .checkpackageignore
Original file line number Diff line number Diff line change
Expand Up @@ -692,7 +692,7 @@ package/glorytun/0002-aegis256.c-fix-aarch64-build-with-uclibc.patch lib_patch.U
package/gnu-efi/0001-Make.defaults-don-t-override-ARCH-when-cross-compili.patch lib_patch.Upstream
package/gnupg/0001-build-Always-use-EXTERN_UNLESS_MAIN_MODULE-pattern.patch lib_patch.Upstream
package/gnuplot/0001-configure-add-without-demo-option.patch lib_patch.Upstream
package/go/0001-build.go-explicit-option-for-crosscompilation.patch lib_patch.Upstream
package/go/go-src/0001-build.go-explicit-option-for-crosscompilation.patch lib_patch.Upstream
package/gob2/0001-dont-include-from-prefix.patch lib_patch.Upstream
package/gobject-introspection/0001-disable-tests.patch lib_patch.Upstream
package/gobject-introspection/0002-Add-rpath-links-to-ccompiler.patch lib_patch.Upstream
Expand Down
6 changes: 3 additions & 3 deletions DEVELOPERS
Original file line number Diff line number Diff line change
Expand Up @@ -617,9 +617,6 @@ F: package/docker-engine/
F: package/embiggen-disk/
F: package/fuse-overlayfs/
F: package/go/
F: package/go-bootstrap-stage1/
F: package/go-bootstrap-stage2/
F: package/go-bootstrap-stage3/
F: package/gocryptfs/
F: package/mbpfan/
F: package/moby-buildkit/
Expand Down Expand Up @@ -3039,6 +3036,9 @@ F: package/frotz/
F: package/kvm-unit-tests/
F: package/xorcurses/

N: Thomas Perale <[email protected]>
F: package/go/

N: Thomas Petazzoni <[email protected]>
F: arch/Config.in.arm
F: board/beaglev/
Expand Down
3 changes: 0 additions & 3 deletions package/Config.in.host
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,6 @@ menu "Host utilities"
source "package/genpart/Config.in.host"
source "package/gnupg/Config.in.host"
source "package/go/Config.in.host"
source "package/go-bootstrap-stage1/Config.in.host"
source "package/go-bootstrap-stage2/Config.in.host"
source "package/go-bootstrap-stage3/Config.in.host"
source "package/google-breakpad/Config.in.host"
source "package/gptfdisk/Config.in.host"
source "package/imagemagick/Config.in.host"
Expand Down
1 change: 1 addition & 0 deletions package/balena-engine/Config.in
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ config BR2_PACKAGE_BALENA_ENGINE
depends on !BR2_TOOLCHAIN_USES_UCLIBC # no fexecve
depends on BR2_USE_MMU # util-linux
select BR2_PACKAGE_CGROUPFS_MOUNT if !BR2_PACKAGE_SYSTEMD # runtime
select BR2_PACKAGE_HOST_GO
select BR2_PACKAGE_IPTABLES # runtime
select BR2_PACKAGE_UTIL_LINUX # runtime
select BR2_PACKAGE_UTIL_LINUX_BINARIES # runtime
Expand Down
1 change: 1 addition & 0 deletions package/cni-plugins/Config.in
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ config BR2_PACKAGE_CNI_PLUGINS
depends on BR2_TOOLCHAIN_HAS_THREADS
depends on !BR2_TOOLCHAIN_USES_UCLIBC # no fexecve
depends on BR2_USE_MMU
select BR2_PACKAGE_HOST_GO
help
Container Networking Interface plugins.

Expand Down
1 change: 1 addition & 0 deletions package/containerd/Config.in
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ config BR2_PACKAGE_CONTAINERD
depends on BR2_TOOLCHAIN_HAS_THREADS
depends on !BR2_TOOLCHAIN_USES_UCLIBC # runc
depends on BR2_USE_MMU # util-linux
select BR2_PACKAGE_HOST_GO
select BR2_PACKAGE_RUNC if !BR2_PACKAGE_CRUN # runtime dependency
select BR2_PACKAGE_UTIL_LINUX # runtime dependency
select BR2_PACKAGE_UTIL_LINUX_BINARIES
Expand Down
1 change: 1 addition & 0 deletions package/crucible/Config.in
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
config BR2_PACKAGE_CRUCIBLE
bool "crucible"
depends on BR2_PACKAGE_HOST_GO_TARGET_ARCH_SUPPORTS
select BR2_PACKAGE_HOST_GO
help
Crucible is a One-Time-Programmable (OTP) fusing tool for the
i.MX family.
Expand Down
1 change: 1 addition & 0 deletions package/delve/Config.in
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ config BR2_PACKAGE_DELVE_ARCH_SUPPORTS
default y if BR2_x86_64
depends on BR2_PACKAGE_HOST_GO_TARGET_ARCH_SUPPORTS
depends on BR2_PACKAGE_HOST_GO_TARGET_CGO_LINKING_SUPPORTS
select BR2_PACKAGE_HOST_GO

config BR2_PACKAGE_DELVE
bool "delve"
Expand Down
1 change: 1 addition & 0 deletions package/delve/Config.in.host
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
config BR2_PACKAGE_HOST_DELVE
bool "host delve"
depends on BR2_PACKAGE_HOST_GO_HOST_ARCH_SUPPORTS
select BR2_PACKAGE_HOST_GO
help
Delve is a debugger for the Go programming language.

Expand Down
1 change: 1 addition & 0 deletions package/docker-cli/Config.in
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ config BR2_PACKAGE_DOCKER_CLI
depends on BR2_PACKAGE_HOST_GO_TARGET_ARCH_SUPPORTS
depends on BR2_PACKAGE_HOST_GO_TARGET_CGO_LINKING_SUPPORTS
depends on BR2_TOOLCHAIN_HAS_THREADS
select BR2_PACKAGE_HOST_GO
help
Docker is a platform to build, ship,
and run applications as lightweight containers.
Expand Down
1 change: 1 addition & 0 deletions package/docker-compose/Config.in
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ config BR2_PACKAGE_DOCKER_COMPOSE
depends on BR2_PACKAGE_HOST_GO_TARGET_CGO_LINKING_SUPPORTS
depends on BR2_TOOLCHAIN_HAS_THREADS
depends on BR2_PACKAGE_DOCKER_CLI
select BR2_PACKAGE_HOST_GO
help
Multi-container applications with the Docker CLI.

Expand Down
1 change: 1 addition & 0 deletions package/docker-engine/Config.in
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ config BR2_PACKAGE_DOCKER_ENGINE
depends on BR2_TOOLCHAIN_HEADERS_AT_LEAST_3_17 # libseccomp
select BR2_PACKAGE_CGROUPFS_MOUNT if !BR2_PACKAGE_SYSTEMD # runtime dependency
select BR2_PACKAGE_CONTAINERD # runtime dependency
select BR2_PACKAGE_HOST_GO
select BR2_PACKAGE_IPTABLES # runtime dependency
select BR2_PACKAGE_LIBSECCOMP
help
Expand Down
1 change: 1 addition & 0 deletions package/embiggen-disk/Config.in
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ config BR2_PACKAGE_EMBIGGEN_DISK
depends on BR2_TOOLCHAIN_HAS_THREADS
depends on !BR2_TOOLCHAIN_USES_UCLIBC # no fexecve
depends on BR2_USE_MMU # util-linux
select BR2_PACKAGE_HOST_GO
select BR2_PACKAGE_UTIL_LINUX # sfdisk
select BR2_PACKAGE_UTIL_LINUX_BINARIES # sfdisk
help
Expand Down
1 change: 1 addition & 0 deletions package/flannel/Config.in
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ config BR2_PACKAGE_FLANNEL
depends on BR2_PACKAGE_HOST_GO_TARGET_ARCH_SUPPORTS
depends on BR2_PACKAGE_HOST_GO_TARGET_CGO_LINKING_SUPPORTS
depends on BR2_TOOLCHAIN_HAS_THREADS
select BR2_PACKAGE_HOST_GO
help
Flannel is a virtual network that gives a subnet to each
host for use with container runtimes.
Expand Down
1 change: 1 addition & 0 deletions package/gitlab-runner/Config.in
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ config BR2_PACKAGE_GITLAB_RUNNER
select BR2_PACKAGE_BUSYBOX_SHOW_OTHERS # bash
select BR2_PACKAGE_CA_CERTIFICATES # runtime
select BR2_PACKAGE_GIT # runtime
select BR2_PACKAGE_HOST_GO
select BR2_PACKAGE_LIBCURL # runtime
select BR2_PACKAGE_LIBCURL_CURL # runtime
select BR2_PACKAGE_LIBCURL_FORCE_TLS # runtime
Expand Down
48 changes: 47 additions & 1 deletion package/go/Config.in.host
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
config BR2_PACKAGE_HOST_GO_TARGET_ARCH_SUPPORTS
bool
default y
depends on BR2_PACKAGE_HOST_GO_BOOTSTRAP_STAGE3_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 \
Expand All @@ -25,9 +24,56 @@ config BR2_PACKAGE_HOST_GO_TARGET_CGO_LINKING_SUPPORTS
# Go doesn't support CGO linking on MIPS64x platforms
# See: https://github.com/karalabe/xgo/issues/46
depends on !BR2_mips64 && !BR2_mips64el
# go uses dlfcn.h + cgo for its plugin module
depends on !BR2_STATIC_LIBS
# cgo supports uses threads
depends on BR2_TOOLCHAIN_HAS_THREADS

# Host go packages should depend on BR2_PACKAGE_HOST_GO_HOST_ARCH_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

# Go packages should select BR2_PACKAGE_HOST_GO
config BR2_PACKAGE_HOST_GO
bool
depends on BR2_PACKAGE_HOST_GO_HOST_ARCH_SUPPORTS

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_BIN if BR2_PACKAGE_HOST_GO_BIN_HOST_ARCH_SUPPORTS
help
Select a Go compiler variant.

Default to 'host-go-src'.

config BR2_PACKAGE_HOST_GO_SRC
bool "host go (source)"
depends on BR2_PACKAGE_HOST_GO_BOOTSTRAP_STAGE3_ARCH_SUPPORTS
help
This package will build the go compiler for the host.

config BR2_PACKAGE_HOST_GO_BIN
bool "host go (pre-built)"
depends on BR2_PACKAGE_HOST_GO_BIN_HOST_ARCH_SUPPORTS
help
This package will install pre-built versions of the compiler

endchoice

config BR2_PACKAGE_PROVIDES_HOST_GO
string
# Default to host-go-src
default "host-go-src" if BR2_PACKAGE_HOST_GO_SRC
default "host-go-bin" if BR2_PACKAGE_HOST_GO_BIN

endif

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"
13 changes: 13 additions & 0 deletions package/go/go-bin/Config.in.host
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
config BR2_PACKAGE_HOST_GO_BIN_HOST_ARCH
string "Translate the HOSTARCH into the architecture name used by the Go compiler"
default "armv6l" if BR2_HOSTARCH = "arm"
default "arm64" if BR2_HOSTARCH = "aarch64"
default "ppc64le" if BR2_HOSTARCH = "powerpc64le"
default "s390x" if BR2_HOSTARCH = "s390x"
default "386" if BR2_HOSTARCH = "x86"
default "amd64" if BR2_HOSTARCH = "x86_64"

config BR2_PACKAGE_HOST_GO_BIN_HOST_ARCH_SUPPORTS
bool
default y
depends on BR2_PACKAGE_HOST_GO_BIN_HOST_ARCH != ""
9 changes: 9 additions & 0 deletions package/go/go-bin/go-bin.hash
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# sha256 checksum from https://go.dev/dl/
sha256 ac9c723f224969aee624bc34fd34c9e13f2a212d75c71c807de644bb46e112f6 go1.22.5.src.tar.gz
sha256 3ea4c78e6fa52978ae1ed2e5927ad17495da440c9fae7787b1ebc1d0572f7f43 go1.22.5.linux-386.tar.gz
sha256 904b924d435eaea086515bc63235b192ea441bd8c9b198c507e85009e6e4c7f0 go1.22.5.linux-amd64.tar.gz
sha256 8d21325bfcf431be3660527c1a39d3d9ad71535fabdf5041c826e44e31642b5a go1.22.5.linux-arm64.tar.gz
sha256 8c4587cf3e63c9aefbcafa92818c4d9d51683af93ea687bf6c7508d6fa36f85e go1.22.5.linux-armv6l.tar.gz
sha256 5312bb420ac0b59175a58927e70b4660b14ab7319aab54398b6071fabcbfbb09 go1.22.5.linux-ppc64le.tar.gz
sha256 24c6c5c9d515adea5d58ae78388348c97614a0c21ac4d4f4c0dab75e893b0b5d go1.22.5.linux-s390x.tar.gz
sha256 2d36597f7117c38b006835ae7f537487207d8ec407aa9d9980794b2030cbc067 LICENSE
20 changes: 20 additions & 0 deletions package/go/go-bin/go-bin.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
################################################################################
#
# go-bin
#
################################################################################

GO_BIN_SITE = https://go.dev/dl
HOST_GO_BIN_ACTUAL_SOURCE_TARBALL = go$(GO_VERSION).src.tar.gz
GO_BIN_LICENSE = BSD-3-Clause
GO_BIN_LICENSE_FILES = LICENSE

HOST_GO_BIN_PROVIDES = host-go

HOST_GO_BIN_SOURCE = go$(GO_VERSION).linux-$(call qstrip, $(BR2_PACKAGE_HOST_GO_BIN_HOST_ARCH)).tar.gz

define HOST_GO_BIN_INSTALL_CMDS
$(GO_BINARIES_INSTALL)
endef

$(eval $(host-generic-package))
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
56 changes: 56 additions & 0 deletions package/go/go-src/go-src.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
################################################################################
#
# go-src
#
################################################################################

GO_SRC_SITE = https://storage.googleapis.com/golang
GO_SRC_SOURCE = go$(GO_VERSION).src.tar.gz

GO_SRC_LICENSE = BSD-3-Clause
GO_SRC_LICENSE_FILES = LICENSE
GO_SRC_CPE_ID_VENDOR = golang

HOST_GO_SRC_PROVIDES = host-go
HOST_GO_SRC_DEPENDENCIES = \
host-go-bootstrap-stage3 \
$(HOST_GO_DEPENDENCIES_CGO)

ifeq ($(BR2_PACKAGE_HOST_GO_TARGET_ARCH_SUPPORTS),y)

HOST_GO_SRC_CROSS_ENV = \
CC_FOR_TARGET="$(TARGET_CC)" \
CXX_FOR_TARGET="$(TARGET_CXX)" \
GOOS="linux" \
GOARCH=$(GO_GOARCH) \
$(if $(GO_GO386),GO386=$(GO_GO386)) \
$(if $(GO_GOARM),GOARM=$(GO_GOARM)) \
GO_ASSUME_CROSSCOMPILING=1

endif

# The go build system is not compatible with ccache, so use
# HOSTCC_NOCCACHE. See https://github.com/golang/go/issues/11685.
HOST_GO_SRC_MAKE_ENV = \
GO111MODULE=off \
GOCACHE=$(HOST_GO_HOST_CACHE) \
GOROOT_BOOTSTRAP=$(HOST_GO_BOOTSTRAP_STAGE3_ROOT) \
GOROOT_FINAL=$(HOST_GO_ROOT) \
GOROOT="$(@D)" \
GOBIN="$(@D)/bin" \
GOOS=linux \
CC=$(HOSTCC_NOCCACHE) \
CXX=$(HOSTCXX_NOCCACHE) \
CGO_ENABLED=$(HOST_GO_CGO_ENABLED) \
$(HOST_GO_SRC_CROSS_ENV)

define HOST_GO_SRC_BUILD_CMDS
cd $(@D)/src && \
$(HOST_GO_SRC_MAKE_ENV) ./make.bash $(if $(VERBOSE),-v)
endef

define HOST_GO_SRC_INSTALL_CMDS
$(GO_BINARIES_INSTALL)
endef

$(eval $(host-generic-package))
64 changes: 17 additions & 47 deletions package/go/go.mk
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,7 @@
################################################################################

GO_VERSION = 1.22.5
GO_SITE = https://storage.googleapis.com/golang
GO_SOURCE = go$(GO_VERSION).src.tar.gz

GO_LICENSE = BSD-3-Clause
GO_LICENSE_FILES = LICENSE
GO_CPE_ID_VENDOR = golang

HOST_GO_DEPENDENCIES = host-go-bootstrap-stage3
HOST_GO_GOPATH = $(HOST_DIR)/share/go-path
HOST_GO_HOST_CACHE = $(HOST_DIR)/share/host-go-cache
HOST_GO_ROOT = $(HOST_DIR)/lib/go
Expand Down Expand Up @@ -85,31 +78,26 @@ HOST_GO_TARGET_ENV = \
CGO_LDFLAGS="$(TARGET_LDFLAGS)" \
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)
HOST_GO_DEPENDENCIES += toolchain
# Allow packages to use cgo support if it is available for the target. They
# will need the toolchain for cgo support; for convenence, include that
# dependency here.
#
# Note that any target package needing cgo support must include 'depends on
# BR2_PACKAGE_HOST_GO_TARGET_CGO_LINKING_SUPPORTS' in its config file.
ifeq ($(BR2_PACKAGE_HOST_GO_TARGET_CGO_LINKING_SUPPORTS),y)
HOST_GO_DEPENDENCIES_CGO += toolchain
HOST_GO_CGO_ENABLED = 1
else
HOST_GO_CGO_ENABLED = 0
endif

HOST_GO_CROSS_ENV = \
CC_FOR_TARGET="$(TARGET_CC)" \
CXX_FOR_TARGET="$(TARGET_CXX)" \
GOOS="linux" \
GOARCH=$(GO_GOARCH) \
$(if $(GO_GO386),GO386=$(GO_GO386)) \
$(if $(GO_GOARM),GOARM=$(GO_GOARM)) \
GO_ASSUME_CROSSCOMPILING=1

else # !BR2_PACKAGE_HOST_GO_TARGET_ARCH_SUPPORTS
# host-go can still be used to build packages for the host. No need to set all
# the arch stuff since we will not be cross-compiling.
# If the target arch does not support go, host-go can still be used to build
# packages for the host, and enable cgo. No need to set all the arch stuff
#since we will not be cross-compiling.
HOST_GO_CGO_ENABLED = 1
endif # BR2_PACKAGE_HOST_GO_TARGET_ARCH_SUPPORTS
# Ensure the toolchain is available, whatever the provider
HOST_GO_DEPENDENCIES += $(HOST_GO_DEPENDENCIES_CGO)

# For the convenience of host golang packages
HOST_GO_HOST_ENV = \
Expand All @@ -123,27 +111,7 @@ HOST_GO_HOST_ENV = \
CGO_CXXFLAGS="$(HOST_CXXFLAGS)" \
CGO_LDFLAGS="$(HOST_LDFLAGS)"

# The go build system is not compatible with ccache, so use
# HOSTCC_NOCCACHE. See https://github.com/golang/go/issues/11685.
HOST_GO_MAKE_ENV = \
GO111MODULE=off \
GOCACHE=$(HOST_GO_HOST_CACHE) \
GOROOT_BOOTSTRAP=$(HOST_GO_BOOTSTRAP_STAGE3_ROOT) \
GOROOT_FINAL=$(HOST_GO_ROOT) \
GOROOT="$(@D)" \
GOBIN="$(@D)/bin" \
GOOS=linux \
CC=$(HOSTCC_NOCCACHE) \
CXX=$(HOSTCXX_NOCCACHE) \
CGO_ENABLED=$(HOST_GO_CGO_ENABLED) \
$(HOST_GO_CROSS_ENV)

define HOST_GO_BUILD_CMDS
cd $(@D)/src && \
$(HOST_GO_MAKE_ENV) ./make.bash $(if $(VERBOSE),-v)
endef

define HOST_GO_INSTALL_CMDS
define GO_BINARIES_INSTALL
$(INSTALL) -D -m 0755 $(@D)/bin/go $(HOST_GO_ROOT)/bin/go
$(INSTALL) -D -m 0755 $(@D)/bin/gofmt $(HOST_GO_ROOT)/bin/gofmt

Expand All @@ -165,4 +133,6 @@ define HOST_GO_INSTALL_CMDS
find $(HOST_GO_ROOT) -type f -exec touch -r $(@D)/bin/go {} \;
endef

$(eval $(host-generic-package))
$(eval $(host-virtual-package))

include $(sort $(wildcard package/go/*/*.mk))
Loading

0 comments on commit 89ba349

Please sign in to comment.