All of lore.kernel.org
 help / color / mirror / Atom feed
* [v3][PATCH 1/2] go.bbclass: Export more GO* environment variables
@ 2019-03-18 15:21 Mark Asselstine
  2019-03-18 15:21 ` [v3][PATCH 2/2] goarch.bbclass: use MACHINEOVERRIDES and simplify go_map_arm() Mark Asselstine
  2019-04-09 21:27 ` [v3][PATCH 1/2] go.bbclass: Export more GO* environment variables richard.purdie
  0 siblings, 2 replies; 6+ messages in thread
From: Mark Asselstine @ 2019-03-18 15:21 UTC (permalink / raw)
  To: openembedded-core, richard.purdie

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@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"
+
+GOMIPS[export] = "0"
+GOMIPS_mips_class-target = "${TARGET_GOMIPS}"
+GOMIPS_mips_class-target[export] = "1"
+
 DEPENDS_GOLANG_class-target = "virtual/${TUNE_PKGARCH}-go virtual/${TARGET_PREFIX}go-runtime"
 DEPENDS_GOLANG_class-native = "go-native"
 DEPENDS_GOLANG_class-nativesdk = "virtual/${TARGET_PREFIX}go-crosssdk virtual/${TARGET_PREFIX}go-runtime"
-- 
2.7.4



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [v3][PATCH 2/2] goarch.bbclass: use MACHINEOVERRIDES and simplify go_map_arm()
  2019-03-18 15:21 [v3][PATCH 1/2] go.bbclass: Export more GO* environment variables Mark Asselstine
@ 2019-03-18 15:21 ` Mark Asselstine
  2019-03-18 16:40   ` Martin Jansa
  2019-04-09 21:31   ` richard.purdie
  2019-04-09 21:27 ` [v3][PATCH 1/2] go.bbclass: Export more GO* environment variables richard.purdie
  1 sibling, 2 replies; 6+ messages in thread
From: Mark Asselstine @ 2019-03-18 15:21 UTC (permalink / raw)
  To: openembedded-core, richard.purdie

Per https://github.com/golang/go/wiki/GoArm we need to set GOARM when
cross building for ARMv5, ARMv6 and ARMv7. The current approach of
using TUNE_FEATURES can be error prone, as we can see today when
attempting to build for Cortex-A7 which results in GOARM=''.

Since the value of MACHINEOVERRIDES already consolidates the values of
TUNE_FEATURES into something more consistent we can use the overrides
mechanism to set GOARM, leaving just a little bit of logic in
go_map_arm() to trigger off the arch (basically target vs host)
for the setting of GOARM.

Signed-off-by: Mark Asselstine <mark.asselstine@windriver.com>
---

V2
* Cover all ARMv7 Cortex* variants

V3
* Switch to using MACHINEOVERRIDES/overrides mechanism

 meta/classes/goarch.bbclass | 19 +++++++++++--------
 1 file changed, 11 insertions(+), 8 deletions(-)

diff --git a/meta/classes/goarch.bbclass b/meta/classes/goarch.bbclass
index 39fea5e..8fdb443 100644
--- a/meta/classes/goarch.bbclass
+++ b/meta/classes/goarch.bbclass
@@ -3,18 +3,26 @@ BUILD_GOARCH = "${@go_map_arch(d.getVar('BUILD_ARCH'), d)}"
 BUILD_GOTUPLE = "${BUILD_GOOS}_${BUILD_GOARCH}"
 HOST_GOOS = "${@go_map_os(d.getVar('HOST_OS'), d)}"
 HOST_GOARCH = "${@go_map_arch(d.getVar('HOST_ARCH'), d)}"
-HOST_GOARM = "${@go_map_arm(d.getVar('HOST_ARCH'), d.getVar('TUNE_FEATURES'), d)}"
+HOST_GOARM = "${@go_map_arm(d.getVar('HOST_ARCH'), d.getVar('BASE_GOARM'), d)}"
 HOST_GO386 = "${@go_map_386(d.getVar('HOST_ARCH'), d.getVar('TUNE_FEATURES'), d)}"
 HOST_GOMIPS = "${@go_map_mips(d.getVar('HOST_ARCH'), d.getVar('TUNE_FEATURES'), d)}"
 HOST_GOTUPLE = "${HOST_GOOS}_${HOST_GOARCH}"
 TARGET_GOOS = "${@go_map_os(d.getVar('TARGET_OS'), d)}"
 TARGET_GOARCH = "${@go_map_arch(d.getVar('TARGET_ARCH'), d)}"
-TARGET_GOARM = "${@go_map_arm(d.getVar('TARGET_ARCH'), d.getVar('TUNE_FEATURES'), d)}"
+TARGET_GOARM = "${@go_map_arm(d.getVar('TARGET_ARCH'), d.getVar('BASE_GOARM'), d)}"
 TARGET_GO386 = "${@go_map_386(d.getVar('TARGET_ARCH'), d.getVar('TUNE_FEATURES'), d)}"
 TARGET_GOMIPS = "${@go_map_mips(d.getVar('TARGET_ARCH'), d.getVar('TUNE_FEATURES'), d)}"
 TARGET_GOTUPLE = "${TARGET_GOOS}_${TARGET_GOARCH}"
 GO_BUILD_BINDIR = "${@['bin/${HOST_GOTUPLE}','bin'][d.getVar('BUILD_GOTUPLE') == d.getVar('HOST_GOTUPLE')]}"
 
+# Use the MACHINEOVERRIDES to map ARM CPU architecture passed to GO via GOARM.
+# This is combined with *_ARCH to set HOST_GOARM and TARGET_GOARM.
+BASE_GOARM = ''
+BASE_GOARM_armv7ve = '7'
+BASE_GOARM_armv7a = '7'
+BASE_GOARM_armv6 = '6'
+BASE_GOARM_armv5 = '5'
+
 # Go supports dynamic linking on a limited set of architectures.
 # See the supportsDynlink function in go/src/cmd/compile/internal/gc/main.go
 GO_DYNLINK = ""
@@ -74,12 +82,7 @@ def go_map_arch(a, d):
 def go_map_arm(a, f, d):
     import re
     if re.match('arm.*', a):
-        if 'armv7' in f:
-            return '7'
-        elif 'armv6' in f:
-            return '6'
-        elif 'armv5' in f:
-            return '5'
+        return f
     return ''
 
 def go_map_386(a, f, d):
-- 
2.7.4



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [v3][PATCH 2/2] goarch.bbclass: use MACHINEOVERRIDES and simplify go_map_arm()
  2019-03-18 15:21 ` [v3][PATCH 2/2] goarch.bbclass: use MACHINEOVERRIDES and simplify go_map_arm() Mark Asselstine
@ 2019-03-18 16:40   ` Martin Jansa
  2019-03-18 17:49     ` Mark Asselstine
  2019-04-09 21:31   ` richard.purdie
  1 sibling, 1 reply; 6+ messages in thread
From: Martin Jansa @ 2019-03-18 16:40 UTC (permalink / raw)
  To: Mark Asselstine; +Cc: openembedded-core

[-- Attachment #1: Type: text/plain, Size: 3733 bytes --]

On Mon, Mar 18, 2019 at 11:21:53AM -0400, Mark Asselstine wrote:
> Per https://github.com/golang/go/wiki/GoArm we need to set GOARM when
> cross building for ARMv5, ARMv6 and ARMv7. The current approach of
> using TUNE_FEATURES can be error prone, as we can see today when
> attempting to build for Cortex-A7 which results in GOARM=''.
> 
> Since the value of MACHINEOVERRIDES already consolidates the values of
> TUNE_FEATURES into something more consistent we can use the overrides
> mechanism to set GOARM, leaving just a little bit of logic in
> go_map_arm() to trigger off the arch (basically target vs host)
> for the setting of GOARM.
> 
> Signed-off-by: Mark Asselstine <mark.asselstine@windriver.com>
> ---
> 
> V2
> * Cover all ARMv7 Cortex* variants
> 
> V3
> * Switch to using MACHINEOVERRIDES/overrides mechanism
> 
>  meta/classes/goarch.bbclass | 19 +++++++++++--------
>  1 file changed, 11 insertions(+), 8 deletions(-)
> 
> diff --git a/meta/classes/goarch.bbclass b/meta/classes/goarch.bbclass
> index 39fea5e..8fdb443 100644
> --- a/meta/classes/goarch.bbclass
> +++ b/meta/classes/goarch.bbclass
> @@ -3,18 +3,26 @@ BUILD_GOARCH = "${@go_map_arch(d.getVar('BUILD_ARCH'), d)}"
>  BUILD_GOTUPLE = "${BUILD_GOOS}_${BUILD_GOARCH}"
>  HOST_GOOS = "${@go_map_os(d.getVar('HOST_OS'), d)}"
>  HOST_GOARCH = "${@go_map_arch(d.getVar('HOST_ARCH'), d)}"
> -HOST_GOARM = "${@go_map_arm(d.getVar('HOST_ARCH'), d.getVar('TUNE_FEATURES'), d)}"
> +HOST_GOARM = "${@go_map_arm(d.getVar('HOST_ARCH'), d.getVar('BASE_GOARM'), d)}"
>  HOST_GO386 = "${@go_map_386(d.getVar('HOST_ARCH'), d.getVar('TUNE_FEATURES'), d)}"
>  HOST_GOMIPS = "${@go_map_mips(d.getVar('HOST_ARCH'), d.getVar('TUNE_FEATURES'), d)}"
>  HOST_GOTUPLE = "${HOST_GOOS}_${HOST_GOARCH}"
>  TARGET_GOOS = "${@go_map_os(d.getVar('TARGET_OS'), d)}"
>  TARGET_GOARCH = "${@go_map_arch(d.getVar('TARGET_ARCH'), d)}"
> -TARGET_GOARM = "${@go_map_arm(d.getVar('TARGET_ARCH'), d.getVar('TUNE_FEATURES'), d)}"
> +TARGET_GOARM = "${@go_map_arm(d.getVar('TARGET_ARCH'), d.getVar('BASE_GOARM'), d)}"
>  TARGET_GO386 = "${@go_map_386(d.getVar('TARGET_ARCH'), d.getVar('TUNE_FEATURES'), d)}"
>  TARGET_GOMIPS = "${@go_map_mips(d.getVar('TARGET_ARCH'), d.getVar('TUNE_FEATURES'), d)}"
>  TARGET_GOTUPLE = "${TARGET_GOOS}_${TARGET_GOARCH}"
>  GO_BUILD_BINDIR = "${@['bin/${HOST_GOTUPLE}','bin'][d.getVar('BUILD_GOTUPLE') == d.getVar('HOST_GOTUPLE')]}"
>  
> +# Use the MACHINEOVERRIDES to map ARM CPU architecture passed to GO via GOARM.
> +# This is combined with *_ARCH to set HOST_GOARM and TARGET_GOARM.
> +BASE_GOARM = ''
> +BASE_GOARM_armv7ve = '7'
> +BASE_GOARM_armv7a = '7'
> +BASE_GOARM_armv6 = '6'
> +BASE_GOARM_armv5 = '5'
> +
>  # Go supports dynamic linking on a limited set of architectures.
>  # See the supportsDynlink function in go/src/cmd/compile/internal/gc/main.go
>  GO_DYNLINK = ""
> @@ -74,12 +82,7 @@ def go_map_arch(a, d):
>  def go_map_arm(a, f, d):
>      import re
>      if re.match('arm.*', a):
> -        if 'armv7' in f:
> -            return '7'
> -        elif 'armv6' in f:
> -            return '6'
> -        elif 'armv5' in f:
> -            return '5'
> +        return f
>      return ''

Is this function still useful? Cannot you set TARGET_GOARM and
HOST_GOARM with arm override (to simulate the effect of "re.match('arm.*', a)")?

Regards,

>  
>  def go_map_386(a, f, d):
> -- 
> 2.7.4
> 
> -- 
> _______________________________________________
> Openembedded-core mailing list
> Openembedded-core@lists.openembedded.org
> http://lists.openembedded.org/mailman/listinfo/openembedded-core

-- 
Martin 'JaMa' Jansa     jabber: Martin.Jansa@gmail.com

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 201 bytes --]

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [v3][PATCH 2/2] goarch.bbclass: use MACHINEOVERRIDES and simplify go_map_arm()
  2019-03-18 16:40   ` Martin Jansa
@ 2019-03-18 17:49     ` Mark Asselstine
  0 siblings, 0 replies; 6+ messages in thread
From: Mark Asselstine @ 2019-03-18 17:49 UTC (permalink / raw)
  To: Martin Jansa; +Cc: openembedded-core

On Monday, March 18, 2019 12:40:28 PM EDT Martin Jansa wrote:
> On Mon, Mar 18, 2019 at 11:21:53AM -0400, Mark Asselstine wrote:
> > Per https://github.com/golang/go/wiki/GoArm we need to set GOARM when
> > cross building for ARMv5, ARMv6 and ARMv7. The current approach of
> > using TUNE_FEATURES can be error prone, as we can see today when
> > attempting to build for Cortex-A7 which results in GOARM=''.
> > 
> > Since the value of MACHINEOVERRIDES already consolidates the values of
> > TUNE_FEATURES into something more consistent we can use the overrides
> > mechanism to set GOARM, leaving just a little bit of logic in
> > go_map_arm() to trigger off the arch (basically target vs host)
> > for the setting of GOARM.
> > 
> > Signed-off-by: Mark Asselstine <mark.asselstine@windriver.com>
> > ---
> > 
> > V2
> > * Cover all ARMv7 Cortex* variants
> > 
> > V3
> > * Switch to using MACHINEOVERRIDES/overrides mechanism
> > 
> >  meta/classes/goarch.bbclass | 19 +++++++++++--------
> >  1 file changed, 11 insertions(+), 8 deletions(-)
> > 
> > diff --git a/meta/classes/goarch.bbclass b/meta/classes/goarch.bbclass
> > index 39fea5e..8fdb443 100644
> > --- a/meta/classes/goarch.bbclass
> > +++ b/meta/classes/goarch.bbclass
> > @@ -3,18 +3,26 @@ BUILD_GOARCH = "${@go_map_arch(d.getVar('BUILD_ARCH'),
> > d)}"> 
> >  BUILD_GOTUPLE = "${BUILD_GOOS}_${BUILD_GOARCH}"
> >  HOST_GOOS = "${@go_map_os(d.getVar('HOST_OS'), d)}"
> >  HOST_GOARCH = "${@go_map_arch(d.getVar('HOST_ARCH'), d)}"
> > 
> > -HOST_GOARM = "${@go_map_arm(d.getVar('HOST_ARCH'),
> > d.getVar('TUNE_FEATURES'), d)}" +HOST_GOARM =
> > "${@go_map_arm(d.getVar('HOST_ARCH'), d.getVar('BASE_GOARM'), d)}"> 
> >  HOST_GO386 = "${@go_map_386(d.getVar('HOST_ARCH'),
> >  d.getVar('TUNE_FEATURES'), d)}" HOST_GOMIPS =
> >  "${@go_map_mips(d.getVar('HOST_ARCH'), d.getVar('TUNE_FEATURES'), d)}"
> >  HOST_GOTUPLE = "${HOST_GOOS}_${HOST_GOARCH}"
> >  TARGET_GOOS = "${@go_map_os(d.getVar('TARGET_OS'), d)}"
> >  TARGET_GOARCH = "${@go_map_arch(d.getVar('TARGET_ARCH'), d)}"
> > 
> > -TARGET_GOARM = "${@go_map_arm(d.getVar('TARGET_ARCH'),
> > d.getVar('TUNE_FEATURES'), d)}" +TARGET_GOARM =
> > "${@go_map_arm(d.getVar('TARGET_ARCH'), d.getVar('BASE_GOARM'), d)}"> 
> >  TARGET_GO386 = "${@go_map_386(d.getVar('TARGET_ARCH'),
> >  d.getVar('TUNE_FEATURES'), d)}" TARGET_GOMIPS =
> >  "${@go_map_mips(d.getVar('TARGET_ARCH'), d.getVar('TUNE_FEATURES'), d)}"
> >  TARGET_GOTUPLE = "${TARGET_GOOS}_${TARGET_GOARCH}"
> >  GO_BUILD_BINDIR =
> >  "${@['bin/${HOST_GOTUPLE}','bin'][d.getVar('BUILD_GOTUPLE') ==
> >  d.getVar('HOST_GOTUPLE')]}"> 
> > +# Use the MACHINEOVERRIDES to map ARM CPU architecture passed to GO via
> > GOARM. +# This is combined with *_ARCH to set HOST_GOARM and
> > TARGET_GOARM. +BASE_GOARM = ''
> > +BASE_GOARM_armv7ve = '7'
> > +BASE_GOARM_armv7a = '7'
> > +BASE_GOARM_armv6 = '6'
> > +BASE_GOARM_armv5 = '5'
> > +
> > 
> >  # Go supports dynamic linking on a limited set of architectures.
> >  # See the supportsDynlink function in
> >  go/src/cmd/compile/internal/gc/main.go GO_DYNLINK = ""
> > 
> > @@ -74,12 +82,7 @@ def go_map_arch(a, d):
> >  def go_map_arm(a, f, d):
> >      import re
> > 
> >      if re.match('arm.*', a):
> > -        if 'armv7' in f:
> > -            return '7'
> > -        elif 'armv6' in f:
> > -            return '6'
> > -        elif 'armv5' in f:
> > -            return '5'
> > +        return f
> > 
> >      return ''
> 
> Is this function still useful? Cannot you set TARGET_GOARM and
> HOST_GOARM with arm override (to simulate the effect of "re.match('arm.*',
> a)")?

No. Attempting to use the override will not result in the same result for 
HOST_GOARM. The overrides will represent the target and not the host. Unless 
you have an implementation to backup your suggestion and I am just not seeing 
it.

MarkA

> 
> Regards,
> 
> >  def go_map_386(a, f, d):






^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [v3][PATCH 1/2] go.bbclass: Export more GO* environment variables
  2019-03-18 15:21 [v3][PATCH 1/2] go.bbclass: Export more GO* environment variables Mark Asselstine
  2019-03-18 15:21 ` [v3][PATCH 2/2] goarch.bbclass: use MACHINEOVERRIDES and simplify go_map_arm() Mark Asselstine
@ 2019-04-09 21:27 ` richard.purdie
  1 sibling, 0 replies; 6+ messages in thread
From: richard.purdie @ 2019-04-09 21:27 UTC (permalink / raw)
  To: Mark Asselstine, openembedded-core

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@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



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [v3][PATCH 2/2] goarch.bbclass: use MACHINEOVERRIDES and simplify go_map_arm()
  2019-03-18 15:21 ` [v3][PATCH 2/2] goarch.bbclass: use MACHINEOVERRIDES and simplify go_map_arm() Mark Asselstine
  2019-03-18 16:40   ` Martin Jansa
@ 2019-04-09 21:31   ` richard.purdie
  1 sibling, 0 replies; 6+ messages in thread
From: richard.purdie @ 2019-04-09 21:31 UTC (permalink / raw)
  To: Mark Asselstine, openembedded-core

On Mon, 2019-03-18 at 11:21 -0400, Mark Asselstine wrote:
> Per https://github.com/golang/go/wiki/GoArm we need to set GOARM when
> cross building for ARMv5, ARMv6 and ARMv7. The current approach of
> using TUNE_FEATURES can be error prone, as we can see today when
> attempting to build for Cortex-A7 which results in GOARM=''.
> 
> Since the value of MACHINEOVERRIDES already consolidates the values
> of
> TUNE_FEATURES into something more consistent we can use the overrides
> mechanism to set GOARM, leaving just a little bit of logic in
> go_map_arm() to trigger off the arch (basically target vs host)
> for the setting of GOARM.
> 
> Signed-off-by: Mark Asselstine <mark.asselstine@windriver.com>
> ---
> 
> V2
> * Cover all ARMv7 Cortex* variants
> 
> V3
> * Switch to using MACHINEOVERRIDES/overrides mechanism
> 
>  meta/classes/goarch.bbclass | 19 +++++++++++--------
>  1 file changed, 11 insertions(+), 8 deletions(-)
> 
> diff --git a/meta/classes/goarch.bbclass
> b/meta/classes/goarch.bbclass
> index 39fea5e..8fdb443 100644
> --- a/meta/classes/goarch.bbclass
> +++ b/meta/classes/goarch.bbclass
> @@ -3,18 +3,26 @@ BUILD_GOARCH = "${@go_map_arch(d.getVar('BUILD_ARCH
> '), d)}"
>  BUILD_GOTUPLE = "${BUILD_GOOS}_${BUILD_GOARCH}"
>  HOST_GOOS = "${@go_map_os(d.getVar('HOST_OS'), d)}"
>  HOST_GOARCH = "${@go_map_arch(d.getVar('HOST_ARCH'), d)}"
> -HOST_GOARM = "${@go_map_arm(d.getVar('HOST_ARCH'),
> d.getVar('TUNE_FEATURES'), d)}"
> +HOST_GOARM = "${@go_map_arm(d.getVar('HOST_ARCH'),
> d.getVar('BASE_GOARM'), d)}"
>  HOST_GO386 = "${@go_map_386(d.getVar('HOST_ARCH'),
> d.getVar('TUNE_FEATURES'), d)}"
>  HOST_GOMIPS = "${@go_map_mips(d.getVar('HOST_ARCH'),
> d.getVar('TUNE_FEATURES'), d)}"
>  HOST_GOTUPLE = "${HOST_GOOS}_${HOST_GOARCH}"
>  TARGET_GOOS = "${@go_map_os(d.getVar('TARGET_OS'), d)}"
>  TARGET_GOARCH = "${@go_map_arch(d.getVar('TARGET_ARCH'), d)}"
> -TARGET_GOARM = "${@go_map_arm(d.getVar('TARGET_ARCH'),
> d.getVar('TUNE_FEATURES'), d)}"
> +TARGET_GOARM = "${@go_map_arm(d.getVar('TARGET_ARCH'),
> d.getVar('BASE_GOARM'), d)}"
>  TARGET_GO386 = "${@go_map_386(d.getVar('TARGET_ARCH'),
> d.getVar('TUNE_FEATURES'), d)}"
>  TARGET_GOMIPS = "${@go_map_mips(d.getVar('TARGET_ARCH'),
> d.getVar('TUNE_FEATURES'), d)}"
>  TARGET_GOTUPLE = "${TARGET_GOOS}_${TARGET_GOARCH}"
>  GO_BUILD_BINDIR =
> "${@['bin/${HOST_GOTUPLE}','bin'][d.getVar('BUILD_GOTUPLE') ==
> d.getVar('HOST_GOTUPLE')]}"
>  
> +# Use the MACHINEOVERRIDES to map ARM CPU architecture passed to GO
> via GOARM.
> +# This is combined with *_ARCH to set HOST_GOARM and TARGET_GOARM.
> +BASE_GOARM = ''
> +BASE_GOARM_armv7ve = '7'
> +BASE_GOARM_armv7a = '7'
> +BASE_GOARM_armv6 = '6'
> +BASE_GOARM_armv5 = '5'
> +
>  # Go supports dynamic linking on a limited set of architectures.
>  # See the supportsDynlink function in
> go/src/cmd/compile/internal/gc/main.go
>  GO_DYNLINK = ""
> @@ -74,12 +82,7 @@ def go_map_arch(a, d):
>  def go_map_arm(a, f, d):
>      import re
>      if re.match('arm.*', a):
> -        if 'armv7' in f:
> -            return '7'
> -        elif 'armv6' in f:
> -            return '6'
> -        elif 'armv5' in f:
> -            return '5'
> +        return f
>      return ''

regexs are slow, this is probably more pythonic too:

def go_map_arm(a, f, d):
    if a.startswith("arm"):
        return d.getVar('BASE_GOARM')
    return ''

and ditch f as a parameter?

Cheers,

Richard





^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2019-04-09 21:31 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-03-18 15:21 [v3][PATCH 1/2] go.bbclass: Export more GO* environment variables Mark Asselstine
2019-03-18 15:21 ` [v3][PATCH 2/2] goarch.bbclass: use MACHINEOVERRIDES and simplify go_map_arm() Mark Asselstine
2019-03-18 16:40   ` Martin Jansa
2019-03-18 17:49     ` Mark Asselstine
2019-04-09 21:31   ` richard.purdie
2019-04-09 21:27 ` [v3][PATCH 1/2] go.bbclass: Export more GO* environment variables richard.purdie

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.