toolchain, without having to modify the package build scripts, or install
wrapper scripts or target-specific versions of the go tool.
Ideally cross-compiling would work just like it does with the Linux kernel
and other non-go projects, where the value of CROSS_COMPILE environment
variable gets tacked onto the front of any invocation of gcc, g++, ld, and
so on. If you're building for, say, a MIPS target, and your build machine
has cross compilers installed as mips-linux-gnu-gcc, mips-linux-gnu-g++,
and so on, you run make CROSS_COMPILE=mips-linux-gnu-. To build with the
normal compilers, you just leave CROSS_COMPILE unset or empty.
The following patch is my attempt to add this capability to go. With this
patch, setting CROSS_COMPILE to xxx-yyy-zzz- causes go build to:
- use gccgo rather than gc toolchain (similar to passing -compiler gccgo,
except it doesn't whine when the architecture is something other than x86
- set GOARCH=xxx
- set GOOS=yyy
- enable cgo (and pass actual arch and os to cgo via GOARCH and GOOS)
- prepend xxx-yyy-zzz- default compiler names, e.g. xxx-yyy-zzz-gccgo
instead of gccgo
You can still override these parameters individually by setting GOARCH,
GOOS, CGO_ENABLED, CC, and so on. But my goal is to make cross-compiling as
transparent as possible, requiring only the CROSS_COMPILE environment
variable to be set.
When CROSS_COMPILE is empty or unset, go build behaves as usual.
The attached patch should work with the recent default branch of the golang
source tree. I have also backported the changes to the Debian 1.2.1-2
version of golang.
You received this message because you are subscribed to the Google Groups "golang-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firstname.lastname@example.org.
For more options, visit https://groups.google.com/d/optout.