doumei1955 2019-01-24 22:08
浏览 1234
已采纳

Go工具链编译期间如何使用GOARCH和GOOS?

I am trying to reconcile why make.bash accepts GOARCH, GOOS and other target variables when it also supports cross compiling to all supported architectures by default. I am compiling this for amd64/linux but will be using the compiler to cross-compile apps for arm/linux in an embedded context. Buildroot builds Go with the following command

cd /builddir/build/host-go-1.10.2/src && 
    GOROOT_BOOTSTRAP=/builddir/host/lib/go-1.4.3 
    GOROOT_FINAL=/builddir/host/lib/go 
    GOROOT="/builddir/build/host-go-1.10.2" 
    GOBIN="/builddir/build/host-go-1.10.2/bin" 
    GOARCH=arm 
    GOARM=7 
    GOOS=linux 
    CC=/usr/bin/gcc 
    CXX=/usr/bin/g++ 
    GO_ASSUME_CROSSCOMPILING=1 
    CC_FOR_TARGET="/builddir/host/bin/arm-linux-gnueabihf-gcc" 
    CXX_FOR_TARGET="/builddir/host/bin/arm-linux-gnueabihf-g++" 
    CGO_ENABLED=1 
    ./make.bash

Which works and goes on to build other apps just fine. My question is why are these target variables relevant at this stage? Wouldn't that only be relevant to the applications being compiled with this program?

  • 写回答

1条回答 默认 最新

  • dqp21271 2019-01-24 22:20
    关注

    The Go compiler and linker are Go programs. make.bash needs to know which architecture and which operating system to build the Go toolchain for.

    See Downloads - The Go Programming Language for examples of the different architectures and operating systems.

    See Installing Go from source.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 文本数据挖掘分析报告
  • ¥15 代写uni代码,app唤醒
  • ¥15 全志t113i启动qt应用程序提示internal error
  • ¥15 ensp可以看看嘛.
  • ¥80 51单片机C语言代码解决单片机为AT89C52是清翔单片机
  • ¥60 优博讯DT50高通安卓11系统刷完机自动进去fastboot模式
  • ¥15 minist数字识别
  • ¥15 在安装gym库的pygame时遇到问题,不知道如何解决
  • ¥20 uniapp中的webview 使用的是本地的vue页面,在模拟器上显示无法打开
  • ¥15 网上下载的3DMAX模型,不显示贴图怎么办