DSO with DMD 2.052 on Linux?

Jacob Carlborg doob at me.com
Tue May 3 06:33:55 PDT 2011


On 2011-05-03 11:14, Alexander wrote:
> On 03.05.2011 09:15, Jacob Carlborg wrote:
>
>> This is a showstopper for shared libraries on Linux: http://d.puremagic.com/issues/show_bug.cgi?id=4583
>> A few things in the runtime need to be changed as well.
>
>    OK, I see. But isn't simple linking to DSO (no dlopen calls) should be handled by the linker itself? Or even this needs runtime support?
>
>    Long time ago, I remember, I did a few tests, and everything was fine. Though, I am not sure that this was D2, and I lost my test code...
>
> /Alexander

If DMD doesn't generate the correct PIC code if won't work (I think). 
You will also get missing symbol error for the "main" function when 
building a shared library. This can be suppressed by making it a week 
symbol, using a gcc __attribute__ extension.

Then when the library is loaded you would need to make some 
initializations like:

* Exception handling tables
* TLS
* Run module constructors
* Module info
* Probably a few things I missed

-- 
/Jacob Carlborg


More information about the Digitalmars-d mailing list