如何为Go构建8g和6g Go编译器

I'm writing software that will be somewhat widely deployed amongst Windows, Mac, and Linux systems on x86 and x86-64 architectures. Whenever I set up the go compiler on my Mac and Linux systems I only ever get 6g built. On Windows I just use the pre-built experimental binaries, which uses 8g.

When I get around to setting up build servers, I assume I need to also build 8g so I can produce 32 bit builds as well. How do I set up 8g, in particular on a Mac (since they can be x86 or x64 depending on how old they are)?

As another poster said, use GOARCH. What he didn't say is that you don't need multiple directories.

Run all.bash twice, same GOROOT:

GOARCH=amd64 ./all.bash
GOARCH=386 ./all.bash

When you build something with gomake set up GOARCH if the default doesn't suit you

GOARCH=386 gomake

Unfortunately goinstall doesn't honor GOARCH yet.

Notice that gc compilers are always cross compiling. Once you have the compilers for the architecture you need, set GOOS and build the packages in $GOROOT/src/pkg, then you should be able to build your software targeting any operating system or architecture.

GOARCH=386 GOOS=windows gomake

You have to set the environment variable GOARCH to 386 instead of probably automatically chosen amd64 by the all.bash build script. See environment variables in Go documentation for details.