www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 13287] New: Plugin can't access its moduleinfo in constructors


          Issue ID: 13287
           Summary: Plugin can't access its moduleinfo in constructors
           Product: D
           Version: D2
          Hardware: All
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P1
         Component: druntime
          Assignee: nobody puremagic.com
          Reporter: johannespfau gmail.com

import core.runtime, std.stdio;

void main(string[] args)
    auto name = args[0];
    assert(name[$-5 .. $] == "/load");
    name = name[0 .. $-4] ~ "lib.so";
    writeln("laoding" ~ name);

module test;
import std.stdio;

shared static this()
    bool found = false;
    foreach(minfo; ModuleInfo)
        if(minfo.name == "test")
            found = true;
    writeln("Found: ", found);

dmd test.d -shared -oflib.so -fPIC -defaultlib=libphobos2.so
-L-rpath=./linux/lib64/ -L-L./linux/lib64/
dmd load.d -defaultlib=libphobos2.so -L-rpath=./linux/lib64/ -L-L./linux/lib64/

Found: false

Tested with dmd 2.065.0

This is actually a problem because std.encoding actually does use moduleinfo in
its constructor. In GDC we'll probably ship libgdrutime.so and libgphobos.so.
If the main program now does not link against libphobos and loads a plugin
which links against libphobos it'll trigger this bug.

Aug 12 2014