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

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.

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

报告相同问题?

悬赏问题

  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 有没有帮写代码做实验仿真的
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥30 vmware exsi重置后登不上
  • ¥15 易盾点选的cb参数怎么解啊
  • ¥15 MATLAB运行显示错误,如何解决?
  • ¥15 c++头文件不能识别CDialog
  • ¥15 Excel发现不可读取的内容
  • ¥15 关于#stm32#的问题:CANOpen的PDO同步传输问题
  • ¥20 yolov5自定义Prune报错,如何解决?