今天在编译一个“东西”居然提示一个错误
```
linux_amd64/link: running gcc failed: exit status 1
```
网上有人说,这个可能是 gcc的版本与 golang 之前编译的版本不一样导致,建议自己用本机环境编译golang源码。于是在 go.dev上面下载了最新的源码 go1.20(昨天看还在rc,今天已经正式发布了,庆祝一下)到本机。解压之后进入其目录,准备编译;操作如下
```shell
wget https://go.dev/dl/go1.20.src.tar.gz
tar zxvf go1.20.src.tar.gz
cd go/src
```
![image.png](https://static.golangjob.cn/230202/15d3ea64fc2b441fbb66f5fa3280c94d.png)
经过一段时间的等待后:
```
##### ../misc/cgo/testgodefs
PASS
##### ../misc/cgo/testso
ok misc/cgo/testso 0.718s
##### ../misc/cgo/testsovar
ok misc/cgo/testsovar 0.720s
##### ../misc/cgo/testcarchive
SKIP - short mode and $GO_BUILDER_NAME not set
##### ../misc/cgo/testcshared
SKIP - short mode and $GO_BUILDER_NAME not set
##### ../misc/cgo/testshared
ok misc/cgo/testshared 28.882s
##### ../misc/cgo/testplugin
ok misc/cgo/testplugin 0.001s
##### ../misc/cgo/testsanitizers
PASS
##### ../misc/cgo/errors
PASS
##### ../test/bench/go1
ok test/bench/go1 0.028s [no tests to run]
##### ../test
##### cmd/api
ok cmd/api 41.140s
ALL TESTS PASSED
---
Installed Go for linux/amd64 in /home/simon/src/go
Installed commands in /home/simon/src/go/bin
*** You need to add /home/simon/src/go/bin to your PATH.
```
全部正常 pass 居然一次编译成功了。可见golang的源码真是很了不起,估计是对诸多环境做了校验。
接着把他配置到 系统当中,运行 go env 正常。
然后回到之前编译失败的软件,继续
```
make geth
```
也是一路绿灯,成功了 !
有疑问加站长微信联系(非本文作者))