[Dlang-internal] Attempt to export ModuleInfo on Windows

Rikki Cattermole alphaglosined at gmail.com
Tue Nov 15 23:44:58 UTC 2022


Hello,

I'm having another attempt at solving ModuleInfo not being 
exported on Windows.

This is an issue as it prevents D executable importing a D module 
in a DLL.

So far I've managed to get exported and added to the 
importedModules member, except:

Its being added as ``ModuleInfo**[]`` rather than 
``ModuleInfo*[]``.

In dmodule.d ~364: ``Symbol* isym; /// Import version of csym``

In toobj.d ~190 in the importedModules handling:

```d
             import std.algorithm : canFind;
             if (mod.ident.toString().canFind("second")) {
                 if (!mod.isym) {
                     mod.isym = s.toImport(mod.loc);
                     outdata(mod.isym);
                 }
                 s = mod.isym;
                 //s.Sflags |= SFLweak;
                 dtb.xoff(s, 0, TYnptr);
             } else {
                 /* Weak references don't pull objects in from the 
library,
                  * they resolve to 0 if not pulled in by 
something else.
                  * Don't pull in a module just because it was 
imported.
                  */
                 s.Sflags |= SFLweak;
                 dtb.xoff(s, 0, TYnptr);
             }
```

And of course the export:

```d
     objmod.export_symbol(m.csym, 0);
```

This is very frustrating, what should be quite simple, doesn't 
appear to be easily solved (by me) and is a massive blocker.

Note: in my above code I am hard coding it to only apply to the 
"second" module, to prevent needing to build druntime.


More information about the Dlang-internal mailing list