doucu7330 2016-05-12 16:33
浏览 116
已采纳

从源代码构建go编译器时出错

I am trying to build the latest version (tip of the master branch) of Go from source.

The official Go documentation (https://golang.org/doc/install/source) states that you should download Go 1.4 binaries to build a more recent version. However it should be possible to build all from source.

To do this, I set variables in .bashrc :

PATH="$HOME/go/bin:$PATH"
export GOPATH=$HOME

then to build go 1.4 from source :

source ~/.bashrc
git clone https://go.googlesource.com/go
mkdir ~/go1.4
cd ~/go
git archive --format=tar go1.4.3 |tar -xv -C ~/go1.4
cd ~/go1.4/src
./make.bash

and finally build the latest version :

cd ~/go/src/
GOROOT_BOOTSTRAP=$HOME/go1.4 ./make.bash

I remember doing this months ago without problems, but today I get these errors building go 1.4 make.bash:

# cmd/pprof
.../go1.4/pkg/linux_amd64/runtime/cgo.a(_all.o): unknown relocation type 42; compiled without -fpic?
.../go1.4/pkg/linux_amd64/runtime/cgo.a(_all.o): unknown relocation type 42; compiled without -fpic?
runtime/cgo(.text): unexpected relocation type 298
runtime/cgo(.text): unexpected relocation type 298
...

Is there something wrong in my method ?

  • 写回答

1条回答 默认 最新

  • douyin8809 2016-05-12 20:08
    关注

    The error messages point to CGO, and environment variables that control make.bash are explained at the beginning of the file :

    CGO_ENABLED: Controls cgo usage during the build. Set it to 1 to include all cgo related files, .c and .go file with "cgo" build directive, in the build. Set it to 0 to ignore them.

    so if you disable CGO while building GO 1.4 :

    cd ~/go1.4/src
    CGO_ENABLED=0 ./make.bash
    

    everything works and pass the tests.

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

报告相同问题?

悬赏问题

  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog