Golang support in Yocto Project greatly improved!

Since our first post about the Golang improvements being done for the Yocto Project 2.4 release we did another batch of improvements and tests on OpenEmbedded-Core. There are few worth mentioning features when we compare the feature set of initial Golang support, landed in Yocto Project 2.3, and the upcoming release after these changes:

Upgrade to latest Go toolchain - Golang 1.9;

Share runtime libraries to save storage space - critical for embedded systems;

Parallel build of modules - greatly speed Go package and libraries packaging;

SDK support - allowing for Yocto Project to generate cross-compilers for use targeting the embedded system specific requirements;

Availability of Go dep tool which is likely to become the official dependency tracking tool for Go in Golang 1.10 release.

The contributions shortlog can be seen which can be seen below:

Matt Madison (23): go-native: remove dependency on go-bootstrap-native go-bootstrap-native: remove recipe go: split out go-runtime into separate recipe go.bbclass: remove GO_GCFLAGS nad GO_LDFLAGS go.bbclass: remove some xxx_FINAL variables go.bbclass: clean up CGO_xxx settings go: rename go.inc -> go-target.inc go-cross: take GOARM environment setting go: enable nativesdk builds for the toolchain go-crosssdk: add recipe go.bbclass: enable nativesdk builds for Go packages go-cross-canadian: add recipe go-runtime: extend to nativesdk builds goarch.bbclass: identify archs with Go dynamic linking support go-1.8: add patch for set soname in ELF shared objects go-runtime: build the Go runtime as a shared library go.bbclass: add support linking against shared runtime goarch.bbclass: set ARM_INSTRUCTION_SET to "arm" go: update to go 1.9 go-crosssdk: fix host/target references and cleanup go: fix linking issues for nativesdk builds go: fixes for cross-canadian builds go.bbclass: set TMPDIR during compilation Otavio Salvador (4): go-dep: Move bash dependency to -dev package go.bbclass: Add "ldflags" to QA skip list go.bbclass: Add ptest support Add Go toolchain support

The SDK support has been polished and it is likely few minor improvements are still going to be done. Now we have a very good base for Go usage in Yocto Project 2.4 and beyond.

To demonstrate how easy is to create a recipe to package a Go-based tool, we are pasting the go-dep_0.3.0.bb recipe below:

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 SUMMARY = "Dependency management tool for Golang" HOMEPAGE = "https://github.com/golang/dep" LICENSE = "BSD-3-Clause" LIC_FILES_CHKSUM = "file://src/${GO_IMPORT}/LICENSE;md5=1bad315647751fab0007812f70d42c0d" GO_IMPORT = "github.com/golang/dep" SRC_URI = "git://${GO_IMPORT}" # Points to 0.3.0 tag SRCREV = "7a91b794bbfbf1f3b8b79823799316451127801b" inherit go GO_INSTALL = "${GO_IMPORT}/cmd/dep" RDEPENDS_${PN}-dev += "bash"

This is enough to properly build and install the Go dep tool. Isn’t it nice? :-D

O.S. Systems is greatly involved in Golang development within Yocto Project and is ready to assist you in your next great project, please contact us if you need help!