summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools
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:55:29 +0100
commit9060b87711ffc5892c343165236ec40e5e3478e6 (patch)
treeb3b1d79264f22f000140d703849ba8ae4d41e010 /meta/recipes-devtools
parent2a7a37e70d3709a0e2ca96d0341bbde102ee9978 (diff)
downloadpoky-9060b87711ffc5892c343165236ec40e5e3478e6.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. (From OE-Core rev: d2a7af7cd834e218c39d43ee3fa0c14d4f748727) 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')
-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 += "\
14 file://fix-cc-handling.patch \ 14 file://fix-cc-handling.patch \
15 file://split-host-and-target-build.patch \ 15 file://split-host-and-target-build.patch \
16 file://gotooldir.patch \ 16 file://gotooldir.patch \
17 file://make-goroot-precious.patch \
17" 18"
18SRC_URI[main.md5sum] = "64e9380e07bba907e26a00cf5fcbe77e" 19SRC_URI[main.md5sum] = "64e9380e07bba907e26a00cf5fcbe77e"
19SRC_URI[main.sha256sum] = "5f5dea2447e7dcfdc50fa6b94c512e58bfba5673c039259fd843f68829d99fa6" 20SRC_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 @@
1Prevent GOROOT-resident packages from being rebuilt
2
3Signed-off-by: Matt Madison <matt@madison.systems>
4Upstream-Status: Pending
5
6--- go.orig/src/cmd/go/pkg.go
7+++ go/src/cmd/go/pkg.go
8@@ -1496,6 +1496,13 @@ func isStale(p *Package) (bool, string)
9 return true, "build ID mismatch"
10 }
11
12+ // For OE builds, make anything in GOROOT non-stale,
13+ // to prevent a package build from overwriting the
14+ // build root.
15+ if p.Goroot && os.Getenv("GOROOT_OVERRIDE") != "1" {
16+ return false, "GOROOT-resident packages do not get rebuilt"
17+ }
18+
19 // Package is stale if a dependency is.
20 for _, p1 := range p.deps {
21 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 @@
1inherit cross 1inherit cross
2 2
3DEPENDS += "gcc-cross-${TARGET_ARCH}" 3PROVIDES = "virtual/${TARGET_PREFIX}go"
4DEPENDS += "go-native"
4 5
5PN = "go-cross-${TARGET_ARCH}" 6PN = "go-cross-${TARGET_ARCH}"
6 7
7# Ignore how TARGET_ARCH is computed. 8export GOHOSTOS = "${BUILD_GOOS}"
8TARGET_ARCH[vardepvalue] = "${TARGET_ARCH}" 9export GOHOSTARCH = "${BUILD_GOARCH}"
9# Ignore target os libc for cross compiler 10export GOOS = "${TARGET_GOOS}"
10#TARGET_OS[vardepexclude] = "LIBCEXTENSION" 11export GOARCH = "${TARGET_GOARCH}"
11FILESEXTRAPATHS =. "${FILE_DIRNAME}/go-cross:" 12export GOARM = "${TARGET_GOARM}"
13export GOROOT_BOOTSTRAP = "${STAGING_LIBDIR_NATIVE}/go"
14export GOROOT_FINAL = "${libdir}/go"
15export CGO_ENABLED = "1"
16export CC_FOR_TARGET="${TARGET_PREFIX}gcc ${TARGET_CC_ARCH} --sysroot=${STAGING_DIR_TARGET}"
17export CXX_FOR_TARGET="${TARGET_PREFIX}g++ ${TARGET_CC_ARCH} --sysroot=${STAGING_DIR_TARGET}"
18CC = "${@d.getVar('BUILD_CC', True).strip()}"
12 19
13GOROOT_FINAL = "${libdir}/go" 20do_configure[noexec] = "1"
14export GOROOT_FINAL
15 21
22do_compile() {
23 export GOBIN="${B}/bin"
24 rm -rf ${GOBIN} ${B}/pkg
25 mkdir ${GOBIN}
26 cd src
27 ./make.bash --host-only
28 cd ${B}
29}
30
31
32make_wrapper() {
33 rm -f ${D}${bindir}/$2
34 cat <<END >${D}${bindir}/$2
35#!/bin/bash
36here=\`dirname \$0\`
37export GOARCH="${TARGET_GOARCH}"
38export GOOS="${TARGET_GOOS}"
39export GOARM="${TARGET_GOARM}"
40\$here/../../lib/${CROSS_TARGET_SYS_DIR}/go/bin/$1 "\$@"
41END
42 chmod +x ${D}${bindir}/$2
43}
44
45do_install() {
46 install -d ${D}${libdir}/go
47 cp --preserve=mode,timestamps -R ${B}/pkg ${D}${libdir}/go/
48 install -d ${D}${libdir}/go/src
49 (cd ${S}/src; for d in *; do \
50 [ ! -d $d ] || cp --preserve=mode,timestamps -R ${S}/src/$d ${D}${libdir}/go/src/; \
51 done)
52
53 install -d ${D}${bindir} ${D}${libdir}/go/bin
54 for f in ${B}/bin/*
55 do
56 base=`basename $f`
57 install -m755 $f ${D}${libdir}/go/bin
58 make_wrapper $base ${TARGET_PREFIX}$base
59 done
60}
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 @@
1require go-cross.inc 1require go-cross.inc
2require go_${PV}.bb 2require go-${PV}.inc
3
4# Go binaries are not understood by the strip tool.
5INHIBIT_SYSROOT_STRIP = "1"
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 @@
1DEPENDS = "virtual/${TARGET_PREFIX}go go-native"
2PROVIDES = "virtual/${TARGET_PREFIX}go-runtime"
3
4export GOHOSTOS = "${BUILD_GOOS}"
5export GOHOSTARCH = "${BUILD_GOARCH}"
6export GOOS = "${TARGET_GOOS}"
7export GOARCH = "${TARGET_GOARCH}"
8export GOARM = "${TARGET_GOARM}"
9export GOROOT_BOOTSTRAP = "${STAGING_LIBDIR_NATIVE}/go"
10export GOROOT_FINAL = "${libdir}/go"
11export GO_TARGET_INSTALL = "std"
12export CGO_ENABLED = "1"
13export CC_FOR_TARGET="${CC}"
14export CXX_FOR_TARGET="${CXX}"
15export GOROOT_OVERRIDE = "1"
16
17do_configure[noexec] = "1"
18
19do_compile() {
20 export GOBIN="${B}/bin"
21 export CC="${@d.getVar('BUILD_CC').strip()}"
22 rm -rf ${GOBIN} ${B}/pkg
23 mkdir ${GOBIN}
24 cd src
25 GO_FLAGS="" ./make.bash
26 cd ${B}
27}
28
29do_install() {
30 install -d ${D}${libdir}/go/src
31 cp --preserve=mode,timestamps -R ${B}/pkg ${D}${libdir}/go/
32 if [ "${BUILD_GOTUPLE}" != "${TARGET_GOTUPLE}" ]; then
33 rm -rf ${D}${libdir}/go/pkg/${BUILD_GOTUPLE}
34 rm -rf ${D}${libdir}/go/pkg/obj/${BUILD_GOTUPLE}
35 fi
36 rm -rf ${D}${libdir}/go/pkg/tool
37 rm -rf ${D}${libdir}/go/pkg/obj
38 rm -rf ${D}${libdir}/go/pkg/bootstrap
39 find src -mindepth 1 -maxdepth 1 -type d | while read srcdir; do
40 [ "$srcdir" = "./cmd" ] || cp --preserve=mode,timestamps -R $srcdir ${D}${libdir}/go/src/
41 done
42}
43
44# These testdata directories aren't needed for builds and contain binaries
45# that can cause errors in sysroot_strip(), so just remove them.
46sysroot_stage_all_append() {
47 find ${SYSROOT_DESTDIR}${libdir}/go/src -depth -type d -name 'testdata' -exec rm -rf {} \;
48}
49
50ALLOW_EMPTY_${PN} = "1"
51FILES_${PN}-dev = "${libdir}/go/src ${libdir}/go/pkg/include"
52FILES_${PN}-staticdev = "${libdir}/go/pkg/${TARGET_GOTUPLE} ${libdir}/go/pkg/${TARGET_GOTUPLE}"
53# The testdata directories in the source tree include some binaries for various
54# architectures, scripts, and .a files
55INSANE_SKIP_${PN}-dev = "staticdev ldflags file-rdeps arch"
56
57INHIBIT_PACKAGE_STRIP = "1"
58INHIBIT_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 @@
1require go-${PV}.inc
2require 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 @@
1inherit goarch 1inherit goarch
2DEPENDS += "go-native" 2DEPENDS = "virtual/${TARGET_PREFIX}go go-native"
3
4# libgcc is required for the target specific libraries to build
5# properly, but apparently not for go-cross and, more importantly,
6# also can't be used there because go-cross cannot depend on
7# the tune-specific libgcc. Otherwise go-cross also would have
8# to be tune-specific.
9DEPENDS += "${@ 'libgcc' if not oe.utils.inherits(d, 'cross') else ''}"
10
11# Prevent runstrip from running because you get errors when the host arch != target arch
12INHIBIT_PACKAGE_STRIP = "1"
13INHIBIT_SYSROOT_STRIP = "1"
14 3
15export GOHOSTOS = "${BUILD_GOOS}" 4export GOHOSTOS = "${BUILD_GOOS}"
16export GOHOSTARCH = "${BUILD_GOARCH}" 5export GOHOSTARCH = "${BUILD_GOARCH}"
@@ -22,13 +11,11 @@ export GOROOT_FINAL = "${libdir}/go"
22export CGO_ENABLED = "1" 11export CGO_ENABLED = "1"
23export CC_FOR_TARGET = "${CC}" 12export CC_FOR_TARGET = "${CC}"
24export CXX_FOR_TARGET = "${CXX}" 13export CXX_FOR_TARGET = "${CXX}"
14export GO_TARGET_INSTALL = "cmd"
15export GO_FLAGS = "-a"
25 16
26do_configure[noexec] = "1" 17do_configure[noexec] = "1"
27 18
28do_compile_prepend_class-cross() {
29 export CGO_ENABLED=0
30}
31
32do_compile() { 19do_compile() {
33 export GOBIN="${B}/bin" 20 export GOBIN="${B}/bin"
34 export CC="${@d.getVar('BUILD_CC', True).strip()}" 21 export CC="${@d.getVar('BUILD_CC', True).strip()}"
@@ -39,43 +26,26 @@ do_compile() {
39 mkdir -p ${WORKDIR}/build-tmp 26 mkdir -p ${WORKDIR}/build-tmp
40 27
41 cd src 28 cd src
42 ./make.bash --host-only 29 ./make.bash
43 # Ensure cgo.a is built with the target toolchain 30 cd ${B}
44 export GOBIN="${B}/target/bin"
45 rm -rf ${GOBIN}
46 mkdir -p ${GOBIN}
47 GO_FLAGS="-a" ./make.bash
48}
49
50do_install_class-target() {
51 install -d ${D}${libdir}/go
52 cp -a ${B}/pkg ${D}${libdir}/go/
53 install -d ${D}${libdir}/go/src
54 (cd ${S}/src; for d in *; do \
55 [ -d $d ] && cp -a ${S}/src/$d ${D}${libdir}/go/src/; \
56 done)
57 install -d ${D}${bindir}
58 if [ -d ${B}/bin/${GOOS}_${GOARCH} ]
59 then
60 install -m 0755 ${B}/bin/${GOOS}_${GOARCH}/* ${D}${bindir}
61 else
62 install -m 0755 ${B}/bin/* ${D}${bindir}
63 fi
64} 31}
65 32
66do_install_class-cross() { 33do_install() {
67 install -d ${D}${libdir}/go 34 install -d ${D}${libdir}/go/pkg/tool
68 cp -a ${B}/pkg ${D}${libdir}/go/ 35 cp --preserve=mode,timestamps -R ${B}/pkg/tool/${TARGET_GOTUPLE} ${D}${libdir}/go/pkg/tool/
69 install -d ${D}${libdir}/go/src 36 install -d ${D}${libdir}/go/src
70 (cd ${S}/src; for d in *; do \ 37 cp --preserve=mode,timestamps -R ${S}/src/cmd ${D}${libdir}/go/src/
71 [ -d $d ] && cp -a ${S}/src/$d ${D}${libdir}/go/src/; \ 38 install -d ${D}${libdir}/go/bin
72 done)
73 install -d ${D}${bindir} 39 install -d ${D}${bindir}
74 for f in ${B}/bin/go* 40 for f in ${B}/${GO_BUILD_BINDIR}/*; do
75 do 41 name=`basename $f`
76 install -m755 $f ${D}${bindir} 42 install -m 0755 $f ${D}${libdir}/go/bin/
43 ln -sf ../${BASELIB}/go/bin/$name ${D}${bindir}/
77 done 44 done
78} 45}
79do_package_qa[noexec] = "1"
80 46
81RDEPENDS_${PN} += "perl" 47PACKAGES = "${PN} ${PN}-dev"
48FILES_${PN} = "${libdir}/go/bin ${libdir}/go/pkg/tool/${TARGET_GOTUPLE} ${bindir}"
49FILES_${PN}-dev = "${libdir}/go"
50RDEPENDS_${PN}-dev = "perl bash"
51INSANE_SKIP_${PN} = "ldflags"