问题现象
[root@localhost main]# go run -race mrsequential.go wc.so pg*.txt
# command-line-arguments
/root/go/pkg/tool/linux_amd64/link: running gcc failed: exit status 1
/usr/bin/ld: /tmp/go-link-3541234412/000010.o: unrecognized relocation (0x2a) in section `.text'
/usr/bin/ld: final link failed: Bad value
collect2: error: ld returned 1 exit status
问题原因
由于ld的版本过低导致的。
解决办法
升级ld版本即可,升级方法如下,对应centos系统
[root@localhost main]# yum install binutils
Loaded plugins: fastestmirror, langpacks
Repodata is over 2 weeks old. Install yum-cron? Or run: yum makecache fast
base | 3.6 kB 00:00:00
epel/x86_64/metalink | 6.6 kB 00:00:00
https://mirror.sjtu.edu.cn/fedora/epel/7/x86_64/repodata/repomd.xml: [Errno 14] curl#60 - "Peer's Certificate issuer is not recognized."
Trying other mirror.
It was impossible to connect to the CentOS servers.
This could mean a connectivity issue in your environment, such as the requirement to configure a proxy,
or a transparent proxy that tampers with TLS security, or an incorrect system clock.
Please collect information about the specific failure that occurs in your environment,
using the instructions in: https://access.redhat.com/solutions/1527033 and create a bug on https://bugs.centos.org/
epel | 4.7 kB 00:00:00
extras | 2.9 kB 00:00:00
updates | 2.9 kB 00:00:00
(1/7): epel/x86_64/group_gz | 96 kB 00:00:00
(2/7): base/7/x86_64/group_gz | 153 kB 00:00:00
(3/7): extras/7/x86_64/primary_db | 243 kB 00:00:00
epel/x86_64/updateinfo FAILED ] 4.5 MB/s | 5.4 MB 00:00:04 ETA
https://repo.extreme-ix.org/epel/7/x86_64/repodata/d96a5371f4668273e30e45b84bc5ed65c73d01c86c09f96c70612709824c4765-updateinfo.xml.bz2: [Errno 14] curl#60 - "The certificate issuer's certificate has expired. Check your system date and time."
Trying other mirror.
(4/7): base/7/x86_64/primary_db | 6.1 MB 00:00:01
(5/7): epel/x86_64/updateinfo | 1.0 MB 00:00:00
(6/7): epel/x86_64/primary_db | 7.0 MB 00:00:05
(7/7): updates/7/x86_64/primary_db | 13 MB 00:00:06
Loading mirror speeds from cached hostfile
* base: mirrors.huaweicloud.com
* epel: mirror.sjtu.edu.cn
* extras: mirrors.huaweicloud.com
* updates: mirrors.cn99.com
Resolving Dependencies
--> Running transaction check
---> Package binutils.x86_64 0:2.23.52.0.1-55.el7 will be updated
---> Package binutils.x86_64 0:2.27-44.base.el7_9.1 will be an update
--> Finished Dependency Resolution
Dependencies Resolved
=================================================================================================================================================
Package Arch Version Repository Size
=================================================================================================================================================
Updating:
binutils x86_64 2.27-44.base.el7_9.1 updates 5.9 M
Transaction Summary
=================================================================================================================================================
Upgrade 1 Package
Total download size: 5.9 M
Is this ok [y/d/N]: y
Downloading packages:
No Presto metadata available for updates
binutils-2.27-44.base.el7_9.1.x86_64.rpm | 5.9 MB 00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Updating : binutils-2.27-44.base.el7_9.1.x86_64 1/2
Cleanup : binutils-2.23.52.0.1-55.el7.x86_64 2/2
Verifying : binutils-2.27-44.base.el7_9.1.x86_64 1/2
Verifying : binutils-2.23.52.0.1-55.el7.x86_64 2/2
Updated:
binutils.x86_64 0:2.27-44.base.el7_9.1
Complete!
#再运行没有问题了
[root@localhost main]# go run -race mrsequential.go wc.so pg*.txt
[root@localhost main]#