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/go: internal/test.test build faild on linux/loong64 #67538

Closed
abner-chenc opened this issue May 21, 2024 · 2 comments
Closed

cmd/go: internal/test.test build faild on linux/loong64 #67538

abner-chenc opened this issue May 21, 2024 · 2 comments
Assignees
Labels
arch-loong64 Issues solely affecting the loongson architecture.
Milestone

Comments

@abner-chenc
Copy link
Contributor

Go version

go version devel go1.23-105ac94486 Fri May 17 21:53:50 2024 +0000 linux/loong64

Output of go env in your module/workspace:

GO111MODULE=''
GOARCH='loong64'
GOBIN=''
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='loong64'
GOHOSTOS='linux'
GOINSECURE=''
GOMODCACHE='/home/data/chenguoqi/go/pkg/mod'
GONOPROXY=''
GONOSUMDB=''
GOOS='linux'
GOPRIVATE=''
GOPROXY='https://proxy.golang.org,direct'
GOSUMDB='sum.golang.org'
GOTMPDIR='/tmp/abner-gotmp'
GOTOOLCHAIN='auto'
GOVCS=''
GOVERSION='devel go1.23-105ac94486 Fri May 17 21:53:50 2024 +0000'
GODEBUG=''
GOTELEMETRY='local'
GCCGO='gccgo'
AR='ar'
CC='gcc'
CXX='g++'
CGO_ENABLED='1'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -mabi=lp64d -pthread -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/abner-gotmp/go-build336619057=/tmp/go-build -gno-record-gcc-switches'

What did you do?

cd src && ./all.bash

What did you see happen?

ok  	cmd/cgo/internal/testfortran	2.677s
ok  	cmd/cgo/internal/testgodefs	1.360s
ok  	cmd/cgo/internal/testlife	1.400s
ok  	cmd/cgo/internal/testnocgo	0.003s
# cmd/go/internal/test.test
/home/data/chenguoqi/golang/go-loong64-newworld/pkg/tool/linux_loong64/link: running gcc failed: exit status 1
/usr/bin/gcc -mabi=lp64d -s -o $WORK/b2303/test.test -Wl,--export-dynamic-symbol=_cgo_panic -Wl,--export-dynamic-symbol=_cgo_topofstack -Wl,--export-dynamic-symbol=crosscall2 -Wl,--compress-debug-sections=zlib /tmp/go-link-3068833131/go.o /tmp/go-link-3068833131/000000.o /tmp/go-link-3068833131/000001.o /tmp/go-link-3068833131/000002.o /tmp/go-link-3068833131/000003.o /tmp/go-link-3068833131/000004.o /tmp/go-link-3068833131/000005.o /tmp/go-link-3068833131/000006.o /tmp/go-link-3068833131/000007.o /tmp/go-link-3068833131/000008.o /tmp/go-link-3068833131/000009.o /tmp/go-link-3068833131/000010.o /tmp/go-link-3068833131/000011.o /tmp/go-link-3068833131/000012.o /tmp/go-link-3068833131/000013.o /tmp/go-link-3068833131/000014.o /tmp/go-link-3068833131/000015.o /tmp/go-link-3068833131/000016.o /tmp/go-link-3068833131/000017.o /tmp/go-link-3068833131/000018.o -O2 -g -lresolv -O2 -g -lpthread -no-pie
/usr/bin/ld: /tmp/go-link-3068833131/000011.o: relocation R_LARCH_PCREL20_S2 overflow 0x200038
Dump relocate record:
stack top		relocation name		symbol
at /tmp/go-link-3068833131/000010.o(.eh_frame+0x3f):
...
0x0000000000000000 R_LARCH_SUB6	`L0'

at /tmp/go-link-3068833131/000010.o(.eh_frame+0x44):
0x0000000000000000 R_LARCH_ADD6	`L0'
0x0000000000000000 R_LARCH_SUB6	`L0'

at /tmp/go-link-3068833131/000010.o(.eh_frame+0x4e):
0x0000000000000000 R_LARCH_ADD6	`L0'
0x0000000000000000 R_LARCH_SUB6	`L0'

at /tmp/go-link-3068833131/000010.o(.eh_frame+0x58):
0x0000000000000000 R_LARCH_32_PCREL	`L0'

at /tmp/go-link-3068833131/000010.o(.eh_frame+0x5c):
0x0000000000000000 R_LARCH_ADD32	`L0'
0x0000000000000000 R_LARCH_SUB32	`L0'

at /tmp/go-link-3068833131/000010.o(.eh_frame+0x6d):
0x0000000000000000 R_LARCH_ADD6	`L0'
0x0000000000000000 R_LARCH_SUB6	`L0'

at /tmp/go-link-3068833131/000010.o(.eh_frame+0x84):
0x0000000000000000 R_LARCH_32_PCREL	`L0'

at /tmp/go-link-3068833131/000010.o(.eh_frame+0x88):
0x0000000000000000 R_LARCH_ADD32	`L0'
0x0000000000000000 R_LARCH_SUB32	`L0'

at /tmp/go-link-3068833131/000010.o(.eh_frame+0x98):
0x0000000000000000 R_LARCH_32_PCREL	`L0'

at /tmp/go-link-3068833131/000010.o(.eh_frame+0x9c):
0x0000000000000000 R_LARCH_ADD32	`L0'
0x0000000000000000 R_LARCH_SUB32	`L0'

at /tmp/go-link-3068833131/000010.o(.eh_frame+0xa4):
0x0000000000000000 R_LARCH_ADD6	`L0'
0x0000000000000000 R_LARCH_SUB6	`L0'

at /tmp/go-link-3068833131/000010.o(.eh_frame+0xa9):
0x0000000000000000 R_LARCH_ADD6	`L0'
0x0000000000000000 R_LARCH_SUB6	`L0'

at /tmp/go-link-3068833131/000010.o(.eh_frame+0xad):
0x0000000000000000 R_LARCH_ADD6	`L0'
0x0000000000000000 R_LARCH_SUB6	`L0'

at /tmp/go-link-3068833131/000010.o(.eh_frame+0xb8):
0x0000000000000000 R_LARCH_32_PCREL	`L0'

at /tmp/go-link-3068833131/000010.o(.eh_frame+0xbc):
0x0000000000000000 R_LARCH_ADD32	`L0'
0x0000000000000000 R_LARCH_SUB32	`L0'

at /tmp/go-link-3068833131/000010.o(.eh_frame+0xcc):
0x0000000000000000 R_LARCH_32_PCREL	`L0'

at /tmp/go-link-3068833131/000010.o(.eh_frame+0xd0):
0x0000000000000000 R_LARCH_ADD32	`L0'
0x0000000000000000 R_LARCH_SUB32	`L0'

at /tmp/go-link-3068833131/000010.o(.eh_frame+0xe0):
0x0000000000000000 R_LARCH_32_PCREL	`L0'

at /tmp/go-link-3068833131/000010.o(.eh_frame+0xe4):
0x0000000000000000 R_LARCH_ADD32	`L0'
0x0000000000000000 R_LARCH_SUB32	`L0'

at /tmp/go-link-3068833131/000010.o(.eh_frame+0x105):
0x0000000000000000 R_LARCH_ADD8	`L0'
0x0000000000000000 R_LARCH_SUB8	`L0'

at /tmp/go-link-3068833131/000010.o(.eh_frame+0x11f):
0x0000000000000000 R_LARCH_ADD6	`L0'
0x0000000000000000 R_LARCH_SUB6	`L0'

at /tmp/go-link-3068833131/000010.o(.eh_frame+0x12c):
0x0000000000000000 R_LARCH_32_PCREL	`L0'

at /tmp/go-link-3068833131/000010.o(.eh_frame+0x130):
0x0000000000000000 R_LARCH_ADD32	`L0'
0x0000000000000000 R_LARCH_SUB32	`L0'

at /tmp/go-link-3068833131/000010.o(.eh_frame+0x13b):
0x0000000000000000 R_LARCH_ADD6	`L0'
0x0000000000000000 R_LARCH_SUB6	`L0'

at /tmp/go-link-3068833131/000010.o(.eh_frame+0x143):
0x0000000000000000 R_LARCH_ADD6	`L0'
0x0000000000000000 R_LARCH_SUB6	`L0'

at /tmp/go-link-3068833131/000011.o(.text+0x0):
0x0000000000000000 R_LARCH_NONE	`<nameless>' + 4(0x4)

at /tmp/go-link-3068833131/000011.o(.text+0x18):
0x0000000000000000 R_LARCH_B26	`free@@GLIBC_2.36'

at /tmp/go-link-3068833131/000011.o(.text+0x1c):
0x0000000000000000 R_LARCH_PCALA_HI20	`.LANCHOR0'

at /tmp/go-link-3068833131/000011.o(.text+0x20):
0x0000000000000000 R_LARCH_PCALA_LO12	`.LANCHOR0'

at /tmp/go-link-3068833131/000011.o(.text+0x2c):
0x0000000000000000 R_LARCH_B26	`crosscall1'

at /tmp/go-link-3068833131/000011.o(.text+0x48):
0x0000000000000000 R_LARCH_NONE	`<nameless>' + 4(0x4)

at /tmp/go-link-3068833131/000011.o(.text+0x50):
0x0000000000000000 R_LARCH_PCALA_HI20	`.LANCHOR0'

at /tmp/go-link-3068833131/000011.o(.text+0x60):
0x0000000000000000 R_LARCH_PCALA_LO12	`.LANCHOR0'

at /tmp/go-link-3068833131/000011.o(.text+0x70):
0x0000000000000000 R_LARCH_B26	`_cgo_set_stacklo'

at /tmp/go-link-3068833131/000011.o(.text+0x74):
0x0000000000000000 R_LARCH_PCALA_HI20	`x_cgo_inittls'
0x0000000000000000 R_LARCH_RELAX	`<nameless>'

at /tmp/go-link-3068833131/000011.o(.text+0x78):
0x0000000000000000 R_LARCH_PCALA_LO12	`x_cgo_inittls'
0x0000000000000000 R_LARCH_RELAX	`<nameless>'

at /tmp/go-link-3068833131/000011.o(.text+0x80):
0x0000000000000000 R_LARCH_B21	`.L4'

at /tmp/go-link-3068833131/000011.o(.text+0xa0):
0x0000000000000000 R_LARCH_NONE	`<nameless>' + 28(0x1c)

at /tmp/go-link-3068833131/000011.o(.text+0xb4):
0x0000000000000000 R_LARCH_NONE	`<nameless>' + 4(0x4)

at /tmp/go-link-3068833131/000011.o(.text+0xd8):
0x0000000000000000 R_LARCH_B26	`sigfillset@@GLIBC_2.36'

at /tmp/go-link-3068833131/000011.o(.text+0xec):
0x0000000000000000 R_LARCH_B26	`pthread_sigmask@@GLIBC_2.36'

at /tmp/go-link-3068833131/000011.o(.text+0xf8):
0x0000000000000000 R_LARCH_B26	`pthread_attr_init@@GLIBC_2.36'

at /tmp/go-link-3068833131/000011.o(.text+0x104):
0x0000000000000000 R_LARCH_B26	`pthread_attr_getstacksize@@GLIBC_2.36'

at /tmp/go-link-3068833131/000011.o(.text+0x110):
0x0000000000000000 R_LARCH_PCREL20_S2	`threadentry'
0x0000000000000000 R_LARCH_RELAX	`<nameless>'

at /tmp/go-link-3068833131/000011.o(.text+0x114):
0x0000000000000000 R_LARCH_NONE	`<nameless>'
0x0000000000000000 R_LARCH_RELAX	`<nameless>'

at /tmp/go-link-3068833131/000011.o(.text+0x124):
0x0000000000000000 R_LARCH_B26	`_cgo_try_pthread_create'

at /tmp/go-link-3068833131/000011.o(.text+0x13c):
0x0000000000000000 R_LARCH_B26	`pthread_sigmask@@GLIBC_2.36'

at /tmp/go-link-3068833131/000011.o(.text+0x140):
0x0000000000000000 R_LARCH_B21	`.L10'

at /tmp/go-link-3068833131/000011.o(.text+0x160):
0x0000000000000000 R_LARCH_B26	`strerror@@GLIBC_2.36'

at /tmp/go-link-3068833131/000011.o(.text+0x168):
0x0000000000000000 R_LARCH_PCREL20_S2	`.LC0'

-- Record dump end --

/tmp/go-link-3068833131/000011.o: in function `_cgo_sys_thread_start':
/_/GOROOT/src/runtime/cgo/gcc_linux.c:50:(.text+0x168): relocation truncated to fit: R_LARCH_PCREL20_S2 against `.LC0'
/usr/bin/ld: final link failed: bad value
collect2: error: ld returned 1 exit status

FAIL	cmd/go/internal/test [build failed]
ok  	cmd/cgo/internal/testplugin	78.641s
ok  	cmd/cgo/internal/testsanitizers	32.062s
ok  	cmd/cgo/internal/testshared	0.008s

What did you expect to see?

all.bash pass.

@abner-chenc
Copy link
Contributor Author

This issue has been clearly introduced by the relax feature of gcc on Loong64, which is caused by the unpleasant coordination between data gcc and ld

@abner-chenc abner-chenc added the arch-loong64 Issues solely affecting the loongson architecture. label May 21, 2024
@abner-chenc abner-chenc added this to the Unreleased milestone May 21, 2024
@abner-chenc abner-chenc self-assigned this May 21, 2024
@abner-chenc
Copy link
Contributor Author

This error has been fixed in binutils on LoongArch64. Here are the relevant patches: https://sourceware.org/pipermail/binutils/2024-May/134285.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
arch-loong64 Issues solely affecting the loongson architecture.
Projects
None yet
Development

No branches or pull requests

1 participant