Do you have qemu-user-static or a similarly named package installed? Then the magic of binfmt_misc may be invoking it. For me:
$ cat /proc/sys/fs/binfmt_misc/qemu-arm enabled interpreter /usr/bin/qemu-arm-static flags: OC offset 0 magic 7f454c4601010100000000000000000002002800 mask ffffffffffffff00fffffffffffffffffeffffff Cheers, mwh On 16 February 2017 at 20:37, Dan Kortschak <dan.kortsc...@adelaide.edu.au> wrote: > Can someone explain to me why this works? I am cross-compiling for > arm5, but the executable works on amd64. > > $ cat hello.go > package main > > import "fmt" > > func main() { > fmt.Println("hello") > } > $ GOARCH=arm GOARM=5 go build hello.go > $ ./hello > hello > $ go env > GOARCH="amd64" > GOBIN="" > GOEXE="" > GOHOSTARCH="amd64" > GOHOSTOS="linux" > GOOS="linux" > GOPATH="/home/daniel" > GORACE="" > GOROOT="/home/daniel/go" > GOTOOLDIR="/home/daniel/go/pkg/tool/linux_amd64" > CC="gcc" > GOGCCFLAGS="-fPIC -m64 -pthread -fmessage-length=0 -fdebug-prefix- > map=/tmp/go-build014006335=/tmp/go-build -gno-record-gcc-switches" > CXX="g++" > CGO_ENABLED="1" > $ go version > go version go1.7.4 linux/amd64 > > > The executable also works on the arm5 device. I'm not worried, but I > don't understand how this works. > > -- > You received this message because you are subscribed to the Google Groups > "golang-nuts" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to golang-nuts+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.