Cross compilation is easy with Go and there are numerous articles on how to do it. However, there are some caveats. Specifically the standard library must be built for the lowest common denominator you want to support for each platform. Here’s how I do it for syncthing. This assumes you have a Go source tree checked out into
cd /usr/local/go/src ./all.bash # Build Go for your native architecture/OS export GOARM=5 # ARMv5 is the lowest supported ARM architecture GOOS=linux GOARCH=arm ./make.bash --no-clean # Build linux/arm export GO386=387 # This disables SSE/SSE2 requirements for 32 bit builds # Here we build for 32+64 bit platforms for os in linux windows freebsd ; do GOOS=$os GOARCH=386 ./make.bash --no-clean GOOS=$os GOARCH=amd64 ./make.bash --no-clean done # Now we build for 64-bit only platforms for os in darwin solaris ; do GOOS=$os GOARCH=amd64 ./make.bash --no-clean done
When this is done, you can use the
./build.sh all command in the syncthing dist. Solaris supports requires Go1.3.
You should install
go vet after recompiling Go;
go get code.google.com/p/go.tools/cmd/vet