Skip to contentSkip to conversation

go language enhancements

PATCH New Geoff Levand 4 participants 8 messages May 19, 2016 – Jul 4, 2016

lore
Share & tools
lore
#0 lore raw

cover go language enhancements

Patch 3 adds a new package etcd, which does not use cgo support and can be used to test builds without BR2_TOOLCHAIN_HAS_THREADS.

-Geoff

The following changes since commit 3f3342a581970977f28620f17391d8aaf2204fec:

Update for 2016.05-rc2 (2016-05-17 16:11:24 +0200)

are available in the git repository at:

git at github.com:glevand/buildroot--buildroot.git for-merge-go-enhancements

for you to fetch changes up to 2693e1ba9409afcdea6b26f0d118c48cdfd0766e:

etcd: new package (2016-05-19 15:20:13 -0700)

----------------------------------------------------------------
Geoff Levand (3):
package/go-bootstrap: Build host tools with host CC package/go: Enable MIPS support
etcd: new package

 package/Config.in                    |  1 +
 package/etcd/Config.in               |  9 +++++
 package/etcd/S80etcd2                | 33 ++++++++++++++++++
 package/etcd/etcd.hash               |  2 ++
 package/etcd/etcd.mk                 | 67 ++++++++++++++++++++++++++++++++++++
 package/etcd/etcd2.service           | 17 +++++++++
 package/etcd/etcd2_sysv.conf         | 13 +++++++
 package/etcd/etcd2_tmpfiles.conf     |  1 +
 package/go-bootstrap/go-bootstrap.mk |  3 ++
 package/go/Config.in.host            |  2 +-
 package/go/go.mk                     |  4 +++
 11 files changed, 151 insertions(+), 1 deletion(-)
 create mode 100644 package/etcd/Config.in
 create mode 100644 package/etcd/S80etcd2
 create mode 100644 package/etcd/etcd.hash
 create mode 100644 package/etcd/etcd.mk
 create mode 100644 package/etcd/etcd2.service
 create mode 100644 package/etcd/etcd2_sysv.conf
 create mode 100644 package/etcd/etcd2_tmpfiles.conf
Signature · 1 line
2.5.0
#1 lore raw

PATCH 1/3 package/go-bootstrap: Build host tools with host CC

Use the host compiler when building host tools.

The go build system is not compatable with ccache, so use HOSTCC_NOCCACHE here. See https://github.com/golang/go/issues/11685.

---
 package/go-bootstrap/go-bootstrap.mk | 3 +++
 1 file changed, 3 insertions(+)
package/go-bootstrap/go-bootstrap.mk +3 -0
index 47f5013..29f2b03 100644
@@ -19,11 +19,14 @@ HOST_GO_BOOTSTRAP_DEPENDENCIES = toolchain
 
 HOST_GO_BOOTSTRAP_ROOT = $(HOST_DIR)/usr/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
Signature · 1 line
2.5.0
#4 lore raw

PATCH 2/3 package/go: Enable MIPS support

In reply to Geoff Levand

Enable go language support for mips64 and mips64el (mips64le), which were added in go-1.6.2.

---
 package/go/Config.in.host | 2 +-
 package/go/go.mk          | 4 ++++
 2 files changed, 5 insertions(+), 1 deletion(-)
package/go/Config.in.host +1 -1
index b570803..446e505 100644
@@ -1,5 +1,5 @@
 config BR2_PACKAGE_HOST_GO_ARCH_SUPPORTS
 	bool
 	default y
-	depends on BR2_arm || BR2_aarch64 || BR2_i386 || BR2_x86_64 || BR2_powerpc64 || BR2_powerpc64le
+	depends on BR2_arm || BR2_aarch64 || BR2_i386 || BR2_x86_64 || BR2_powerpc64 || BR2_powerpc64le || BR2_mips64 || BR2_mips64el
 	depends on !BR2_ARM_CPU_ARMV4
package/go/go.mk +4 -0
index a9e16dd..00b1d21 100644
@@ -30,6 +30,10 @@ 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
 endif
 
 HOST_GO_DEPENDENCIES = host-go-bootstrap
Signature · 1 line
2.5.0
#6 lore raw

PATCH 3/3 etcd: new package

In reply to Geoff Levand

etcd is a distributed key value store that provides a reliable way to store data across a cluster of machines.

https://coreos.com/etcd

---
 package/Config.in                |  1 +
 package/etcd/Config.in           |  9 ++++++
 package/etcd/S80etcd2            | 33 ++++++++++++++++++++
 package/etcd/etcd.hash           |  2 ++
 package/etcd/etcd.mk             | 67 ++++++++++++++++++++++++++++++++++++++++
 package/etcd/etcd2.service       | 17 ++++++++++
 package/etcd/etcd2_sysv.conf     | 13 ++++++++
 package/etcd/etcd2_tmpfiles.conf |  1 +
 8 files changed, 143 insertions(+)
 create mode 100644 package/etcd/Config.in
 create mode 100644 package/etcd/S80etcd2
 create mode 100644 package/etcd/etcd.hash
 create mode 100644 package/etcd/etcd.mk
 create mode 100644 package/etcd/etcd2.service
 create mode 100644 package/etcd/etcd2_sysv.conf
 create mode 100644 package/etcd/etcd2_tmpfiles.conf
package/Config.in +1 -0
index 9d668bf..1825b6d 100644
@@ -1381,6 +1381,7 @@ endif
 	source "package/dnsmasq/Config.in"
 	source "package/drbd-utils/Config.in"
 	source "package/dropbear/Config.in"
+	source "package/etcd/Config.in"
 	source "package/ebtables/Config.in"
 	source "package/ejabberd/Config.in"
 	source "package/ethtool/Config.in"
package/etcd/Config.in new file +9 -0
new file mode 100644
index 0000000..f7f19c0
@@ -0,0 +1,9 @@
+config BR2_PACKAGE_ETCD
+	bool "etcd"
+	depends on BR2_PACKAGE_HOST_GO_ARCH_SUPPORTS
+	depends on BR2_aarch64 || BR2_i386 || BR2_x86_64
+	help
+	  etcd is a distributed key value store that provides a reliable
+	  way to store data across a cluster of machines.
+
+	  https://coreos.com/etcd
package/etcd/S80etcd2 new file +33 -0
new file mode 100644
index 0000000..f6727d8
@@ -0,0 +1,33 @@
+#!/bin/sh
+
+DAEMON=/usr/bin/etcd2
+CONFIG=/etc/etcd2.conf
+
+[ -x $DAEMON ] || exit 0
+[ -f $CONFIG ] || exit 0
+
+source $CONFIG
+
+case "$1" in
+	start)
+		printf "Starting etcd daemon: "
+		[ -n $ETCD_DATA_DIR ] || [ -d $ETCD_DATA_DIR ] || mkdir -p $ETCD_DATA_DIR
+		start-stop-daemon -S -x $DAEMON
+		[ $? = 0 ] && echo "OK" || echo "FAIL"
+		;;
+	stop)
+		printf "Stopping etcd daemon: "
+		start-stop-daemon -K -x $DAEMON
+		[ $? = 0 ] && echo "OK" || echo "FAIL"
+		;;
+	restart|reload|force-reload)
+		$0 stop || true
+		sleep 1
+		$0 start
+		;;
+	*)
+		echo "Usage: $0 {start|stop|restart|reload|force-reload}"
+		exit 1
+esac
+
+exit 0
package/etcd/etcd.hash new file +2 -0
new file mode 100644
index 0000000..0802793
@@ -0,0 +1,2 @@
+# Locally computed:
+sha256 c08f68c3d21929ed3683fe94acefcd871bb3c4339117e745033bf2fb990966a9  v2.3.4.tar.gz
package/etcd/etcd.mk new file +67 -0

67 lines not on this page · raw message

package/etcd/etcd2.service new file +17 -0
new file mode 100644
index 0000000..288a0db
@@ -0,0 +1,17 @@
+[Unit]
+Description=etcd2
+Conflicts=etcd.service
+
+[Service]
+User=etcd
+Type=notify
+Environment=ETCD_DATA_DIR=/var/lib/etcd2
+Environment=ETCD_NAME=%m
+ExecStart=/usr/bin/etcd2
+Restart=always
+RestartSec=10s
+LimitNOFILE=40000
+TimeoutStartSec=0
+
+[Install]
+WantedBy=multi-user.target
package/etcd/etcd2_sysv.conf new file +13 -0
new file mode 100644
index 0000000..2e397e9
@@ -0,0 +1,13 @@
+# See https://coreos.com/etcd/docs/latest/configuration.html
+
+ETCD_NAME=default
+#ETCD_DISCOVERY=""
+#ETCD_DEBUG="true"
+
+ETCD_DATA_DIR="/var/lib/etcd"
+
+ETCD_LISTEN_CLIENT_URLS="http://0.0.0.0:2379"
+ETCD_LISTEN_PEER_URLS="http://0.0.0.0:2380"
+
+ETCD_ADVERTISE_CLIENT_URLS="http://localhost:2379"
+ETCD_INITIAL_ADVERTISE_PEER_URLS="http://localhost:2380"
package/etcd/etcd2_tmpfiles.conf new file +1 -0
new file mode 100644
index 0000000..d8bfc78
@@ -0,0 +1 @@
+d    /var/lib/etcd2 0755 etcd etcd - -
Signature · 1 line
2.5.0
#5 lore raw

PATCH 2/3 package/go: Enable MIPS support

In reply to Geoff Levand

Hello,

Quoted 8 lines · Geoff Levand

Enable go language support for mips64 and mips64el (mips64le), which were added in go-1.6.2.

---
 package/go/Config.in.host | 2 +-
 package/go/go.mk          | 4 ++++
 2 files changed, 5 insertions(+), 1 deletion(-)

Applied to master, thanks.

Thomas

Signature · 3 lines
Thomas Petazzoni, CTO, Free Electrons
Embedded Linux, Kernel and Android engineering
http://free-electrons.com
#7 lore raw

PATCH 3/3 etcd: new package

In reply to Geoff Levand

Hi Geoff,

Le 20/05/2016 ? 00:33, Geoff Levand a ?crit :

Quoted 29 lines

etcd is a distributed key value store that provides a reliable way to store data across a cluster of machines.

https://coreos.com/etcd

---
 package/Config.in                |  1 +
 package/etcd/Config.in           |  9 ++++++
 package/etcd/S80etcd2            | 33 ++++++++++++++++++++
 package/etcd/etcd.hash           |  2 ++
 package/etcd/etcd.mk             | 67 ++++++++++++++++++++++++++++++++++++++++
 package/etcd/etcd2.service       | 17 ++++++++++
 package/etcd/etcd2_sysv.conf     | 13 ++++++++
 package/etcd/etcd2_tmpfiles.conf |  1 +
 8 files changed, 143 insertions(+)
 create mode 100644 package/etcd/Config.in
 create mode 100644 package/etcd/S80etcd2
 create mode 100644 package/etcd/etcd.hash
 create mode 100644 package/etcd/etcd.mk
 create mode 100644 package/etcd/etcd2.service
 create mode 100644 package/etcd/etcd2_sysv.conf
 create mode 100644 package/etcd/etcd2_tmpfiles.conf
package/Config.in +0 -0
index 9d668bf..1825b6d 100644

package/Config.in endif · line 1384

Quoted 4 lines
package/Config.in +1 -0
@@ -1381,6 +1381,7 @@ endif
 	source "package/dnsmasq/Config.in"
 	source "package/drbd-utils/Config.in"
 	source "package/dropbear/Config.in"
+	source "package/etcd/Config.in"

Please, keep packages sorted alphabetically

Quoted 71 lines
package/Config.in +0 -0
 	source "package/ebtables/Config.in"
 	source "package/ejabberd/Config.in"
 	source "package/ethtool/Config.in"
package/etcd/Config.in new file +9 -0
new file mode 100644
index 0000000..f7f19c0
@@ -0,0 +1,9 @@
+config BR2_PACKAGE_ETCD
+	bool "etcd"
+	depends on BR2_PACKAGE_HOST_GO_ARCH_SUPPORTS
+	depends on BR2_aarch64 || BR2_i386 || BR2_x86_64
+	help
+	  etcd is a distributed key value store that provides a reliable
+	  way to store data across a cluster of machines.
+
+	  https://coreos.com/etcd
package/etcd/S80etcd2 new file +33 -0
new file mode 100644
index 0000000..f6727d8
@@ -0,0 +1,33 @@
+#!/bin/sh
+
+DAEMON=/usr/bin/etcd2
+CONFIG=/etc/etcd2.conf
+
+[ -x $DAEMON ] || exit 0
+[ -f $CONFIG ] || exit 0
+
+source $CONFIG
+
+case "$1" in
+	start)
+		printf "Starting etcd daemon: "
+		[ -n $ETCD_DATA_DIR ] || [ -d $ETCD_DATA_DIR ] || mkdir -p $ETCD_DATA_DIR
+		start-stop-daemon -S -x $DAEMON
+		[ $? = 0 ] && echo "OK" || echo "FAIL"
+		;;
+	stop)
+		printf "Stopping etcd daemon: "
+		start-stop-daemon -K -x $DAEMON
+		[ $? = 0 ] && echo "OK" || echo "FAIL"
+		;;
+	restart|reload|force-reload)
+		$0 stop || true
+		sleep 1
+		$0 start
+		;;
+	*)
+		echo "Usage: $0 {start|stop|restart|reload|force-reload}"
+		exit 1
+esac
+
+exit 0
package/etcd/etcd.hash new file +2 -0
new file mode 100644
index 0000000..0802793
@@ -0,0 +1,2 @@
+# Locally computed:
+sha256 c08f68c3d21929ed3683fe94acefcd871bb3c4339117e745033bf2fb990966a9  v2.3.4.tar.gz
package/etcd/etcd.mk new file +0 -0
new file mode 100644
index 0000000..223745d

package/etcd/etcd.mk line 8

Quoted 8 lines
package/etcd/etcd.mk new file +8 -0
@@ -0,0 +1,67 @@
+################################################################################
+#
+# etcd
+#
+################################################################################
+ETCD_VERSION = v2.3.4
+ETCD_SITE = https://github.com/coreos/etcd/archive
+ETCD_SOURCE = $(ETCD_VERSION).tar.gz

Can you try with the github helper:
http://nightly.buildroot.org/manual.html#github-download-url

Quoted 17 lines
package/etcd/etcd.mk new file +17 -0
+
+ETCD_LICENSE = Apache-2.0
+ETCD_LICENSE_FILES = LICENSE
+
+ETCD_DEPENDENCIES = host-go
+
+ETCD_MAKE_ENV = \
+	$(HOST_GO_TARGET_ENV) \
+	GOBIN="$(@D)/bin" \
+	GOPATH="$(@D)/gopath" \
+	CGO_ENABLED=0 \
+
+ETCD_REPO_PATH = github.com/coreos/etcd
+
+ETCD_GLDFLAGS = \
+	-X $(ETCD_REPO_PATH)/version.GitSHA=$(ETCD_VERSION) \
+	-extldflags '-static'

package/etcd/etcd.mk line 35

Quoted 10 lines
package/etcd/etcd.mk new file +10 -0
+
+define ETCD_CONFIGURE_CMDS
+	# Put sources at prescribed GOPATH location.
+	mkdir -p $(@D)/gopath/src/github.com/coreos
+	ln -s $(@D) $(@D)/gopath/src/$(ETCD_REPO_PATH)
+endef
+
+define ETCD_BUILD_CMDS
+	cd $(@D) && $(ETCD_MAKE_ENV) $(HOST_GO_ROOT)/bin/go \
+		build -v -x -ldflags "$(FLANNEL_GLDFLAGS)" \
                                        ^

should be ETCD_GLDFLAGS

package/etcd/etcd.mk line 38

Quoted 3 lines
package/etcd/etcd.mk new file +3 -0
+		-o $(@D)/bin/etcd $(ETCD_REPO_PATH)
+	cd $(@D) && $(ETCD_MAKE_ENV) $(HOST_GO_ROOT)/bin/go \
+		build -v -x -ldflags "$(FLANNEL_GLDFLAGS)" \
                                        ^

same here

package/etcd/etcd.mk line 43

Quoted 5 lines
package/etcd/etcd.mk new file +5 -0
+		-o $(@D)/bin/etcdctl $(ETCD_REPO_PATH)/etcdctl
+endef
+
+define ETCD_INSTALL_TARGET_CMDS
+	$(INSTALL) -D -m 0755 $(@D)/bin/etcd $(TARGET_DIR)/usr/bin/etcd2

Why did you rename etcd to etcd2 ?

Quoted 53 lines
package/etcd/etcd.mk new file +24 -0
+	$(INSTALL) -D -m 0755 $(@D)/bin/etcdctl $(TARGET_DIR)/usr/bin/etcdctl
+endef
+
+define ETCD_INSTALL_INIT_SYSV
+	$(INSTALL) -m 0755 -D package/etcd/etcd2_sysv.conf \
+		$(TARGET_DIR)/etc/etcd2.conf
+	$(INSTALL) -m 0755 -D package/etcd/S80etcd2 \
+		$(TARGET_DIR)/etc/init.d/S80etcd2
+endef
+
+define ETCD_INSTALL_INIT_SYSTEMD
+	$(INSTALL) -D -m 644 package/etcd/etcd2.service \
+		$(TARGET_DIR)/usr/lib/systemd/system/etcd2.service
+
+	$(INSTALL) -D -m 644 package/etcd/etcd2_tmpfiles.conf \
+		$(TARGET_DIR)/usr/lib/tmpfiles.d/etcd2.config
+
+	mkdir -p $(TARGET_DIR)/etc/systemd/system/multi-user.target.wants
+
+	ln -sf /usr/lib/systemd/system/etcd2.service \
+		$(TARGET_DIR)/etc/systemd/system/multi-user.target.wants/etcd2.service
+endef
+
+$(eval $(generic-package))
package/etcd/etcd2.service new file +17 -0
new file mode 100644
index 0000000..288a0db
@@ -0,0 +1,17 @@
+[Unit]
+Description=etcd2
+Conflicts=etcd.service
+
+[Service]
+User=etcd
+Type=notify
+Environment=ETCD_DATA_DIR=/var/lib/etcd2
+Environment=ETCD_NAME=%m
+ExecStart=/usr/bin/etcd2
+Restart=always
+RestartSec=10s
+LimitNOFILE=40000
+TimeoutStartSec=0
+
+[Install]
+WantedBy=multi-user.target
package/etcd/etcd2_sysv.conf new file +0 -0
new file mode 100644
index 0000000..2e397e9

package/etcd/etcd2_sysv.conf line 5

Quoted 5 lines
package/etcd/etcd2_sysv.conf new file +5 -0
@@ -0,0 +1,13 @@
+# See https://coreos.com/etcd/docs/latest/configuration.html
+
+ETCD_NAME=default
+#ETCD_DISCOVERY=""
+#ETCD_DEBUG="true"

Please, remove commented line.

Otherwise look good.

Best regards,
Romain

Quoted 16 lines
package/etcd/etcd2_sysv.conf new file +8 -0
+
+ETCD_DATA_DIR="/var/lib/etcd"
+
+ETCD_LISTEN_CLIENT_URLS="http://0.0.0.0:2379"
+ETCD_LISTEN_PEER_URLS="http://0.0.0.0:2380"
+
+ETCD_ADVERTISE_CLIENT_URLS="http://localhost:2379"
+ETCD_INITIAL_ADVERTISE_PEER_URLS="http://localhost:2380"
package/etcd/etcd2_tmpfiles.conf new file +1 -0
new file mode 100644
index 0000000..d8bfc78
@@ -0,0 +1 @@
+d    /var/lib/etcd2 0755 etcd etcd - -
#2 lore raw

PATCH 1/3 package/go-bootstrap: Build host tools with host CC

In reply to Geoff Levand

Hi Geoff,

Le 20/05/2016 ? 00:33, Geoff Levand a ?crit :

Quoted 6 lines

Use the host compiler when building host tools.

The go build system is not compatable with ccache, so use HOSTCC_NOCCACHE here. See https://github.com/golang/go/issues/11685.

Best regards,
Romain

Quoted 24 lines
---
 package/go-bootstrap/go-bootstrap.mk | 3 +++
 1 file changed, 3 insertions(+)
package/go-bootstrap/go-bootstrap.mk +3 -0
index 47f5013..29f2b03 100644
@@ -19,11 +19,14 @@ HOST_GO_BOOTSTRAP_DEPENDENCIES = toolchain
 
 HOST_GO_BOOTSTRAP_ROOT = $(HOST_DIR)/usr/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
#3 lore raw

PATCH 1/3 package/go-bootstrap: Build host tools with host CC

Quoted 4 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line

"Romain" == Romain Naour <[email protected]> writes:

Hi Geoff,
Le 20/05/2016 ? 00:33, Geoff Levand a ?crit :

Quoted 8 lines
Quoted 6 lines

Use the host compiler when building host tools.

The go build system is not compatable with ccache, so use HOSTCC_NOCCACHE here. See https://github.com/golang/go/issues/11685.

Committed, thanks.

Signature · 1 line
Bye, Peter Korsgaard