Skip to contentSkip to conversation

go-cross-canadian: fix binaries install and GOARCH

PATCH In review Osama Abdelkader 2 participants 4 messages Aug 12, 2025 – Aug 15, 2025

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 go-cross-canadian: fix binaries install and GOARCH

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").

---
v2:
- Fixed commit message

---
 meta/recipes-devtools/go/go-cross-canadian.inc | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
meta/recipes-devtools/go/go-cross-canadian.inc +3 -1
index 39330fc98b..4a6f2f4c36 100644
@@ -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
Signature · 1 line
2.43.0
#1 lore raw

Thanks, lgtm.

Alex

Quoted 41 lines · Osama Abdelkader

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").

---
v2:
- Fixed commit message

---
 meta/recipes-devtools/go/go-cross-canadian.inc | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
meta/recipes-devtools/go/go-cross-canadian.inc +3 -2
index 39330fc98b..4a6f2f4c36 100644
@@ -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

#2 lore raw
In reply to Osama Abdelkader

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/[email protected]/

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

Quoted 41 lines · Osama Abdelkader

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").

---
v2:
- Fixed commit message

---
 meta/recipes-devtools/go/go-cross-canadian.inc | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
meta/recipes-devtools/go/go-cross-canadian.inc +3 -2
index 39330fc98b..4a6f2f4c36 100644
@@ -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

#3 lore raw

Thanks Alex, I will try that.

BR,
Osama

Quoted 63 lines · Alexander Kanavin

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/[email protected]/

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

Quoted 3 lines · Osama Abdelkader

set GOARCH to HOST_GOARCH which is set from SDKMACHINE, since GOARCH defaults to TARGET_GOARCH, which is set from MACHINE (wrong

arch).

Quoted 6 lines

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").

Review

Quoted 8 lines

---
v2:
- Fixed commit message

---
 meta/recipes-devtools/go/go-cross-canadian.inc | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
(quoted diff) +0 -0

b/meta/recipes-devtools/go/go-cross-canadian.inc

meta/recipes-devtools/go/go-cross-canadian.inc DEPENDS = "go-native virtual/${HOST_PREFIX}go

Quoted 4 lines

index 39330fc98b..4a6f2f4c36 100644

meta/recipes-devtools/go/go-cross-canadian.inc +0 -0
@@ -5,6 +5,8 @@ DEPENDS = "go-native virtual/${HOST_PREFIX}go

virtual/nativesdk-${HOST_PREFIX}go

meta/recipes-devtools/go/go-cross-canadian.inc do_install() { · line 54

Quoted 11 lines
meta/recipes-devtools/go/go-cross-canadian.inc +2 -0
            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/

Quoted 9 lines
meta/recipes-devtools/go/go-cross-canadian.inc +1 -2
        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