Skip to contentSkip to conversation

Add go language support

PATCH Superseded Geoff Levand 2 participants 5 messages Mar 4, 2016

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

v2 cover Add go language support

This series adds support for the go programming language. I tested the build of the included flannel package on i386, powerpc64, arm (32 bit) and arm64. I did runtime testing of the generated flannel binary on arm64.

Patch 1 adds a host only bootstrap compiler needed to build the latest go versions.

Patch 2 adds support for a host cross compiler, libraries and tools.

Patch 3 adds a go language package flannel that can be used to test the go compiler.

Changes for v2:

o Dropped go target support. We can consider it again if there is a strong use case.
o General cleanup of package files. Added comments, fixed variable names, use github helper function.

-Geoff

The following changes since commit aaf6c28a5c49251df31b82c48c971bc18183cf6b:

Update for 2016.02 (2016-03-01 21:47:30 +0100)

are available in the git repository at:

git at github.com:glevand/buildroot--buildroot.git go-v2

for you to fetch changes up to 85c7aa882469bf71a7cd6463768f81fb19fdd4fc:

flannel: new package (2016-03-04 10:13:29 -0800)

----------------------------------------------------------------
Geoff Levand (3):
go-bootstrap: new host package
go: new host package
flannel: new package

 package/Config.in                      |  1 +
 package/Config.in.host                 |  1 +
 package/flannel/Config.in              |  9 ++++
 package/flannel/flannel.hash           |  2 +
 package/flannel/flannel.mk             | 38 +++++++++++++++++
 package/go-bootstrap/go-bootstrap.hash |  2 +
 package/go-bootstrap/go-bootstrap.mk   | 38 +++++++++++++++++
 package/go/Config.in.host              | 13 ++++++
 package/go/go.hash                     |  2 +
 package/go/go.mk                       | 75 ++++++++++++++++++++++++++++++++++
 10 files changed, 181 insertions(+)
 create mode 100644 package/flannel/Config.in
 create mode 100644 package/flannel/flannel.hash
 create mode 100644 package/flannel/flannel.mk
 create mode 100644 package/go-bootstrap/go-bootstrap.hash
 create mode 100644 package/go-bootstrap/go-bootstrap.mk
 create mode 100644 package/go/Config.in.host
 create mode 100644 package/go/go.hash
 create mode 100644 package/go/go.mk
Signature · 1 line
2.5.0
#1 lore raw

PATCH v2 1/3 go-bootstrap: new host package

Add a new package go-bootstrap which builds a bootstrap compiler for the go programming language.

---
 package/go-bootstrap/go-bootstrap.hash |  2 ++
 package/go-bootstrap/go-bootstrap.mk   | 38 ++++++++++++++++++++++++++++++++++
 2 files changed, 40 insertions(+)
 create mode 100644 package/go-bootstrap/go-bootstrap.hash
 create mode 100644 package/go-bootstrap/go-bootstrap.mk
package/go-bootstrap/go-bootstrap.hash new file +2 -0
new file mode 100644
index 0000000..1d0566a
@@ -0,0 +1,2 @@
+# Locally computed:
+sha256 299a6fd8f8adfdce15bc06bde926e7b252ae8e24dd5b16b7d8791ed79e7b5e9b go1.4.2.src.tar.gz
package/go-bootstrap/go-bootstrap.mk new file +38 -0
new file mode 100644
index 0000000..ccb932d
@@ -0,0 +1,38 @@
+################################################################################
+#
+# go-bootstrap
+#
+################################################################################
+
+GO_BOOTSTRAP_VERSION = 1.4.2
+GO_BOOTSTRAP_SITE = https://storage.googleapis.com/golang
+GO_BOOTSTRAP_SOURCE = go$(GO_BOOTSTRAP_VERSION).src.tar.gz
+
+GO_BOOTSTRAP_LICENSE = BSD-3c
+GO_BOOTSTRAP_LICENSE_FILES = LICENSE
+
+GO_BOOTSTRAP_FINAL = $(HOST_DIR)/usr/lib/go-$(GO_BOOTSTRAP_VERSION)
+
+GO_BOOTSTRAP_MAKE_ENV = \
+	GOOS=linux \
+	GOROOT_FINAL="$(GO_BOOTSTRAP_FINAL)" \
+	GOROOT="$(@D)" \
+	GOBIN="$(@D)/bin"
+
+define HOST_GO_BOOTSTRAP_BUILD_CMDS
+	cd $(@D)/src && $(GO_BOOTSTRAP_MAKE_ENV) ./make.bash
+endef
+
+define HOST_GO_BOOTSTRAP_INSTALL_CMDS
+	$(INSTALL) -D -m 0755 $(@D)/bin/go $(GO_BOOTSTRAP_FINAL)/bin/go
+	$(INSTALL) -D -m 0755 $(@D)/bin/gofmt $(GO_BOOTSTRAP_FINAL)/bin/gofmt
+
+	cp -a $(@D)/lib $(GO_BOOTSTRAP_FINAL)/
+	cp -a $(@D)/pkg $(GO_BOOTSTRAP_FINAL)/
+
+	# There is a known issue which requires the go sources to be installed
+	# https://golang.org/issue/2775
+	cp -a $(@D)/src $(GO_BOOTSTRAP_FINAL)/
+endef
+
+$(eval $(host-generic-package))
Signature · 1 line
2.5.0
#2 lore raw

PATCH v2 2/3 go: new host package

In reply to Geoff Levand

Add a new package 'go' which builds the host cross compiler and libraries for the go programming language.

---
 package/Config.in.host    |  1 +
 package/go/Config.in.host | 13 ++++++++
 package/go/go.hash        |  2 ++
 package/go/go.mk          | 75 +++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 91 insertions(+)
 create mode 100644 package/go/Config.in.host
 create mode 100644 package/go/go.hash
 create mode 100644 package/go/go.mk
package/Config.in.host +1 -0
index 1c691a3..4dae12f 100644
@@ -13,6 +13,7 @@ menu "Host utilities"
 	source "package/genext2fs/Config.in.host"
 	source "package/genimage/Config.in.host"
 	source "package/genpart/Config.in.host"
+	source "package/go/Config.in.host"
 	source "package/gptfdisk/Config.in.host"
 	source "package/imx-usb-loader/Config.in.host"
 	source "package/jq/Config.in.host"
package/go/Config.in.host new file +13 -0
new file mode 100644
index 0000000..e69259c
@@ -0,0 +1,13 @@
+config BR2_PACKAGE_GO_ARCH_SUPPORTS
+	bool
+	default y
+	depends on BR2_arm || BR2_aarch64 || BR2_i386 || BR2_x86_64 || BR2_powerpc
+	depends on !BR2_ARM_CPU_ARMV4
+
+config BR2_PACKAGE_HOST_GO
+	bool "host go"
+	depends on BR2_PACKAGE_GO_ARCH_SUPPORTS
+	help
+	  The Go Programming Language.
+
+	  https://golang.org
package/go/go.hash new file +2 -0
new file mode 100644
index 0000000..e7c72de
@@ -0,0 +1,2 @@
+# Locally computed:
+sha256  754e06dab1c31ab168fc9db9e32596734015ea9e24bc44cae7f237f417ce4efe  go1.5.3.src.tar.gz
package/go/go.mk new file +75 -0

75 lines not on this page · raw message

Signature · 1 line
2.5.0
#3 lore raw

PATCH v2 3/3 flannel: new package

In reply to Geoff Levand

Flannel is a virtual network that gives a subnet to each host for use with container runtimes.

Cc Brandon Philips <[email protected]>
---
 package/Config.in            |  1 +
 package/flannel/Config.in    |  9 +++++++++
 package/flannel/flannel.hash |  2 ++
 package/flannel/flannel.mk   | 38 ++++++++++++++++++++++++++++++++++++++
 4 files changed, 50 insertions(+)
 create mode 100644 package/flannel/Config.in
 create mode 100644 package/flannel/flannel.hash
 create mode 100644 package/flannel/flannel.mk
package/Config.in +1 -0
index 529ad33..08f950a 100644
@@ -1331,6 +1331,7 @@ endif
 	source "package/faifa/Config.in"
 	source "package/fastd/Config.in"
 	source "package/fcgiwrap/Config.in"
+	source "package/flannel/Config.in"
 	source "package/fmc/Config.in"
 	source "package/foomatic-filters/Config.in"
 	source "package/fping/Config.in"
package/flannel/Config.in new file +9 -0
new file mode 100644
index 0000000..0da356d
@@ -0,0 +1,9 @@
+config BR2_PACKAGE_FLANNEL
+	bool "flannel"
+	depends on BR2_PACKAGE_GO_ARCH_SUPPORTS
+	select BR2_PACKAGE_HOST_GO
+	help
+	  Flannel is a virtual network that gives a subnet to each host for use
+	  with container runtimes.
+
+	  https://github.com/coreos/flannel
package/flannel/flannel.hash new file +2 -0
new file mode 100644
index 0000000..a19329a
@@ -0,0 +1,2 @@
+# Locally computed:
+sha256 c09a76e80647282687b8db36f28dd3aede650f8f71dad0cf9f453f2ae3a0635d flannel-v0.5.5.tar.gz
package/flannel/flannel.mk new file +38 -0
new file mode 100644
index 0000000..724d2a3
@@ -0,0 +1,38 @@
+################################################################################
+#
+# flannel
+#
+################################################################################
+
+FLANNEL_VERSION = v0.5.5
+FLANNEL_SITE = $(call github,coreos,flannel.git,$(FLANNEL_VERSION))
+
+FLANNEL_LICENSE = Apache-2.0
+FLANNEL_LICENSE_FILES = LICENSE
+
+FLANNEL_DEPENDENCIES = host-go
+
+FLANNEL_MAKE_ENV = \
+	GOBIN="$(@D)/bin" \
+	GOPATH="$(@D)/gopath" \
+	GOARCH=$(GO_GOARCH) \
+	CGO_ENABLED=1
+
+define FLANNEL_CONFIGURE_CMDS
+	# Put sources at prescribed GOPATH location.
+	mkdir -p $(@D)/gopath/src/github.com/coreos
+	ln -s $(@D) $(@D)/gopath/src/github.com/coreos/flannel
+endef
+
+define FLANNEL_BUILD_CMDS
+	cd $(@D) && $(FLANNEL_MAKE_ENV) $(HOST_GO_FINAL)/bin/go \
+		build -v -o $(@D)/bin/flanneld .
+endef
+
+define FLANNEL_INSTALL_TARGET_CMDS
+	# Install flannel to its well known location.
+	$(INSTALL) -D -m 0755 $(@D)/bin/flanneld $(TARGET_DIR)/opt/bin/flanneld
+	$(INSTALL) -D -m 0755 $(@D)/dist/mk-docker-opts.sh $(TARGET_DIR)/opt/bin/mk-docker-opts.sh
+endef
+
+$(eval $(generic-package))
Signature · 1 line
2.5.0
#4 lore raw

v2 cover Add go language support

In reply to Geoff Levand

Geoff,

Quoted 1 line · Geoff Levand

Patch 3 adds a go language package flannel that can be used to test the go

compiler.

This patch series looks good, nice and clean. Interesting that you chose to include Flannel. This indicates to me that you've worked a bit on creating a Docker package as well. Is that the case?

Here's my previous implementation:
https://github.com/paralin/buildroot/commit/b3cb1b334c1a23136e77ea7d34aafb24e8a186db

I have around ~20 commits with docker utilities on top of that as well.

I'm still working on testing this series, and will send my ack once I know everything's working. I probably will make a new branch in my repo and rebase everything on top of this series.

Best,
Christian
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.busybox.net/pipermail/buildroot/attachments/20160304/6ab367d6/attachment.html>