Re: [go-nuts] go executable cross-compiled for arm5 works on amd64 (and arm5)

2017-02-16 Thread Dan Kortschak
Thank you. Yes, I had forgotten I'd installed that (needed for kernel
building for the very same arm5 device).

Dan

On Thu, 2017-02-16 at 21:31 +1300, Michael Hudson-Doyle wrote:
> 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 7f454c460101010002002800
> mask ff00feff
> 
> Cheers,
> mwh

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


Re: [go-nuts] go executable cross-compiled for arm5 works on amd64 (and arm5)

2017-02-16 Thread Michael Hudson-Doyle
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 7f454c460101010002002800
mask ff00feff

Cheers,
mwh

On 16 February 2017 at 20:37, Dan Kortschak 
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.