From patchwork Thu Feb 2 10:55:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Stewart X-Patchwork-Id: 1736252 Return-Path: X-Original-To: incoming-buildroot@patchwork.ozlabs.org Delivered-To: patchwork-incoming-buildroot@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=buildroot.org (client-ip=2605:bc80:3010::133; helo=smtp2.osuosl.org; envelope-from=buildroot-bounces@buildroot.org; receiver=) Received: from smtp2.osuosl.org (smtp2.osuosl.org [IPv6:2605:bc80:3010::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4P6wh067p6z23hh for ; Thu, 2 Feb 2023 21:56:16 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp2.osuosl.org (Postfix) with ESMTP id C223440250; Thu, 2 Feb 2023 10:56:14 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org C223440250 X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp2.osuosl.org ([127.0.0.1]) by localhost (smtp2.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id HWtg19Bxxkqw; Thu, 2 Feb 2023 10:56:13 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by smtp2.osuosl.org (Postfix) with ESMTP id 6D77340B9A; Thu, 2 Feb 2023 10:56:12 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp2.osuosl.org 6D77340B9A X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from smtp1.osuosl.org (smtp1.osuosl.org [140.211.166.138]) by ash.osuosl.org (Postfix) with ESMTP id 58B1B1BF287 for ; Thu, 2 Feb 2023 10:55:59 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id E1A2780BAF for ; Thu, 2 Feb 2023 10:55:58 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org E1A2780BAF X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id tgKqUkj0E8sb for ; Thu, 2 Feb 2023 10:55:55 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.8.0 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org 60D6C8125B Received: from mail-pg1-f173.google.com (mail-pg1-f173.google.com [209.85.215.173]) by smtp1.osuosl.org (Postfix) with ESMTPS id 60D6C8125B for ; Thu, 2 Feb 2023 10:55:55 +0000 (UTC) Received: by mail-pg1-f173.google.com with SMTP id s67so1041219pgs.3 for ; Thu, 02 Feb 2023 02:55:55 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=mc6FalGItM6j2mj17C9a++aJxCQhrwiO4IutO4Ayj+M=; b=qyBiIqJ7X63UtFDNcLOXC9CnrKGsaDTuyMx0yk1X4ZHOYMUGHV6MZ3OWKn0I1UG25B 1NPQEuhDCKmciP2eHqCEbxulTtzKgo/eKcPDmQ6p8vq2y7H8szA3n1GdM4SaLlvnSTe5 20MbA2CMjuY8MSaf2VBjRedFgssZROe/4SSsyqD+1c528rK8mN4MWIa9nQTz/lRCw0U5 SeKWfoOloybkrRnmRonkh8Ac2+7gAd2nsMD7EhJ7ZlRQjNL9rknJRBjYbXBZjAMWVd5E nz/rKsi2qo7jjygwTUnarai2IAqB6xtyyQRd7OCtMVB/ohygwauwCD+qOmKWI6s8G0Km iWdQ== X-Gm-Message-State: AO0yUKXv8jApo0SyNojyAvBy0iWV2eqjbTjV9opXvhaVr6EDHa8/Nc6W mynh2hxOoFf1WjNQV/jeyybGYnZp+FGQww== X-Google-Smtp-Source: AK7set9pIdOh6ZGceUV3wMDM3vASO8GK0fDxdtMpsurGoTWM+YQ5ENMfK+6FjgZqlc0gSA7UaP/LXA== X-Received: by 2002:a05:6a00:18a0:b0:588:a156:6a3d with SMTP id x32-20020a056a0018a000b00588a1566a3dmr7627530pfh.26.1675335354114; Thu, 02 Feb 2023 02:55:54 -0800 (PST) Received: from localhost.localdomain (ip184-189-231-225.sb.sd.cox.net. [184.189.231.225]) by smtp.gmail.com with ESMTPSA id h18-20020a056a00219200b0059416691b64sm3513218pfi.19.2023.02.02.02.55.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Feb 2023 02:55:53 -0800 (PST) To: buildroot@buildroot.org Date: Thu, 2 Feb 2023 02:55:42 -0800 Message-Id: <20230202105544.315452-1-christian@paral.in> X-Mailer: git-send-email 2.39.1 MIME-Version: 1.0 Subject: [Buildroot] [PATCH v1 1/3] package/go-bootstrap: split into two stages: go1.4 and go1.19.5 X-BeenThere: buildroot@buildroot.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Discussion and development of buildroot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Christian Stewart via buildroot From: Christian Stewart Reply-To: Christian Stewart Cc: Christian Stewart , "Yann E . MORIN" , Thomas Petazzoni , Anisse Astier Errors-To: buildroot-bounces@buildroot.org Sender: "buildroot" Go 1.20 will require a minimum version of go 1.17.13 to bootstrap. https://go.dev/doc/go1.20#bootstrap As Go 1.4 was the previous version that could be compiled with C, there is now no way to bootstrap go with a C compiler, unless we use a two-stage bootstrap: - build host-go-bootstrap-1.4-20170531 - build host-go-bootstrap-1.19.5 with host-go-bootstrap-1.4-20170531 - build host-go-1.20 with host-go-bootstrap-1.19.5 This is implemented in this commit first, before upgrading host-go to 1.20. Note: the .patch files from package/go version 1.19.x are not necessary for package/go-bootstrap-stage2 and have not been included there. Discussion of possible alternate approaches for future use: https://lore.kernel.org/all/CA+h8R2rtcynkCBsz=_9yANOEguyPCOcQDj8_ns+cv8RS8+8t9A@mail.gmail.com/ https://lore.kernel.org/all/20220525234312.643dfc03@windsurf/T/ Signed-off-by: Christian Stewart --- DEVELOPERS | 2 + package/Config.in.host | 3 +- package/go-bootstrap-stage1/Config.in.host | 6 ++ .../go-bootstrap-stage1.hash} | 0 .../go-bootstrap-stage1.mk | 46 +++++++++++++++ package/go-bootstrap-stage2/Config.in.host | 4 ++ .../go-bootstrap-stage2.hash | 3 + .../go-bootstrap-stage2.mk | 56 +++++++++++++++++++ package/go-bootstrap/Config.in.host | 7 --- package/go-bootstrap/go-bootstrap.mk | 50 ----------------- package/go/Config.in.host | 6 +- package/go/go.mk | 9 ++- 12 files changed, 127 insertions(+), 65 deletions(-) create mode 100644 package/go-bootstrap-stage1/Config.in.host rename package/{go-bootstrap/go-bootstrap.hash => go-bootstrap-stage1/go-bootstrap-stage1.hash} (100%) create mode 100644 package/go-bootstrap-stage1/go-bootstrap-stage1.mk create mode 100644 package/go-bootstrap-stage2/Config.in.host create mode 100644 package/go-bootstrap-stage2/go-bootstrap-stage2.hash create mode 100644 package/go-bootstrap-stage2/go-bootstrap-stage2.mk delete mode 100644 package/go-bootstrap/Config.in.host delete mode 100644 package/go-bootstrap/go-bootstrap.mk diff --git a/DEVELOPERS b/DEVELOPERS index e19087c577..16119b008a 100644 --- a/DEVELOPERS +++ b/DEVELOPERS @@ -549,6 +549,8 @@ F: package/docker-proxy/ F: package/embiggen-disk/ F: package/fuse-overlayfs/ F: package/go/ +F: package/go-bootstrap-stage1/ +F: package/go-bootstrap-stage2/ F: package/gocryptfs/ F: package/mbpfan/ F: package/moby-buildkit/ diff --git a/package/Config.in.host b/package/Config.in.host index b76bea60d0..6374547b39 100644 --- a/package/Config.in.host +++ b/package/Config.in.host @@ -39,7 +39,8 @@ 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/Config.in.host" + source "package/go-bootstrap-stage1/Config.in.host" + source "package/go-bootstrap-stage2/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-bootstrap-stage1/Config.in.host b/package/go-bootstrap-stage1/Config.in.host new file mode 100644 index 0000000000..56a743caf9 --- /dev/null +++ b/package/go-bootstrap-stage1/Config.in.host @@ -0,0 +1,6 @@ +config BR2_PACKAGE_HOST_GO_BOOTSTRAP_STAGE1_ARCH_SUPPORTS + bool + # See src/cmd/dist/unix.c for the list of supported architectures + default y if BR2_HOSTARCH = "x86" + default y if BR2_HOSTARCH = "x86_64" + default y if BR2_HOSTARCH = "arm" diff --git a/package/go-bootstrap/go-bootstrap.hash b/package/go-bootstrap-stage1/go-bootstrap-stage1.hash similarity index 100% rename from package/go-bootstrap/go-bootstrap.hash rename to package/go-bootstrap-stage1/go-bootstrap-stage1.hash diff --git a/package/go-bootstrap-stage1/go-bootstrap-stage1.mk b/package/go-bootstrap-stage1/go-bootstrap-stage1.mk new file mode 100644 index 0000000000..77e7046cd7 --- /dev/null +++ b/package/go-bootstrap-stage1/go-bootstrap-stage1.mk @@ -0,0 +1,46 @@ +################################################################################ +# +# go-bootstrap-stage1 +# +################################################################################ + +# Use last C-based Go compiler: v1.4.x +# See https://golang.org/doc/install/source#bootstrapFromSource +GO_BOOTSTRAP_STAGE1_VERSION = 1.4-bootstrap-20171003 +GO_BOOTSTRAP_STAGE1_SITE = https://dl.google.com/go +GO_BOOTSTRAP_STAGE1_SOURCE = go$(GO_BOOTSTRAP_STAGE1_VERSION).tar.gz + +GO_BOOTSTRAP_STAGE1_LICENSE = BSD-3-Clause +GO_BOOTSTRAP_STAGE1_LICENSE_FILES = LICENSE + +# The toolchain is needed for HOSTCC_NOCACHE used to compile the Go compiler. +HOST_GO_BOOTSTRAP_STAGE1_DEPENDENCIES = toolchain + +HOST_GO_BOOTSTRAP_STAGE1_ROOT = $(HOST_DIR)/lib/go-$(GO_BOOTSTRAP_STAGE1_VERSION) + +# The go build system is not compatable with ccache, so use HOSTCC_NOCCACHE. +# See https://github.com/golang/go/issues/11685. +HOST_GO_BOOTSTRAP_STAGE1_MAKE_ENV = \ + GOOS=linux \ + GOROOT_FINAL="$(HOST_GO_BOOTSTRAP_STAGE1_ROOT)" \ + GOROOT="$(@D)" \ + GOBIN="$(@D)/bin" \ + CC=$(HOSTCC_NOCCACHE) \ + CGO_ENABLED=0 + +define HOST_GO_BOOTSTRAP_STAGE1_BUILD_CMDS + cd $(@D)/src && $(HOST_GO_BOOTSTRAP_STAGE1_MAKE_ENV) ./make.bash +endef + +define HOST_GO_BOOTSTRAP_STAGE1_INSTALL_CMDS + $(INSTALL) -D -m 0755 $(@D)/bin/go $(HOST_GO_BOOTSTRAP_STAGE1_ROOT)/bin/go + $(INSTALL) -D -m 0755 $(@D)/bin/gofmt $(HOST_GO_BOOTSTRAP_STAGE1_ROOT)/bin/gofmt + + cp -a $(@D)/lib $(HOST_GO_BOOTSTRAP_STAGE1_ROOT)/ + cp -a $(@D)/pkg $(HOST_GO_BOOTSTRAP_STAGE1_ROOT)/ + + # https://golang.org/issue/2775 + cp -a $(@D)/src $(HOST_GO_BOOTSTRAP_STAGE1_ROOT)/ +endef + +$(eval $(host-generic-package)) diff --git a/package/go-bootstrap-stage2/Config.in.host b/package/go-bootstrap-stage2/Config.in.host new file mode 100644 index 0000000000..967ddaed1d --- /dev/null +++ b/package/go-bootstrap-stage2/Config.in.host @@ -0,0 +1,4 @@ +config BR2_PACKAGE_HOST_GO_BOOTSTRAP_STAGE2_ARCH_SUPPORTS + bool + default y + depends on BR2_PACKAGE_HOST_GO_BOOTSTRAP_STAGE1_ARCH_SUPPORTS diff --git a/package/go-bootstrap-stage2/go-bootstrap-stage2.hash b/package/go-bootstrap-stage2/go-bootstrap-stage2.hash new file mode 100644 index 0000000000..4c22f0f274 --- /dev/null +++ b/package/go-bootstrap-stage2/go-bootstrap-stage2.hash @@ -0,0 +1,3 @@ +# From https://go.dev/dl +sha256 8e486e8e85a281fc5ce3f0bedc5b9d2dbf6276d7db0b25d3ec034f313da0375f go1.19.5.src.tar.gz +sha256 2d36597f7117c38b006835ae7f537487207d8ec407aa9d9980794b2030cbc067 LICENSE diff --git a/package/go-bootstrap-stage2/go-bootstrap-stage2.mk b/package/go-bootstrap-stage2/go-bootstrap-stage2.mk new file mode 100644 index 0000000000..da2e1f4f46 --- /dev/null +++ b/package/go-bootstrap-stage2/go-bootstrap-stage2.mk @@ -0,0 +1,56 @@ +################################################################################ +# +# go-bootstrap-stage2 +# +################################################################################ + +GO_BOOTSTRAP_STAGE2_VERSION = 1.19.5 +GO_BOOTSTRAP_STAGE2_SITE = https://storage.googleapis.com/golang +GO_BOOTSTRAP_STAGE2_SOURCE = go$(GO_BOOTSTRAP_STAGE2_VERSION).src.tar.gz + +GO_BOOTSTRAP_STAGE2_LICENSE = BSD-3-Clause +GO_BOOTSTRAP_STAGE2_LICENSE_FILES = LICENSE + +# Use go-bootstrap-stage1 to bootstrap. +HOST_GO_BOOTSTRAP_STAGE2_DEPENDENCIES = host-go-bootstrap-stage1 +HOST_GO_BOOTSTRAP_STAGE2_MAKE_ENV += GOROOT_BOOTSTRAP=$(HOST_GO_BOOTSTRAP_STAGE2_BOOTSTRAP_ROOT) + +HOST_GO_BOOTSTRAP_STAGE2_ROOT = $(HOST_DIR)/lib/go-$(GO_BOOTSTRAP_STAGE2_VERSION) + +# The go build system is not compatable with ccache, so use HOSTCC_NOCCACHE. +# See https://github.com/golang/go/issues/11685. +HOST_GO_BOOTSTRAP_STAGE2_MAKE_ENV = \ + GO111MODULE=off \ + GOROOT_BOOTSTRAP=$(HOST_GO_BOOTSTRAP_STAGE1_ROOT) \ + GOROOT_FINAL=$(HOST_GO_BOOTSTRAP_STAGE2_ROOT) \ + GOROOT="$(@D)" \ + GOBIN="$(@D)/bin" \ + GOOS=linux \ + CC=$(HOSTCC_NOCCACHE) \ + CXX=$(HOSTCXX_NOCCACHE) \ + CGO_ENABLED=0 + +define HOST_GO_BOOTSTRAP_STAGE2_BUILD_CMDS + cd $(@D)/src && \ + $(HOST_GO_BOOTSTRAP_STAGE2_MAKE_ENV) ./make.bash $(if $(VERBOSE),-v) +endef + +define HOST_GO_BOOTSTRAP_STAGE2_INSTALL_CMDS + $(INSTALL) -D -m 0755 $(@D)/bin/go $(HOST_GO_BOOTSTRAP_STAGE2_ROOT)/bin/go + $(INSTALL) -D -m 0755 $(@D)/bin/gofmt $(HOST_GO_BOOTSTRAP_STAGE2_ROOT)/bin/gofmt + + cp -a $(@D)/lib $(HOST_GO_BOOTSTRAP_STAGE2_ROOT)/ + + mkdir -p $(HOST_GO_BOOTSTRAP_STAGE2_ROOT)/pkg + cp -a $(@D)/pkg/include $(@D)/pkg/linux_* $(HOST_GO_BOOTSTRAP_STAGE2_ROOT)/pkg/ + cp -a $(@D)/pkg/tool $(HOST_GO_BOOTSTRAP_STAGE2_ROOT)/pkg/ + + # https://golang.org/issue/2775 + cp -a $(@D)/src $(HOST_GO_BOOTSTRAP_STAGE2_ROOT)/ + + # Set all file timestamps to prevent the go compiler from rebuilding any + # built in packages when programs are built. + find $(HOST_GO_BOOTSTRAP_STAGE2_ROOT) -type f -exec touch -r $(@D)/bin/go {} \; +endef + +$(eval $(host-generic-package)) diff --git a/package/go-bootstrap/Config.in.host b/package/go-bootstrap/Config.in.host deleted file mode 100644 index fab80d24b4..0000000000 --- a/package/go-bootstrap/Config.in.host +++ /dev/null @@ -1,7 +0,0 @@ -config BR2_PACKAGE_HOST_GO_BOOTSTRAP_ARCH_SUPPORTS - bool - # See src/cmd/dist/unix.c for the list of support - # architectures - default y if BR2_HOSTARCH = "x86" - default y if BR2_HOSTARCH = "x86_64" - default y if BR2_HOSTARCH = "arm" diff --git a/package/go-bootstrap/go-bootstrap.mk b/package/go-bootstrap/go-bootstrap.mk deleted file mode 100644 index 71696a1540..0000000000 --- a/package/go-bootstrap/go-bootstrap.mk +++ /dev/null @@ -1,50 +0,0 @@ -################################################################################ -# -# go-bootstrap -# -################################################################################ - -# Use last C-based Go compiler: v1.4.x -# See https://golang.org/doc/install/source#bootstrapFromSource -GO_BOOTSTRAP_VERSION = 1.4-bootstrap-20171003 -GO_BOOTSTRAP_SITE = https://dl.google.com/go -GO_BOOTSTRAP_SOURCE = go$(GO_BOOTSTRAP_VERSION).tar.gz - -GO_BOOTSTRAP_LICENSE = BSD-3-Clause -GO_BOOTSTRAP_LICENSE_FILES = LICENSE - -# To build programs that need cgo support the toolchain needs to be -# available, so the toolchain is not needed to build host-go-bootstrap -# itself, but needed by other packages that depend on -# host-go-bootstrap. -HOST_GO_BOOTSTRAP_DEPENDENCIES = toolchain - -HOST_GO_BOOTSTRAP_ROOT = $(HOST_DIR)/lib/go-$(GO_BOOTSTRAP_VERSION) - -# The go build system is not compatable with ccache, so use HOSTCC_NOCCACHE -# here. See https://github.com/golang/go/issues/11685. -HOST_GO_BOOTSTRAP_MAKE_ENV = \ - GOOS=linux \ - GOROOT_FINAL="$(HOST_GO_BOOTSTRAP_ROOT)" \ - GOROOT="$(@D)" \ - GOBIN="$(@D)/bin" \ - CC=$(HOSTCC_NOCCACHE) \ - CGO_ENABLED=0 - -define HOST_GO_BOOTSTRAP_BUILD_CMDS - cd $(@D)/src && $(HOST_GO_BOOTSTRAP_MAKE_ENV) ./make.bash -endef - -define HOST_GO_BOOTSTRAP_INSTALL_CMDS - $(INSTALL) -D -m 0755 $(@D)/bin/go $(HOST_GO_BOOTSTRAP_ROOT)/bin/go - $(INSTALL) -D -m 0755 $(@D)/bin/gofmt $(HOST_GO_BOOTSTRAP_ROOT)/bin/gofmt - - cp -a $(@D)/lib $(HOST_GO_BOOTSTRAP_ROOT)/ - cp -a $(@D)/pkg $(HOST_GO_BOOTSTRAP_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_BOOTSTRAP_ROOT)/ -endef - -$(eval $(host-generic-package)) diff --git a/package/go/Config.in.host b/package/go/Config.in.host index ded02d3b3a..43cb62309d 100644 --- a/package/go/Config.in.host +++ b/package/go/Config.in.host @@ -2,7 +2,9 @@ config BR2_PACKAGE_HOST_GO_TARGET_ARCH_SUPPORTS bool default y - depends on BR2_PACKAGE_HOST_GO_BOOTSTRAP_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_PACKAGE_HOST_GO_BOOTSTRAP_STAGE2_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 +30,4 @@ 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_STAGE2_ARCH_SUPPORTS diff --git a/package/go/go.mk b/package/go/go.mk index c38ae0b99c..b0dd002712 100644 --- a/package/go/go.mk +++ b/package/go/go.mk @@ -12,7 +12,7 @@ GO_LICENSE = BSD-3-Clause GO_LICENSE_FILES = LICENSE GO_CPE_ID_VENDOR = golang -HOST_GO_DEPENDENCIES = host-go-bootstrap +HOST_GO_DEPENDENCIES = host-go-bootstrap-stage2 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 @@ -121,12 +121,12 @@ 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. +# The go build system is not compatable 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_ROOT) \ + GOROOT_BOOTSTRAP=$(HOST_GO_BOOTSTRAP_STAGE2_ROOT) \ GOROOT_FINAL=$(HOST_GO_ROOT) \ GOROOT="$(@D)" \ GOBIN="$(@D)/bin" \ @@ -154,7 +154,6 @@ define HOST_GO_INSTALL_CMDS cp -a $(@D)/pkg/include $(@D)/pkg/linux_* $(HOST_GO_ROOT)/pkg/ cp -a $(@D)/pkg/tool $(HOST_GO_ROOT)/pkg/ - # There is a known issue which requires the go sources to be installed # https://golang.org/issue/2775 cp -a $(@D)/src $(HOST_GO_ROOT)/ From patchwork Thu Feb 2 10:55:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Stewart X-Patchwork-Id: 1736251 Return-Path: X-Original-To: incoming-buildroot@patchwork.ozlabs.org Delivered-To: patchwork-incoming-buildroot@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=buildroot.org (client-ip=2605:bc80:3010::136; helo=smtp3.osuosl.org; envelope-from=buildroot-bounces@buildroot.org; receiver=) Received: from smtp3.osuosl.org (smtp3.osuosl.org [IPv6:2605:bc80:3010::136]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4P6wgl5J4gz23hh for ; Thu, 2 Feb 2023 21:56:03 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id 33FE8606ED; Thu, 2 Feb 2023 10:56:01 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 33FE8606ED X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id CARCOkm6Rz8M; Thu, 2 Feb 2023 10:56:00 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by smtp3.osuosl.org (Postfix) with ESMTP id EC34360AF2; Thu, 2 Feb 2023 10:55:58 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org EC34360AF2 X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from smtp3.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by ash.osuosl.org (Postfix) with ESMTP id CBE3E1BF287 for ; Thu, 2 Feb 2023 10:55:57 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id A59DE60AC2 for ; Thu, 2 Feb 2023 10:55:57 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org A59DE60AC2 X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id RiBnYkDdjpSI for ; Thu, 2 Feb 2023 10:55:56 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.8.0 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org CA88B606ED Received: from mail-pg1-f176.google.com (mail-pg1-f176.google.com [209.85.215.176]) by smtp3.osuosl.org (Postfix) with ESMTPS id CA88B606ED for ; Thu, 2 Feb 2023 10:55:56 +0000 (UTC) Received: by mail-pg1-f176.google.com with SMTP id f3so1046472pgc.2 for ; Thu, 02 Feb 2023 02:55:56 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=SXKi8mLvHG25fXdBhsPPvZlm5/gzKERNTf8sol4pw40=; b=3Ac8BJCHLrbOYWE8ZIk2jDRV7QflkxAzW3/H+V5EIX+0H5T39wnVI8F+C2WA8JmkOo HXGjVEW2F6sUByWEX0BU0R4PN5QjxgEgKn/tVBz8FP/lQ6+7X1rb7rpWcJHtd2kCMW8G nCBIEYXBFDfg3EI9Ip8kCc5fLL7FVHYVmHplNaoeHXkAqogKYUdnw8lRHV5CzblBjn4O W4AD8fV1ecC2i4S277NpEVs6stgBD5lFuqctXULP/7v7B//j4qVoNy6aXlVh9OVPD37g B1Tb4cX4clWxRar5EUvWOB3YJgSphtcPpoI36KT11dAx65iB3JXXjTOKrQ2zRMKa01Ai CGkA== X-Gm-Message-State: AO0yUKWwB3jGXc3mtGCwhTWXCy7qD6NPfI5zf8QHjHXRpeJF5DcyCokk q1xg5EDSfAbFChf15tuAK2xpm4ypBwKFKg== X-Google-Smtp-Source: AK7set/HuUbs8XDzHC2hMdYkYwqZvzDk3t0PCKOIZnvJBXvkkw8TM3Mdj47WjrzQgvc0d085UQRaxg== X-Received: by 2002:aa7:9618:0:b0:58b:c3b3:d3dd with SMTP id q24-20020aa79618000000b0058bc3b3d3ddmr5386657pfg.21.1675335355811; Thu, 02 Feb 2023 02:55:55 -0800 (PST) Received: from localhost.localdomain (ip184-189-231-225.sb.sd.cox.net. [184.189.231.225]) by smtp.gmail.com with ESMTPSA id h18-20020a056a00219200b0059416691b64sm3513218pfi.19.2023.02.02.02.55.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Feb 2023 02:55:55 -0800 (PST) To: buildroot@buildroot.org Date: Thu, 2 Feb 2023 02:55:43 -0800 Message-Id: <20230202105544.315452-2-christian@paral.in> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230202105544.315452-1-christian@paral.in> References: <20230202105544.315452-1-christian@paral.in> MIME-Version: 1.0 Subject: [Buildroot] [PATCH v1 2/3] package/go: bump to version 1.20 X-BeenThere: buildroot@buildroot.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Discussion and development of buildroot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Christian Stewart via buildroot From: Christian Stewart Reply-To: Christian Stewart Cc: Christian Stewart , "Yann E . MORIN" , Thomas Petazzoni , Anisse Astier Errors-To: buildroot-bounces@buildroot.org Sender: "buildroot" The latest Go release, version 1.20, arrives six months after Go 1.19. Most of its changes are in the implementation of the toolchain, runtime, and libraries. https://go.dev/doc/go1.20 Signed-off-by: Christian Stewart --- ...03-runtime-support-riscv64-SV57-mode.patch | 65 ------------------- package/go/Config.in.host | 2 +- package/go/go.hash | 2 +- package/go/go.mk | 4 +- 4 files changed, 4 insertions(+), 69 deletions(-) delete mode 100644 package/go/0003-runtime-support-riscv64-SV57-mode.patch diff --git a/package/go/0003-runtime-support-riscv64-SV57-mode.patch b/package/go/0003-runtime-support-riscv64-SV57-mode.patch deleted file mode 100644 index f51c2ca093..0000000000 --- a/package/go/0003-runtime-support-riscv64-SV57-mode.patch +++ /dev/null @@ -1,65 +0,0 @@ -From 6618c7af436488fa12018cdcd31eeedb3a698745 Mon Sep 17 00:00:00 2001 -From: Dmitry Vyukov -Date: Fri, 27 May 2022 18:55:35 +0200 -Subject: [PATCH] runtime: support riscv64 SV57 mode - -Riscv64 has SV57 mode when user-space VA is 56 bits. -Linux kernel recently got support for this mode and Go binaries started crashing as: - -runtime: lfstack.push invalid packing: node=0xffffff5908a940 cnt=0x1 -packed=0xffff5908a9400001 -> node=0xffff5908a940 - -Adjust lfstack code to use only 8 top bits of pointers on riscv64. - -For context see: -https://groups.google.com/g/syzkaller-bugs/c/lU0GQTZoNQQ/m/O_c3vmE3AAAJ - -Update #54104 - -Change-Id: Ib5d3d6a79c0c6eddf11618d73fcc8bc1832a9c25 -Signed-off-by: Christian Stewart ---- - -Upstream: https://go-review.googlesource.com/c/go/+/409055/4 ---- - src/runtime/lfstack_64bit.go | 12 ++++++++++++ - 1 file changed, 12 insertions(+) - -diff --git a/src/runtime/lfstack_64bit.go b/src/runtime/lfstack_64bit.go -index 154130cf63..39fa647b9e 100644 ---- a/src/runtime/lfstack_64bit.go -+++ b/src/runtime/lfstack_64bit.go -@@ -36,12 +36,21 @@ const ( - // We use one bit to distinguish between the two ranges. - aixAddrBits = 57 - aixCntBits = 64 - aixAddrBits + 3 -+ -+ // Riscv64 SV57 mode gives 56 bits of userspace VA. -+ // lfstack code supports it, but broader support for SV57 mode is incomplete, -+ // and there may be other issues (see #54104). -+ riscv64AddrBits = 56 -+ riscv64CntBits = 64 - riscv64AddrBits + 3 - ) - - func lfstackPack(node *lfnode, cnt uintptr) uint64 { - if GOARCH == "ppc64" && GOOS == "aix" { - return uint64(uintptr(unsafe.Pointer(node)))<<(64-aixAddrBits) | uint64(cnt&(1<> aixCntBits << 3) | 0xa<<56))) - } -+ if GOARCH == "riscv64" { -+ return (*lfnode)(unsafe.Pointer(uintptr(val >> riscv64CntBits << 3))) -+ } - return (*lfnode)(unsafe.Pointer(uintptr(val >> cntBits << 3))) - } --- -2.35.1 - diff --git a/package/go/Config.in.host b/package/go/Config.in.host index 43cb62309d..b87b862cec 100644 --- a/package/go/Config.in.host +++ b/package/go/Config.in.host @@ -2,9 +2,9 @@ config BR2_PACKAGE_HOST_GO_TARGET_ARCH_SUPPORTS bool default y + depends on BR2_PACKAGE_HOST_GO_BOOTSTRAP_STAGE2_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_PACKAGE_HOST_GO_BOOTSTRAP_STAGE2_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 diff --git a/package/go/go.hash b/package/go/go.hash index 4c22f0f274..204e508fc3 100644 --- a/package/go/go.hash +++ b/package/go/go.hash @@ -1,3 +1,3 @@ # From https://go.dev/dl -sha256 8e486e8e85a281fc5ce3f0bedc5b9d2dbf6276d7db0b25d3ec034f313da0375f go1.19.5.src.tar.gz +sha256 3a29ff0421beaf6329292b8a46311c9fbf06c800077ceddef5fb7f8d5b1ace33 go1.20.src.tar.gz sha256 2d36597f7117c38b006835ae7f537487207d8ec407aa9d9980794b2030cbc067 LICENSE diff --git a/package/go/go.mk b/package/go/go.mk index b0dd002712..18d3a80212 100644 --- a/package/go/go.mk +++ b/package/go/go.mk @@ -4,7 +4,7 @@ # ################################################################################ -GO_VERSION = 1.19.5 +GO_VERSION = 1.20 GO_SITE = https://storage.googleapis.com/golang GO_SOURCE = go$(GO_VERSION).src.tar.gz @@ -151,7 +151,7 @@ define HOST_GO_INSTALL_CMDS cp -a $(@D)/lib $(HOST_GO_ROOT)/ mkdir -p $(HOST_GO_ROOT)/pkg - cp -a $(@D)/pkg/include $(@D)/pkg/linux_* $(HOST_GO_ROOT)/pkg/ + cp -a $(@D)/pkg/include $(HOST_GO_ROOT)/pkg/ cp -a $(@D)/pkg/tool $(HOST_GO_ROOT)/pkg/ # https://golang.org/issue/2775 From patchwork Thu Feb 2 10:55:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Stewart X-Patchwork-Id: 1736253 Return-Path: X-Original-To: incoming-buildroot@patchwork.ozlabs.org Delivered-To: patchwork-incoming-buildroot@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=buildroot.org (client-ip=140.211.166.138; helo=smtp1.osuosl.org; envelope-from=buildroot-bounces@buildroot.org; receiver=) Received: from smtp1.osuosl.org (smtp1.osuosl.org [140.211.166.138]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4P6whF64Q1z23hh for ; Thu, 2 Feb 2023 21:56:29 +1100 (AEDT) Received: from localhost (localhost [127.0.0.1]) by smtp1.osuosl.org (Postfix) with ESMTP id A817F812E5; Thu, 2 Feb 2023 10:56:27 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org A817F812E5 X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp1.osuosl.org ([127.0.0.1]) by localhost (smtp1.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id rbHszwGzH2sA; Thu, 2 Feb 2023 10:56:26 +0000 (UTC) Received: from ash.osuosl.org (ash.osuosl.org [140.211.166.34]) by smtp1.osuosl.org (Postfix) with ESMTP id BD00B8125B; Thu, 2 Feb 2023 10:56:25 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp1.osuosl.org BD00B8125B X-Original-To: buildroot@lists.busybox.net Delivered-To: buildroot@osuosl.org Received: from smtp3.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by ash.osuosl.org (Postfix) with ESMTP id 1F3291BF287 for ; Thu, 2 Feb 2023 10:56:01 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by smtp3.osuosl.org (Postfix) with ESMTP id EDD0A60AFF for ; Thu, 2 Feb 2023 10:56:00 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org EDD0A60AFF X-Virus-Scanned: amavisd-new at osuosl.org Received: from smtp3.osuosl.org ([127.0.0.1]) by localhost (smtp3.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id YXWp7p8T3SQT for ; Thu, 2 Feb 2023 10:55:58 +0000 (UTC) X-Greylist: whitelisted by SQLgrey-1.8.0 DKIM-Filter: OpenDKIM Filter v2.11.0 smtp3.osuosl.org 4D424606ED Received: from mail-pf1-f169.google.com (mail-pf1-f169.google.com [209.85.210.169]) by smtp3.osuosl.org (Postfix) with ESMTPS id 4D424606ED for ; Thu, 2 Feb 2023 10:55:58 +0000 (UTC) Received: by mail-pf1-f169.google.com with SMTP id cr11so901626pfb.1 for ; Thu, 02 Feb 2023 02:55:58 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=4j00AePncG2//dwJxy6j314TcwkDa41PCQzwZ54lFYE=; b=Dxv06A9UaIGR/Zmm4YxjLT9dLfmqRnbRKFZTOFjhInHGVsWpTbzVAWB+UWKXdlqM/J BqbSAM+xS4tVLBcCjnTa+cDDK8fB8mV2t0Ez17BUUglprostvgJLqD+dgpp6pnaCf2um SULezvwEhRi+xygHARa7rfXFO/n0bQ15nIf2ZLUWA7b7lEHDVyvbnt5SnTtVXMidmmsg kcsOUxN3FFK/5MOuOdICUcpgr9wwiwJNPWg0HsDQk4TEiikhxQ8kfIEcKKJFBfy9K+kt hOT03ysCxhUvh/QS6Dk2Hr61Fqr3DEqcHOSJvQfvMopUqLyuYTdKhrMPGtfeXJ6VfHPo pQUQ== X-Gm-Message-State: AO0yUKXYjoITKo9/3hC/d7yvYz9eK/t7eu3gSZze+7zWRPg1A9G5BnPM RdNOO0V/mCTGv5nBmv4ppyxaDeNmbtOx6g== X-Google-Smtp-Source: AK7set9A8cIcmEEEvgzcsGXwDjrczV2tnaj0hUiNpO7X4oqDUMEBRI7WZp9A3YUSvpk1Hcw265MQWQ== X-Received: by 2002:a05:6a00:330d:b0:587:8d47:acdd with SMTP id cq13-20020a056a00330d00b005878d47acddmr5534142pfb.34.1675335357334; Thu, 02 Feb 2023 02:55:57 -0800 (PST) Received: from localhost.localdomain (ip184-189-231-225.sb.sd.cox.net. [184.189.231.225]) by smtp.gmail.com with ESMTPSA id h18-20020a056a00219200b0059416691b64sm3513218pfi.19.2023.02.02.02.55.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 02 Feb 2023 02:55:56 -0800 (PST) To: buildroot@buildroot.org Date: Thu, 2 Feb 2023 02:55:44 -0800 Message-Id: <20230202105544.315452-3-christian@paral.in> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230202105544.315452-1-christian@paral.in> References: <20230202105544.315452-1-christian@paral.in> MIME-Version: 1.0 Subject: [Buildroot] [PATCH v1 3/3] package/go: use host compiler when go-bootstrap unsupported X-BeenThere: buildroot@buildroot.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Discussion and development of buildroot List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Christian Stewart via buildroot From: Christian Stewart Reply-To: Christian Stewart Cc: Christian Stewart , "Yann E . MORIN" , Thomas Petazzoni , Anisse Astier Errors-To: buildroot-bounces@buildroot.org Sender: "buildroot" All Go compiler versions > 1.4.x (old) are written in Go, and require a existing compiled Go version to use to build from source. https://golang.org/doc/install/source#bootstrapFromSource The process for "bootstrapping" the Go compiler in Buildroot is: 1. Compile a C/C++ cross-compiler (gcc) as the host toolchain. 2. Build go-bootstrap-stage1 (which is Go 1.4.x and written in C) 3. Build go-bootstrap-stage2 (which is Go 1.19.x and written in Go) 3. Build go 1.20 (written in Go) using go-bootstrap-stage2. go-bootstrap-stage1 does not work on 64-bit arm. The Go 1.4.x bootstrap compiler is compatible with x86, x86_64, and arm (32 bit) only. This patch adds a fallback to require a host Go compiler to build host-go when BR2_PACKAGE_HOST_GO_BOOTSTRAP_STAGE2_ARCH_SUPPORTS is not set. Signed-off-by: Christian Stewart --- v1 -> v2: - thanks Thomas for the review & suggestions - added NEEDS_HOST_GO boolean - added dependency checks to support/dependencies/dependencies.sh - removed unnecessary changes to go-bootstrap package v2 -> v3: - add dependency on toolchain if Cgo is enabled v3 -> v4: - updates for go1.20 - updates for go-bootstrap-stage{1,2} Signed-off-by: Christian Stewart --- Config.in | 4 ++++ package/go-bootstrap-stage2/go-bootstrap-stage2.mk | 2 +- package/go/Config.in.host | 2 +- package/go/go.mk | 14 ++++++++++++-- support/dependencies/dependencies.sh | 4 ++++ 5 files changed, 22 insertions(+), 4 deletions(-) diff --git a/Config.in b/Config.in index 86699f58c6..c53757f671 100644 --- a/Config.in +++ b/Config.in @@ -58,6 +58,10 @@ config BR2_HOST_GCC_AT_LEAST_9 # When adding new entries above, be sure to update # the HOSTCC_MAX_VERSION variable in the Makefile. +# Hidden boolean selected if bootstrapping Go w/ GCC is not supported. +config BR2_NEEDS_HOST_GO + bool + # Hidden boolean selected by packages in need of Java in order to build # (example: kodi) config BR2_NEEDS_HOST_JAVA diff --git a/package/go-bootstrap-stage2/go-bootstrap-stage2.mk b/package/go-bootstrap-stage2/go-bootstrap-stage2.mk index da2e1f4f46..421342ee02 100644 --- a/package/go-bootstrap-stage2/go-bootstrap-stage2.mk +++ b/package/go-bootstrap-stage2/go-bootstrap-stage2.mk @@ -13,7 +13,7 @@ GO_BOOTSTRAP_STAGE2_LICENSE_FILES = LICENSE # Use go-bootstrap-stage1 to bootstrap. HOST_GO_BOOTSTRAP_STAGE2_DEPENDENCIES = host-go-bootstrap-stage1 -HOST_GO_BOOTSTRAP_STAGE2_MAKE_ENV += GOROOT_BOOTSTRAP=$(HOST_GO_BOOTSTRAP_STAGE2_BOOTSTRAP_ROOT) +HOST_GO_BOOTSTRAP_STAGE2_MAKE_ENV += GOROOT_BOOTSTRAP=$(HOST_GO_BOOTSTRAP_STAGE2_BOOTSTRAP_ROOT) HOST_GO_BOOTSTRAP_STAGE2_ROOT = $(HOST_DIR)/lib/go-$(GO_BOOTSTRAP_STAGE2_VERSION) diff --git a/package/go/Config.in.host b/package/go/Config.in.host index b87b862cec..7f049ff1ae 100644 --- a/package/go/Config.in.host +++ b/package/go/Config.in.host @@ -30,4 +30,4 @@ 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_STAGE2_ARCH_SUPPORTS + select BR2_NEEDS_HOST_GO if !BR2_PACKAGE_HOST_GO_BOOTSTRAP_STAGE2_ARCH_SUPPORTS diff --git a/package/go/go.mk b/package/go/go.mk index 18d3a80212..9dcc9321f9 100644 --- a/package/go/go.mk +++ b/package/go/go.mk @@ -12,7 +12,6 @@ GO_LICENSE = BSD-3-Clause GO_LICENSE_FILES = LICENSE GO_CPE_ID_VENDOR = golang -HOST_GO_DEPENDENCIES = host-go-bootstrap-stage2 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 @@ -109,6 +108,11 @@ else # !BR2_PACKAGE_HOST_GO_TARGET_ARCH_SUPPORTS HOST_GO_CGO_ENABLED = 1 endif # BR2_PACKAGE_HOST_GO_TARGET_ARCH_SUPPORTS +ifeq ($(HOST_GO_CGO_ENABLED),1) +# For cgo support the toolchain needs to be available. +HOST_GO_DEPENDENCIES += toolchain +endif + # For the convenience of host golang packages HOST_GO_HOST_ENV = \ $(HOST_GO_COMMON_ENV) \ @@ -126,7 +130,6 @@ HOST_GO_HOST_ENV = \ HOST_GO_MAKE_ENV = \ GO111MODULE=off \ GOCACHE=$(HOST_GO_HOST_CACHE) \ - GOROOT_BOOTSTRAP=$(HOST_GO_BOOTSTRAP_STAGE2_ROOT) \ GOROOT_FINAL=$(HOST_GO_ROOT) \ GOROOT="$(@D)" \ GOBIN="$(@D)/bin" \ @@ -136,6 +139,13 @@ HOST_GO_MAKE_ENV = \ CGO_ENABLED=$(HOST_GO_CGO_ENABLED) \ $(HOST_GO_CROSS_ENV) +# Use the Go compiler bootstrapped by Buildroot if available. +# Otherwise, use the host Go compiler. +ifeq ($(BR2_PACKAGE_HOST_GO_BOOTSTRAP_STAGE2_ARCH_SUPPORTS),y) +HOST_GO_DEPENDENCIES += host-go-bootstrap-stage2 +HOST_GO_MAKE_ENV += GOROOT_BOOTSTRAP=$(HOST_GO_BOOTSTRAP_STAGE2_ROOT) +endif + define HOST_GO_BUILD_CMDS cd $(@D)/src && \ $(HOST_GO_MAKE_ENV) ./make.bash $(if $(VERBOSE),-v) diff --git a/support/dependencies/dependencies.sh b/support/dependencies/dependencies.sh index 4b5012b807..89a8f6adc0 100755 --- a/support/dependencies/dependencies.sh +++ b/support/dependencies/dependencies.sh @@ -207,6 +207,10 @@ if grep ^BR2_NEEDS_HOST_UTF8_LOCALE=y $BR2_CONFIG > /dev/null; then fi fi +if grep -q ^BR2_NEEDS_HOST_GO=y $BR2_CONFIG ; then + check_prog_host "go" +fi + if grep -q ^BR2_NEEDS_HOST_JAVA=y $BR2_CONFIG ; then check_prog_host "java" JAVA_GCJ=$(java -version 2>&1 | grep gcj)