Cross compiling go programs to ARM with big pages
Disclaimer: I have no idea of what I am doing.
I have a WD My Cloud with an ARM processor running on 4.x of WD's OS, which is a Debian with large page sizes. From my 32-bit i386 normal page sized Linux I just tried this:
GOOS=linux GOARCH=arm GOARM=7 CGO_ENABLED=1 go build -ldflags "-R 65536" hello.go
And that runs on the WD device. Not sure if it just dumb luck, maybe it won'y work for bigger programs.
Update: I have now tried to compile a much bigger program and it seems it worked fine, but I got
fatal error: runtime: cannot map pages in arena address space
Which if I undertand golang correctly, is an out of memory error. I never thought of how much RAM my little NAS has. It turns out it has 277MB of which 45MB is free. That is a bit on the low side for the rather huge project I was trying to run. I had to drop the CGO_ENABLED flag but I think that is only needed if there is C code in the project. I have an idea of putting a USB stick into the USB3 port of the NAS and use that as swap to increase the memory available.
I got the flags and switches from here, but I think that guy also built a special golang compiler:
panic on arm cross compile - Google Groups
Cross compilation just got a whole lot better in Go 1.5 | Dave Cheney