Bug 16702 – DMD emit PIC relocation when it isn't appropriate, program won't link.

Status
NEW
Severity
enhancement
Priority
P4
Component
dmd
Product
D
Version
D2
Platform
x86_64
OS
Linux
Creation time
2016-11-19T06:22:51Z
Last change time
2024-12-13T18:50:41Z
Assigned to
No Owner
Creator
deadalnix
Moved to GitHub: dmd#17781 →

Comments

Comment #0 by deadalnix — 2016-11-19T06:22:51Z
$ dmd -c -ofobj/libd.o allmyfiles.d -m64 -w -debug -g -unittest -Ilibd/src $ ar rcs lib/libd.a obj/libd.o $ gcc -o bin/sdc obj/driver.o -m64 -Llib -lsdc -ld-llvm -ld -lphobos2 `llvm-config-3.9 --ldflags` `llvm-config-3.9 --libs` `llvm-config-3.9 --system-libs` -fuse-ld=gold -lstdc++ -export-dynamic And I get many relocation error. Nothing is PIC in there, all is statically linked. I get a ton of relocation R_X86_64_PC32 against symbol « _D6object8opEqualsFxC6ObjectxC6ObjectZb » can't be used when making shared object;recompile with -fPIC $ readelf --relocs obj/libd.o | egrep '(GOT|PLT|JU?MP_SLOT)' 00000000001c 32af00000016 R_X86_64_GOTTPOFF 0000000000000000 _D4util9condition59__T - 4 00000000001c 32af00000016 R_X86_64_GOTTPOFF 0000000000000000 _D4util9condition59__T - 4 000000000038 32af00000016 R_X86_64_GOTTPOFF 0000000000000000 _D4util9condition59__T - 4 00000000006b 32af00000016 R_X86_64_GOTTPOFF 0000000000000000 _D4util9condition59__T - 4 00000000001c 32af00000016 R_X86_64_GOTTPOFF 0000000000000000 _D4util9condition59__T - 4 000000000038 32af00000016 R_X86_64_GOTTPOFF 0000000000000000 _D4util9condition59__T - 4 00000000006b 32af00000016 R_X86_64_GOTTPOFF 0000000000000000 _D4util9condition59__T - 4 000000000028 4b4b00000004 R_X86_64_PLT32 0000000000000000 _d_dso_registry - 4 This seems to be the offending relocations (or is it ?).
Comment #1 by deadalnix — 2016-11-19T06:24:41Z
Also, I tested with gold and ld, both give me the same errors (ld seems to be bailing out earlier, but I get the same errors). It is not the linker.
Comment #2 by deadalnix — 2016-11-19T07:12:04Z
Ha and because libphobos.a is not complied with -fPIC (because it is actually the right thing to do), it is now unusable.
Comment #3 by Marco.Leise — 2017-10-01T21:53:52Z
I only get errors with ld.gold (binutils 2.28.1) now. It is still a problem for systems where 'ld' is ld.gold as there is no way to tell dmd to invoke 'ld.bfd'.
Comment #4 by robert.schadek — 2024-12-13T18:50:41Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/17781 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB