-
Notifications
You must be signed in to change notification settings - Fork 17.7k
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: unresolvable R_RISCV_HI20 relocation against symbol `stderr@@GLIBC_2.27' #70076
Comments
It looks like a mis-configuration on cross compile environment. that glibc didn't contains |
I can find the symbol stderr@@GLIBC_2.27 in my RISCV libc.so. /usr/local/sysroot/lib/libc.so.6: ELF 64-bit LSB pie executable, UCB RISC-V, version 1 (GNU/Linux), dynamically linked, interpreter /lib/ld-linux-riscv64-lp64d.so.1, for GNU/Linux 4.15.0, with debug_info, not stripped readelf -s /usr/local/sysroot/lib/libc.so.6 | grep stderr 146: 000000000014c398 224 OBJECT GLOBAL DEFAULT 29 IO_2_1_stderr@@GLIBC_2.27 1771: 000000000014c558 8 OBJECT GLOBAL DEFAULT 29 stderr@@GLIBC_2.27 9353: 000000000014c398 224 OBJECT GLOBAL DEFAULT 29 IO_2_1_stderr 9538: 000000000014c558 8 OBJECT GLOBAL DEFAULT 29 stderr` |
After I removed the option " -Wl,-z,nocopyreloc" added by golang in src/cmd/link/internal/ld/lib.go:1654, I can successfully link the file now.
|
CC @golang/riscv64 |
Go version
1.23.2 linux amd64
Output of
go env
in your module/workspace:What did you do?
I was compiling a large Go project, which includes cgo and has a Go cache size of approximately 15GB. Target arch is RISCV64. When linker called ld, there’s an issue related to glibc symbols.
What did you see happen?
/workspace/go/pkg/tool/linux_amd64/link: running riscv64-unknown-linux-gnu-g++ failed: exit status 1
/usr/local/bin/riscv64-unknown-linux-gnu-g++ -Wl,-z,now -Wl,-z,nocopyreloc -o $WORK/b001/exe/a.out -rdynamic -Wl,--compress-debug-sections=zlib /workspace/tmp/go-link-3293404590/go.o /workspace/tmp/go-link-3293404590/000000.o /workspace/tmp/go-link-3293404590/000001.o /workspace/tmp/go-link-3293404590/000002.o /workspace/tmp/go-link-3293404590/000003.o /workspace/tmp/go-link-3293404590/000004.o /workspace/tmp/go-link-3293404590/000005.o /workspace/tmp/go-link-3293404590/000006.o /workspace/tmp/go-link-3293404590/000007.o /workspace/tmp/go-link-3293404590/000008.o /workspace/tmp/go-link-3293404590/000009.o /workspace/tmp/go-link-3293404590/000010.o /workspace/tmp/go-link-3293404590/000011.o /workspace/tmp/go-link-3293404590/000012.o /workspace/tmp/go-link-3293404590/000013.o /workspace/tmp/go-link-3293404590/000014.o /workspace/tmp/go-link-3293404590/000015.o /workspace/tmp/go-link-3293404590/000016.o /workspace/tmp/go-link-3293404590/000017.o /workspace/tmp/go-link-3293404590/000018.o /workspace/tmp/go-link-3293404590/000019.o /workspace/tmp/go-link-3293404590/000020.o /workspace/tmp/go-link-3293404590/000021.o /workspace/tmp/go-link-3293404590/000022.o /workspace/tmp/go-link-3293404590/000023.o /workspace/tmp/go-link-3293404590/000024.o /workspace/tmp/go-link-3293404590/000025.o /workspace/tmp/go-link-3293404590/000026.o /workspace/tmp/go-link-3293404590/000027.o /workspace/tmp/go-link-3293404590/000028.o /workspace/tmp/go-link-3293404590/000029.o /workspace/tmp/go-link-3293404590/000030.o /workspace/tmp/go-link-3293404590/000031.o /workspace/tmp/go-link-3293404590/000032.o /workspace/tmp/go-link-3293404590/000033.o /workspace/tmp/go-link-3293404590/000034.o /workspace/tmp/go-link-3293404590/000035.o /workspace/tmp/go-link-3293404590/000036.o /workspace/tmp/go-link-3293404590/000037.o /workspace/tmp/go-link-3293404590/000038.o /workspace/tmp/go-link-3293404590/000039.o /workspace/tmp/go-link-3293404590/000040.o /workspace/tmp/go-link-3293404590/000041.o /workspace/tmp/go-link-3293404590/000042.o /workspace/tmp/go-link-3293404590/000043.o /workspace/tmp/go-link-3293404590/000044.o /workspace/tmp/go-link-3293404590/000045.o /workspace/tmp/go-link-3293404590/000046.o /workspace/tmp/go-link-3293404590/000047.o /workspace/tmp/go-link-3293404590/000048.o /workspace/tmp/go-link-3293404590/000049.o /workspace/tmp/go-link-3293404590/000050.o /workspace/tmp/go-link-3293404590/000051.o /workspace/tmp/go-link-3293404590/000052.o /workspace/tmp/go-link-3293404590/000053.o /workspace/tmp/go-link-3293404590/000054.o -O2 -g --sysroot=/usr/local/sysroot -lresolv -O2 -g --sysroot=/usr/local/sysroot -O2 -g --sysroot=/usr/local/sysroot -ldl -O2 -g --sysroot=/usr/local/sysroot -lpthread -O2 -g --sysroot=/usr/local/sysroot -O2 -g --sysroot=/usr/local/sysroot -O2 -g --sysroot=/usr/local/sysroot -ldl -ldl -O2 -g --sysroot=/usr/local/sysroot -ldl -O2 -g --sysroot=/usr/local/sysroot /workspace/build/pkg/mod/code.byted.org/iesarch/gozstd@v1.17.4/libzstd_linux_riscv64.a -no-pie
/usr/local/lib/gcc/riscv64-unknown-linux-gnu/13.2.1/../../../../riscv64-unknown-linux-gnu/bin/ld: unresolvable R_RISCV_HI20 relocation against symbol
stderr@@GLIBC_2.27' /usr/local/lib/gcc/riscv64-unknown-linux-gnu/13.2.1/../../../../riscv64-unknown-linux-gnu/bin/ld: unresolvable R_RISCV_HI20 relocation against symbol
stderr@@GLIBC_2.27'/usr/local/lib/gcc/riscv64-unknown-linux-gnu/13.2.1/../../../../riscv64-unknown-linux-gnu/bin/ld: unresolvable R_RISCV_HI20 relocation against symbol `stderr@@GLIBC_2.27'
collect2: error: ld returned 1 exit status
What did you expect to see?
Maybe Go generated an incorrect relocation type for the symbol reference to stderr.
The text was updated successfully, but these errors were encountered: