summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason Wessel <jason.wessel@windriver.com>2016-09-20 12:01:12 -0500
committerBruce Ashfield <bruce.ashfield@windriver.com>2016-09-22 10:03:23 -0400
commit7ff08e542d15b8e0104185768debf360044af7d1 (patch)
treeb37dbf52f90b1d9c05b5dceb9743fa8144c3bea1
parent1bf8c777315120ca9a4a424a35b00af1e841ecf8 (diff)
downloadmeta-virtualization-7ff08e542d15b8e0104185768debf360044af7d1.tar.gz
go-cross: Fix host contamination for x86_64 host to x86_64 target
The go-cross package is explicitly for compiling target libraries on the host system. When the target architecture matches the host architecture it will actually use the host's linker and compiler however which can result in the generation of the cgo.a library having linker symbols which might not work properly when compiling other packages. A typical error looks like this when building consul-migrate: /opt/build-intel-x86/tmp/sysroots/x86_64-linux/usr/lib/x86_64-linux/go/pkg/tool/linux_amd64/link: running x86_64-yocto-linux-gcc failed: exit status 1 /opt/build-intel-x86/tmp/sysroots/x86_64-linux/usr/libexec/x86_64-yocto-linux/gcc/x86_64-yocto-linux/5.2.0/ld: /opt/build-intel-x86/tmp/work/core2-64-yocto-linux/consul-migrate/git-r0/build-tmp/go-link-956548052/000002.o: unrecognized relocation (0x2a) in section `.text' /opt/build-intel-x86/tmp/sysroots/x86_64-linux/usr/libexec/x86_64-yocto-linux/gcc/x86_64-yocto-linux/5.2.0/ld: final link failed: Bad value collect2: error: ld returned 1 exit status The fix is to use the make.bash --target-only option to properly build the libraries with the target toolchain. When the host architecture does not match the target architecture we must also force build the target libraries or they get dynamically populated into the sysroot in an uncontrolled manner by the first package that uses go-cross to compile code. Signed-off-by: Jason Wessel <jason.wessel@windriver.com> Signed-off-by: Bruce Ashfield <bruce.ashfield@windriver.com>
-rw-r--r--recipes-devtools/go-cross/go-cross.inc10
1 files changed, 9 insertions, 1 deletions
diff --git a/recipes-devtools/go-cross/go-cross.inc b/recipes-devtools/go-cross/go-cross.inc
index 613e9c7c..6363a789 100644
--- a/recipes-devtools/go-cross/go-cross.inc
+++ b/recipes-devtools/go-cross/go-cross.inc
@@ -2,6 +2,10 @@ inherit cross
2 2
3DEPENDS += "go-native" 3DEPENDS += "go-native"
4 4
5# Prevent runstrip from running because you get errors when the host arch != target arch
6#INHIBIT_PACKAGE_STRIP = "1"
7STRIP = "echo"
8
5export GOHOSTOS = "${BUILD_GOOS}" 9export GOHOSTOS = "${BUILD_GOOS}"
6export GOHOSTARCH = "${BUILD_GOARCH}" 10export GOHOSTARCH = "${BUILD_GOARCH}"
7export GOOS = "${TARGET_GOOS}" 11export GOOS = "${TARGET_GOOS}"
@@ -26,6 +30,8 @@ do_compile() {
26 30
27 cd src 31 cd src
28 ./make.bash --host-only 32 ./make.bash --host-only
33 # Ensure cgo.a is built with the target toolchain
34 GO_FLAGS="-a" ./make.bash --target-only
29} 35}
30 36
31do_install() { 37do_install() {
@@ -38,7 +44,9 @@ do_install() {
38 install -d ${D}${bindir} 44 install -d ${D}${bindir}
39 for f in ${B}/bin/* 45 for f in ${B}/bin/*
40 do 46 do
41 install -m755 $f ${D}${bindir} 47 if [ ! -d "$f" ] ; then
48 install -m755 $f ${D}${bindir}
49 fi
42 done 50 done
43} 51}
44 52