aboutsummaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/go
diff options
context:
space:
mode:
authorMatt Madison <matt@madison.systems>2017-09-12 09:50:21 -0300
committerRichard Purdie <richard.purdie@linuxfoundation.org>2017-09-12 23:51:37 +0100
commitd2a7af7cd834e218c39d43ee3fa0c14d4f748727 (patch)
treedcf3007032b00a663a84e1259eac7693e2559184 /meta/recipes-devtools/go
parentd9f54865ac90ed8d39a70b7989b1bf43ab26e248 (diff)
downloadopenembedded-core-contrib-d2a7af7cd834e218c39d43ee3fa0c14d4f748727.tar.gz
go: split out go-runtime into separate recipe
Reorganize the Go toolchain build to split out the Go standard runtime libraries into a separate recipe. This simplifies the extension to crosssdk and cross-canadian builds. * Adds a patch to the go build tool to prevent it from trying to rebuild anything in GOROOT, which is now resident in the target sysroot. * 'go' bb and inc files are now for building the compiler for the target only. * 'go-cross' bb and inc files are now just for the cross-compiler. * Adds virtual/<prefix> PROVIDES for the compiler and runtime * Removes testdata directories from the sysroot during staging, as they are unnecessary and can cause strip errors (some of the test files are ELF files). * Re-enables pacakage QA checks, adding selective INSANE_SKIP settings where needed. Signed-off-by: Matt Madison <matt@madison.systems> Signed-off-by: Otavio Salvador <otavio@ossystems.com.br> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/recipes-devtools/go')
-rw-r--r--meta/recipes-devtools/go/go-1.8.inc1
-rw-r--r--meta/recipes-devtools/go/go-1.8/make-goroot-precious.patch21
-rw-r--r--meta/recipes-devtools/go/go-cross.inc61
-rw-r--r--meta/recipes-devtools/go/go-cross_1.8.bb5
-rw-r--r--meta/recipes-devtools/go/go-runtime.inc58
-rw-r--r--meta/recipes-devtools/go/go-runtime_1.8.bb2
-rw-r--r--meta/recipes-devtools/go/go.inc68
7 files changed, 155 insertions, 61 deletions
diff --git a/meta/recipes-devtools/go/go-1.8.inc b/meta/recipes-devtools/go/go-1.8.inc
index bfb26de01d..2920d06f60 100644
--- a/meta/recipes-devtools/go/go-1.8.inc
+++ b/meta/recipes-devtools/go/go-1.8.inc
@@ -14,6 +14,7 @@ SRC_URI += "\
file://fix-cc-handling.patch \
file://split-host-and-target-build.patch \
file://gotooldir.patch \
+ file://make-goroot-precious.patch \
"
SRC_URI[main.md5sum] = "64e9380e07bba907e26a00cf5fcbe77e"
SRC_URI[main.sha256sum] = "5f5dea2447e7dcfdc50fa6b94c512e58bfba5673c039259fd843f68829d99fa6"
diff --git a/meta/recipes-devtools/go/go-1.8/make-goroot-precious.patch b/meta/recipes-devtools/go/go-1.8/make-goroot-precious.patch
new file mode 100644
index 0000000000..28a7a34773
--- /dev/null
+++ b/meta/recipes-devtools/go/go-1.8/make-goroot-precious.patch
@@ -0,0 +1,21 @@
+Prevent GOROOT-resident packages from being rebuilt
+
+Signed-off-by: Matt Madison <matt@madison.systems>
+Upstream-Status: Pending
+
+--- go.orig/src/cmd/go/pkg.go
++++ go/src/cmd/go/pkg.go
+@@ -1496,6 +1496,13 @@ func isStale(p *Package) (bool, string)
+ return true, "build ID mismatch"
+ }
+
++ // For OE builds, make anything in GOROOT non-stale,
++ // to prevent a package build from overwriting the
++ // build root.
++ if p.Goroot && os.Getenv("GOROOT_OVERRIDE") != "1" {
++ return false, "GOROOT-resident packages do not get rebuilt"
++ }
++
+ // Package is stale if a dependency is.
+ for _, p1 := range p.deps {
+ if p1.Stale {
diff --git a/meta/recipes-devtools/go/go-cross.inc b/meta/recipes-devtools/go/go-cross.inc
index 1c2d9e3a3d..df3e4ea914 100644
--- a/meta/recipes-devtools/go/go-cross.inc
+++ b/meta/recipes-devtools/go/go-cross.inc
@@ -1,15 +1,60 @@
inherit cross
-DEPENDS += "gcc-cross-${TARGET_ARCH}"
+PROVIDES = "virtual/${TARGET_PREFIX}go"
+DEPENDS += "go-native"
PN = "go-cross-${TARGET_ARCH}"
-# Ignore how TARGET_ARCH is computed.
-TARGET_ARCH[vardepvalue] = "${TARGET_ARCH}"
-# Ignore target os libc for cross compiler
-#TARGET_OS[vardepexclude] = "LIBCEXTENSION"
-FILESEXTRAPATHS =. "${FILE_DIRNAME}/go-cross:"
+export GOHOSTOS = "${BUILD_GOOS}"
+export GOHOSTARCH = "${BUILD_GOARCH}"
+export GOOS = "${TARGET_GOOS}"
+export GOARCH = "${TARGET_GOARCH}"
+export GOARM = "${TARGET_GOARM}"
+export GOROOT_BOOTSTRAP = "${STAGING_LIBDIR_NATIVE}/go"
+export GOROOT_FINAL = "${libdir}/go"
+export CGO_ENABLED = "1"
+export CC_FOR_TARGET="${TARGET_PREFIX}gcc ${TARGET_CC_ARCH} --sysroot=${STAGING_DIR_TARGET}"
+export CXX_FOR_TARGET="${TARGET_PREFIX}g++ ${TARGET_CC_ARCH} --sysroot=${STAGING_DIR_TARGET}"
+CC = "${@d.getVar('BUILD_CC', True).strip()}"
-GOROOT_FINAL = "${libdir}/go"
-export GOROOT_FINAL
+do_configure[noexec] = "1"
+do_compile() {
+ export GOBIN="${B}/bin"
+ rm -rf ${GOBIN} ${B}/pkg
+ mkdir ${GOBIN}
+ cd src
+ ./make.bash --host-only
+ cd ${B}
+}
+
+
+make_wrapper() {
+ rm -f ${D}${bindir}/$2
+ cat <<END >${D}${bindir}/$2
+#!/bin/bash
+here=\`dirname \$0\`
+export GOARCH="${TARGET_GOARCH}"
+export GOOS="${TARGET_GOOS}"
+export GOARM="${TARGET_GOARM}"
+\$here/../../lib/${CROSS_TARGET_SYS_DIR}/go/bin/$1 "\$@"
+END
+ chmod +x ${D}${bindir}/$2
+}
+
+do_install() {
+ install -d ${D}${libdir}/go
+ cp --preserve=mode,timestamps -R ${B}/pkg ${D}${libdir}/go/
+ install -d ${D}${libdir}/go/src
+ (cd ${S}/src; for d in *; do \
+ [ ! -d $d ] || cp --preserve=mode,timestamps -R ${S}/src/$d ${D}${libdir}/go/src/; \
+ done)
+
+ install -d ${D}${bindir} ${D}${libdir}/go/bin
+ for f in ${B}/bin/*
+ do
+ base=`basename $f`
+ install -m755 $f ${D}${libdir}/go/bin
+ make_wrapper $base ${TARGET_PREFIX}$base
+ done
+}
diff --git a/meta/recipes-devtools/go/go-cross_1.8.bb b/meta/recipes-devtools/go/go-cross_1.8.bb
index 56ee084b10..80b5a03f6c 100644
--- a/meta/recipes-devtools/go/go-cross_1.8.bb
+++ b/meta/recipes-devtools/go/go-cross_1.8.bb
@@ -1,5 +1,2 @@
require go-cross.inc
-require go_${PV}.bb
-
-# Go binaries are not understood by the strip tool.
-INHIBIT_SYSROOT_STRIP = "1"
+require go-${PV}.inc
diff --git a/meta/recipes-devtools/go/go-runtime.inc b/meta/recipes-devtools/go/go-runtime.inc
new file mode 100644
index 0000000000..e3eddda837
--- /dev/null
+++ b/meta/recipes-devtools/go/go-runtime.inc
@@ -0,0 +1,58 @@
+DEPENDS = "virtual/${TARGET_PREFIX}go go-native"
+PROVIDES = "virtual/${TARGET_PREFIX}go-runtime"
+
+export GOHOSTOS = "${BUILD_GOOS}"
+export GOHOSTARCH = "${BUILD_GOARCH}"
+export GOOS = "${TARGET_GOOS}"
+export GOARCH = "${TARGET_GOARCH}"
+export GOARM = "${TARGET_GOARM}"
+export GOROOT_BOOTSTRAP = "${STAGING_LIBDIR_NATIVE}/go"
+export GOROOT_FINAL = "${libdir}/go"
+export GO_TARGET_INSTALL = "std"
+export CGO_ENABLED = "1"
+export CC_FOR_TARGET="${CC}"
+export CXX_FOR_TARGET="${CXX}"
+export GOROOT_OVERRIDE = "1"
+
+do_configure[noexec] = "1"
+
+do_compile() {
+ export GOBIN="${B}/bin"
+ export CC="${@d.getVar('BUILD_CC').strip()}"
+ rm -rf ${GOBIN} ${B}/pkg
+ mkdir ${GOBIN}
+ cd src
+ GO_FLAGS="" ./make.bash
+ cd ${B}
+}
+
+do_install() {
+ install -d ${D}${libdir}/go/src
+ cp --preserve=mode,timestamps -R ${B}/pkg ${D}${libdir}/go/
+ if [ "${BUILD_GOTUPLE}" != "${TARGET_GOTUPLE}" ]; then
+ rm -rf ${D}${libdir}/go/pkg/${BUILD_GOTUPLE}
+ rm -rf ${D}${libdir}/go/pkg/obj/${BUILD_GOTUPLE}
+ fi
+ rm -rf ${D}${libdir}/go/pkg/tool
+ rm -rf ${D}${libdir}/go/pkg/obj
+ rm -rf ${D}${libdir}/go/pkg/bootstrap
+ find src -mindepth 1 -maxdepth 1 -type d | while read srcdir; do
+ [ "$srcdir" = "./cmd" ] || cp --preserve=mode,timestamps -R $srcdir ${D}${libdir}/go/src/
+ done
+}
+
+# These testdata directories aren't needed for builds and contain binaries
+# that can cause errors in sysroot_strip(), so just remove them.
+sysroot_stage_all_append() {
+ find ${SYSROOT_DESTDIR}${libdir}/go/src -depth -type d -name 'testdata' -exec rm -rf {} \;
+}
+
+ALLOW_EMPTY_${PN} = "1"
+FILES_${PN}-dev = "${libdir}/go/src ${libdir}/go/pkg/include"
+FILES_${PN}-staticdev = "${libdir}/go/pkg/${TARGET_GOTUPLE} ${libdir}/go/pkg/${TARGET_GOTUPLE}"
+# The testdata directories in the source tree include some binaries for various
+# architectures, scripts, and .a files
+INSANE_SKIP_${PN}-dev = "staticdev ldflags file-rdeps arch"
+
+INHIBIT_PACKAGE_STRIP = "1"
+INHIBIT_PACKAGE_DEBUG_SPLIT = "1"
diff --git a/meta/recipes-devtools/go/go-runtime_1.8.bb b/meta/recipes-devtools/go/go-runtime_1.8.bb
new file mode 100644
index 0000000000..43b68b4e46
--- /dev/null
+++ b/meta/recipes-devtools/go/go-runtime_1.8.bb
@@ -0,0 +1,2 @@
+require go-${PV}.inc
+require go-runtime.inc
diff --git a/meta/recipes-devtools/go/go.inc b/meta/recipes-devtools/go/go.inc
index 9efbd275bd..5984a60c28 100644
--- a/meta/recipes-devtools/go/go.inc
+++ b/meta/recipes-devtools/go/go.inc
@@ -1,16 +1,5 @@
inherit goarch
-DEPENDS += "go-native"
-
-# libgcc is required for the target specific libraries to build
-# properly, but apparently not for go-cross and, more importantly,
-# also can't be used there because go-cross cannot depend on
-# the tune-specific libgcc. Otherwise go-cross also would have
-# to be tune-specific.
-DEPENDS += "${@ 'libgcc' if not oe.utils.inherits(d, 'cross') else ''}"
-
-# Prevent runstrip from running because you get errors when the host arch != target arch
-INHIBIT_PACKAGE_STRIP = "1"
-INHIBIT_SYSROOT_STRIP = "1"
+DEPENDS = "virtual/${TARGET_PREFIX}go go-native"
export GOHOSTOS = "${BUILD_GOOS}"
export GOHOSTARCH = "${BUILD_GOARCH}"
@@ -22,13 +11,11 @@ export GOROOT_FINAL = "${libdir}/go"
export CGO_ENABLED = "1"
export CC_FOR_TARGET = "${CC}"
export CXX_FOR_TARGET = "${CXX}"
+export GO_TARGET_INSTALL = "cmd"
+export GO_FLAGS = "-a"
do_configure[noexec] = "1"
-do_compile_prepend_class-cross() {
- export CGO_ENABLED=0
-}
-
do_compile() {
export GOBIN="${B}/bin"
export CC="${@d.getVar('BUILD_CC', True).strip()}"
@@ -39,43 +26,26 @@ do_compile() {
mkdir -p ${WORKDIR}/build-tmp
cd src
- ./make.bash --host-only
- # Ensure cgo.a is built with the target toolchain
- export GOBIN="${B}/target/bin"
- rm -rf ${GOBIN}
- mkdir -p ${GOBIN}
- GO_FLAGS="-a" ./make.bash
-}
-
-do_install_class-target() {
- install -d ${D}${libdir}/go
- cp -a ${B}/pkg ${D}${libdir}/go/
- install -d ${D}${libdir}/go/src
- (cd ${S}/src; for d in *; do \
- [ -d $d ] && cp -a ${S}/src/$d ${D}${libdir}/go/src/; \
- done)
- install -d ${D}${bindir}
- if [ -d ${B}/bin/${GOOS}_${GOARCH} ]
- then
- install -m 0755 ${B}/bin/${GOOS}_${GOARCH}/* ${D}${bindir}
- else
- install -m 0755 ${B}/bin/* ${D}${bindir}
- fi
+ ./make.bash
+ cd ${B}
}
-do_install_class-cross() {
- install -d ${D}${libdir}/go
- cp -a ${B}/pkg ${D}${libdir}/go/
+do_install() {
+ install -d ${D}${libdir}/go/pkg/tool
+ cp --preserve=mode,timestamps -R ${B}/pkg/tool/${TARGET_GOTUPLE} ${D}${libdir}/go/pkg/tool/
install -d ${D}${libdir}/go/src
- (cd ${S}/src; for d in *; do \
- [ -d $d ] && cp -a ${S}/src/$d ${D}${libdir}/go/src/; \
- done)
+ cp --preserve=mode,timestamps -R ${S}/src/cmd ${D}${libdir}/go/src/
+ install -d ${D}${libdir}/go/bin
install -d ${D}${bindir}
- for f in ${B}/bin/go*
- do
- install -m755 $f ${D}${bindir}
+ for f in ${B}/${GO_BUILD_BINDIR}/*; do
+ name=`basename $f`
+ install -m 0755 $f ${D}${libdir}/go/bin/
+ ln -sf ../${BASELIB}/go/bin/$name ${D}${bindir}/
done
}
-do_package_qa[noexec] = "1"
-RDEPENDS_${PN} += "perl"
+PACKAGES = "${PN} ${PN}-dev"
+FILES_${PN} = "${libdir}/go/bin ${libdir}/go/pkg/tool/${TARGET_GOTUPLE} ${bindir}"
+FILES_${PN}-dev = "${libdir}/go"
+RDEPENDS_${PN}-dev = "perl bash"
+INSANE_SKIP_${PN} = "ldflags"