Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

cgo error unrecognized relocation (0x2a) in section `.text'

Tags:

go

debian

cgo

While build Go program with use of Cgo I get error

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

Tried to google that issue and found some bugs (https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=808205) on Debian and Ubuntu with C compiler and linker in versions of libc6 (2.21) which are newer than version I use (2.19).

Also there mentioned having problems compiling C programs and I compile example in C successfully.

I tried to build my Go program on other machine with same system and libraries versions and the build succeeded.

like image 209
Igor Avatar asked Jul 15 '16 05:07

Igor


1 Answers

check if you are not using ccache. ie by : echo $PATH if something like /usr/local/ccache path comes first... be aware! ccache try to optimize compilation time, using a cache. If you have build a lib with a first compiler and then trying to compile with another, you are expose to such relocation trouble.

so try to clear the ccache : ccache -C or simply edit your PATH removing the path dedicated to ccache by export PATH=/usr/bin: ...

A++ Thilas

like image 126
Thilas Avatar answered Sep 26 '22 15:09

Thilas