www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Dynamic loading

reply "Steve Teale" <steve.teale britseyeview.com> writes:
Any progress?
Oct 27 2013
next sibling parent reply Benjamin Thaut <code benjamin-thaut.de> writes:
Am 27.10.2013 09:08, schrieb Steve Teale:
 Any progress?
Yes. The implementation of the linux part seems to be done and will be included in 2.064. On windows it will take some time because "export" has to be fixed first. Kind Regards Benjamin Thaut
Oct 27 2013
next sibling parent reply "evilrat" <evilrat666 gmail.com> writes:
On Sunday, 27 October 2013 at 08:23:26 UTC, Benjamin Thaut wrote:
 Am 27.10.2013 09:08, schrieb Steve Teale:
 Any progress?
Yes. The implementation of the linux part seems to be done and will be included in 2.064. On windows it will take some time because "export" has to be fixed first. Kind Regards Benjamin Thaut
<sarcasm> wow. cool. most people developing(using) linux version. so what do we have: we(me?) have COM problems(can't figure what causes them). we have OS X development which is still real hardcore. but wait, we have more and more working linux version, who need other OS if we had linux \0/ </sarcasm>
Oct 27 2013
next sibling parent "QAston" <qaston gmail.com> writes:
On Sunday, 27 October 2013 at 08:52:02 UTC, evilrat wrote:
 <sarcasm>
 wow. cool. most people developing(using) linux version. so what 
 do we have:
 we(me?) have COM problems(can't figure what causes them).  we 
 have OS X development which is still real hardcore. but wait, 
 we have more and more working linux version, who need other OS 
 if we had linux \0/
 </sarcasm>
It's time to learn that life is cruel and unjust and people don't do whatever they're ask to do :P.
Oct 27 2013
prev sibling next sibling parent Benjamin Thaut <code benjamin-thaut.de> writes:
Am 27.10.2013 09:52, schrieb evilrat:
 On Sunday, 27 October 2013 at 08:23:26 UTC, Benjamin Thaut wrote:
 Am 27.10.2013 09:08, schrieb Steve Teale:
 Any progress?
Yes. The implementation of the linux part seems to be done and will be included in 2.064. On windows it will take some time because "export" has to be fixed first. Kind Regards Benjamin Thaut
<sarcasm> wow. cool. most people developing(using) linux version. so what do we have: we(me?) have COM problems(can't figure what causes them). we have OS X development which is still real hardcore. but wait, we have more and more working linux version, who need other OS if we had linux \0/ </sarcasm>
You are welcome to discuss DIP 45 which aims to fix "export" so that shared library support can be added to windows plattforms. You are also welcome to point out wherever you can that you are interrested in shared library support for windows. http://forum.dlang.org/thread/kvhu2c$2ikq$1 digitalmars.com#post-kvhu2c:242ikq:241:40digitalmars.com Kind Regards Benjamin Thaut
Oct 27 2013
prev sibling next sibling parent Jacob Carlborg <doob me.com> writes:
On 2013-10-27 09:52, evilrat wrote:

 <sarcasm>
 wow. cool. most people developing(using) linux version. so what do we have:
 we(me?) have COM problems(can't figure what causes them).  we have OS X
 development which is still real hardcore. but wait, we have more and
 more working linux version, who need other OS if we had linux \0/
 </sarcasm>
We most likely need native TLS for Mac OS X before supporting dynamic libraries. -- /Jacob Carlborg
Oct 27 2013
prev sibling parent "Dicebot" <public dicebot.lv> writes:
On Sunday, 27 October 2013 at 08:52:02 UTC, evilrat wrote:
 who need other OS if we had linux \0/
So glad to see this becoming a common wisdom :P
Oct 27 2013
prev sibling next sibling parent "Steve Teale" <steve.teale britseyeview.com> writes:
On Sunday, 27 October 2013 at 08:23:26 UTC, Benjamin Thaut wrote:
 Am 27.10.2013 09:08, schrieb Steve Teale:
 Any progress?
Yes. The implementation of the linux part seems to be done and will be included in 2.064. On windows it will take some time because "export" has to be fixed first. Kind Regards Benjamin Thaut
Thanks Benjamin - Linux will suit me ;=)
Oct 27 2013
prev sibling next sibling parent reply "Steve Teale" <steve.teale britseyeview.com> writes:
On Sunday, 27 October 2013 at 08:23:26 UTC, Benjamin Thaut wrote:
 Am 27.10.2013 09:08, schrieb Steve Teale:
 Any progress?
Yes. The implementation of the linux part seems to be done and will be included in 2.064. On windows it will take some time because "export" has to be fixed first. Kind Regards Benjamin Thaut
Is there a description somewhere of how this will work? Is it language, Phobos, linker, or what.
Oct 28 2013
parent reply Jacob Carlborg <doob me.com> writes:
On 2013-10-28 18:45, Steve Teale wrote:

 Is there a description somewhere of how this will work? Is it language,
 Phobos, linker, or what.
I guess it's compiler and runtime. -- /Jacob Carlborg
Oct 28 2013
parent reply "Steve Teale" <steve.teale britseyeview.com> writes:
On Monday, 28 October 2013 at 17:49:23 UTC, Jacob Carlborg wrote:
 On 2013-10-28 18:45, Steve Teale wrote:

 Is there a description somewhere of how this will work? Is it 
 language,
 Phobos, linker, or what.
I guess it's compiler and runtime.
That sounds a bit implausible. New language keyword or something to load a library or object file. My best guess is that extern(C) dlopen() will just work correctly, failing that I'd think we need an equivalent Phobos call.
Oct 28 2013
next sibling parent "Dicebot" <public dicebot.lv> writes:
On Monday, 28 October 2013 at 18:01:14 UTC, Steve Teale wrote:
 That sounds a bit implausible. New language keyword or 
 something to load a library or object file. My best guess is 
 that extern(C) dlopen() will just work correctly, failing that 
 I'd think we need an equivalent Phobos call.
1) it is not new, it is the old one that needs fixing : http://dlang.org/attribute.html#ProtectionAttribute 2) it work just fine in Linux (dlopen) because all symbols are exported there by default. Proper symbol visibility definition is still needed for any cross-platform implementation (and for some optimization potential). Right now on Linux naive dlopen + calling Phobos stdio function from shared lib works on 2.064beta so you can be calm about that part.
Oct 28 2013
prev sibling next sibling parent reply Jacob Carlborg <doob me.com> writes:
On 2013-10-28 19:00, Steve Teale wrote:

 That sounds a bit implausible. New language keyword or something to load
 a library or object file. My best guess is that extern(C) dlopen() will
 just work correctly, failing that I'd think we need an equivalent Phobos
 call.
Sorry, I wasn't very clear. The correct function to use is core.runtime.Runtime.loadLibrary: https://github.com/D-Programming-Language/druntime/blob/master/src/core/runtime.d#L178 -- /Jacob Carlborg
Oct 28 2013
parent "Steve Teale" <steve.teale britseyeview.com> writes:
On Monday, 28 October 2013 at 20:42:00 UTC, Jacob Carlborg wrote:
 On 2013-10-28 19:00, Steve Teale wrote:

 That sounds a bit implausible. New language keyword or 
 something to load
 a library or object file. My best guess is that extern(C) 
 dlopen() will
 just work correctly, failing that I'd think we need an 
 equivalent Phobos
 call.
Sorry, I wasn't very clear. The correct function to use is core.runtime.Runtime.loadLibrary: https://github.com/D-Programming-Language/druntime/blob/master/src/core/runtime.d#L178
I was forgetting the runtime library - that seems like the place ;=)
Oct 29 2013
prev sibling next sibling parent reply Jacob Carlborg <doob me.com> writes:
On 2013-10-28 19:00, Steve Teale wrote:
 On Monday, 28 October 2013 at 17:49:23 UTC, Jacob Carlborg wrote:
 On 2013-10-28 18:45, Steve Teale wrote:

 Is there a description somewhere of how this will work? Is it language,
 Phobos, linker, or what.
I guess it's compiler and runtime.
That sounds a bit implausible. New language keyword or something to load a library or object file. My best guess is that extern(C) dlopen() will just work correctly, failing that I'd think we need an equivalent Phobos call.
It's not completely done yet but I think core.runtime.Runtime.loadLibrary will be the function used to load libraries. See: https://github.com/D-Programming-Language/druntime/pull/617 -- /Jacob Carlborg
Oct 28 2013
parent "David Nadlinger" <code klickverbot.at> writes:
On Monday, 28 October 2013 at 20:44:11 UTC, Jacob Carlborg wrote:
 That sounds a bit implausible. New language keyword or 
 something to load
 a library or object file. My best guess is that extern(C) 
 dlopen() will
 just work correctly, failing that I'd think we need an 
 equivalent Phobos
 call.
It's not completely done yet but I think core.runtime.Runtime.loadLibrary will be the function used to load libraries. See: https://github.com/D-Programming-Language/druntime/pull/617
In the current implementation, just loading a library using the C functions would indeed work, as the D runtime registration/initialization happens in a C .ctor. The actual implementation in druntime is a bit more complex, mainly to handle thread synchronization. David
Oct 28 2013
prev sibling parent Martin Nowak <code dawg.eu> writes:
On 10/28/2013 07:00 PM, Steve Teale wrote:
 That sounds a bit implausible. New language keyword or something to load
 a library or object file. My best guess is that extern(C) dlopen() will
 just work correctly, failing that I'd think we need an equivalent Phobos
 call.
We need another runtime layer to account for per-thread initialization/finalization of modules (static this()/static ~this()). There is Runtime.loadLibrary/Runtime.unloadLibrary and rt_loadLibrary/rt_unloadLibrary to do this. You can use dlopen from a C executable but the loaded D library is only usable from the loading thread. For a C executable the recommended pattern is to dlopen or link druntime (libphobos2.so) and to use rt_loadLibrary/rt_unloadLibrary to load D libraries. Currently the best available documentation are the tests (https://github.com/D-Programming-Language/druntime/tree/master/test/shared).
Oct 29 2013
prev sibling parent Martin Nowak <code dawg.eu> writes:
On 10/27/2013 09:23 AM, Benjamin Thaut wrote:
 Am 27.10.2013 09:08, schrieb Steve Teale:
 Any progress?
Yes. The implementation of the linux part seems to be done and will be included in 2.064. On windows it will take some time because "export" has to be fixed first. Kind Regards Benjamin Thaut
Not entirely true. We have the basic low-level support but the high-level stuff isn't ready for this release (https://github.com/D-Programming-Language/druntime/pull/617). If you're curious you can try the low-level stuff. Currently the most accurate howto is the unittests :(, (https://github.com/D-Programming-Language/druntime/tree/master/test/shared).
Oct 29 2013
prev sibling parent reply "Flamaros" <flamaros.xavier gmail.com> writes:
On Sunday, 27 October 2013 at 08:08:08 UTC, Steve Teale wrote:
 Any progress?
There is no way to do something best with llvm? I don't really understand why for static and dynamic libraries we need rely on OS implementation. llvm intermediate byte code isn't fast enough translatable at runtime? Actual binaries format on Windows and Linux seems old and limited, I dream of cross platforms compilers that are based on binaries format that contains all necessary information to be able to operate correct inlining,... It's a real strength that VM based language have to be binary inter-operable. A lot of Java developers don't see C/C++ as portable languages just cause of the necessity to rebuild binaries on each OS even their runs on same architecture.
Oct 28 2013
next sibling parent reply "evilrat" <evilrat666 gmail.com> writes:
On Monday, 28 October 2013 at 22:25:12 UTC, Flamaros wrote:
 On Sunday, 27 October 2013 at 08:08:08 UTC, Steve Teale wrote:
 Any progress?
There is no way to do something best with llvm? I don't really understand why for static and dynamic libraries we need rely on OS implementation. llvm intermediate byte code isn't fast enough translatable at runtime? Actual binaries format on Windows and Linux seems old and limited, I dream of cross platforms compilers that are based on binaries format that contains all necessary information to be able to operate correct inlining,...
maybe our childrens will see it one day :)
 It's a real strength that VM based language have to be binary 
 inter-operable. A lot of Java developers don't see C/C++ as 
 portable languages just cause of the necessity to rebuild 
 binaries on each OS even their runs on same architecture.
to be honest, many C/C++ developers don't think it is portable, so Java developers are not alone here O_-
Oct 28 2013
parent "Flamaros" <flamaros.xavier gmail.com> writes:
On Tuesday, 29 October 2013 at 04:28:24 UTC, evilrat wrote:
 On Monday, 28 October 2013 at 22:25:12 UTC, Flamaros wrote:
 On Sunday, 27 October 2013 at 08:08:08 UTC, Steve Teale wrote:
 Any progress?
There is no way to do something best with llvm? I don't really understand why for static and dynamic libraries we need rely on OS implementation. llvm intermediate byte code isn't fast enough translatable at runtime? Actual binaries format on Windows and Linux seems old and limited, I dream of cross platforms compilers that are based on binaries format that contains all necessary information to be able to operate correct inlining,...
maybe our childrens will see it one day :)
It makes me sad :(
 It's a real strength that VM based language have to be binary 
 inter-operable. A lot of Java developers don't see C/C++ as 
 portable languages just cause of the necessity to rebuild 
 binaries on each OS even their runs on same architecture.
to be honest, many C/C++ developers don't think it is portable, so Java developers are not alone here O_-
Oct 29 2013
prev sibling parent "Moritz Maxeiner" <moritz ucworks.org> writes:
On Monday, 28 October 2013 at 22:25:12 UTC, Flamaros wrote:
 On Sunday, 27 October 2013 at 08:08:08 UTC, Steve Teale wrote:
 Any progress?
There is no way to do something best with llvm? I don't really understand why for static and dynamic libraries we need rely on OS implementation. llvm intermediate byte code isn't fast enough translatable at runtime?
LLVM IR is not fully cross-platform, sadly. Sure, the more basic, core feature are platform independent, but once you need more advanced features you will need to adjust the LLVM IR for your architecture, such as x86, x86_64, or ARM. I'd suggest to give this document a read on the topic: http://llvm.org/docs/LangRef.html
Oct 29 2013