summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/go
diff options
context:
space:
mode:
authorMatt Madison <matt@madison.systems>2017-09-12 09:50:31 -0300
committerRichard Purdie <richard.purdie@linuxfoundation.org>2017-09-12 23:55:29 +0100
commit6255c002af95ba4481d96741bea59e3db7c663df (patch)
treeccc117fdfc71e55f29d767efc7e61833691a287c /meta/recipes-devtools/go
parentd7f07283dec4a77c293318cdfee4566fe21cd3c2 (diff)
downloadpoky-6255c002af95ba4481d96741bea59e3db7c663df.tar.gz
go-cross-canadian: add recipe
Enable cross-canadian builds of the Go toolchain. This requires an additional patch to the Go source to allow us to use the native GOTOOLDIR during the bootstrap phase. (From OE-Core rev: 9daa02f63a0d53ab90a515f2bd3e783187c9415b) 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/set-gotooldir-during-bootstrap.patch22
-rw-r--r--meta/recipes-devtools/go/go-cross-canadian.inc64
-rw-r--r--meta/recipes-devtools/go/go-cross-canadian_1.8.bb2
4 files changed, 89 insertions, 0 deletions
diff --git a/meta/recipes-devtools/go/go-1.8.inc b/meta/recipes-devtools/go/go-1.8.inc
index 2920d06f60..141c0994c3 100644
--- a/meta/recipes-devtools/go/go-1.8.inc
+++ b/meta/recipes-devtools/go/go-1.8.inc
@@ -15,6 +15,7 @@ SRC_URI += "\
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 file://make-goroot-precious.patch \
18 file://set-gotooldir-during-bootstrap.patch \
18" 19"
19SRC_URI[main.md5sum] = "64e9380e07bba907e26a00cf5fcbe77e" 20SRC_URI[main.md5sum] = "64e9380e07bba907e26a00cf5fcbe77e"
20SRC_URI[main.sha256sum] = "5f5dea2447e7dcfdc50fa6b94c512e58bfba5673c039259fd843f68829d99fa6" 21SRC_URI[main.sha256sum] = "5f5dea2447e7dcfdc50fa6b94c512e58bfba5673c039259fd843f68829d99fa6"
diff --git a/meta/recipes-devtools/go/go-1.8/set-gotooldir-during-bootstrap.patch b/meta/recipes-devtools/go/go-1.8/set-gotooldir-during-bootstrap.patch
new file mode 100644
index 0000000000..4b5e424d96
--- /dev/null
+++ b/meta/recipes-devtools/go/go-1.8/set-gotooldir-during-bootstrap.patch
@@ -0,0 +1,22 @@
1Set GOTOOLDIR during bootstrap
2
3Signed-off-by: Matt Madison <matt@madison.systems>
4Upstream-Status: Pending
5
6Index: go/src/make.bash
7===================================================================
8--- go.orig/src/make.bash
9+++ go/src/make.bash
10@@ -172,10 +172,11 @@ if [ "$do_host_build" = "yes" ]; then
11 mv cmd/dist/dist "$GOTOOLDIR"/dist
12 echo
13
14+ GOTOOLDIR_BOOTSTRAP="${GOTOOLDIR_BOOTSTRAP:-$GOTOOLDIR}"
15 echo "##### Building packages and commands for host, $GOHOSTOS/$GOHOSTARCH."
16 # CC_FOR_TARGET is recorded as the default compiler for the go tool. When building for the host, however,
17 # use the host compiler, CC, from `cmd/dist/dist env` instead.
18- CC=$CC GOOS=$GOHOSTOS GOARCH=$GOHOSTARCH \
19+ CC=$CC GOOS=$GOHOSTOS GOARCH=$GOHOSTARCH GOTOOLDIR="$GOTOOLDIR_BOOTSTRAP" \
20 "$GOTOOLDIR"/go_bootstrap install -gcflags "$GO_GCFLAGS" -ldflags "$GO_LDFLAGS" -v std cmd
21 echo
22 fi
diff --git a/meta/recipes-devtools/go/go-cross-canadian.inc b/meta/recipes-devtools/go/go-cross-canadian.inc
new file mode 100644
index 0000000000..f0315d558a
--- /dev/null
+++ b/meta/recipes-devtools/go/go-cross-canadian.inc
@@ -0,0 +1,64 @@
1inherit cross-canadian
2
3DEPENDS = "go-native virtual/${HOST_PREFIX}gcc-crosssdk virtual/nativesdk-${HOST_PREFIX}libc-for-gcc virtual/nativesdk-${HOST_PREFIX}compilerlibs"
4PN = "go-cross-canadian-${TRANSLATED_TARGET_ARCH}"
5
6export GOHOSTOS = "${BUILD_GOOS}"
7export GOHOSTARCH = "${BUILD_GOARCH}"
8export GOOS = "${HOST_GOOS}"
9export GOARCH = "${HOST_GOARCH}"
10export GOARM = "${HOST_GOARM}"
11export GOROOT_BOOTSTRAP = "${STAGING_LIBDIR_NATIVE}/go"
12export GOTOOLDIR_BOOTSTRAP = "${GOROOT_BOOTSTRAP}/pkg/tool/${BUILD_GOTUPLE}"
13export GOROOT_FINAL = "${libdir}/go"
14export CGO_ENABLED = "1"
15export CC_FOR_TARGET = "${HOST_CC}"
16export CXX_FOR_TARGET = "${HOST_CXX}"
17CC = "${@d.getVar('BUILD_CC', True).strip()}"
18export GO_LDFLAGS = '-linkmode external -extld ${HOST_PREFIX}gcc -extldflags "${TOOLCHAIN_OPTIONS} ${LDFLAGS}"'
19
20do_configure[noexec] = "1"
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 --no-banner
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\`
37native_goroot=\`readlink -f \$here/../../lib/${TARGET_SYS}/go\`
38export GOARCH="${TARGET_GOARCH}"
39export GOOS="${TARGET_GOOS}"
40export GOARM="\${GOARM:-${TARGET_GOARM}}"
41export GOTOOLDIR="\$native_goroot/pkg/tool/${HOST_GOTUPLE}"
42export GOROOT="\${GOROOT:-\$OECORE_TARGET_SYSROOT/${target_libdir}/go}"
43\$here/../../lib/${TARGET_SYS}/go/bin/$1 "\$@"
44END
45 chmod +x ${D}${bindir}/$2
46}
47
48do_install() {
49 install -d ${D}${libdir}/go
50 cp --preserve=mode,timestamps -R ${B}/pkg ${D}${libdir}/go/
51 install -d ${D}${libdir}/go/src
52 (cd ${S}/src; for d in *; do \
53 [ -d $d ] && cp --preserve=mode,timestamps -R ${S}/src/$d ${D}${libdir}/go/src/; \
54 done)
55 install -d ${D}${bindir} ${D}${libdir}/go/bin
56 for f in ${B}/bin/*
57 do
58 base=`basename $f`
59 install -m755 $f ${D}${libdir}/go/bin
60 make_wrapper $base ${TARGET_PREFIX}$base
61 done
62}
63
64FILES_${PN}-staticdev = "${libdir}/go/pkg"
diff --git a/meta/recipes-devtools/go/go-cross-canadian_1.8.bb b/meta/recipes-devtools/go/go-cross-canadian_1.8.bb
new file mode 100644
index 0000000000..7ac9449e47
--- /dev/null
+++ b/meta/recipes-devtools/go/go-cross-canadian_1.8.bb
@@ -0,0 +1,2 @@
1require go-cross-canadian.inc
2require go-${PV}.inc