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.
Comment #1 by alphaglosined — 2022-12-15T09:28:31Z
Still happening as of 2.101.0.
Comment #2 by robert.schadek — 2024-12-07T13:34:09Z