https://issues.dlang.org/show_bug.cgi?id=10775

Martin Nowak <[email protected]> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |[email protected]
         Resolution|---                         |WORKSFORME

--- Comment #1 from Martin Nowak <[email protected]> ---
This was implemented by
https://github.com/D-Programming-Language/druntime/pull/593
(https://github.com/D-Programming-Language/druntime/commit/73d067fd04ed8c9588c5ae09ebe48fdb1b528793).

Works for me, I had to change dlopen("libdll.so", RTLD_LAZY) to
dlopen("./libdll.so", RTLD_LAZY) though.

+main()
libdll.so construction
libdll.so is loaded
dll() function is found
dll()
unloading libdll.so
libdll.so destruction
-main()

Note: It's better to use Runtime.load/unloadLibrary [¹] instead of
dlopen/dlclose b/c then we can run the TLS ctors/dtors without holding the
loader lock, thus avoiding a common source of deadlocks and reducing possible
contention.

[¹]: http://dlang.org/phobos/core_runtime.html#.Runtime.loadLibrary
rt_loadLibrary or core.runtime.Runtime.loadLibrary.

--

Reply via email to