Linker error for d.o: relocation R_X86_64_32 against `__dmd_personality_v0'

Rene Zwanenburg via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Apr 21 05:57:36 PDT 2016


On Thursday, 21 April 2016 at 11:54:27 UTC, rcorre wrote:
>
> Thanks for the tip. Here's the linking code it shows:
>
>
> cc d.o -o d -m64 -L/usr/lib -L/usr/lib32 -Xlinker 
> --export-dynamic -Xlinker -Bstatic -lphobos2 -Xlinker -Bdynamic 
> -lpthread -lm -lrt -ldl
> /usr/bin/ld: d.o: relocation R_X86_64_32 against 
> `__dmd_personality_v0' can not be used when making a shared 
> object; recompile with -fPIC
>
> I tried `cc d.o -o d -m64 -fPIC and still get the error.

Right, the -fPIC should be used while compiling the source code, 
but that's a gcc option. I think DMD is supposed to always 
generates position independent code.

Here are a few things you can try to narrow the problem down. I'm 
not too familiar with this stuff though, so I'm just shooting in 
the dark here and not all of it may make sense ^^

- What happens when you mark main() as nothrow? That personality 
symbol has to do with exception handling.
- Is it possible the linker is picking up 32 bit libraries? That 
-L/usr/lib32 switch is a bit suspicious.
- What happens when you compile for 32 bit?
- What happens when you compile a binary without phobos and 
druntime, and with a custom entry point? I've never done that 
myself and don't remember how to do that off the top of my head, 
but the info should be somewhere on dlang.org.
- What happens when you compile some D code as a static lib, and 
link it with a main written in C?

Oh, and I take it you've already tried to simply reinstall DMD? 
If you uninstall DMD, look if there are still sc.ini's and 
libphobos.a's floating around.


More information about the Digitalmars-d-learn mailing list