Closed
Description
What version of Go are you using (go version
)?
$ go version go version go1.19 linux/loong64
Does this issue reproduce with the latest release?
Yes (found during packaging testing)
What operating system and processor architecture are you using (go env
)?
Gentoo Linux, Loongson 3A5000.
go env
Output
$ go env GO111MODULE="" GOARCH="loong64" GOBIN="" GOCACHE="/home/xenon/.cache/go-build" GOENV="/home/xenon/.config/go/env" GOEXE="" GOEXPERIMENT="" GOFLAGS="" GOHOSTARCH="loong64" GOHOSTOS="linux" GOINSECURE="" GOMODCACHE="/home/xenon/go/pkg/mod" GONOPROXY="" GONOSUMDB="" GOOS="linux" GOPATH="/home/xenon/go" GOPRIVATE="" GOPROXY="https://proxy.golang.org,direct" GOROOT="/usr/lib/go" GOSUMDB="sum.golang.org" GOTMPDIR="" GOTOOLDIR="/usr/lib/go/pkg/tool/linux_loong64" GOVCS="" GOVERSION="go1.19" GCCGO="gccgo" AR="ar" CC="loongarch64-unknown-linux-gnu-gcc" CXX="loongarch64-unknown-linux-gnu-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 -mabi=lp64d -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build2883565165=/tmp/go-build -gno-record-gcc-switches"
What did you do?
cd $GOROOT/src/cmd/link && go test ./...
What did you expect to see?
all tests pass
What did you see instead?
--- FAIL: TestMinusRSymsWithSameName (0.34s)
elf_test.go:166: gcc [-fPIC -mabi=lp64d -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build2982345155=/tmp/go-build -gno-record-gcc-switches] -c -o /tmp/TestMinusRSymsWithSameName2770862762/001/x0.o /tmp/TestMinusRSymsWithSameName2770862762/001/x0.c
elf_test.go:166: gcc [-fPIC -mabi=lp64d -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build2982345155=/tmp/go-build -gno-record-gcc-switches] -c -o /tmp/TestMinusRSymsWithSameName2770862762/001/x1.o /tmp/TestMinusRSymsWithSameName2770862762/001/x1.c
elf_test.go:174: gcc [-fPIC -mabi=lp64d -pthread -fmessage-length=0 -fdebug-prefix-map=/tmp/go-build2982345155=/tmp/go-build -gno-record-gcc-switches] -nostdlib -r -o /tmp/TestMinusRSymsWithSameName2770862762/001/ldr.syso [/tmp/TestMinusRSymsWithSameName2770862762/001/x0.o /tmp/TestMinusRSymsWithSameName2770862762/001/x1.o]
elf_test.go:194: /home/xenon/src/go/bin/go build
elf_test.go:199: # elf_test
/tmp/go-build846848018/b001/_pkg_.a(ldr.syso): unknown relocation type 99; compiled without -fpic?
elf_test.go:200: exit status 2
FAIL
FAIL cmd/link 0.340s
This is because I'm using the next iteration of LoongArch GNU toolchain that includes support for the "new-style" relocs, producing relocs unknown to cmd/link/internal/loadelf
.
debug/elf
and several other places need syncing.
I don't plan to immediately change codegen and remove support for generating old-style relocs, since doing so will break compatibility with the binutils-{2.38,2.39} and gcc-12.1 combo that doesn't recognize the new reloc types.
This might need backporting but I fear the change is too big for a 1.19.x point release.
EDIT: toolchain versions
$ ld --version
GNU ld (Gentoo 9999 p0) 2.39.50.20220729
Copyright (C) 2022 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License version 3 or (at your option) a later version.
This program has absolutely no warranty.
$ gcc --version
gcc (Gentoo 13.0.0 p, commit 1a5882abf01ae085e999ddcf4d208105e21e1a0d) 13.0.0 20220729 (experimental)
Copyright (C) 2022 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.