[meta-virtualization] [v2 PATCH] go-cross: Fix host contamination for x86_64 host to x86_64 target

Bruce Ashfield bruce.ashfield at gmail.com
Thu Sep 22 07:04:53 PDT 2016


merged.

Bruce

On Tue, Sep 20, 2016 at 1:01 PM, Jason Wessel <jason.wessel at windriver.com>
wrote:

> 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 at windriver.com>
> ---
>  recipes-devtools/go-cross/go-cross.inc | 10 +++++++++-
>  1 file changed, 9 insertions(+), 1 deletion(-)
>
> diff --git a/recipes-devtools/go-cross/go-cross.inc
> b/recipes-devtools/go-cross/go-cross.inc
> index 613e9c7..6363a78 100644
> --- a/recipes-devtools/go-cross/go-cross.inc
> +++ b/recipes-devtools/go-cross/go-cross.inc
> @@ -2,6 +2,10 @@ inherit cross
>
>  DEPENDS += "go-native"
>
> +# Prevent runstrip from running because you get errors when the host arch
> != target arch
> +#INHIBIT_PACKAGE_STRIP = "1"
> +STRIP = "echo"
> +
>  export GOHOSTOS = "${BUILD_GOOS}"
>  export GOHOSTARCH = "${BUILD_GOARCH}"
>  export GOOS = "${TARGET_GOOS}"
> @@ -26,6 +30,8 @@ do_compile() {
>
>      cd src
>      ./make.bash --host-only
> +    # Ensure cgo.a is built with the target toolchain
> +    GO_FLAGS="-a" ./make.bash --target-only
>  }
>
>  do_install() {
> @@ -38,7 +44,9 @@ do_install() {
>      install -d ${D}${bindir}
>      for f in ${B}/bin/*
>      do
> -        install -m755 $f ${D}${bindir}
> +        if [ ! -d "$f" ] ; then
> +            install -m755 $f ${D}${bindir}
> +        fi
>      done
>  }
>
> --
> 1.9.1
>
> --
> _______________________________________________
> meta-virtualization mailing list
> meta-virtualization at yoctoproject.org
> https://lists.yoctoproject.org/listinfo/meta-virtualization
>



-- 
"Thou shalt not follow the NULL pointer, for chaos and madness await thee
at its end"
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.yoctoproject.org/pipermail/meta-virtualization/attachments/20160922/63f9afe0/attachment-0001.html>


More information about the meta-virtualization mailing list