Revamp the Go support
v3 cover Revamp the Go support
This is not yet complete but does improve some parts of Go support on OE-Core.
We are trying to port as much as possible work done by Matt on meta-golang back to OE-Core and also to avoid carrying old releases as there is no need to support more versions of Go toolchain.
The first commits on this patchset fix errors in current implementation, the others are improvements and clean ups.
Changes in v3:
- new patch
- new patch
- new patch
Changes in v2:
- New patch
- Remove -x flag (madisongh)
- Remove GO_EXTLDFLAGS for now (madisongh)
Matt Madison (3):
go.bbclass: exported function cleanup go.bbclass: separate ${S} and ${B}
go.bbclass: add do_unpack function to handle common cases
Otavio Salvador (8):
goarch.bbclass: Stop passing True as second argument of d.getVar go.bbclass: Fix binary installation path detection
go-dep: Add 0.3.0 release
go: Remove Go 1.6 and 1.7 releases
goarch.bbclass: Add support for ARMv5
go.bbclass: Use a global Go build flags
go.bbclass: Enable parallel build
go.bbclass: Use an auxiliary variable to add the build dependencies
meta/classes/go.bbclass | 104 +++++++++++++-------- meta/classes/goarch.bbclass | 20 ++-- meta/recipes-devtools/go/go-1.6.inc | 19 ---- .../go/go-1.6/armhf-elf-header.patch | 23 ----- .../go/go-1.6/fix-cc-handling.patch | 50 ---------- .../go/go-1.6/fix-target-cc-for-build.patch | 17 ---- meta/recipes-devtools/go/go-1.6/gotooldir.patch | 30 ------ .../go/go-1.6/split-host-and-target-build.patch | 63 ------------- meta/recipes-devtools/go/go-1.6/syslog.patch | 62 ------------ meta/recipes-devtools/go/go-1.7.inc | 19 ---- .../go/go-1.7/armhf-elf-header.patch | 23 ----- .../go/go-1.7/fix-cc-handling.patch | 50 ---------- .../go/go-1.7/fix-target-cc-for-build.patch | 17 ---- meta/recipes-devtools/go/go-1.7/gotooldir.patch | 30 ------ .../go/go-1.7/split-host-and-target-build.patch | 62 ------------ meta/recipes-devtools/go/go-1.7/syslog.patch | 62 ------------ meta/recipes-devtools/go/go-cross_1.7.bb | 5 - meta/recipes-devtools/go/go-dep_0.3.0.bb | 20 ++++ meta/recipes-devtools/go/go_1.6.bb | 4 - meta/recipes-devtools/go/go_1.7.bb | 2 - 20 files changed, 97 insertions(+), 585 deletions(-) delete mode 100644 meta/recipes-devtools/go/go-1.6.inc delete mode 100644 meta/recipes-devtools/go/go-1.6/armhf-elf-header.patch delete mode 100644 meta/recipes-devtools/go/go-1.6/fix-cc-handling.patch delete mode 100644 meta/recipes-devtools/go/go-1.6/fix-target-cc-for-build.patch delete mode 100644 meta/recipes-devtools/go/go-1.6/gotooldir.patch delete mode 100644 meta/recipes-devtools/go/go-1.6/split-host-and-target-build.patch delete mode 100644 meta/recipes-devtools/go/go-1.6/syslog.patch delete mode 100644 meta/recipes-devtools/go/go-1.7.inc delete mode 100644 meta/recipes-devtools/go/go-1.7/armhf-elf-header.patch delete mode 100644 meta/recipes-devtools/go/go-1.7/fix-cc-handling.patch delete mode 100644 meta/recipes-devtools/go/go-1.7/fix-target-cc-for-build.patch delete mode 100644 meta/recipes-devtools/go/go-1.7/gotooldir.patch delete mode 100644 meta/recipes-devtools/go/go-1.7/split-host-and-target-build.patch delete mode 100644 meta/recipes-devtools/go/go-1.7/syslog.patch delete mode 100644 meta/recipes-devtools/go/go-cross_1.7.bb create mode 100644 meta/recipes-devtools/go/go-dep_0.3.0.bb delete mode 100644 meta/recipes-devtools/go/go_1.6.bb delete mode 100644 meta/recipes-devtools/go/go_1.7.bb
Signature · 1 line
2.14.1
PATCH v3 1/11 goarch.bbclass: Stop passing True as second argument of d.getVar
The d.getVar has the second argument as True by default, avoid passing it here.
---
Changes in v3: None
Changes in v2: None
meta/classes/goarch.bbclass | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-)
meta/classes/goarch.bbclass +9 -9
@@ -1,15 +1,15 @@ -BUILD_GOOS = "${@go_map_os(d.getVar('BUILD_OS', True), d)}" -BUILD_GOARCH = "${@go_map_arch(d.getVar('BUILD_ARCH', True), d)}" +BUILD_GOOS = "${@go_map_os(d.getVar('BUILD_OS'), d)}" +BUILD_GOARCH = "${@go_map_arch(d.getVar('BUILD_ARCH'), d)}" BUILD_GOTUPLE = "${BUILD_GOOS}_${BUILD_GOARCH}" -HOST_GOOS = "${@go_map_os(d.getVar('HOST_OS', True), d)}" -HOST_GOARCH = "${@go_map_arch(d.getVar('HOST_ARCH', True), d)}" -HOST_GOARM = "${@go_map_arm(d.getVar('HOST_ARCH', True), d.getVar('TUNE_FEATURES', True), d)}" +HOST_GOOS = "${@go_map_os(d.getVar('HOST_OS'), d)}" +HOST_GOARCH = "${@go_map_arch(d.getVar('HOST_ARCH'), d)}" +HOST_GOARM = "${@go_map_arm(d.getVar('HOST_ARCH'), d.getVar('TUNE_FEATURES'), d)}" HOST_GOTUPLE = "${HOST_GOOS}_${HOST_GOARCH}" -TARGET_GOOS = "${@go_map_os(d.getVar('TARGET_OS', True), d)}" -TARGET_GOARCH = "${@go_map_arch(d.getVar('TARGET_ARCH', True), d)}" -TARGET_GOARM = "${@go_map_arm(d.getVar('TARGET_ARCH', True), d.getVar('TUNE_FEATURES', True), d)}" +TARGET_GOOS = "${@go_map_os(d.getVar('TARGET_OS'), d)}" +TARGET_GOARCH = "${@go_map_arch(d.getVar('TARGET_ARCH'), d)}" +TARGET_GOARM = "${@go_map_arm(d.getVar('TARGET_ARCH'), d.getVar('TUNE_FEATURES'), d)}" TARGET_GOTUPLE = "${TARGET_GOOS}_${TARGET_GOARCH}" -GO_BUILD_BINDIR = "${@['bin/${HOST_GOTUPLE}','bin'][d.getVar('BUILD_GOTUPLE',True) == d.getVar('HOST_GOTUPLE',True)]}" +GO_BUILD_BINDIR = "${@['bin/${HOST_GOTUPLE}','bin'][d.getVar('BUILD_GOTUPLE') == d.getVar('HOST_GOTUPLE')]}" # define here because everybody inherits this class #
Signature · 1 line
2.14.1
PATCH v3 2/11 go.bbclass: Fix binary installation path detection
In reply to Otavio SalvadorGo toolchain changes the installation path when building for the same architecture as the build host. This was already been considered in the GO_BUILD_BINDIR variable but was not being used by the go class.
This fixes following error:
,----
| ERROR: go-dep-0.3.0-r0 do_package: QA Issue: go-dep: Files/directories | were installed but not shipped in any package: | /usr/lib/x86_64-oel-linux/go/bin/dep | Please set FILES such that these items are packaged. Alternatively if | they are unneeded, avoid installing them or delete them within | do_install.
`----
---
Changes in v3: None
Changes in v2: None
meta/classes/go.bbclass | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
meta/classes/go.bbclass +1 -1
@@ -3,7 +3,7 @@ inherit goarch GOROOT_class-native = "${STAGING_LIBDIR_NATIVE}/go" GOROOT = "${STAGING_LIBDIR_NATIVE}/${TARGET_SYS}/go" GOBIN_FINAL_class-native = "${GOROOT_FINAL}/bin" -GOBIN_FINAL = "${GOROOT_FINAL}/bin/${GOOS}_${GOARCH}" +GOBIN_FINAL = "${GOROOT_FINAL}/${GO_BUILD_BINDIR}" export GOOS = "${TARGET_GOOS}" export GOARCH = "${TARGET_GOARCH}"
Signature · 1 line
2.14.1
PATCH v3 3/11 go-dep: Add 0.3.0 release
In reply to Otavio SalvadorThis is the Golang dependency management tool under development; it is ready for production use and intended to be merged onto Golang 1.10. Until that, projects are starting to use it and making it available on OE-Core reduces the Golang integration work for new recipes.
---
Changes in v3: None
Changes in v2:
- New patch
meta/recipes-devtools/go/go-dep_0.3.0.bb | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 meta/recipes-devtools/go/go-dep_0.3.0.bb
meta/recipes-devtools/go/go-dep_0.3.0.bb new file +20 -0
@@ -0,0 +1,20 @@ +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};destsuffix=${BPN}-${PV}/src/${GO_IMPORT};nobranch=1" + +# Points to 0.3.0 tag +SRCREV = "7a91b794bbfbf1f3b8b79823799316451127801b" + +inherit go + +GO_INSTALL = "${GO_IMPORT}/cmd/dep" + +INSANE_SKIP_${PN} += "ldflags" + +BBCLASSEXTEND = "native nativesdk" + +RDEPENDS_${PN}-staticdev += "bash"
Signature · 1 line
2.14.1
PATCH v3 4/11 go: Remove Go 1.6 and 1.7 releases
In reply to Otavio SalvadorThe OE-Core has no reason to support multiple versions of Go as this increases the maintenance work and testing efforts. So we are going to support just a single version from now on which currently is 1.8.3.
The 1.4 release is kept around as it is used for bootstrap, as such, it cannot be removed.
---
Changes in v3: None
Changes in v2: None
meta/recipes-devtools/go/go-1.6.inc | 19 ------- .../go/go-1.6/armhf-elf-header.patch | 23 -------- .../go/go-1.6/fix-cc-handling.patch | 50 ----------------- .../go/go-1.6/fix-target-cc-for-build.patch | 17 ------ meta/recipes-devtools/go/go-1.6/gotooldir.patch | 30 ----------- .../go/go-1.6/split-host-and-target-build.patch | 63 ---------------------- meta/recipes-devtools/go/go-1.6/syslog.patch | 62 --------------------- meta/recipes-devtools/go/go-1.7.inc | 19 ------- .../go/go-1.7/armhf-elf-header.patch | 23 -------- .../go/go-1.7/fix-cc-handling.patch | 50 ----------------- .../go/go-1.7/fix-target-cc-for-build.patch | 17 ------ meta/recipes-devtools/go/go-1.7/gotooldir.patch | 30 ----------- .../go/go-1.7/split-host-and-target-build.patch | 62 --------------------- meta/recipes-devtools/go/go-1.7/syslog.patch | 62 --------------------- meta/recipes-devtools/go/go-cross_1.7.bb | 5 -- meta/recipes-devtools/go/go_1.6.bb | 4 -- meta/recipes-devtools/go/go_1.7.bb | 2 - 17 files changed, 538 deletions(-) delete mode 100644 meta/recipes-devtools/go/go-1.6.inc delete mode 100644 meta/recipes-devtools/go/go-1.6/armhf-elf-header.patch delete mode 100644 meta/recipes-devtools/go/go-1.6/fix-cc-handling.patch delete mode 100644 meta/recipes-devtools/go/go-1.6/fix-target-cc-for-build.patch delete mode 100644 meta/recipes-devtools/go/go-1.6/gotooldir.patch delete mode 100644 meta/recipes-devtools/go/go-1.6/split-host-and-target-build.patch delete mode 100644 meta/recipes-devtools/go/go-1.6/syslog.patch delete mode 100644 meta/recipes-devtools/go/go-1.7.inc delete mode 100644 meta/recipes-devtools/go/go-1.7/armhf-elf-header.patch delete mode 100644 meta/recipes-devtools/go/go-1.7/fix-cc-handling.patch delete mode 100644 meta/recipes-devtools/go/go-1.7/fix-target-cc-for-build.patch delete mode 100644 meta/recipes-devtools/go/go-1.7/gotooldir.patch delete mode 100644 meta/recipes-devtools/go/go-1.7/split-host-and-target-build.patch delete mode 100644 meta/recipes-devtools/go/go-1.7/syslog.patch delete mode 100644 meta/recipes-devtools/go/go-cross_1.7.bb delete mode 100644 meta/recipes-devtools/go/go_1.6.bb delete mode 100644 meta/recipes-devtools/go/go_1.7.bb
meta/recipes-devtools/go/go-1.6.inc deleted +0 -19
@@ -1,19 +0,0 @@ -require go-common.inc - -PV = "1.6.3" -GO_BASEVERSION = "1.6" -FILESEXTRAPATHS_prepend := "${FILE_DIRNAME}/go-${GO_BASEVERSION}:" - -LIC_FILES_CHKSUM = "file://LICENSE;md5=591778525c869cdde0ab5a1bf283cd81" - -SRC_URI += "\ - file://armhf-elf-header.patch \ - file://syslog.patch \ - file://fix-target-cc-for-build.patch \ - file://fix-cc-handling.patch \ - file://split-host-and-target-build.patch \ - file://gotooldir.patch \ -" -SRC_URI[md5sum] = "bf3fce6ccaadd310159c9e874220e2a2" -SRC_URI[sha256sum] = "6326aeed5f86cf18f16d6dc831405614f855e2d416a91fd3fdc334f772345b00" -
meta/recipes-devtools/go/go-1.6/armhf-elf-header.patch deleted +0 -23
@@ -1,23 +0,0 @@ -Encode arm EABI ( hard/soft ) calling convention in ELF header - -Signed-off-by: Khem Raj <[email protected]> -Upstream-Status: Pending -Index: go/src/cmd/link/internal/ld/elf.go -=================================================================== ---- go.orig/src/cmd/link/internal/ld/elf.go -+++ go/src/cmd/link/internal/ld/elf.go -@@ -827,7 +827,13 @@ - // 32-bit architectures - case '5': - // we use EABI on both linux/arm and freebsd/arm. -- if HEADTYPE == obj.Hlinux || HEADTYPE == obj.Hfreebsd { -+ if HEADTYPE == obj.Hlinux { -+ if Ctxt.Goarm == 7 { -+ ehdr.flags = 0x5000402 // has entry point, Version5 EABI, hard float -+ } else { -+ ehdr.flags = 0x5000202 // has entry point, Version5 EABI, soft float -+ } -+ } else if HEADTYPE == obj.Hfreebsd { - // We set a value here that makes no indication of which - // float ABI the object uses, because this is information - // used by the dynamic linker to compare executables and
meta/recipes-devtools/go/go-1.6/fix-cc-handling.patch deleted +0 -50
50 lines not on this page · raw message
meta/recipes-devtools/go/go-1.6/fix-target-cc-for-build.patch deleted +0 -17
@@ -1,17 +0,0 @@ -Put Quotes around CC_FOR_TARGET since it can be mutliple words e.g. in OE - -Signed-off-by: Khem Raj <[email protected]> -Upstream-Status: Pending -Index: go/src/make.bash -=================================================================== ---- go.orig/src/make.bash 2015-07-29 13:28:11.334031696 -0700 -+++ go/src/make.bash 2015-07-29 13:36:55.814465630 -0700 -@@ -158,7 +158,7 @@ - fi - - echo "##### Building packages and commands for $GOOS/$GOARCH." --CC=$CC_FOR_TARGET "$GOTOOLDIR"/go_bootstrap install $GO_FLAGS -gcflags "$GO_GCFLAGS" -ldflags "$GO_LDFLAGS" -v std cmd -+CC="$CC_FOR_TARGET" "$GOTOOLDIR"/go_bootstrap install $GO_FLAGS -gcflags "$GO_GCFLAGS" -ldflags "$GO_LDFLAGS" -v std cmd - echo - - rm -f "$GOTOOLDIR"/go_bootstrap
meta/recipes-devtools/go/go-1.6/gotooldir.patch deleted +0 -30
@@ -1,30 +0,0 @@ -Define tooldir in relation to GOTOOLDIR env var - -Signed-off-by: Khem Raj <[email protected]> -Upstream-Status: Pending -Index: go/src/go/build/build.go -=================================================================== ---- go.orig/src/go/build/build.go -+++ go/src/go/build/build.go -@@ -1388,7 +1388,7 @@ func init() { - } - - // ToolDir is the directory containing build tools. --var ToolDir = filepath.Join(runtime.GOROOT(), "pkg/tool/"+runtime.GOOS+"_"+runtime.GOARCH) -+var ToolDir = envOr("GOTOOLDIR", filepath.Join(runtime.GOROOT(), "pkg/tool/"+runtime.GOOS+"_"+runtime.GOARCH)) - - // IsLocalImport reports whether the import path is - // a local import path, like ".", "..", "./foo", or "../foo". -Index: go/src/cmd/go/build.go -=================================================================== ---- go.orig/src/cmd/go/build.go -+++ go/src/cmd/go/build.go -@@ -1312,7 +1312,7 @@ func (b *builder) build(a *action) (err - } - - cgoExe := tool("cgo") -- if a.cgo != nil && a.cgo.target != "" { -+ if a.cgo != nil && a.cgo.target != "" && os.Getenv("GOTOOLDIR") == "" { - cgoExe = a.cgo.target - } - outGo, outObj, err := b.cgo(a.p, cgoExe, obj, pcCFLAGS, pcLDFLAGS, cgofiles, gccfiles, cxxfiles, a.p.MFiles)
meta/recipes-devtools/go/go-1.6/split-host-and-target-build.patch deleted +0 -63
63 lines not on this page · raw message
meta/recipes-devtools/go/go-1.6/syslog.patch deleted +0 -62
62 lines not on this page · raw message
meta/recipes-devtools/go/go-1.7.inc deleted +0 -19
@@ -1,19 +0,0 @@ -require go-common.inc - -PV = "1.7.4" -GO_BASEVERSION = "1.7" -FILESEXTRAPATHS_prepend := "${FILE_DIRNAME}/go-${GO_BASEVERSION}:" - -LIC_FILES_CHKSUM = "file://LICENSE;md5=5d4950ecb7b26d2c5e4e7b4e0dd74707" - -SRC_URI += "\ - file://armhf-elf-header.patch \ - file://syslog.patch \ - file://fix-target-cc-for-build.patch \ - file://fix-cc-handling.patch \ - file://split-host-and-target-build.patch \ - file://gotooldir.patch \ -" -SRC_URI[md5sum] = "49c1076428a5d3b5ad7ac65233fcca2f" -SRC_URI[sha256sum] = "4c189111e9ba651a2bb3ee868aa881fab36b2f2da3409e80885ca758a6b614cc" -
meta/recipes-devtools/go/go-1.7/armhf-elf-header.patch deleted +0 -23
@@ -1,23 +0,0 @@ -Encode arm EABI ( hard/soft ) calling convention in ELF header - -Signed-off-by: Khem Raj <[email protected]> -Upstream-Status: Pending -Index: go/src/cmd/link/internal/ld/elf.go -=================================================================== ---- go.orig/src/cmd/link/internal/ld/elf.go -+++ go/src/cmd/link/internal/ld/elf.go -@@ -827,7 +827,13 @@ - // 32-bit architectures - case '5': - // we use EABI on both linux/arm and freebsd/arm. -- if HEADTYPE == obj.Hlinux || HEADTYPE == obj.Hfreebsd { -+ if HEADTYPE == obj.Hlinux { -+ if Ctxt.Goarm == 7 { -+ ehdr.flags = 0x5000402 // has entry point, Version5 EABI, hard float -+ } else { -+ ehdr.flags = 0x5000202 // has entry point, Version5 EABI, soft float -+ } -+ } else if HEADTYPE == obj.Hfreebsd { - // We set a value here that makes no indication of which - // float ABI the object uses, because this is information - // used by the dynamic linker to compare executables and
meta/recipes-devtools/go/go-1.7/fix-cc-handling.patch deleted +0 -50
50 lines not on this page · raw message
meta/recipes-devtools/go/go-1.7/fix-target-cc-for-build.patch deleted +0 -17
@@ -1,17 +0,0 @@ -Put Quotes around CC_FOR_TARGET since it can be mutliple words e.g. in OE - -Signed-off-by: Khem Raj <[email protected]> -Upstream-Status: Pending -Index: go/src/make.bash -=================================================================== ---- go.orig/src/make.bash 2015-07-29 13:28:11.334031696 -0700 -+++ go/src/make.bash 2015-07-29 13:36:55.814465630 -0700 -@@ -158,7 +158,7 @@ - fi - - echo "##### Building packages and commands for $GOOS/$GOARCH." --CC=$CC_FOR_TARGET "$GOTOOLDIR"/go_bootstrap install $GO_FLAGS -gcflags "$GO_GCFLAGS" -ldflags "$GO_LDFLAGS" -v std cmd -+CC="$CC_FOR_TARGET" "$GOTOOLDIR"/go_bootstrap install $GO_FLAGS -gcflags "$GO_GCFLAGS" -ldflags "$GO_LDFLAGS" -v std cmd - echo - - rm -f "$GOTOOLDIR"/go_bootstrap
meta/recipes-devtools/go/go-1.7/gotooldir.patch deleted +0 -30
@@ -1,30 +0,0 @@ -Define tooldir in relation to GOTOOLDIR env var - -Signed-off-by: Khem Raj <[email protected]> -Upstream-Status: Pending -Index: go/src/go/build/build.go -=================================================================== ---- go.orig/src/go/build/build.go -+++ go/src/go/build/build.go -@@ -1388,7 +1388,7 @@ func init() { - } - - // ToolDir is the directory containing build tools. --var ToolDir = filepath.Join(runtime.GOROOT(), "pkg/tool/"+runtime.GOOS+"_"+runtime.GOARCH) -+var ToolDir = envOr("GOTOOLDIR", filepath.Join(runtime.GOROOT(), "pkg/tool/"+runtime.GOOS+"_"+runtime.GOARCH)) - - // IsLocalImport reports whether the import path is - // a local import path, like ".", "..", "./foo", or "../foo". -Index: go/src/cmd/go/build.go -=================================================================== ---- go.orig/src/cmd/go/build.go -+++ go/src/cmd/go/build.go -@@ -1312,7 +1312,7 @@ func (b *builder) build(a *action) (err - } - - cgoExe := tool("cgo") -- if a.cgo != nil && a.cgo.target != "" { -+ if a.cgo != nil && a.cgo.target != "" && os.Getenv("GOTOOLDIR") == "" { - cgoExe = a.cgo.target - } - outGo, outObj, err := b.cgo(a.p, cgoExe, obj, pcCFLAGS, pcLDFLAGS, cgofiles, gccfiles, cxxfiles, a.p.MFiles)
meta/recipes-devtools/go/go-1.7/split-host-and-target-build.patch deleted +0 -62
62 lines not on this page · raw message
meta/recipes-devtools/go/go-1.7/syslog.patch deleted +0 -62
62 lines not on this page · raw message
meta/recipes-devtools/go/go-cross_1.7.bb deleted +0 -5
@@ -1,5 +0,0 @@ -require go-cross.inc -require go_${PV}.bb - -# Go binaries are not understood by the strip tool. -INHIBIT_SYSROOT_STRIP = "1"
meta/recipes-devtools/go/go_1.6.bb deleted +0 -4
@@ -1,4 +0,0 @@ -require go.inc -require go-${PV}.inc - -BBCLASSEXTEND = "cross"
meta/recipes-devtools/go/go_1.7.bb deleted +0 -2
@@ -1,2 +0,0 @@ -require go-${PV}.inc -require go.inc
Signature · 1 line
2.14.1
PATCH v3 5/11 goarch.bbclass: Add support for ARMv5
In reply to Otavio SalvadorThis adds support to return the proper ARMv5 format.
This change is based on the meta-golang[1] layer. Thanks to Matt Madison <[email protected]> for his work on this.
1. https://github.com/madisongh/meta-golang
---
Changes in v3: None
Changes in v2: None
meta/classes/goarch.bbclass | 2 ++ 1 file changed, 2 insertions(+)
meta/classes/goarch.bbclass +2 -0
@@ -47,6 +47,8 @@ def go_map_arm(a, f, d): import re if re.match('arm.*', a) and re.match('arm.*7.*', f): return '7' + if re.match('arm.*', a) and re.match('arm.*5.*', f): + return '5' return '' def go_map_os(o, d):
Signature · 1 line
2.14.1
Re: [PATCH v3 05/11] goarch.bbclass: Add support for ARMv5
Quoted 21 lines · Otavio Salvador
This adds support to return the proper ARMv5 format.
This change is based on the meta-golang[1] layer. Thanks to Matt Madison <[email protected]> for his work on this.
1. https://github.com/madisongh/meta-golang
Signed-off-by Otavio Salvador <[email protected]>---
Changes in v3: None
Changes in v2: Nonemeta/classes/goarch.bbclass | 2 ++ 1 file changed, 2 insertions(+)meta/classes/goarch.bbclass +0
-0
meta/classes/goarch.bbclass def go_map_arm(a, f, d): · line 51
Quoted 5 lines
meta/classes/goarch.bbclass +2
-0@@ -47,6 +47,8 @@ def go_map_arm(a, f, d): import re if re.match('arm.*', a) and re.match('arm.*7.*', f): return '7' + if re.match('arm.*', a) and re.match('arm.*5.*', f): + return '5'
I suspect this regular expression is overly general, see:
http://lists.openembedded.org/pipermail/openembedded-core/2017-September/141938.html
The Go toolchain default is for ARMv5 when cross-compiling so as far as I know setting this explicitly should have no effect at the moment, although it may be valuable to protect against changes to the default.
Quoted 11 lines
meta/classes/goarch.bbclass +0
-1return '' def go_map_os(o, d): --2.14.1
--
_______________________________________________
Openembedded-core mailing list
[email protected]
http://lists.openembedded.org/mailman/listinfo/openembedded-core
Re: [PATCH v3 05/11] goarch.bbclass: Add support for ARMv5
Quoted 30 lines · Will Newton
Quoted 21 lines · Otavio Salvador
This adds support to return the proper ARMv5 format.
This change is based on the meta-golang[1] layer. Thanks to Matt Madison <[email protected]> for his work on this.
1. https://github.com/madisongh/meta-golang
Signed-off-by Otavio Salvador <[email protected]>---
Changes in v3: None
Changes in v2: Nonemeta/classes/goarch.bbclass | 2 ++ 1 file changed, 2 insertions(+)meta/classes/goarch.bbclass +0
-0meta/classes/goarch.bbclass def go_map_arm(a, f, d): · line 51
Quoted 5 lines
meta/classes/goarch.bbclass +2
-0@@ -47,6 +47,8 @@ def go_map_arm(a, f, d): import re if re.match('arm.*', a) and re.match('arm.*7.*', f): return '7' + if re.match('arm.*', a) and re.match('arm.*5.*', f): + return '5'I suspect this regular expression is overly general, see:
Quoted 5 lines
http://lists.openembedded.org/pipermail/openembedded-core/2017-September/141938.html
The Go toolchain default is for ARMv5 when cross-compiling so as far as I know setting this explicitly should have no effect at the moment, although it may be valuable to protect against changes to the default.
If you don't mind, I will add your patch in my patchset and rebase mine on top of this one so we have a single patchset with all this rework included. Are you Ok with that?
Signature · 3 lines
Otavio Salvador O.S. Systems http://www.ossystems.com.br http://code.ossystems.com.br Mobile: +55 (53) 9981-7854 Mobile: +1 (347) 903-9750
PATCH v3 6/11 go.bbclass: Use a global Go build flags
In reply to Otavio SalvadorWe now use a GOBUILDFLAGS to provide a global variable to control the build flags to be given to Go.
This change is based on the meta-golang[1] layer. Thanks to Matt Madison <[email protected]> for his work on this.
1. https://github.com/madisongh/meta-golang
---
Changes in v3: None
Changes in v2:
- Remove -x flag (madisongh)
- Remove GO_EXTLDFLAGS for now (madisongh)
meta/classes/go.bbclass | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
meta/classes/go.bbclass +3 -1
@@ -5,6 +5,8 @@ GOROOT = "${STAGING_LIBDIR_NATIVE}/${TARGET_SYS}/go" GOBIN_FINAL_class-native = "${GOROOT_FINAL}/bin" GOBIN_FINAL = "${GOROOT_FINAL}/${GO_BUILD_BINDIR}" +export GOBUILDFLAGS ?= "-v" + export GOOS = "${TARGET_GOOS}" export GOARCH = "${TARGET_GOARCH}" export GOARM = "${TARGET_GOARM}"
@@ -32,7 +34,7 @@ GO_INSTALL ?= "${GO_IMPORT}/..." do_go_compile() { GOPATH=${S}:${STAGING_LIBDIR}/${TARGET_SYS}/go go env if [ -n "${GO_INSTALL}" ]; then - GOPATH=${S}:${STAGING_LIBDIR}/${TARGET_SYS}/go go install -v ${GO_INSTALL} + GOPATH=${S}:${STAGING_LIBDIR}/${TARGET_SYS}/go go install ${GOBUILDFLAGS} ${GO_INSTALL} fi }
Signature · 1 line
2.14.1
PATCH v3 7/11 go.bbclass: Enable parallel build
In reply to Otavio SalvadorThe parallel build is based on PARALLEL_MAKE variable but can be overriden setting the GO_PARALLEL_BUILD one.
This change is based on the meta-golang[1] layer. Thanks to Matt Madison <[email protected]> for his work on this.
1. https://github.com/madisongh/meta-golang
---
Changes in v3: None
Changes in v2: None
meta/classes/go.bbclass | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+)
meta/classes/go.bbclass +20 -0
@@ -1,11 +1,31 @@ inherit goarch +def get_go_parallel_make(d): + pm = (d.getVar('PARALLEL_MAKE') or '').split() + # look for '-j' and throw other options (e.g. '-l') away + # because they might have a different meaning in golang + while pm: + opt = pm.pop(0) + if opt == '-j': + v = pm.pop(0) + elif opt.startswith('-j'): + v = opt[2:].strip() + else: + continue + + return '-p %d' % int(v) + + return "" + +GO_PARALLEL_BUILD ?= "${@get_go_parallel_make(d)}" + GOROOT_class-native = "${STAGING_LIBDIR_NATIVE}/go" GOROOT = "${STAGING_LIBDIR_NATIVE}/${TARGET_SYS}/go" GOBIN_FINAL_class-native = "${GOROOT_FINAL}/bin" GOBIN_FINAL = "${GOROOT_FINAL}/${GO_BUILD_BINDIR}" export GOBUILDFLAGS ?= "-v" +GOBUILDFLAGS_prepend_task-compile = "${GO_PARALLEL_BUILD} " export GOOS = "${TARGET_GOOS}" export GOARCH = "${TARGET_GOARCH}"
Signature · 1 line
2.14.1
PATCH v3 8/11 go.bbclass: exported function cleanup
In reply to Otavio SalvadorFrom: Matt Madison <[email protected]>
Since this is a class, it should follow the class function export mechanism for its task functions, and should set directory-related flags for directories they need.
---
Changes in v3:
- new patch
Changes in v2: None
meta/classes/go.bbclass | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-)
meta/classes/go.bbclass +5 -9
@@ -51,14 +51,14 @@ FILES_${PN}-staticdev += "${GOPKG_FINAL}/${GO_IMPORT}*" GO_INSTALL ?= "${GO_IMPORT}/..." -do_go_compile() { +go_do_compile() { GOPATH=${S}:${STAGING_LIBDIR}/${TARGET_SYS}/go go env if [ -n "${GO_INSTALL}" ]; then GOPATH=${S}:${STAGING_LIBDIR}/${TARGET_SYS}/go go install ${GOBUILDFLAGS} ${GO_INSTALL} fi } -do_go_install() { +go_do_install() { rm -rf ${WORKDIR}/staging install -d ${WORKDIR}/staging${GOROOT_FINAL} ${D}${GOROOT_FINAL} tar -C ${S} -cf - . | tar -C ${WORKDIR}/staging${GOROOT_FINAL} -xpvf -
@@ -84,11 +84,7 @@ do_go_install() { rmdir -p "${D}${GOBIN_FINAL}" || true fi } +do_install[dirs] =+ "${WORKDIR}/staging" +do_install[cleandirs] += "${WORKDIR}/staging" -do_compile() { - do_go_compile -} - -do_install() { - do_go_install -} +EXPORT_FUNCTIONS do_compile do_install
Signature · 1 line
2.14.1
PATCH v3 9/11 go.bbclass: Use an auxiliary variable to add the build dependencies
In reply to Otavio SalvadorThis is going to easy the addition of nativesdk and virtual providers in the future.
This change is based on the meta-golang[1] layer. Thanks to Matt Madison <[email protected]> for his work on this.
1. https://github.com/madisongh/meta-golang
---
Changes in v3: None
Changes in v2: None
meta/classes/go.bbclass | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
meta/classes/go.bbclass +5 -3
@@ -24,6 +24,11 @@ GOROOT = "${STAGING_LIBDIR_NATIVE}/${TARGET_SYS}/go" GOBIN_FINAL_class-native = "${GOROOT_FINAL}/bin" GOBIN_FINAL = "${GOROOT_FINAL}/${GO_BUILD_BINDIR}" +DEPENDS_GOLANG_class-target = "go-cross-${TARGET_ARCH}" +DEPENDS_GOLANG_class-native = "go-native" + +DEPENDS_append = " ${DEPENDS_GOLANG}" + export GOBUILDFLAGS ?= "-v" GOBUILDFLAGS_prepend_task-compile = "${GO_PARALLEL_BUILD} "
@@ -43,9 +48,6 @@ export CGO_CPPFLAGS = "${TARGET_CPPFLAGS}" export CGO_CXXFLAGS = "${TARGET_CC_ARCH}${TOOLCHAIN_OPTIONS} ${TARGET_CXXFLAGS}" export CGO_LDFLAGS = "${TARGET_CC_ARCH}${TOOLCHAIN_OPTIONS} ${TARGET_LDFLAGS}" -DEPENDS += "go-cross-${TARGET_ARCH}" -DEPENDS_class-native += "go-native" - FILES_${PN}-staticdev += "${GOSRC_FINAL}/${GO_IMPORT}" FILES_${PN}-staticdev += "${GOPKG_FINAL}/${GO_IMPORT}*"
Signature · 1 line
2.14.1
PATCH v3 10/11 go.bbclass: separate ${S} and ${B}
In reply to Otavio SalvadorFrom: Matt Madison <[email protected]>
Add a do_configure task to populate ${B} by symlinking in the src subdirectory under ${S}, which lets us point GOPATH at ${B}. This lets us take advantage of the automatic directory creation and cleaning for do_configure.
This necessitates a change to do_install to split the installation of the sources and built artifacts. Taking advantage of some additional tar options, we can eliminate the extra staging area and extra recursive chown command. So overall efficiency should be improved.
---
Changes in v3:
- new patch
Changes in v2: None
meta/classes/go.bbclass | 46 ++++++++++++++++++---------------------------- 1 file changed, 18 insertions(+), 28 deletions(-)
meta/classes/go.bbclass +18 -28
@@ -53,40 +53,30 @@ FILES_${PN}-staticdev += "${GOPKG_FINAL}/${GO_IMPORT}*" GO_INSTALL ?= "${GO_IMPORT}/..." +B = "${WORKDIR}/build" + +go_do_configure() { + ln -snf ${S}/src ${B}/ +} + go_do_compile() { - GOPATH=${S}:${STAGING_LIBDIR}/${TARGET_SYS}/go go env + GOPATH=${B}:${STAGING_LIBDIR}/${TARGET_SYS}/go go env if [ -n "${GO_INSTALL}" ]; then - GOPATH=${S}:${STAGING_LIBDIR}/${TARGET_SYS}/go go install ${GOBUILDFLAGS} ${GO_INSTALL} + GOPATH=${B}:${STAGING_LIBDIR}/${TARGET_SYS}/go go install ${GOBUILDFLAGS} ${GO_INSTALL} fi } +do_compile[cleandirs] = "${B}/bin ${B}/pkg" go_do_install() { - rm -rf ${WORKDIR}/staging - install -d ${WORKDIR}/staging${GOROOT_FINAL} ${D}${GOROOT_FINAL} - tar -C ${S} -cf - . | tar -C ${WORKDIR}/staging${GOROOT_FINAL} -xpvf - - - find ${WORKDIR}/staging${GOROOT_FINAL} \( \ - -name \*.indirectionsymlink -o \ - -name .git\* -o \ - -name .hg -o \ - -name .svn -o \ - -name .pc\* -o \ - -name patches\* \ - \) -print0 | \ - xargs -r0 rm -rf - - tar -C ${WORKDIR}/staging${GOROOT_FINAL} -cf - . | \ - tar -C ${D}${GOROOT_FINAL} -xpvf - - - chown -R root:root "${D}${GOROOT_FINAL}" - - if [ -e "${D}${GOBIN_FINAL}" ]; then - install -d -m 0755 "${D}${bindir}" - find "${D}${GOBIN_FINAL}" ! -type d -print0 | xargs -r0 mv --target-directory="${D}${bindir}" - rmdir -p "${D}${GOBIN_FINAL}" || true + install -d ${D}${GOROOT_FINAL}/src/${GO_IMPORT} + tar -C ${S}/src/${GO_IMPORT} -cf - --exclude-vcs . | \ + tar -C ${D}${GOROOT_FINAL}/src/${GO_IMPORT} --no-same-owner -xf - + tar -C ${B} -cf - pkg | tar -C ${D}${GOROOT_FINAL} --no-same-owner -xf - + + if [ -n "`ls ${B}/${GO_BUILD_BINDIR}/`" ]; then + install -d ${D}${bindir} + install -m 0755 ${B}/${GO_BUILD_BINDIR}/* ${D}${bindir}/ fi } -do_install[dirs] =+ "${WORKDIR}/staging" -do_install[cleandirs] += "${WORKDIR}/staging" -EXPORT_FUNCTIONS do_compile do_install +EXPORT_FUNCTIONS do_configure do_compile do_install
Signature · 1 line
2.14.1
PATCH v3 11/11 go.bbclass: add do_unpack function to handle common cases
In reply to Otavio SalvadorFrom: Matt Madison <[email protected]>
Go source trees have a particular structure, with all sources located under ${GOROOT}/src/<import-path>. The fetcher step implemented by the 'go get' command automatically follows this structure, so we need to do the same here.
Since most Go packages are hosted in git repositories, this adds a custom do_unpack() function that sets the destsuffix to match the expected directory structure, for any git SRC_URIs that haven't had a destsuffix explicitly set in the recipe.
This simplifies recipe writing for the most common cases.
---
Changes in v3:
- new patch
Changes in v2: None
meta/classes/go.bbclass | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-)
meta/classes/go.bbclass +19 -1
@@ -55,6 +55,24 @@ GO_INSTALL ?= "${GO_IMPORT}/..." B = "${WORKDIR}/build" +python go_do_unpack() { + src_uri = (d.getVar('SRC_URI') or "").split() + if len(src_uri) == 0: + return + + try: + fetcher = bb.fetch2.Fetch(src_uri, d) + for url in fetcher.urls: + if fetcher.ud[url].type == 'git': + if fetcher.ud[url].parm.get('destsuffix') is None: + s_dirname = os.path.basename(d.getVar('S')) + fetcher.ud[url].parm['destsuffix'] = os.path.join(s_dirname, 'src', + d.getVar('GO_IMPORT')) + '/' + fetcher.unpack(d.getVar('WORKDIR')) + except bb.fetch2.BBFetchException as e: + raise bb.build.FuncFailed(e) +} + go_do_configure() { ln -snf ${S}/src ${B}/ }
@@ -79,4 +97,4 @@ go_do_install() { fi } -EXPORT_FUNCTIONS do_configure do_compile do_install +EXPORT_FUNCTIONS do_unpack do_configure do_compile do_install
Signature · 1 line
2.14.1