[OE-core] [v3][PATCH 1/2] go.bbclass: Export more GO* environment variables

richard.purdie at linuxfoundation.org richard.purdie at linuxfoundation.org
Tue Apr 9 21:27:42 UTC 2019


On Mon, 2019-03-18 at 11:21 -0400, Mark Asselstine wrote:
> Currently we are not doing a good job of consolidating GO environment
> variables used by the go build system in the go.bbclass, instead we
> are relying on the individual GO recipe authors to perform the
> exports. This can result in inconsistent build results and often
> binaries that are not properly cross compiled, resulting in segfaults
> when the applications are run on the target.
> 
> For example the GO documentation recommends that the environment
> include a value assigned to GOARM when cross building for ARMv5,
> ARMv6
> and ARMv7 (https://github.com/golang/go/wiki/GoArm).
> 
> In order to avoid polluting the build scripts with unnecessary
> exports, such as run.do_compile, we attempt to only export variables
> when they apply to a specific arch.
> 
> Signed-off-by: Mark Asselstine <mark.asselstine at windriver.com>
> ---
> 
> V2
> * Avoid potential undefined situations
> 
> V3
> * Add more exports to cover the basics
> * Tested on all qemu* variants, -native and build test other BSPs
> 
>  meta/classes/go.bbclass | 19 +++++++++++++++++++
>  1 file changed, 19 insertions(+)
> 
> diff --git a/meta/classes/go.bbclass b/meta/classes/go.bbclass
> index 7069c5f..78c2d68 100644
> --- a/meta/classes/go.bbclass
> +++ b/meta/classes/go.bbclass
> @@ -8,6 +8,25 @@ GOROOT = "${STAGING_LIBDIR}/go"
>  export GOROOT
>  export GOROOT_FINAL = "${libdir}/go"
>  
> +export GOARCH = "${TARGET_GOARCH}"
> +export GOOS = "${TARGET_GOOS}"
> +export GOHOSTARCH="${BUILD_GOARCH}"
> +export GOHOSTOS="${BUILD_GOOS}"
> +
> +GOARM[export] = "0"
> +GOARM_arm_class-target = "${TARGET_GOARM}"
> +GOARM_arm_class-target[export] = "1"
> +
> +GO386[export] = "0"
> +GO386_x86_class-target = "${TARGET_GO386}"
> +GO386_x86_class-target[export] = "1"
> +GO386_i586_class-target = "${TARGET_GO386}"
> +GO386_i586_class-target[export] = "1"

I'm almost certain that you don't need the i586 variant here as the x86
class should cover that already.

The export 0/1 thing is ugly and I which we had better syntax in
bitbake but its too late in the release for that now.

Cheers,

Richard



More information about the Openembedded-core mailing list