How do you build the 8g and 6g Go compilers for Go

有些话、适合烂在心里 提交于 2019-12-10 10:51:40

问题


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)?


回答1:


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



回答2:


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.



来源:https://stackoverflow.com/questions/7786492/how-do-you-build-the-8g-and-6g-go-compilers-for-go

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!