From: Charles Hardin <ckhardin@gmail.com>
To: buildroot@buildroot.org
Cc: Charles Hardin <ckhardin@gmail.com>,
Christian Stewart <christian@aperture.us>,
Thomas Petazzoni <thomas.petazzoni@bootlin.com>,
Anisse Astier <anisse@astier.eu>
Subject: [Buildroot] [PATCH 1/1] package/go-native: add a new download only package for go compilers
Date: Fri, 7 Jul 2023 11:51:06 -0700 [thread overview]
Message-ID: <20230707185106.98208-1-ckhardin@gmail.com> (raw)
The go-native is mainly for the aarch64 support since that was
added after the go-bootstrap written in C was dropped. So, to
get a cross compiler for go a host/native compiler needs to be
available to generate the setup for the needed target. This is
using the same go version as the expected cross-compiler to
keep the packages in sync. A specific version could be used.
Signed-off-by: Charles Hardin <ckhardin@gmail.com>
---
package/Config.in.host | 1 +
package/go-native/Config.in.host | 12 ++++++++
package/go-native/go-native.hash | 5 ++++
package/go-native/go-native.mk | 48 ++++++++++++++++++++++++++++++++
package/go/Config.in.host | 6 ++--
package/go/go.mk | 12 +++++++-
6 files changed, 81 insertions(+), 3 deletions(-)
create mode 100644 package/go-native/Config.in.host
create mode 100644 package/go-native/go-native.hash
create mode 100644 package/go-native/go-native.mk
diff --git a/package/Config.in.host b/package/Config.in.host
index dcadbfdfc1..d7932f048b 100644
--- a/package/Config.in.host
+++ b/package/Config.in.host
@@ -41,6 +41,7 @@ menu "Host utilities"
source "package/gnupg/Config.in.host"
source "package/go/Config.in.host"
source "package/go-bootstrap/Config.in.host"
+ source "package/go-native/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/go-native/Config.in.host b/package/go-native/Config.in.host
new file mode 100644
index 0000000000..7e978e02b5
--- /dev/null
+++ b/package/go-native/Config.in.host
@@ -0,0 +1,12 @@
+config BR2_PACKAGE_HOST_GO_NATIVE_ARCH_SUPPORTS
+ bool
+ # See https://go.dev/dl/ for supported architecture downloads
+ default y if BR2_HOSTARCH = "x86"
+ default y if BR2_HOSTARCH = "x86_64"
+ default y if BR2_HOSTARCH = "arm"
+ default y if BR2_HOSTARCH = "aarch64"
+
+config BR2_PACKAGE_HOST_GO_NATIVE
+ bool "host go-native"
+ depends on BR2_PACKAGE_HOST_GO_NATIVE_ARCH_SUPPORTS
+ default y if !BR2_PACKAGE_HOST_GO_BOOTSTRAP_ARCH_SUPPORTS
diff --git a/package/go-native/go-native.hash b/package/go-native/go-native.hash
new file mode 100644
index 0000000000..3af2f51abc
--- /dev/null
+++ b/package/go-native/go-native.hash
@@ -0,0 +1,5 @@
+# From https://go.dev/dl/
+sha256 45a34313664d66087d49b46ca63a3ecf292f56e9e63bd439829b5eaf0270586d go1.19.10.linux-386.tar.gz
+sha256 8b045a483d3895c6edba2e90a9189262876190dbbd21756870cdd63821810677 go1.19.10.linux-amd64.tar.gz
+sha256 df98698821211c819e8b2420c77a0f802d989e377718578a31b1f91f6be2c5b4 go1.19.10.linux-arm64.tar.gz
+sha256 937f885c35f191be4c6a618868ae0dbbb15b0213925a1a104d122eba02622356 go1.19.10.linux-armv6l.tar.gz
diff --git a/package/go-native/go-native.mk b/package/go-native/go-native.mk
new file mode 100644
index 0000000000..4b541cce73
--- /dev/null
+++ b/package/go-native/go-native.mk
@@ -0,0 +1,48 @@
+################################################################################
+#
+# go-native
+#
+################################################################################
+
+# Fixup the host arch as needed
+ifeq ($(HOSTARCH),x86)
+GO_NATIVE_HOST_ARCH = 386
+else ifeq ($(HOSTARCH),x86_64)
+GO_NATIVE_HOST_ARCH = amd64
+else ifeq ($(HOSTARCH),arm)
+GO_NATIVE_HOST_ARCH = armv6l
+else ifeq ($(HOSTARCH),aarch64)
+GO_NATIVE_HOST_ARCH = arm64
+else
+GO_NATIVE_HOST_ARCH = $(HOSTARCH)
+endif
+
+# Download the native tools from as the same go version from golang
+GO_NATIVE_VERSION = $(GO_VERSION)
+GO_NATIVE_SITE = https://go.dev/dl
+GO_NATIVE_LICENSE = BSD-3-Clause
+GO_NATIVE_LICENSE_FILES = LICENSE
+
+HOST_GO_NATIVE_SOURCE = go$(GO_NATIVE_VERSION).linux-$(GO_NATIVE_HOST_ARCH).tar.gz
+
+# To build programs that need cgo support the toolchain needs to be
+# available, so the toolchain is not needed to build host-go-native
+# itself, but needed by other packages that depend on
+# host-go-native.
+HOST_GO_NATIVE_DEPENDENCIES = toolchain
+
+HOST_GO_NATIVE_ROOT = $(HOST_DIR)/lib/go-$(GO_NATIVE_VERSION)
+
+define HOST_GO_NATIVE_INSTALL_CMDS
+ $(INSTALL) -D -m 0755 $(@D)/bin/go $(HOST_GO_NATIVE_ROOT)/bin/go
+ $(INSTALL) -D -m 0755 $(@D)/bin/gofmt $(HOST_GO_NATIVE_ROOT)/bin/gofmt
+
+ cp -a $(@D)/lib $(HOST_GO_NATIVE_ROOT)/
+ cp -a $(@D)/pkg $(HOST_GO_NATIVE_ROOT)/
+
+ # There is a known issue which requires the go sources to be installed
+ # https://golang.org/issue/2775
+ cp -a $(@D)/src $(HOST_GO_NATIVE_ROOT)/
+endef
+
+$(eval $(host-generic-package))
diff --git a/package/go/Config.in.host b/package/go/Config.in.host
index ded02d3b3a..4dbbe9a221 100644
--- a/package/go/Config.in.host
+++ b/package/go/Config.in.host
@@ -2,7 +2,8 @@
config BR2_PACKAGE_HOST_GO_TARGET_ARCH_SUPPORTS
bool
default y
- depends on BR2_PACKAGE_HOST_GO_BOOTSTRAP_ARCH_SUPPORTS
+ depends on BR2_PACKAGE_HOST_GO_BOOTSTRAP_ARCH_SUPPORTS \
+ || BR2_PACKAGE_HOST_GO_NATIVE_ARCH_SUPPORTS
depends on (BR2_arm && BR2_TOOLCHAIN_SUPPORTS_PIE) || BR2_aarch64 \
|| BR2_i386 || BR2_x86_64 || BR2_powerpc64le \
|| BR2_mips64 || BR2_mips64el || BR2_riscv || BR2_s390x
@@ -28,4 +29,5 @@ 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_ARCH_SUPPORTS
+ depends on BR2_PACKAGE_HOST_GO_BOOTSTRAP_ARCH_SUPPORTS \
+ || BR2_PACKAGE_HOST_GO_NATIVE_ARCH_SUPPORTS
diff --git a/package/go/go.mk b/package/go/go.mk
index 545d2117b7..af2e3b2f74 100644
--- a/package/go/go.mk
+++ b/package/go/go.mk
@@ -12,7 +12,11 @@ GO_LICENSE = BSD-3-Clause
GO_LICENSE_FILES = LICENSE
GO_CPE_ID_VENDOR = golang
+ifeq ($(BR2_PACKAGE_HOST_GO_NATIVE),y)
+HOST_GO_DEPENDENCIES = host-go-native
+else
HOST_GO_DEPENDENCIES = host-go-bootstrap
+endif
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
@@ -123,10 +127,16 @@ HOST_GO_HOST_ENV = \
# The go build system is not compatible with ccache, so use
# HOSTCC_NOCCACHE. See https://github.com/golang/go/issues/11685.
+ifeq ($(BR2_PACKAGE_HOST_GO_NATIVE),y)
HOST_GO_MAKE_ENV = \
+ GOROOT_BOOTSTRAP=$(HOST_GO_NATIVE_ROOT)
+else
+HOST_GO_MAKE_ENV = \
+ GOROOT_BOOTSTRAP=$(HOST_GO_BOOTSTRAP_ROOT)
+endif
+HOST_GO_MAKE_ENV += \
GO111MODULE=off \
GOCACHE=$(HOST_GO_HOST_CACHE) \
- GOROOT_BOOTSTRAP=$(HOST_GO_BOOTSTRAP_ROOT) \
GOROOT_FINAL=$(HOST_GO_ROOT) \
GOROOT="$(@D)" \
GOBIN="$(@D)/bin" \
--
2.39.2 (Apple Git-143)
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot
next reply other threads:[~2023-07-07 18:51 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-07-07 18:51 Charles Hardin [this message]
2023-07-07 19:04 ` [Buildroot] [PATCH 1/1] package/go-native: add a new download only package for go compilers Christian Stewart via buildroot
2023-07-07 19:07 ` Christian Stewart via buildroot
2023-07-07 20:05 ` Charles Hardin
2023-07-07 20:19 ` Christian Stewart via buildroot
2026-11-20 22:13 ` [Buildroot] [1/1] " Angelo Compagnucci
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20230707185106.98208-1-ckhardin@gmail.com \
--to=ckhardin@gmail.com \
--cc=anisse@astier.eu \
--cc=buildroot@buildroot.org \
--cc=christian@aperture.us \
--cc=thomas.petazzoni@bootlin.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox