gdc-4.5 testing

Anders F Björklund afb at algonet.se
Wed Dec 22 02:59:57 PST 2010


Neal Becker wrote:
>>>> AFAIK both shared libraries and x86_64 code have been working
>>>> for years with GDC, even though that is not the case with DMD.
>>>>
>>>> Phobos is still static, though.
>>>>
>>> But you can't link shared obj to static lib (Phobos), except on i386 - so
>>> you really can't use shared obj on x86_64 (if you need phobos).
>>
>> I don't get it, it shouldn't be that much different from a
>> static libstdc++ or something. You do need libgcc_s.so for
>> the exceptions to be thrown correctly, but otherwise your
>> application would be linking to Phobos anyway I thought...
>>
>> Do you have some more advanced example than the toy tests ?

> IIUC, the issue isn't exactly shared vs static lib, it's linking -fPIC code
> to a lib that is non-PIC code.  You can't link PIC code to non-PIC code
> except on i386.
>
> http://www.technovelty.org/code/c/amd64-pic.html

Yeah, that was why the -fPIC was added to the DFLAGS in the test...

To avoid the linker error, when trying to make the shared library:
$ gcc -shared -o libfoo.so foo.o
/usr/bin/ld: foo.o: relocation R_X86_64_32 against `.rodata' can not be 
used when making a shared object; recompile with -fPIC

So I still don't get it.

--anders

PS. I put the toy test example code up, for reference:
     http://www.algonet.se/~afb/d/dsharedlibs.tar.gz


More information about the Digitalmars-d mailing list