Shared library in D on Linux

Timo Westkämper" <timo.westkamper at gmail.com> Timo Westkämper" <timo.westkamper at gmail.com>
Mon Apr 9 12:37:53 PDT 2012


On Monday, 9 April 2012 at 15:14:45 UTC, Ellery Newcomer wrote:
> Well, if you're really hankering for a shared lib, try ldc. I 
> have gotten it to compile working shared libs in the past.
>
> On 04/09/2012 01:24 AM, "Timo Westkämper" 
> <timo.westkamper at gmail.com>" wrote:
>> On Sunday, 8 April 2012 at 17:59:28 UTC, Timo Westkämper 
>> wrote:
>>> Does someone know why the lib (.a) packaging instead of 
>>> objects (.o)
>>> works better in this case?
>>
>> Didn't work after all with -lib. I mixed up outputs.

Thanks, I might switch to ldc, if dmd and gdc fail here.

I found this tls.S script in the druntime sources (src/rt/tls.S). 
Do you think it could be included in the library to make tls 
initialization work?

#if linux

/* The memory between the addresses of _tlsstart and _tlsend is 
the storage for
  * thread-local data in D 2.0.  Both of these rely on the default 
linker script
  * of:
  *      .tdata : { *(.tdata .tdata.* .gnu.linkonce.td.*) }
  *      .tbss  : { *(.tbss .tbss.* .gnu.linkonce.tb.*) 
*(.tcommon) }
  * to group the sections in that order.
  *
  * Sadly, this does not work because ld orders .tdata after 
.tdata.*, despite
  * what the linker script says.
  */

.file "tls.S"

.globl _tlsstart
     .section .tdata,"awT", at progbits
     .align 4
     .type   _tlsstart, @object
     .size   _tlsstart, 4
_tlsstart:
     .long   3

.globl _tlsend
     .section .tcommon,"awT", at nobits
     .align 4
     .type   _tlsend, @object
     .size   _tlsend, 4
_tlsend:
     .zero   4

#endif


I will see if I can copy the exception handling parts from the D 
main wrapping code.

As a temporary solution I did this

extern(C) void _deh_beg() { }
extern(C) void _deh_end() { }


More information about the Digitalmars-d mailing list