Buildroot Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [Buildroot] [PATCH 1/3] package/go: expose option to enable via configurator
@ 2024-06-10 15:40 Athaariq Ardhiansyah
  2024-06-10 15:40 ` [Buildroot] [PATCH 2/3] package/go: move source-specific to go-src Athaariq Ardhiansyah
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Athaariq Ardhiansyah @ 2024-06-10 15:40 UTC (permalink / raw)
  To: buildroot
  Cc: Athaariq Ardhiansyah, Anisse Astier, Christian Stewart,
	Thomas Perale

Just in case you forgot it, I re-exposed the configuration option for
enabling host-go virtual package before I'm adding host-go-bin
subpackage.

Signed-off-by: Athaariq Ardhiansyah <foss@athaariq.my.id>
---
 package/go/Config.in.host | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/package/go/Config.in.host b/package/go/Config.in.host
index 483393f8e4..32483871e7 100644
--- a/package/go/Config.in.host
+++ b/package/go/Config.in.host
@@ -34,7 +34,7 @@ config BR2_PACKAGE_HOST_GO_HOST_ARCH_SUPPORTS
 
 # Go packages should select BR2_PACKAGE_HOST_GO
 config BR2_PACKAGE_HOST_GO
-	bool
+	bool "host go"
 	depends on BR2_PACKAGE_HOST_GO_HOST_ARCH_SUPPORTS
 
 if BR2_PACKAGE_HOST_GO
-- 
2.45.2

_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [Buildroot] [PATCH 2/3] package/go: move source-specific to go-src
  2024-06-10 15:40 [Buildroot] [PATCH 1/3] package/go: expose option to enable via configurator Athaariq Ardhiansyah
@ 2024-06-10 15:40 ` Athaariq Ardhiansyah
  2024-09-14 16:27   ` Yann E. MORIN
  2024-06-10 15:40 ` [Buildroot] [PATCH 3/3] package/go: add prebuilt Go compiler option Athaariq Ardhiansyah
  2024-09-14 16:24 ` [Buildroot] [PATCH 1/3] package/go: expose option to enable via configurator Yann E. MORIN
  2 siblings, 1 reply; 6+ messages in thread
From: Athaariq Ardhiansyah @ 2024-06-10 15:40 UTC (permalink / raw)
  To: buildroot
  Cc: Athaariq Ardhiansyah, Anisse Astier, Christian Stewart,
	Thomas Perale

Some of package/go/go.mk includes source compilation specific
requirements, which are not effective for prebuilt Go compiler option.
Therefore, I moved some of source-specific conditionals and variables to
the host-go-src before adding host-go-bin support.

Signed-off-by: Athaariq Ardhiansyah <foss@athaariq.my.id>
---
 package/go/go-src/go-src.mk | 68 +++++++++++++++++++++++++++++++++++
 package/go/go.mk            | 71 -------------------------------------
 2 files changed, 68 insertions(+), 71 deletions(-)

diff --git a/package/go/go-src/go-src.mk b/package/go/go-src/go-src.mk
index 1e061e20bc..a0c903282f 100644
--- a/package/go/go-src/go-src.mk
+++ b/package/go/go-src/go-src.mk
@@ -16,6 +16,67 @@ HOST_GO_SRC_DEPENDENCIES = host-go-bootstrap-stage3
 
 ifeq ($(BR2_PACKAGE_HOST_GO_TARGET_ARCH_SUPPORTS),y)
 
+ifeq ($(BR2_arm),y)
+GO_GOARCH = arm
+ifeq ($(BR2_ARM_CPU_ARMV5),y)
+GO_GOARM = 5
+else ifeq ($(BR2_ARM_CPU_ARMV6),y)
+GO_GOARM = 6
+else ifeq ($(BR2_ARM_CPU_ARMV7A),y)
+GO_GOARM = 7
+else ifeq ($(BR2_ARM_CPU_ARMV8A),y)
+# Go doesn't support 32-bit GOARM=8 (https://github.com/golang/go/issues/29373)
+# but can still benefit from armv7 optimisations
+GO_GOARM = 7
+endif
+else ifeq ($(BR2_aarch64),y)
+GO_GOARCH = arm64
+else ifeq ($(BR2_i386),y)
+GO_GOARCH = 386
+# i386: use softfloat if no SSE2: https://golang.org/doc/go1.16#386
+ifneq ($(BR2_X86_CPU_HAS_SSE2),y)
+GO_GO386 = softfloat
+endif
+else ifeq ($(BR2_x86_64),y)
+GO_GOARCH = amd64
+else ifeq ($(BR2_powerpc64),y)
+GO_GOARCH = ppc64
+else ifeq ($(BR2_powerpc64le),y)
+GO_GOARCH = ppc64le
+else ifeq ($(BR2_mips64),y)
+GO_GOARCH = mips64
+else ifeq ($(BR2_mips64el),y)
+GO_GOARCH = mips64le
+else ifeq ($(BR2_riscv),y)
+GO_GOARCH = riscv64
+else ifeq ($(BR2_s390x),y)
+GO_GOARCH = s390x
+endif
+
+# For the convienience of target packages.
+HOST_GO_TOOLDIR = $(HOST_GO_ROOT)/pkg/tool/linux_$(GO_GOARCH)
+HOST_GO_TARGET_ENV = \
+	$(HOST_GO_COMMON_ENV) \
+	GOOS="linux" \
+	GOARCH=$(GO_GOARCH) \
+	CC="$(TARGET_CC)" \
+	CXX="$(TARGET_CXX)" \
+	CGO_CFLAGS="$(TARGET_CFLAGS)" \
+	CGO_CXXFLAGS="$(TARGET_CXXFLAGS)" \
+	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
+HOST_GO_CGO_ENABLED = 1
+else
+HOST_GO_CGO_ENABLED = 0
+endif
+
 HOST_GO_SRC_CROSS_ENV = \
 	CC_FOR_TARGET="$(TARGET_CC)" \
 	CXX_FOR_TARGET="$(TARGET_CXX)" \
@@ -25,6 +86,11 @@ HOST_GO_SRC_CROSS_ENV = \
 	$(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.
+HOST_GO_CGO_ENABLED = 1
+
 endif
 
 # The go build system is not compatible with ccache, so use
@@ -52,3 +118,5 @@ define HOST_GO_SRC_INSTALL_CMDS
 endef
 
 $(eval $(host-generic-package))
+
+include $(sort $(wildcard package/go/go-bootstrap-*/*.mk))
diff --git a/package/go/go.mk b/package/go/go.mk
index dfcb633aa7..489d749d46 100644
--- a/package/go/go.mk
+++ b/package/go/go.mk
@@ -26,75 +26,6 @@ HOST_GO_COMMON_ENV = \
 	GOBIN= \
 	CGO_ENABLED=$(HOST_GO_CGO_ENABLED)
 
-ifeq ($(BR2_PACKAGE_HOST_GO_TARGET_ARCH_SUPPORTS),y)
-
-ifeq ($(BR2_arm),y)
-GO_GOARCH = arm
-ifeq ($(BR2_ARM_CPU_ARMV5),y)
-GO_GOARM = 5
-else ifeq ($(BR2_ARM_CPU_ARMV6),y)
-GO_GOARM = 6
-else ifeq ($(BR2_ARM_CPU_ARMV7A),y)
-GO_GOARM = 7
-else ifeq ($(BR2_ARM_CPU_ARMV8A),y)
-# Go doesn't support 32-bit GOARM=8 (https://github.com/golang/go/issues/29373)
-# but can still benefit from armv7 optimisations
-GO_GOARM = 7
-endif
-else ifeq ($(BR2_aarch64),y)
-GO_GOARCH = arm64
-else ifeq ($(BR2_i386),y)
-GO_GOARCH = 386
-# i386: use softfloat if no SSE2: https://golang.org/doc/go1.16#386
-ifneq ($(BR2_X86_CPU_HAS_SSE2),y)
-GO_GO386 = softfloat
-endif
-else ifeq ($(BR2_x86_64),y)
-GO_GOARCH = amd64
-else ifeq ($(BR2_powerpc64),y)
-GO_GOARCH = ppc64
-else ifeq ($(BR2_powerpc64le),y)
-GO_GOARCH = ppc64le
-else ifeq ($(BR2_mips64),y)
-GO_GOARCH = mips64
-else ifeq ($(BR2_mips64el),y)
-GO_GOARCH = mips64le
-else ifeq ($(BR2_riscv),y)
-GO_GOARCH = riscv64
-else ifeq ($(BR2_s390x),y)
-GO_GOARCH = s390x
-endif
-
-# For the convienience of target packages.
-HOST_GO_TOOLDIR = $(HOST_GO_ROOT)/pkg/tool/linux_$(GO_GOARCH)
-HOST_GO_TARGET_ENV = \
-	$(HOST_GO_COMMON_ENV) \
-	GOOS="linux" \
-	GOARCH=$(GO_GOARCH) \
-	CC="$(TARGET_CC)" \
-	CXX="$(TARGET_CXX)" \
-	CGO_CFLAGS="$(TARGET_CFLAGS)" \
-	CGO_CXXFLAGS="$(TARGET_CXXFLAGS)" \
-	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
-HOST_GO_CGO_ENABLED = 1
-else
-HOST_GO_CGO_ENABLED = 0
-endif
-
-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.
-HOST_GO_CGO_ENABLED = 1
-endif # BR2_PACKAGE_HOST_GO_TARGET_ARCH_SUPPORTS
-
 # For the convenience of host golang packages
 HOST_GO_HOST_ENV = \
 	$(HOST_GO_COMMON_ENV) \
@@ -130,5 +61,3 @@ define GO_BINARIES_INSTALL
 endef
 
 $(eval $(host-virtual-package))
-
-include $(sort $(wildcard package/go/*/*.mk))
-- 
2.45.2

_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [Buildroot] [PATCH 3/3] package/go: add prebuilt Go compiler option
  2024-06-10 15:40 [Buildroot] [PATCH 1/3] package/go: expose option to enable via configurator Athaariq Ardhiansyah
  2024-06-10 15:40 ` [Buildroot] [PATCH 2/3] package/go: move source-specific to go-src Athaariq Ardhiansyah
@ 2024-06-10 15:40 ` Athaariq Ardhiansyah
  2024-09-14 16:31   ` Yann E. MORIN
  2024-09-14 16:24 ` [Buildroot] [PATCH 1/3] package/go: expose option to enable via configurator Yann E. MORIN
  2 siblings, 1 reply; 6+ messages in thread
From: Athaariq Ardhiansyah @ 2024-06-10 15:40 UTC (permalink / raw)
  To: buildroot
  Cc: Christian Stewart, Athaariq Ardhiansyah, Thomas Perale,
	Thomas Petazzoni, Anisse Astier

According to the TO-DO list, the prebuilt Go compiler is considered as
important to be implemented. So, I'm trying to help you to add the
prebuilt Go compiler support into Buildroot.

Signed-off-by: Athaariq Ardhiansyah <foss@athaariq.my.id>
---
 package/go/Config.in.host     | 22 +++++++++++++++-
 package/go/go-bin/go-bin.hash |  8 ++++++
 package/go/go-bin/go-bin.mk   | 47 +++++++++++++++++++++++++++++++++++
 3 files changed, 76 insertions(+), 1 deletion(-)
 create mode 100644 package/go/go-bin/go-bin.hash
 create mode 100644 package/go/go-bin/go-bin.mk

diff --git a/package/go/Config.in.host b/package/go/Config.in.host
index 32483871e7..ffd2594a80 100644
--- a/package/go/Config.in.host
+++ b/package/go/Config.in.host
@@ -32,6 +32,16 @@ config BR2_PACKAGE_HOST_GO_HOST_ARCH_SUPPORTS
 	default y
 	depends on BR2_PACKAGE_HOST_GO_BOOTSTRAP_STAGE3_ARCH_SUPPORTS
 
+# Only required for prebuilt Go compiler
+config BR2_PACKAGE_HOST_GO_ARCH_SUPPORTS
+	bool
+	default y if (BR2_HOSTARCH = "arm" && BR2_TOOLCHAIN_SUPPORTS_PIE)
+	default y if BR2_HOSTARCH = "aarch64"
+	default y if BR2_HOSTARCH = "powerpc64le"
+	default y if BR2_HOSTARCH = "s390x"
+	default y if BR2_HOSTARCH = "x86"
+	default y if BR2_HOSTARCH = "x86_64"
+
 # Go packages should select BR2_PACKAGE_HOST_GO
 config BR2_PACKAGE_HOST_GO
 	bool "host go"
@@ -52,12 +62,22 @@ config BR2_PACKAGE_HOST_GO_SRC
 	help
 	  This package will build the go compiler for the host.
 
+config BR2_PACKAGE_HOST_GO_BIN
+	bool "host go (prebuilt)"
+	depends on BR2_PACKAGE_HOST_GO_ARCH_SUPPORTS
+	help
+	  This package will download the go compiler binary for
+	  the host without build process.
+
+comment "host-go-bin doesn't support $(BR2_HOSTARCH) host architecture."
+	depends on !BR2_PACKAGE_HOST_GO_ARCH_SUPPORTS
+
 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
 
diff --git a/package/go/go-bin/go-bin.hash b/package/go/go-bin/go-bin.hash
new file mode 100644
index 0000000000..52b6c6355f
--- /dev/null
+++ b/package/go/go-bin/go-bin.hash
@@ -0,0 +1,8 @@
+# From https://go.dev/dl
+sha256  fefba30bb0d3dd1909823ee38c9f1930c3dc5337a2ac4701c2277a329a386b57  go1.22.3.linux-386.tar.gz
+sha256  8920ea521bad8f6b7bc377b4824982e011c19af27df88a815e3586ea895f1b36  go1.22.3.linux-amd64.tar.gz
+sha256  6c33e52a5b26e7aa021b94475587fce80043a727a54ceb0eee2f9fc160646434  go1.22.3.linux-arm64.tar.gz
+sha256  f2bacad20cd2b96f23a86d4826525d42b229fd431cc6d0dec61ff3bc448ef46e  go1.22.3.linux-armv6l.tar.gz
+sha256  04b7b05283de30dd2da20bf3114b2e22cc727938aed3148babaf35cc951051ac  go1.22.3.linux-ppc64le.tar.gz
+sha256  2aba796417a69be5f3ed489076bac79c1c02b36e29422712f9f3bf51da9cf2d4  go1.22.3.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 0000000000..cb320f44fa
--- /dev/null
+++ b/package/go/go-bin/go-bin.mk
@@ -0,0 +1,47 @@
+################################################################################
+#
+# go-bin
+#
+################################################################################
+
+# Translate Buildroot's arch enumeration to Go's arch
+ifeq ($(BR2_PACKAGE_HOST_GO_ARCH_SUPPORTS), y)
+
+ifeq ($(BR2_HOSTARCH), "arm")
+GO_GOARCH = "armv6l"
+else ifeq ($(BR2_HOSTARCH), "aarch64")
+GO_GOARCH = "arm64"
+else ifeq ($(BR2_HOSTARCH), "powerpc64le")
+GO_GOARCH = "ppc64le"
+else ifeq ($(BR2_HOSTARCH), "powerpc64le")
+GO_GOARCH = "ppc64le"
+else ifeq ($(BR2_HOSTARCH), "x86")
+GO_GOARCH = "386"
+else ifeq ($(BR2_HOSTARCH), "x86_64")
+GO_GOARCH = "amd64"
+else
+GO_GOARCH = $(BR2_HOSTARCH)
+endif
+
+endif # BR2_PACKAGE_HOST_GO_ARCH_SUPPORTS
+
+GO_BIN_SITE = https://storage.googleapis.com/golang
+GO_BIN_SOURCE = go$(GO_VERSION).linux-$(GO_GOARCH).tar.gz
+
+GO_BIN_LICENSE = BSD-3-Clause
+GO_BIN_LICENSE_FILES = LICENSE
+GO_BIN_CPE_ID_VENDOR = golang
+
+HOST_GO_SRC_PROVIDES = host-go
+
+ifeq ($(BR2_PACKAGE_HOST_GO_TARGET_ARCH_SUPPORTS),y)
+ifeq ($(BR2_PACKAGE_HOST_GO_ARCH_SUPPORTS), y)
+
+define HOST_GO_BIN_INSTALL_CMDS
+	$(GO_BINARIES_INSTALL)
+endef
+
+endif # BR2_PACKAGE_HOST_GO_ARCH_SUPPORTS
+endif # BR2_PACKAGE_HOST_GO_TARGET_ARCH_SUPPORTS
+
+$(eval $(host-generic-package))
-- 
2.45.2

_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [Buildroot] [PATCH 1/3] package/go: expose option to enable via configurator
  2024-06-10 15:40 [Buildroot] [PATCH 1/3] package/go: expose option to enable via configurator Athaariq Ardhiansyah
  2024-06-10 15:40 ` [Buildroot] [PATCH 2/3] package/go: move source-specific to go-src Athaariq Ardhiansyah
  2024-06-10 15:40 ` [Buildroot] [PATCH 3/3] package/go: add prebuilt Go compiler option Athaariq Ardhiansyah
@ 2024-09-14 16:24 ` Yann E. MORIN
  2 siblings, 0 replies; 6+ messages in thread
From: Yann E. MORIN @ 2024-09-14 16:24 UTC (permalink / raw)
  To: Athaariq Ardhiansyah
  Cc: Thomas Perale, Anisse Astier, Christian Stewart, buildroot

Athaariq, All,

On 2024-06-10 22:40 +0700, Athaariq Ardhiansyah spake thusly:
> Just in case you forgot it, I re-exposed the configuration option for
> enabling host-go virtual package before I'm adding host-go-bin
> subpackage.

Thank you for your patch.

I reworded the entire commit log when aplying: we want the commit log to
be in a neutral tense (no "I'), and explain why the patch is needed on
tehcnical grounds. You can check what I wrote:

    https://gitlab.com/buildroot.org/buildroot/-/commit/7cac7bc3c98c5008b646d2f33b386a45c0271a34

Thank you!

Regards,
Yann E. MORIN.

> Signed-off-by: Athaariq Ardhiansyah <foss@athaariq.my.id>
> ---
>  package/go/Config.in.host | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/package/go/Config.in.host b/package/go/Config.in.host
> index 483393f8e4..32483871e7 100644
> --- a/package/go/Config.in.host
> +++ b/package/go/Config.in.host
> @@ -34,7 +34,7 @@ config BR2_PACKAGE_HOST_GO_HOST_ARCH_SUPPORTS
>  
>  # Go packages should select BR2_PACKAGE_HOST_GO
>  config BR2_PACKAGE_HOST_GO
> -	bool
> +	bool "host go"
>  	depends on BR2_PACKAGE_HOST_GO_HOST_ARCH_SUPPORTS
>  
>  if BR2_PACKAGE_HOST_GO
> -- 
> 2.45.2
> 
> _______________________________________________
> buildroot mailing list
> buildroot@buildroot.org
> https://lists.buildroot.org/mailman/listinfo/buildroot

-- 
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 561 099 427 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Buildroot] [PATCH 2/3] package/go: move source-specific to go-src
  2024-06-10 15:40 ` [Buildroot] [PATCH 2/3] package/go: move source-specific to go-src Athaariq Ardhiansyah
@ 2024-09-14 16:27   ` Yann E. MORIN
  0 siblings, 0 replies; 6+ messages in thread
From: Yann E. MORIN @ 2024-09-14 16:27 UTC (permalink / raw)
  To: Athaariq Ardhiansyah
  Cc: Thomas Perale, Anisse Astier, Christian Stewart, buildroot

Athaariq, All,

On 2024-06-10 22:40 +0700, Athaariq Ardhiansyah spake thusly:
> Some of package/go/go.mk includes source compilation specific
> requirements, which are not effective for prebuilt Go compiler option.
> Therefore, I moved some of source-specific conditionals and variables to
> the host-go-src before adding host-go-bin support.

In fact, a lot of those variables are going to be needed for both cases,
like GO_GOARCH, GO_GOARM, et al, so we do want to keep a songle place
where they aredefined, even if some of them are only used once in the
go-src case.

Regards,
Yann E. MORIN.

> Signed-off-by: Athaariq Ardhiansyah <foss@athaariq.my.id>
> ---
>  package/go/go-src/go-src.mk | 68 +++++++++++++++++++++++++++++++++++
>  package/go/go.mk            | 71 -------------------------------------
>  2 files changed, 68 insertions(+), 71 deletions(-)
> 
> diff --git a/package/go/go-src/go-src.mk b/package/go/go-src/go-src.mk
> index 1e061e20bc..a0c903282f 100644
> --- a/package/go/go-src/go-src.mk
> +++ b/package/go/go-src/go-src.mk
> @@ -16,6 +16,67 @@ HOST_GO_SRC_DEPENDENCIES = host-go-bootstrap-stage3
>  
>  ifeq ($(BR2_PACKAGE_HOST_GO_TARGET_ARCH_SUPPORTS),y)
>  
> +ifeq ($(BR2_arm),y)
> +GO_GOARCH = arm
> +ifeq ($(BR2_ARM_CPU_ARMV5),y)
> +GO_GOARM = 5
> +else ifeq ($(BR2_ARM_CPU_ARMV6),y)
> +GO_GOARM = 6
> +else ifeq ($(BR2_ARM_CPU_ARMV7A),y)
> +GO_GOARM = 7
> +else ifeq ($(BR2_ARM_CPU_ARMV8A),y)
> +# Go doesn't support 32-bit GOARM=8 (https://github.com/golang/go/issues/29373)
> +# but can still benefit from armv7 optimisations
> +GO_GOARM = 7
> +endif
> +else ifeq ($(BR2_aarch64),y)
> +GO_GOARCH = arm64
> +else ifeq ($(BR2_i386),y)
> +GO_GOARCH = 386
> +# i386: use softfloat if no SSE2: https://golang.org/doc/go1.16#386
> +ifneq ($(BR2_X86_CPU_HAS_SSE2),y)
> +GO_GO386 = softfloat
> +endif
> +else ifeq ($(BR2_x86_64),y)
> +GO_GOARCH = amd64
> +else ifeq ($(BR2_powerpc64),y)
> +GO_GOARCH = ppc64
> +else ifeq ($(BR2_powerpc64le),y)
> +GO_GOARCH = ppc64le
> +else ifeq ($(BR2_mips64),y)
> +GO_GOARCH = mips64
> +else ifeq ($(BR2_mips64el),y)
> +GO_GOARCH = mips64le
> +else ifeq ($(BR2_riscv),y)
> +GO_GOARCH = riscv64
> +else ifeq ($(BR2_s390x),y)
> +GO_GOARCH = s390x
> +endif
> +
> +# For the convienience of target packages.
> +HOST_GO_TOOLDIR = $(HOST_GO_ROOT)/pkg/tool/linux_$(GO_GOARCH)
> +HOST_GO_TARGET_ENV = \
> +	$(HOST_GO_COMMON_ENV) \
> +	GOOS="linux" \
> +	GOARCH=$(GO_GOARCH) \
> +	CC="$(TARGET_CC)" \
> +	CXX="$(TARGET_CXX)" \
> +	CGO_CFLAGS="$(TARGET_CFLAGS)" \
> +	CGO_CXXFLAGS="$(TARGET_CXXFLAGS)" \
> +	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
> +HOST_GO_CGO_ENABLED = 1
> +else
> +HOST_GO_CGO_ENABLED = 0
> +endif
> +
>  HOST_GO_SRC_CROSS_ENV = \
>  	CC_FOR_TARGET="$(TARGET_CC)" \
>  	CXX_FOR_TARGET="$(TARGET_CXX)" \
> @@ -25,6 +86,11 @@ HOST_GO_SRC_CROSS_ENV = \
>  	$(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.
> +HOST_GO_CGO_ENABLED = 1
> +
>  endif
>  
>  # The go build system is not compatible with ccache, so use
> @@ -52,3 +118,5 @@ define HOST_GO_SRC_INSTALL_CMDS
>  endef
>  
>  $(eval $(host-generic-package))
> +
> +include $(sort $(wildcard package/go/go-bootstrap-*/*.mk))
> diff --git a/package/go/go.mk b/package/go/go.mk
> index dfcb633aa7..489d749d46 100644
> --- a/package/go/go.mk
> +++ b/package/go/go.mk
> @@ -26,75 +26,6 @@ HOST_GO_COMMON_ENV = \
>  	GOBIN= \
>  	CGO_ENABLED=$(HOST_GO_CGO_ENABLED)
>  
> -ifeq ($(BR2_PACKAGE_HOST_GO_TARGET_ARCH_SUPPORTS),y)
> -
> -ifeq ($(BR2_arm),y)
> -GO_GOARCH = arm
> -ifeq ($(BR2_ARM_CPU_ARMV5),y)
> -GO_GOARM = 5
> -else ifeq ($(BR2_ARM_CPU_ARMV6),y)
> -GO_GOARM = 6
> -else ifeq ($(BR2_ARM_CPU_ARMV7A),y)
> -GO_GOARM = 7
> -else ifeq ($(BR2_ARM_CPU_ARMV8A),y)
> -# Go doesn't support 32-bit GOARM=8 (https://github.com/golang/go/issues/29373)
> -# but can still benefit from armv7 optimisations
> -GO_GOARM = 7
> -endif
> -else ifeq ($(BR2_aarch64),y)
> -GO_GOARCH = arm64
> -else ifeq ($(BR2_i386),y)
> -GO_GOARCH = 386
> -# i386: use softfloat if no SSE2: https://golang.org/doc/go1.16#386
> -ifneq ($(BR2_X86_CPU_HAS_SSE2),y)
> -GO_GO386 = softfloat
> -endif
> -else ifeq ($(BR2_x86_64),y)
> -GO_GOARCH = amd64
> -else ifeq ($(BR2_powerpc64),y)
> -GO_GOARCH = ppc64
> -else ifeq ($(BR2_powerpc64le),y)
> -GO_GOARCH = ppc64le
> -else ifeq ($(BR2_mips64),y)
> -GO_GOARCH = mips64
> -else ifeq ($(BR2_mips64el),y)
> -GO_GOARCH = mips64le
> -else ifeq ($(BR2_riscv),y)
> -GO_GOARCH = riscv64
> -else ifeq ($(BR2_s390x),y)
> -GO_GOARCH = s390x
> -endif
> -
> -# For the convienience of target packages.
> -HOST_GO_TOOLDIR = $(HOST_GO_ROOT)/pkg/tool/linux_$(GO_GOARCH)
> -HOST_GO_TARGET_ENV = \
> -	$(HOST_GO_COMMON_ENV) \
> -	GOOS="linux" \
> -	GOARCH=$(GO_GOARCH) \
> -	CC="$(TARGET_CC)" \
> -	CXX="$(TARGET_CXX)" \
> -	CGO_CFLAGS="$(TARGET_CFLAGS)" \
> -	CGO_CXXFLAGS="$(TARGET_CXXFLAGS)" \
> -	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
> -HOST_GO_CGO_ENABLED = 1
> -else
> -HOST_GO_CGO_ENABLED = 0
> -endif
> -
> -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.
> -HOST_GO_CGO_ENABLED = 1
> -endif # BR2_PACKAGE_HOST_GO_TARGET_ARCH_SUPPORTS
> -
>  # For the convenience of host golang packages
>  HOST_GO_HOST_ENV = \
>  	$(HOST_GO_COMMON_ENV) \
> @@ -130,5 +61,3 @@ define GO_BINARIES_INSTALL
>  endef
>  
>  $(eval $(host-virtual-package))
> -
> -include $(sort $(wildcard package/go/*/*.mk))
> -- 
> 2.45.2
> 
> _______________________________________________
> buildroot mailing list
> buildroot@buildroot.org
> https://lists.buildroot.org/mailman/listinfo/buildroot

-- 
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 561 099 427 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [Buildroot] [PATCH 3/3] package/go: add prebuilt Go compiler option
  2024-06-10 15:40 ` [Buildroot] [PATCH 3/3] package/go: add prebuilt Go compiler option Athaariq Ardhiansyah
@ 2024-09-14 16:31   ` Yann E. MORIN
  0 siblings, 0 replies; 6+ messages in thread
From: Yann E. MORIN @ 2024-09-14 16:31 UTC (permalink / raw)
  To: Athaariq Ardhiansyah
  Cc: Thomas Petazzoni, Anisse Astier, Thomas Perale, Christian Stewart,
	buildroot

Athaariq, All,

On 2024-06-10 22:40 +0700, Athaariq Ardhiansyah spake thusly:
> According to the TO-DO list, the prebuilt Go compiler is considered as
> important to be implemented. So, I'm trying to help you to add the
> prebuilt Go compiler support into Buildroot.
> 
> Signed-off-by: Athaariq Ardhiansyah <foss@athaariq.my.id>

Thank you for your proposal. However, Thomas Perale had been working on
his series and just respun a new iterartion of their patch, that is
musch closer to a solution we were expecting.

Thank you for the effort nonetheless, it is still much appreciated!
Maybe there are a few other, maybe-simpler topics you can have a look
into.

Thanks!

Regards,
Yann E. MORIN.

> ---
>  package/go/Config.in.host     | 22 +++++++++++++++-
>  package/go/go-bin/go-bin.hash |  8 ++++++
>  package/go/go-bin/go-bin.mk   | 47 +++++++++++++++++++++++++++++++++++
>  3 files changed, 76 insertions(+), 1 deletion(-)
>  create mode 100644 package/go/go-bin/go-bin.hash
>  create mode 100644 package/go/go-bin/go-bin.mk
> 
> diff --git a/package/go/Config.in.host b/package/go/Config.in.host
> index 32483871e7..ffd2594a80 100644
> --- a/package/go/Config.in.host
> +++ b/package/go/Config.in.host
> @@ -32,6 +32,16 @@ config BR2_PACKAGE_HOST_GO_HOST_ARCH_SUPPORTS
>  	default y
>  	depends on BR2_PACKAGE_HOST_GO_BOOTSTRAP_STAGE3_ARCH_SUPPORTS
>  
> +# Only required for prebuilt Go compiler
> +config BR2_PACKAGE_HOST_GO_ARCH_SUPPORTS
> +	bool
> +	default y if (BR2_HOSTARCH = "arm" && BR2_TOOLCHAIN_SUPPORTS_PIE)
> +	default y if BR2_HOSTARCH = "aarch64"
> +	default y if BR2_HOSTARCH = "powerpc64le"
> +	default y if BR2_HOSTARCH = "s390x"
> +	default y if BR2_HOSTARCH = "x86"
> +	default y if BR2_HOSTARCH = "x86_64"
> +
>  # Go packages should select BR2_PACKAGE_HOST_GO
>  config BR2_PACKAGE_HOST_GO
>  	bool "host go"
> @@ -52,12 +62,22 @@ config BR2_PACKAGE_HOST_GO_SRC
>  	help
>  	  This package will build the go compiler for the host.
>  
> +config BR2_PACKAGE_HOST_GO_BIN
> +	bool "host go (prebuilt)"
> +	depends on BR2_PACKAGE_HOST_GO_ARCH_SUPPORTS
> +	help
> +	  This package will download the go compiler binary for
> +	  the host without build process.
> +
> +comment "host-go-bin doesn't support $(BR2_HOSTARCH) host architecture."
> +	depends on !BR2_PACKAGE_HOST_GO_ARCH_SUPPORTS
> +
>  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
>  
> diff --git a/package/go/go-bin/go-bin.hash b/package/go/go-bin/go-bin.hash
> new file mode 100644
> index 0000000000..52b6c6355f
> --- /dev/null
> +++ b/package/go/go-bin/go-bin.hash
> @@ -0,0 +1,8 @@
> +# From https://go.dev/dl
> +sha256  fefba30bb0d3dd1909823ee38c9f1930c3dc5337a2ac4701c2277a329a386b57  go1.22.3.linux-386.tar.gz
> +sha256  8920ea521bad8f6b7bc377b4824982e011c19af27df88a815e3586ea895f1b36  go1.22.3.linux-amd64.tar.gz
> +sha256  6c33e52a5b26e7aa021b94475587fce80043a727a54ceb0eee2f9fc160646434  go1.22.3.linux-arm64.tar.gz
> +sha256  f2bacad20cd2b96f23a86d4826525d42b229fd431cc6d0dec61ff3bc448ef46e  go1.22.3.linux-armv6l.tar.gz
> +sha256  04b7b05283de30dd2da20bf3114b2e22cc727938aed3148babaf35cc951051ac  go1.22.3.linux-ppc64le.tar.gz
> +sha256  2aba796417a69be5f3ed489076bac79c1c02b36e29422712f9f3bf51da9cf2d4  go1.22.3.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 0000000000..cb320f44fa
> --- /dev/null
> +++ b/package/go/go-bin/go-bin.mk
> @@ -0,0 +1,47 @@
> +################################################################################
> +#
> +# go-bin
> +#
> +################################################################################
> +
> +# Translate Buildroot's arch enumeration to Go's arch
> +ifeq ($(BR2_PACKAGE_HOST_GO_ARCH_SUPPORTS), y)
> +
> +ifeq ($(BR2_HOSTARCH), "arm")
> +GO_GOARCH = "armv6l"
> +else ifeq ($(BR2_HOSTARCH), "aarch64")
> +GO_GOARCH = "arm64"
> +else ifeq ($(BR2_HOSTARCH), "powerpc64le")
> +GO_GOARCH = "ppc64le"
> +else ifeq ($(BR2_HOSTARCH), "powerpc64le")
> +GO_GOARCH = "ppc64le"
> +else ifeq ($(BR2_HOSTARCH), "x86")
> +GO_GOARCH = "386"
> +else ifeq ($(BR2_HOSTARCH), "x86_64")
> +GO_GOARCH = "amd64"
> +else
> +GO_GOARCH = $(BR2_HOSTARCH)
> +endif
> +
> +endif # BR2_PACKAGE_HOST_GO_ARCH_SUPPORTS
> +
> +GO_BIN_SITE = https://storage.googleapis.com/golang
> +GO_BIN_SOURCE = go$(GO_VERSION).linux-$(GO_GOARCH).tar.gz
> +
> +GO_BIN_LICENSE = BSD-3-Clause
> +GO_BIN_LICENSE_FILES = LICENSE
> +GO_BIN_CPE_ID_VENDOR = golang
> +
> +HOST_GO_SRC_PROVIDES = host-go
> +
> +ifeq ($(BR2_PACKAGE_HOST_GO_TARGET_ARCH_SUPPORTS),y)
> +ifeq ($(BR2_PACKAGE_HOST_GO_ARCH_SUPPORTS), y)
> +
> +define HOST_GO_BIN_INSTALL_CMDS
> +	$(GO_BINARIES_INSTALL)
> +endef
> +
> +endif # BR2_PACKAGE_HOST_GO_ARCH_SUPPORTS
> +endif # BR2_PACKAGE_HOST_GO_TARGET_ARCH_SUPPORTS
> +
> +$(eval $(host-generic-package))
> -- 
> 2.45.2
> 
> _______________________________________________
> buildroot mailing list
> buildroot@buildroot.org
> https://lists.buildroot.org/mailman/listinfo/buildroot

-- 
.-----------------.--------------------.------------------.--------------------.
|  Yann E. MORIN  | Real-Time Embedded | /"\ ASCII RIBBON | Erics' conspiracy: |
| +33 662 376 056 | Software  Designer | \ / CAMPAIGN     |  ___               |
| +33 561 099 427 `------------.-------:  X  AGAINST      |  \e/  There is no  |
| http://ymorin.is-a-geek.org/ | _/*\_ | / \ HTML MAIL    |   v   conspiracy.  |
'------------------------------^-------^------------------^--------------------'
_______________________________________________
buildroot mailing list
buildroot@buildroot.org
https://lists.buildroot.org/mailman/listinfo/buildroot

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2024-09-14 16:31 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-06-10 15:40 [Buildroot] [PATCH 1/3] package/go: expose option to enable via configurator Athaariq Ardhiansyah
2024-06-10 15:40 ` [Buildroot] [PATCH 2/3] package/go: move source-specific to go-src Athaariq Ardhiansyah
2024-09-14 16:27   ` Yann E. MORIN
2024-06-10 15:40 ` [Buildroot] [PATCH 3/3] package/go: add prebuilt Go compiler option Athaariq Ardhiansyah
2024-09-14 16:31   ` Yann E. MORIN
2024-09-14 16:24 ` [Buildroot] [PATCH 1/3] package/go: expose option to enable via configurator Yann E. MORIN

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox