diff --git a/.checkpackageignore b/.checkpackageignore index 4eff91e184d..69dcd26a5e9 100644 --- a/.checkpackageignore +++ b/.checkpackageignore @@ -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 diff --git a/DEVELOPERS b/DEVELOPERS index b66d90d33d6..327365c6419 100644 --- a/DEVELOPERS +++ b/DEVELOPERS @@ -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/ @@ -3039,6 +3036,9 @@ F: package/frotz/ F: package/kvm-unit-tests/ F: package/xorcurses/ +N: Thomas Perale +F: package/go/ + N: Thomas Petazzoni F: arch/Config.in.arm F: board/beaglev/ diff --git a/package/Config.in.host b/package/Config.in.host index 986b2854d0f..eacce5e4482 100644 --- a/package/Config.in.host +++ b/package/Config.in.host @@ -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" diff --git a/package/balena-engine/Config.in b/package/balena-engine/Config.in index 02f694515ec..5966b33f585 100644 --- a/package/balena-engine/Config.in +++ b/package/balena-engine/Config.in @@ -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 diff --git a/package/cni-plugins/Config.in b/package/cni-plugins/Config.in index 25e6ff534df..6d4ca0a5b41 100644 --- a/package/cni-plugins/Config.in +++ b/package/cni-plugins/Config.in @@ -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. diff --git a/package/containerd/Config.in b/package/containerd/Config.in index 2dd04b109c7..f014c56e105 100644 --- a/package/containerd/Config.in +++ b/package/containerd/Config.in @@ -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 diff --git a/package/crucible/Config.in b/package/crucible/Config.in index b27eb31ae5d..1e1b29c3df8 100644 --- a/package/crucible/Config.in +++ b/package/crucible/Config.in @@ -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. diff --git a/package/delve/Config.in b/package/delve/Config.in index 9428e4016ad..288dc1ea15a 100644 --- a/package/delve/Config.in +++ b/package/delve/Config.in @@ -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" diff --git a/package/delve/Config.in.host b/package/delve/Config.in.host index dab5ca89144..0938ab0659b 100644 --- a/package/delve/Config.in.host +++ b/package/delve/Config.in.host @@ -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. diff --git a/package/docker-cli/Config.in b/package/docker-cli/Config.in index 6f187c9d222..52e7f7c8712 100644 --- a/package/docker-cli/Config.in +++ b/package/docker-cli/Config.in @@ -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. diff --git a/package/docker-compose/Config.in b/package/docker-compose/Config.in index 59128f7a199..f3560e402b7 100644 --- a/package/docker-compose/Config.in +++ b/package/docker-compose/Config.in @@ -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. diff --git a/package/docker-engine/Config.in b/package/docker-engine/Config.in index d48ffe6484a..49a002a6478 100644 --- a/package/docker-engine/Config.in +++ b/package/docker-engine/Config.in @@ -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 diff --git a/package/embiggen-disk/Config.in b/package/embiggen-disk/Config.in index 667d71c86e6..c323fb1b6d6 100644 --- a/package/embiggen-disk/Config.in +++ b/package/embiggen-disk/Config.in @@ -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 diff --git a/package/flannel/Config.in b/package/flannel/Config.in index eb8d798f48b..f37cfaa9cc3 100644 --- a/package/flannel/Config.in +++ b/package/flannel/Config.in @@ -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. diff --git a/package/gitlab-runner/Config.in b/package/gitlab-runner/Config.in index 4289613ab9e..cfe8c941bca 100644 --- a/package/gitlab-runner/Config.in +++ b/package/gitlab-runner/Config.in @@ -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 diff --git a/package/go/Config.in.host b/package/go/Config.in.host index 0d89e875adc..ebd97c84df4 100644 --- a/package/go/Config.in.host +++ b/package/go/Config.in.host @@ -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 \ @@ -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" diff --git a/package/go/go-bin/Config.in.host b/package/go/go-bin/Config.in.host new file mode 100644 index 00000000000..51fe3c3fdc9 --- /dev/null +++ b/package/go/go-bin/Config.in.host @@ -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 != "" diff --git a/package/go/go-bin/go-bin.hash b/package/go/go-bin/go-bin.hash new file mode 100644 index 00000000000..b81c9df0f4c --- /dev/null +++ b/package/go/go-bin/go-bin.hash @@ -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 diff --git a/package/go/go-bin/go-bin.mk b/package/go/go-bin/go-bin.mk new file mode 100644 index 00000000000..155483a2fc9 --- /dev/null +++ b/package/go/go-bin/go-bin.mk @@ -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)) diff --git a/package/go-bootstrap-stage1/Config.in.host b/package/go/go-bootstrap-stage1/Config.in.host similarity index 100% rename from package/go-bootstrap-stage1/Config.in.host rename to package/go/go-bootstrap-stage1/Config.in.host diff --git a/package/go-bootstrap-stage1/go-bootstrap-stage1.hash b/package/go/go-bootstrap-stage1/go-bootstrap-stage1.hash similarity index 100% rename from package/go-bootstrap-stage1/go-bootstrap-stage1.hash rename to package/go/go-bootstrap-stage1/go-bootstrap-stage1.hash diff --git a/package/go-bootstrap-stage1/go-bootstrap-stage1.mk b/package/go/go-bootstrap-stage1/go-bootstrap-stage1.mk similarity index 100% rename from package/go-bootstrap-stage1/go-bootstrap-stage1.mk rename to package/go/go-bootstrap-stage1/go-bootstrap-stage1.mk diff --git a/package/go-bootstrap-stage2/Config.in.host b/package/go/go-bootstrap-stage2/Config.in.host similarity index 100% rename from package/go-bootstrap-stage2/Config.in.host rename to package/go/go-bootstrap-stage2/Config.in.host diff --git a/package/go-bootstrap-stage2/go-bootstrap-stage2.hash b/package/go/go-bootstrap-stage2/go-bootstrap-stage2.hash similarity index 100% rename from package/go-bootstrap-stage2/go-bootstrap-stage2.hash rename to package/go/go-bootstrap-stage2/go-bootstrap-stage2.hash diff --git a/package/go-bootstrap-stage2/go-bootstrap-stage2.mk b/package/go/go-bootstrap-stage2/go-bootstrap-stage2.mk similarity index 100% rename from package/go-bootstrap-stage2/go-bootstrap-stage2.mk rename to package/go/go-bootstrap-stage2/go-bootstrap-stage2.mk diff --git a/package/go-bootstrap-stage3/0001-cmd-dist-set-buildvcs-false-when-building-go-bootstr.patch b/package/go/go-bootstrap-stage3/0001-cmd-dist-set-buildvcs-false-when-building-go-bootstr.patch similarity index 100% rename from package/go-bootstrap-stage3/0001-cmd-dist-set-buildvcs-false-when-building-go-bootstr.patch rename to package/go/go-bootstrap-stage3/0001-cmd-dist-set-buildvcs-false-when-building-go-bootstr.patch diff --git a/package/go-bootstrap-stage3/Config.in.host b/package/go/go-bootstrap-stage3/Config.in.host similarity index 100% rename from package/go-bootstrap-stage3/Config.in.host rename to package/go/go-bootstrap-stage3/Config.in.host diff --git a/package/go-bootstrap-stage3/go-bootstrap-stage3.hash b/package/go/go-bootstrap-stage3/go-bootstrap-stage3.hash similarity index 100% rename from package/go-bootstrap-stage3/go-bootstrap-stage3.hash rename to package/go/go-bootstrap-stage3/go-bootstrap-stage3.hash diff --git a/package/go-bootstrap-stage3/go-bootstrap-stage3.mk b/package/go/go-bootstrap-stage3/go-bootstrap-stage3.mk similarity index 100% rename from package/go-bootstrap-stage3/go-bootstrap-stage3.mk rename to package/go/go-bootstrap-stage3/go-bootstrap-stage3.mk diff --git a/package/go/0001-build.go-explicit-option-for-crosscompilation.patch b/package/go/go-src/0001-build.go-explicit-option-for-crosscompilation.patch similarity index 100% rename from package/go/0001-build.go-explicit-option-for-crosscompilation.patch rename to package/go/go-src/0001-build.go-explicit-option-for-crosscompilation.patch diff --git a/package/go/0002-cmd-dist-set-buildvcs-false-when-building-go-bootstr.patch b/package/go/go-src/0002-cmd-dist-set-buildvcs-false-when-building-go-bootstr.patch similarity index 100% rename from package/go/0002-cmd-dist-set-buildvcs-false-when-building-go-bootstr.patch rename to package/go/go-src/0002-cmd-dist-set-buildvcs-false-when-building-go-bootstr.patch diff --git a/package/go/go.hash b/package/go/go-src/go-src.hash similarity index 100% rename from package/go/go.hash rename to package/go/go-src/go-src.hash diff --git a/package/go/go-src/go-src.mk b/package/go/go-src/go-src.mk new file mode 100644 index 00000000000..0d1a9b3187d --- /dev/null +++ b/package/go/go-src/go-src.mk @@ -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)) diff --git a/package/go/go.mk b/package/go/go.mk index e6f61d643be..660c7a9bada 100644 --- a/package/go/go.mk +++ b/package/go/go.mk @@ -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 @@ -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 = \ @@ -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 @@ -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)) diff --git a/package/gocryptfs/Config.in b/package/gocryptfs/Config.in index 2630cafdcfa..2c70b9b21ba 100644 --- a/package/gocryptfs/Config.in +++ b/package/gocryptfs/Config.in @@ -2,6 +2,7 @@ config BR2_PACKAGE_GOCRYPTFS bool "gocryptfs" depends on BR2_PACKAGE_HOST_GO_TARGET_ARCH_SUPPORTS depends on BR2_TOOLCHAIN_HAS_THREADS + select BR2_PACKAGE_HOST_GO help gocryptfs is an encrypted FUSE overlay filesystem. diff --git a/package/mender-artifact/Config.in.host b/package/mender-artifact/Config.in.host index c7be0ed2616..39353b23e74 100644 --- a/package/mender-artifact/Config.in.host +++ b/package/mender-artifact/Config.in.host @@ -1,6 +1,7 @@ config BR2_PACKAGE_HOST_MENDER_ARTIFACT bool "host mender-artifact" depends on BR2_PACKAGE_HOST_GO_HOST_ARCH_SUPPORTS + select BR2_PACKAGE_HOST_GO help The mender-artifact tool is a CLI implementation of the Mender artifacts library. diff --git a/package/mender-connect/Config.in b/package/mender-connect/Config.in index 0845910880b..d478e468c2e 100644 --- a/package/mender-connect/Config.in +++ b/package/mender-connect/Config.in @@ -6,6 +6,7 @@ config BR2_PACKAGE_MENDER_CONNECT depends on BR2_USE_WCHAR # libglib2 -> gettext depends on BR2_USE_MMU # dbus -> fork() select BR2_PACKAGE_DBUS # runtime + select BR2_PACKAGE_HOST_GO select BR2_PACKAGE_LIBGLIB2 select BR2_PACKAGE_MENDER # runtime select BR2_PACKAGE_OPENSSL diff --git a/package/mender/Config.in b/package/mender/Config.in index 7d768cebec6..4831548f76d 100644 --- a/package/mender/Config.in +++ b/package/mender/Config.in @@ -3,6 +3,7 @@ config BR2_PACKAGE_MENDER 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 select BR2_PACKAGE_OPENSSL select BR2_PACKAGE_OPENSSL_FORCE_LIBOPENSSL select BR2_PACKAGE_LIBOPENSSL_ENABLE_MD4 diff --git a/package/moby-buildkit/Config.in b/package/moby-buildkit/Config.in index 93c852bcdb3..1a0b599097c 100644 --- a/package/moby-buildkit/Config.in +++ b/package/moby-buildkit/Config.in @@ -6,6 +6,7 @@ config BR2_PACKAGE_MOBY_BUILDKIT depends on !BR2_TOOLCHAIN_USES_UCLIBC depends on BR2_USE_MMU select BR2_PACKAGE_CGROUPFS_MOUNT if !BR2_PACKAGE_SYSTEMD # runtime dependency + select BR2_PACKAGE_HOST_GO help BuildKit is a toolkit for converting source code to build artifacts in an efficient, expressive and repeatable manner. diff --git a/package/moby-buildkit/Config.in.host b/package/moby-buildkit/Config.in.host index a3b18548f84..d4eb0d74c31 100644 --- a/package/moby-buildkit/Config.in.host +++ b/package/moby-buildkit/Config.in.host @@ -1,6 +1,7 @@ config BR2_PACKAGE_HOST_MOBY_BUILDKIT bool "host moby-buildkit" depends on BR2_PACKAGE_HOST_GO_HOST_ARCH_SUPPORTS + select BR2_PACKAGE_HOST_GO help BuildKit is a toolkit for converting source code to build artifacts in an efficient expressive and repeatable manner. diff --git a/package/nerdctl/Config.in b/package/nerdctl/Config.in index 969b9bb40e9..062b36ab850 100644 --- a/package/nerdctl/Config.in +++ b/package/nerdctl/Config.in @@ -6,6 +6,7 @@ config BR2_PACKAGE_NERDCTL depends on !BR2_TOOLCHAIN_USES_UCLIBC # containerd depends on BR2_USE_MMU # util-linux select BR2_PACKAGE_CONTAINERD # runtime + select BR2_PACKAGE_HOST_GO help Docker-compatible CLI for containerd, controlling runc. diff --git a/package/runc/Config.in b/package/runc/Config.in index fe527b19548..73eac72527c 100644 --- a/package/runc/Config.in +++ b/package/runc/Config.in @@ -4,6 +4,7 @@ config BR2_PACKAGE_RUNC depends on BR2_PACKAGE_HOST_GO_TARGET_CGO_LINKING_SUPPORTS depends on BR2_TOOLCHAIN_HAS_THREADS depends on !BR2_TOOLCHAIN_USES_UCLIBC # no fexecve + select BR2_PACKAGE_HOST_GO help runC is a CLI tool for spawning and running containers according to the OCI specification. diff --git a/package/runc/Config.in.host b/package/runc/Config.in.host index 4b2555e029b..78193cb499b 100644 --- a/package/runc/Config.in.host +++ b/package/runc/Config.in.host @@ -1,6 +1,7 @@ config BR2_PACKAGE_HOST_RUNC bool "host runc" depends on BR2_PACKAGE_HOST_GO_HOST_ARCH_SUPPORTS + select BR2_PACKAGE_HOST_GO help runC is a CLI tool for spawning and running containers according to the OCI specification. diff --git a/package/tinifier/Config.in b/package/tinifier/Config.in index fbadfe6bd9e..eae8b8f4993 100644 --- a/package/tinifier/Config.in +++ b/package/tinifier/Config.in @@ -1,6 +1,7 @@ config BR2_PACKAGE_TINIFIER bool "tinifier" depends on BR2_PACKAGE_HOST_GO_TARGET_ARCH_SUPPORTS + select BR2_PACKAGE_HOST_GO help CLI tool for images compressing diff --git a/package/wtfutil/Config.in b/package/wtfutil/Config.in index 8c3efcea5dd..3fd8c41bab0 100644 --- a/package/wtfutil/Config.in +++ b/package/wtfutil/Config.in @@ -2,6 +2,7 @@ config BR2_PACKAGE_WTFUTIL bool "wtfutil" depends on BR2_USE_MMU # fork() depends on BR2_PACKAGE_HOST_GO_TARGET_ARCH_SUPPORTS + select BR2_PACKAGE_HOST_GO help WTF is the personal information dashboard for your terminal. diff --git a/support/testing/tests/package/test_go.py b/support/testing/tests/package/test_go.py new file mode 100644 index 00000000000..0b25fbc26d5 --- /dev/null +++ b/support/testing/tests/package/test_go.py @@ -0,0 +1,27 @@ +import os + +import infra.basetest + + +class TestGoBase(infra.basetest.BRTest): + + def login(self): + cpio_file = os.path.join(self.builddir, "images", "rootfs.cpio") + self.emulator.boot(arch="armv5", + kernel="builtin", + options=["-initrd", cpio_file]) + self.emulator.login() + + +class TestGoSource(TestGoBase): + config = infra.basetest.BASIC_TOOLCHAIN_CONFIG + \ + """ + BR2_TARGET_ROOTFS_CPIO=y + BR2_PACKAGE_HOST_GO=y + BR2_PACKAGE_HOST_GO_SRC=y + BR2_PACKAGE_TINIFIER=y + """ + + def test_run(self): + self.login() + self.assertRunOk("tinifier -h")