Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/compile: cross compiled arm64 binary can not execute and no response, the program seem to be hung #65361

Open
dabaosun opened this issue Jan 30, 2024 · 1 comment
Labels
NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@dabaosun
Copy link

dabaosun commented Jan 30, 2024

Go version

go version go1.18.1 linux/amd64

Output of go env in your module/workspace:

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/lib/go-1.18"
GOSUMDB="sum.golang.org"
GOTMPDIR=""
GOTOOLDIR="/usr/lib/go-1.18/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="go1.18.1"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="0"
GOMOD="/opt/go.mod"
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 -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build1111527611=/tmp/go-build -gno-record-gcc-switches"

What did you do?

I tried to build arm64 binary on x86_64 env and compiled successfully. But, confused, the binary can not be executed in target arm64 env.
The binary's source code is very simple as below:

package main

import "fmt"

func main() {
	fmt.Println("Hello world")

}

What did you see happen?

When I tried to execute the binary on arm64, it seem to be hung, no error, no output.

/opt/main

What did you expect to see?

The binary run successfully and print "Hello world"

@randall77
Copy link
Contributor

I tried to build arm64 binary on x86_64 env and compiled successfully.

Could you show us the command line you used?

Please try 1.21 and see if it works there. There was some effort into making this kind of cross-compilation work reliably in that release.
See https://go.dev/blog/rebuild for some details.

@mknyszek mknyszek changed the title cross compiled arm64 binary can not execute and no response, the program seem to be hung. cmd/compile: cross compiled arm64 binary can not execute and no response, the program seem to be hung Jan 30, 2024
@gopherbot gopherbot added the compiler/runtime Issues related to the Go compiler and/or runtime. label Jan 30, 2024
@mknyszek mknyszek added NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. and removed compiler/runtime Issues related to the Go compiler and/or runtime. labels Jan 30, 2024
@mknyszek mknyszek added this to the Backlog milestone Jan 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

4 participants