digitalmars.D - DSO with DMD 2.052 on Linux?
- Alexander (6/6) May 02 2011 Is dynamic linking supported on Linux with DMD 2.052 (and D2 in general)...
- Jonathan M Davis (11/18) May 02 2011 The short answer: no.
- Kai Meyer (7/25) May 02 2011 I thought I saw somewhere that you simply have to have the runtime
- Jacob Carlborg (9/27) May 03 2011 This is a showstopper for shared libraries on Linux:
- Alexander (4/6) May 03 2011 OK, I see. But isn't simple linking to DSO (no dlopen calls) should be...
- Jacob Carlborg (14/20) May 03 2011 If DMD doesn't generate the correct PIC code if won't work (I think).
Is dynamic linking supported on Linux with DMD 2.052 (and D2 in general)? I am not talking about Phobos, just modules which I want to compile as DSO. There is -fPIC switch to DMD - does it work as intended? PS: gdc is not an option... -- /Alexander
May 02 2011
Is dynamic linking supported on Linux with DMD 2.052 (and D2 in general)? I am not talking about Phobos, just modules which I want to compile as DSO. There is -fPIC switch to DMD - does it work as intended? PS: gdc is not an option...The short answer: no. As for the long answer, someone else could answer far better than I could. IIRC, the main problem is the runtime. It has issues when you try and split your D code with .so files (I believe that you end up with multiple instances of the runtime). It _might_ work if you don't use the garbage collector at all, but there could be other issues. I don't remember exactly what all of the problems are. But regardless, don't expect shared libraries to work at the moment. Getting shared libraries to work is near the top of the TODO list, but it hasn't been done yet. - Jonathan M Davis
May 02 2011
On 05/02/2011 03:10 PM, Jonathan M Davis wrote:I thought I saw somewhere that you simply have to have the runtime initialized before calling into the shared library (which is done for you when dmd is supposed to produce an executable): http://www.digitalmars.com/d/2.0/phobos/core_runtime.html I may be incorrect too :) -Kai MeyerIs dynamic linking supported on Linux with DMD 2.052 (and D2 in general)? I am not talking about Phobos, just modules which I want to compile as DSO. There is -fPIC switch to DMD - does it work as intended? PS: gdc is not an option...The short answer: no. As for the long answer, someone else could answer far better than I could. IIRC, the main problem is the runtime. It has issues when you try and split your D code with .so files (I believe that you end up with multiple instances of the runtime). It _might_ work if you don't use the garbage collector at all, but there could be other issues. I don't remember exactly what all of the problems are. But regardless, don't expect shared libraries to work at the moment. Getting shared libraries to work is near the top of the TODO list, but it hasn't been done yet. - Jonathan M Davis
May 02 2011
On 2011-05-02 23:10, Jonathan M Davis 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.Is dynamic linking supported on Linux with DMD 2.052 (and D2 in general)? I am not talking about Phobos, just modules which I want to compile as DSO. There is -fPIC switch to DMD - does it work as intended? PS: gdc is not an option...The short answer: no. As for the long answer, someone else could answer far better than I could. IIRC, the main problem is the runtime. It has issues when you try and split your D code with .so files (I believe that you end up with multiple instances of the runtime). It _might_ work if you don't use the garbage collector at all, but there could be other issues. I don't remember exactly what all of the problems are. But regardless, don't expect shared libraries to work at the moment.Getting shared libraries to work is near the top of the TODO list, but it hasn't been done yet. - Jonathan M DavisShared libraries have been working for Tango on Mac OS X from quite some time now. Almost all of the same patches are applied to druntime as well. Just one small change to actually enable the changes. -- /Jacob Carlborg
May 03 2011
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
May 03 2011
On 2011-05-03 11:14, Alexander wrote:On 03.05.2011 09:15, Jacob Carlborg wrote: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 CarlborgThis 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
May 03 2011