Bug 14116

Summary: Go cannot compile on target
Product: [Build System, Metadata & Runtime] OE-Core Reporter: Ross Burton <ross.burton>
Component: devtools / tool chainAssignee: Unassigned <unassigned>
Status: RESOLVED WORKSFORME QA Contact:
Severity: normal    
Priority: Medium+ CC: mark.asselstine, meta.mr.watcher, meta.watcher, randy.macleod
Version: 3.4   
Target Milestone: 4.99   
Hardware: x86   
OS: Multiple   
Whiteboard:
OS type for building Yocto: --- Type of Regression: ---
Verified: Documentation change: No (bug/feature does not impact docs)

Description Ross Burton 2020-11-05 02:18:05 UTC
Building Go code on the target fails because `go env` contains CC assignments which include --sysroot:

go build runtime/cgo: arm-poky-linux-gnueabi-gcc -mfpu=neon -mfloat-abi=hard -mcpu=cortex-a8 -fstack-protector-strong -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security --sysroot=/home/andy/yocto/build/tmp/work/cortexa8hf-neon-poky-linux-gnueabi/go/1.14.7-r0/recipe-sysroot: fork/exec arm-poky-linux-gnueabi-gcc -mfpu=neon -mfloat-abi=hard -mcpu=cortex-a8 -fstack-protector-strong -D_FORTIFY_SOURCE=2 -Wformat -Wformat-security -Werror=format-security --sysroot=/home/andy/yocto/build/tmp/work/cortexa8hf-neon-poky-linux-gnueabi/go/1.14.7-r0/recipe-sysroot: no such file or directory

That's the build sysroot, so obviously shouldn't be used on target.

https://github.com/golang/go/issues/8161 is a related upstream bug, but appears to be saying "the user should work around this" instead of actually fixing the bug.
Comment 1 Randy MacLeod 2021-07-15 15:13:51 UTC
Not much call for using go on target.
Comment 2 Mark 2022-06-14 20:03:07 UTC
Ross, it appears we can close this issue. I just did a build on master of core-image-minimal with "go" and "go-dev" added to the image. I haven't dug around to see what has changed but to help cleanup the bug backlog when you have a chance could you retest and withdraw the bug if you get similar results?

---
root@qemux86-64:~# cat main.go
package main
import "fmt"
func main() {
    fmt.Println("hello world")
}
root@qemux86-64:~# go build main.go 
root@qemux86-64:~# ./main 
hello world
root@qemux86-64:~# go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/root/.cache/go-build"
GOENV="/root/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOMODCACHE="/root/go/pkg/mod"
GONOPROXY=""
GONOSUMDB=""
GOOS="linux"
GOPATH="/root/go"
GOPRIVATE=""
GOPROXY="https://proxy.golang.org,direct"
GOROOT="/usr/lib64/go"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/lib64/go/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.18.2"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/dev/null"
GOWORK=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build2590820835=/tmp/go-build -gno-record-gcc-switches"
root@qemux86-64:~#
---
Comment 3 Ross Burton 2022-06-14 20:30:50 UTC
Good enough for me, thanks Mark.