Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/link: fail to build with -race (unrecognized relocation (0x2a) in section `.text') #54060

Closed
shawndx opened this issue Jul 26, 2022 · 2 comments
Labels
compiler/runtime Issues related to the Go compiler and/or runtime.

Comments

@shawndx
Copy link
Contributor

shawndx commented Jul 26, 2022

What version of Go are you using (go version)?

$ go version
go version devel go1.19-3e97294663 Tue Jul 26 01:49:02 2022 +0000 linux/amd64

Does this issue reproduce with the latest release?

go1.18.4 works fine.
go1.19rc2 fails with the same error.

What operating system and processor architecture are you using (go env)?

go env Output
$ go env
GO111MODULE=""
GOARCH="amd64"
GOBIN=""
GOCACHE="/root/.cache/go-build"
GOENV="/root/.config/go/env"
GOEXE=""
GOEXPERIMENT=""
GOFLAGS=""
GOHOSTARCH="amd64"
GOHOSTOS="linux"
GOINSECURE=""
GOOS="linux"
GOROOT="/home/xd/src/go19"
GOSUMDB="sum.golang.google.cn"
GOTMPDIR=""
GOTOOLDIR="/home/xd/src/go19/pkg/tool/linux_amd64"
GOVCS=""
GOVERSION="devel go1.19-3e97294663 Tue Jul 26 01:49:02 2022 +0000"
GCCGO="gccgo"
GOAMD64="v1"
AR="ar"
CC="gcc"
CXX="g++"
CGO_ENABLED="1"
GOMOD="/dev/null"
GOWORK=""
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"
GOGCCFLAGS="-fPIC -m64 -pthread -Wl,--no-gc-sections -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build4022576170=/tmp/go-build -gno-record-gcc-switches"

What did you do?

% cd <go root>/src/strings
% ../../bin/go test -race -run=. -c

What did you expect to see?

No build error

What did you see instead?

A link error.
According to #44703 the error is not expected with go tool chain built from source.

/home/xd/src/go19/pkg/tool/linux_amd64/link: running gcc failed: exit status 1
/usr/bin/ld: /tmp/go-link-1967702421/000002.o: unrecognized relocation (0x2a) in section `.text'
/usr/bin/ld: final link failed: Bad value
collect2: error: ld returned 1 exit status

Supplementary Info.

% uname -a
Linux 5f7592769aea 5.4.56.bsk.1-amd64 #5.4.56.bsk.1 SMP Debian 5.4.56.bsk.1 Sun Aug 23 12:02:46 UTC 20 x86_64 GNU/Linux

% gcc --version
gcc (Debian 4.9.2-10+deb8u2) 4.9.2

% ld --version
GNU ld (GNU Binutils for Debian) 2.25
@gopherbot gopherbot added the compiler/runtime Issues related to the Go compiler and/or runtime. label Jul 26, 2022
@ianlancetaylor
Copy link
Contributor

ianlancetaylor commented Jul 26, 2022

You need a newer version of the system linker. The 2.25 release is from 2014. I think the support you need was released in the GNU binutils 2.26 release.

This problem is occurring with Go 2.19 because the race detector was updated to thread sanitizer v3.

@gopherbot
Copy link

gopherbot commented Jul 26, 2022

Change https://go.dev/cl/419595 mentions this issue: doc/go1.19: note that updated race syso files require GNU ld 2.26

gopherbot pushed a commit that referenced this issue Jul 26, 2022
For #54060

Change-Id: I6360565056d7fb7110ff00b0f3f9a3fc02ba7f2d
Reviewed-on: https://go-review.googlesource.com/c/go/+/419595
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
jproberts pushed a commit to jproberts/go that referenced this issue Aug 10, 2022
For golang#54060

Change-Id: I6360565056d7fb7110ff00b0f3f9a3fc02ba7f2d
Reviewed-on: https://go-review.googlesource.com/c/go/+/419595
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler/runtime Issues related to the Go compiler and/or runtime.
Projects
None yet
Development

No branches or pull requests

3 participants