July 12, 2014
On 10/07/14 01:35, David Nadlinger via Digitalmars-d wrote:
> A few lost hairs and an implementation of weak symbols later, this should now be
> fixed in Git master.
>
> In other words, there are currently no known issues with shared libraries, so
> everybody test away. ;)

Hmm, I just rebuild current git master from a fresh pull, and the problem is still there. :-(

This is a fresh build on Ubuntu 14.04 with cmake called via:

    cmake -DCMAKE_INSTALL_PREFIX=/opt/ldc -DBUILD_SHARED_LIBS=ON ..

Then if I try to build and run the hap.random benchmark with

    ldmd2 -I./source -O -inline -release -ofbenchmarknew benchmarknew.d source/hap/random/adaptor.d source/hap/random/distribution.d source/hap/random/generator.d source/hap/random/package.d source/hap/random/traits.d

    ./benchmarknew

.... the latter falls over with the error previously mentioned:
error while loading shared libraries: libphobos2-ldc.so.65: cannot open shared object file: No such file or directory.

I note that when "make install" is run, then after libphobos2-ldc.so is installed, I see the following:

-- Removed runtime path from "/opt/ldc/lib/libphobos2-ldc.so.2.0.65"
-- Installing: /opt/ldc/lib/libdruntime-ldc-debug.so.2.0.65
-- Installing: /opt/ldc/lib/libdruntime-ldc-debug.so.65
-- Installing: /opt/ldc/lib/libdruntime-ldc-debug.so
-- Installing: /opt/ldc/lib/libphobos2-ldc-debug.so.2.0.65
-- Installing: /opt/ldc/lib/libphobos2-ldc-debug.so.65
-- Installing: /opt/ldc/lib/libphobos2-ldc-debug.so
-- Removed runtime path from "/opt/ldc/lib/libphobos2-ldc-debug.so.2.0.65"

... is this relevant?
July 12, 2014
On 12/07/14 19:12, Joseph Rushton Wakeling via Digitalmars-d wrote:
> Hmm, I just rebuild current git master from a fresh pull, and the problem is
> still there. :-(

I'm so sorry, this is completely wrong.  I'd just forgotten to put back my /etc/ld.so.conf.d/ldc2.conf file pointing to /opt/ldc/lib.

With this in place, everything seems to work fine.  (Before, it really was a problem, as I was still getting the error even with the ldc2.conf file in place;-)
July 12, 2014
On 08/07/14 19:54, David Nadlinger via Digitalmars-d wrote:
> And secondly, proper support for building druntime/Phobos as shared libraries
> and loading D shared objects dynamically has now arrived in LDC! As you might be
> aware, Martin Nowak has spent a considerable amount of effort on adding runtime
> loading capabilities to DMD and druntime during the last year or so. LDC now
> offers the same level of functionality, to a good part based on Martin's solid
> work. To build a copy of LDC with druntime/Phobos as a shared library, which is
> also required for proper runtime loading, simply pass -DBUILD_SHARED_LIBS=ON to
> CMake. Oh, and for now this is Linux-only too, sorry.

So, now that I have this running, I thought I'd give it a go trying out hap.random's benchmarks with shared and with static druntime/phobos.

Most of hap.random is pretty standalone apart from reliance on std.range and std.traits (and I think that largely for compile-time checks), so, as can be expected, most functions are not meaningfully affected by being compiled against a shared library.  The handful of functions that depend on std.math seem to take a small speed hit that might not be significant.

However, the dice() function, which relies on std.algorithm.reduce, takes a substantial speed hit, taking 20% more time to run compared to when the benchmarks are compiled against a static phobos.

This is probably within the realm of normalcy, and I guess the speed hit might turn out to be smaller on a larger overall timescale/number of calls, but it seems a shame (and unexpected, as reduce is obviously templated, so I wouldn't expect to have a speed hit because of shared library linkage).  Can anyone suggest an explanation?
1 2 3
Next ›   Last »