diff mbox series

[v2] go-cross-canadian: fix binaries install and GOARCH

Message ID 20250812205050.13599-1-osama.abdelkader@gmail.com
State Accepted, archived
Commit 31e3bd61c7986bc044e547aa5cb9caba7b32bf22
Headers show
Series [v2] go-cross-canadian: fix binaries install and GOARCH | expand

Commit Message

Osama Abdelkader Aug. 12, 2025, 8:50 p.m. UTC
set GOARCH to HOST_GOARCH which is set from SDKMACHINE,
since GOARCH defaults to TARGET_GOARCH, which is set from MACHINE (wrong arch).

Also fix do_install to correctly install all binaries from
${GO_BUILD_BINDIR} by using 'find -type f' to avoid issues when the
directory contains subdirectories (e.g. "linux_arm").

Signed-off-by: Osama Abdelkader <osama.abdelkader@gmail.com>
---
v2:
- Fixed commit message
---
 meta/recipes-devtools/go/go-cross-canadian.inc | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Alexander Kanavin Aug. 13, 2025, 9:03 a.m. UTC | #1
Thanks, lgtm.

Alex

On Tue, 12 Aug 2025 at 22:52, Osama Abdelkader
<osama.abdelkader@gmail.com> wrote:
>
> set GOARCH to HOST_GOARCH which is set from SDKMACHINE,
> since GOARCH defaults to TARGET_GOARCH, which is set from MACHINE (wrong arch).
>
> Also fix do_install to correctly install all binaries from
> ${GO_BUILD_BINDIR} by using 'find -type f' to avoid issues when the
> directory contains subdirectories (e.g. "linux_arm").
>
> Signed-off-by: Osama Abdelkader <osama.abdelkader@gmail.com>
> ---
> v2:
> - Fixed commit message
> ---
>  meta/recipes-devtools/go/go-cross-canadian.inc | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/meta/recipes-devtools/go/go-cross-canadian.inc b/meta/recipes-devtools/go/go-cross-canadian.inc
> index 39330fc98b..4a6f2f4c36 100644
> --- a/meta/recipes-devtools/go/go-cross-canadian.inc
> +++ b/meta/recipes-devtools/go/go-cross-canadian.inc
> @@ -5,6 +5,8 @@ DEPENDS = "go-native virtual/${HOST_PREFIX}go virtual/nativesdk-${HOST_PREFIX}go
>             virtual/nativesdk-compilerlibs"
>  PN = "go-cross-canadian-${TRANSLATED_TARGET_ARCH}"
>
> +GOARCH = "${HOST_GOARCH}"
> +
>  # it uses gcc on build machine during go-cross-canadian bootstrap, but
>  # the gcc version may be old and not support option '-fmacro-prefix-map'
>  # which is one of default values of DEBUG_PREFIX_MAP
> @@ -51,7 +53,7 @@ do_install() {
>         install -d ${D}${libdir}/go/pkg/tool
>         cp --preserve=mode,timestamps -R ${B}/pkg/tool/${HOST_GOTUPLE} ${D}${libdir}/go/pkg/tool/
>         install -d ${D}${bindir} ${D}${libdir}/go/bin
> -       for f in ${B}/${GO_BUILD_BINDIR}/*
> +       for f in $(find ${B}/${GO_BUILD_BINDIR} -type f)
>         do
>                 base=`basename $f`
>                 install -m755 $f ${D}${libdir}/go/bin
> --
> 2.43.0
>
Alexander Kanavin Aug. 14, 2025, 11:26 a.m. UTC | #2
This has now merged. I have also sent a followup that would build and
install go toolchain into SDKs in yocto CI (so issues like this should
not reoccur):
https://patchwork.yoctoproject.org/project/oe-core/patch/20250814105604.3586651-1-alex.kanavin@gmail.com/

Another followup would be to add sdk/runtime tests that actually
exercise the toolchain and check that it works properly (we have that
for rust and gcc, but not for go):
https://bugzilla.yoctoproject.org/show_bug.cgi?id=15953

If you can add such tests, would be very appreciated!

Alex

On Tue, 12 Aug 2025 at 22:52, Osama Abdelkader
<osama.abdelkader@gmail.com> wrote:
>
> set GOARCH to HOST_GOARCH which is set from SDKMACHINE,
> since GOARCH defaults to TARGET_GOARCH, which is set from MACHINE (wrong arch).
>
> Also fix do_install to correctly install all binaries from
> ${GO_BUILD_BINDIR} by using 'find -type f' to avoid issues when the
> directory contains subdirectories (e.g. "linux_arm").
>
> Signed-off-by: Osama Abdelkader <osama.abdelkader@gmail.com>
> ---
> v2:
> - Fixed commit message
> ---
>  meta/recipes-devtools/go/go-cross-canadian.inc | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/meta/recipes-devtools/go/go-cross-canadian.inc b/meta/recipes-devtools/go/go-cross-canadian.inc
> index 39330fc98b..4a6f2f4c36 100644
> --- a/meta/recipes-devtools/go/go-cross-canadian.inc
> +++ b/meta/recipes-devtools/go/go-cross-canadian.inc
> @@ -5,6 +5,8 @@ DEPENDS = "go-native virtual/${HOST_PREFIX}go virtual/nativesdk-${HOST_PREFIX}go
>             virtual/nativesdk-compilerlibs"
>  PN = "go-cross-canadian-${TRANSLATED_TARGET_ARCH}"
>
> +GOARCH = "${HOST_GOARCH}"
> +
>  # it uses gcc on build machine during go-cross-canadian bootstrap, but
>  # the gcc version may be old and not support option '-fmacro-prefix-map'
>  # which is one of default values of DEBUG_PREFIX_MAP
> @@ -51,7 +53,7 @@ do_install() {
>         install -d ${D}${libdir}/go/pkg/tool
>         cp --preserve=mode,timestamps -R ${B}/pkg/tool/${HOST_GOTUPLE} ${D}${libdir}/go/pkg/tool/
>         install -d ${D}${bindir} ${D}${libdir}/go/bin
> -       for f in ${B}/${GO_BUILD_BINDIR}/*
> +       for f in $(find ${B}/${GO_BUILD_BINDIR} -type f)
>         do
>                 base=`basename $f`
>                 install -m755 $f ${D}${libdir}/go/bin
> --
> 2.43.0
>
Osama Abdelkader Aug. 15, 2025, 6:53 p.m. UTC | #3
Thanks Alex, I will try that.

BR,
Osama


On Thu 14. Aug 2025 at 1:26 PM, Alexander Kanavin <alex.kanavin@gmail.com>
wrote:

> This has now merged. I have also sent a followup that would build and
> install go toolchain into SDKs in yocto CI (so issues like this should
> not reoccur):
>
> https://patchwork.yoctoproject.org/project/oe-core/patch/20250814105604.3586651-1-alex.kanavin@gmail.com/
>
> Another followup would be to add sdk/runtime tests that actually
> exercise the toolchain and check that it works properly (we have that
> for rust and gcc, but not for go):
> https://bugzilla.yoctoproject.org/show_bug.cgi?id=15953
>
> If you can add such tests, would be very appreciated!
>
> Alex
>
> On Tue, 12 Aug 2025 at 22:52, Osama Abdelkader
> <osama.abdelkader@gmail.com> wrote:
> >
> > set GOARCH to HOST_GOARCH which is set from SDKMACHINE,
> > since GOARCH defaults to TARGET_GOARCH, which is set from MACHINE (wrong
> arch).
> >
> > Also fix do_install to correctly install all binaries from
> > ${GO_BUILD_BINDIR} by using 'find -type f' to avoid issues when the
> > directory contains subdirectories (e.g. "linux_arm").
> >
> > Signed-off-by: Osama Abdelkader <osama.abdelkader@gmail.com>
> > ---
> > v2:
> > - Fixed commit message
> > ---
> >  meta/recipes-devtools/go/go-cross-canadian.inc | 4 +++-
> >  1 file changed, 3 insertions(+), 1 deletion(-)
> >
> > diff --git a/meta/recipes-devtools/go/go-cross-canadian.inc
> b/meta/recipes-devtools/go/go-cross-canadian.inc
> > index 39330fc98b..4a6f2f4c36 100644
> > --- a/meta/recipes-devtools/go/go-cross-canadian.inc
> > +++ b/meta/recipes-devtools/go/go-cross-canadian.inc
> > @@ -5,6 +5,8 @@ DEPENDS = "go-native virtual/${HOST_PREFIX}go
> virtual/nativesdk-${HOST_PREFIX}go
> >             virtual/nativesdk-compilerlibs"
> >  PN = "go-cross-canadian-${TRANSLATED_TARGET_ARCH}"
> >
> > +GOARCH = "${HOST_GOARCH}"
> > +
> >  # it uses gcc on build machine during go-cross-canadian bootstrap, but
> >  # the gcc version may be old and not support option '-fmacro-prefix-map'
> >  # which is one of default values of DEBUG_PREFIX_MAP
> > @@ -51,7 +53,7 @@ do_install() {
> >         install -d ${D}${libdir}/go/pkg/tool
> >         cp --preserve=mode,timestamps -R ${B}/pkg/tool/${HOST_GOTUPLE}
> ${D}${libdir}/go/pkg/tool/
> >         install -d ${D}${bindir} ${D}${libdir}/go/bin
> > -       for f in ${B}/${GO_BUILD_BINDIR}/*
> > +       for f in $(find ${B}/${GO_BUILD_BINDIR} -type f)
> >         do
> >                 base=`basename $f`
> >                 install -m755 $f ${D}${libdir}/go/bin
> > --
> > 2.43.0
> >
>
diff mbox series

Patch

diff --git a/meta/recipes-devtools/go/go-cross-canadian.inc b/meta/recipes-devtools/go/go-cross-canadian.inc
index 39330fc98b..4a6f2f4c36 100644
--- a/meta/recipes-devtools/go/go-cross-canadian.inc
+++ b/meta/recipes-devtools/go/go-cross-canadian.inc
@@ -5,6 +5,8 @@  DEPENDS = "go-native virtual/${HOST_PREFIX}go virtual/nativesdk-${HOST_PREFIX}go
            virtual/nativesdk-compilerlibs"
 PN = "go-cross-canadian-${TRANSLATED_TARGET_ARCH}"
 
+GOARCH = "${HOST_GOARCH}"
+
 # it uses gcc on build machine during go-cross-canadian bootstrap, but
 # the gcc version may be old and not support option '-fmacro-prefix-map'
 # which is one of default values of DEBUG_PREFIX_MAP
@@ -51,7 +53,7 @@  do_install() {
 	install -d ${D}${libdir}/go/pkg/tool
 	cp --preserve=mode,timestamps -R ${B}/pkg/tool/${HOST_GOTUPLE} ${D}${libdir}/go/pkg/tool/
 	install -d ${D}${bindir} ${D}${libdir}/go/bin
-	for f in ${B}/${GO_BUILD_BINDIR}/*
+	for f in $(find ${B}/${GO_BUILD_BINDIR} -type f)
 	do
 		base=`basename $f`
 		install -m755 $f ${D}${libdir}/go/bin