#1 2021-01-23 02:51:47

movax20h
Member

Compiloation failure with some gcc

++ -O3 -fomit-frame-pointer -ffast-math -Wall -fsigned-char -fno-exceptions -fno-rtti -o tess_server standalone/shared/crypto.o standalone/shared/stream.o standalone/shared/tools.o standalone/engine/command.o standalone/engine/server.o standalone/engine/worldio.o standalone/game/entities.o standalone/game/server.o -Lenet -lenet -lz  
/usr/bin/ld: enet/libenet.a(packet.o): relocation R_X86_64_32S against `.bss' can not be used when making a PIE object; recompile with -fPIE
/usr/bin/ld: enet/libenet.a(peer.o): relocation R_X86_64_32S against `.rodata' can not be used when making a PIE object; recompile with -fPIE
/usr/bin/ld: enet/libenet.a(protocol.o): relocation R_X86_64_32S against `.rodata' can not be used when making a PIE object; recompile with -fPIE
/usr/bin/ld: enet/libenet.a(unix.o): relocation R_X86_64_32S against `.rodata' can not be used when making a PIE object; recompile with -fPIE
/usr/bin/ld: enet/libenet.a(unix.o): warning: relocation against `bind@@GLIBC_2.2.5' in read-only section `.text'
/usr/bin/ld: enet/libenet.a(host.o): relocation R_X86_64_PC32 against symbol `memset@@GLIBC_2.2.5' can not be used when making a PIE object; recompile with -fPIE
/usr/bin/ld: final link failed: bad value
collect2: error: ld returned 1 exit status

This is on Debian testing, amd64, with gcc 10.2.1

I believe the issue might be because the Debian gcc defaults to PIE for all shared libraries and executables. But then, the error message doesn't quite make sense, so I don't know.


Adding -fPIC to CFLAGS in enet/Makefile (first line), solves the issue.


However, I would suggest to rework the Makefiles a bit, and also allow for using -flto for example.


Additionally, `make clean` in the main directory, doesn't call `$(MAKE) -C enet clean`. It should.


With all that it compiles and links.

Offline

Board footer