On Tuesday, 18 May 2021 at 15:19:50 UTC, kinke wrote:
On Friday, 14 May 2021 at 22:10:38 UTC, Cléber Zavadniak wrote:
1- Should I compile a `libphobos2.so` "by hand"? Should I use `libphobos2-ldc-shared.so`???

With LDC, -link-defaultlib-shared links the binary against shared druntime/Phobos. It's the default setting when creating a shared library with -shared; use it explicitly when creating an executable. This way, the executable and all .so libs share the same druntime/Phobos, incl. a single GC, default std.parallelism thread pool etc.

Tried that for both a shared library (libtil_exec.so) and the interpreter itself but with LDC2 it keeps throwing this:

object.Exception@source/til/modules.d(100): dlsym error: Library ../til/til.debug is not already loaded

"../til/til.debug" is the interpreter executable.

The intepreter try to load the name "getCommands" from the shared library with:

auto getCommands = cast(CommandHandlerMap function(Process))dlsym(
        lh, "getCommands"
    );

(https://github.com/til-lang/til/blob/8213ab61b87a478f9b2d140a370a870dc9bb0fc9/source/til/modules.d#L94)

Using DMD, everything goes smooth...


`objdump -T libtil_exec.so` shows the name is there as it should in the shared library:

    000000000006df40 g    DF .text      0000000000000069 getCommands

LDC2 info:

    $ ldc2 --version
    LDC - the LLVM D compiler (1.26.0):
      based on DMD v2.096.1 and LLVM 12.0.0
      built with DMD64 D Compiler v2.095.0
      Default target: x86_64-unknown-linux-musl
      Host CPU: skylake

Trying to figure out what's happening, here, but any help is welcome...

Reply via email to