Linker error for d.o: relocation R_X86_64_32 against `__dmd_personality_v0'
rcorre via Digitalmars-d-learn
digitalmars-d-learn at puremagic.com
Thu Apr 21 09:29:14 PDT 2016
On Thursday, 21 April 2016 at 12:57:36 UTC, Rene Zwanenburg wrote:
> 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.
Nothing.
> - Is it possible the linker is picking up 32 bit libraries?
> That -L/usr/lib32 switch is a bit suspicious.
Sure is. I tried manually linking without that but get the same
error. As a matter of fact, I tried removing all the linker flags
and still get that error (just `cc d.o -o d`).
> - What happens when you compile for 32 bit?
/usr/bin/ld: skipping incompatible /usr/lib/libphobos2.a when
searching for -lphobos2
/usr/bin/ld: skipping incompatible
/usr/lib/gcc/x86_64-unknown-linux-gnu/5.3.0/../../../libphobos2.a
when searching for -lphobos2
/usr/bin/ld: skipping incompatible /usr/lib/libphobos2.a when
searching for -lphobos2
/usr/bin/ld: cannot find -lphobos2
/usr/bin/ld: skipping incompatible /usr/lib/libpthread.so when
searching for -lpthread
/usr/bin/ld: skipping incompatible /usr/lib/libpthread.a when
searching for -lpthread
collect2: error: ld returned 1 exit status
> - 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.
I'll look into it.
> - What happens when you compile some D code as a static lib,
> and link it with a main written in C?
Same error.
> 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.
I did. /etc/dmd.conf looks normal, aside from the inclusion of
32-bit libs:
[Environment]
DFLAGS=-I/usr/include/dlang/dmd -L-L/usr/lib -L-L/usr/lib32
-L--export-dynamic
But that's how it gets set up after a fresh install.
More information about the Digitalmars-d-learn
mailing list