[Issue 13287] New: Plugin can't access its moduleinfo in constructors
    via Digitalmars-d-bugs 
    digitalmars-d-bugs at puremagic.com
       
    Tue Aug 12 03:05:56 PDT 2014
    
    
  
https://issues.dlang.org/show_bug.cgi?id=13287
          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 at puremagic.com
          Reporter: johannespfau at gmail.com
load.d
---------------
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);
    Runtime.loadLibrary(name);
}
---------------
test.d
---------------
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/
LD_LIBRARY_PATH=. ./load
laoding./lib.so
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.
--
    
    
More information about the Digitalmars-d-bugs
mailing list