Duplicate of#70868
Description
Go version
go version go1.24.1 linux/arm64
Output of go env
in your module/workspace:
AR='ar'
CC='gcc'
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_ENABLED='1'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
CXX='g++'
GCCGO='gccgo'
GO111MODULE='on'
GOARCH='arm64'
GOARM64='v8.0'
GOAUTH='netrc'
GOBIN=''
GOCACHE='/home/ulin/.cache/go-build'
GOCACHEPROG=''
GODEBUG=''
GOENV='/home/ulin/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFIPS140='off'
GOFLAGS=''
GOGCCFLAGS='-fPIC -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build1300834282=/tmp/go-build -gno-record-gcc-switches'
GOHOSTARCH='arm64'
GOHOSTOS='linux'
GOINSECURE=''
GOMOD='/mnt/data/lean/g/excersize/go.mod'
GOMODCACHE='/home/ulin/gosrc/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPATH='/home/ulin/gosrc'
GOPRIVATE=''
GOPROXY='https://goproxy.cn'
GOROOT='/usr/local/go'
GOSUMDB='off'
GOTELEMETRY='on'
GOTELEMETRYDIR='/home/ulin/.config/go/telemetry'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/usr/local/go/pkg/tool/linux_arm64'
GOVCS=''
GOVERSION='go1.24.1'
GOWORK=''
PKG_CONFIG='pkg-config'
What did you do?
cross compiling a tiny cgo program for riscv64.
package main
/*
#include <stdio.h>
#include <stdlib.h>
// A C function
void myprint() {
printf("env: PATH=%s\n", getenv("PATH"));
}
*/
import "C"
func main() {
C.myprint()
}
CC=/usr/bin/riscv64-linux-gnu-gcc GOARCH=riscv64 go build m.go
What did you see happen?
go: no Go source files
What did you expect to see?
As the default CGO_ENABLED=1 showed in go env
, the build should succeed.
But need to explicitly set CGO_ENABLED=1 in the build command.
FYI, go build
complained "no Go source files" doesn't convey any useful information for one to figure out what's going wrong.
Activity
linsite commentedon Mar 21, 2025
I wonder if this can be covered by #48540?