Bug 23177 – ModuleInfo is not exported on Windows

Status
REOPENED
Severity
blocker
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
Windows
Creation time
2022-06-11T17:16:48Z
Last change time
2024-12-13T19:23:26Z
Keywords
dll, pull
Assigned to
No Owner
Creator
Richard (Rikki) Andrew Cattermole
See also
https://issues.dlang.org/show_bug.cgi?id=23974
Moved to GitHub: dmd#20120 →

Comments

Comment #0 by alphaglosined — 2022-06-11T17:16:48Z
When ModuleInfo is generated it is not added to the export tables. This can lead to linker errors with shared libraries. This should hopefully be a fairly simple fix, a one-liner and I'll be attempting it. If not I'll add a test case.
Comment #1 by dlang-bot — 2022-06-11T17:54:02Z
@rikkimax updated dlang/dmd pull request #14200 "Fix Issue 23177 - ModuleInfo is not exported on Windows" fixing this issue: - Fix issue 23177 https://github.com/dlang/dmd/pull/14200
Comment #2 by alphaglosined — 2022-06-11T21:09:26Z
It was indeed as simple as adding: ```d objmod.export_symbol(m.csym, 0); ``` to ``genModuleInfo``. However I ran into a lot of issues in the test suite (mostly fixable, since it just needed to know about the fact that import + export libraries were being generated). For the test it was as simple as adding a new module ``test/dshell/extra-files/dll/issue23177.d`` and importing it to ``mydll.d`` and ``testdll.d``. I managed to get it down to only one test failing. Unicode symbols are part of it ``runnable/testmodule.d``. I have no idea how to fix this particular issue, so unfortunately my fix is on hold until that can be resolved.
Comment #3 by dlang-bot — 2022-06-12T09:47:10Z
dlang/dmd pull request #14200 "Fix Issue 23177 - ModuleInfo is not exported on Windows" was merged into stable: - 6b93e00b535fc020794c50010e1b9040fa6e2476 by richard andrew cattermole: Fix Issue 23177 - ModuleInfo is not exported on Windows https://github.com/dlang/dmd/pull/14200
Comment #4 by alphaglosined — 2022-06-12T18:32:20Z
Unfortunately, my fix is nowhere near good enough. Here is a code snippet that will fail, it will need to be added to dshell/dll test in its main function (in some form). ```d void main() { import std.stdio; foreach (m; ModuleInfo) { writeln(m.name); if (auto i = m.importedModules()) { writeln(i); stdout.flush; foreach (j; i) { writeln(" - ", j.name.ptr); stdout.flush; } } } } ```
Comment #5 by dlang-bot — 2022-06-13T00:04:28Z
dlang/dmd pull request #14206 "Revert "Fix Issue 23177 - ModuleInfo is not exported on Windows"" was merged into stable: - aa10936019c4b68ffef39fff6af605e067f0e9e2 by Martin Kinkelin: Revert "Fix Issue 23177 - ModuleInfo is not exported on Windows" This reverts commit 2aabe864da7c95ea8eb8abbca7c4f0b1dcfe55ae. https://github.com/dlang/dmd/pull/14206
Comment #6 by dlang-bot — 2022-06-17T10:18:06Z
@BorisCarvajal updated dlang/dmd pull request #14226 "Fix Issue 23172 - [REG2.100] Wrong cast inserted for ternary operator and non-int enums" fixing this issue: - Fix Issue 23177 - ModuleInfo is not exported on Windows - Revert "Fix Issue 23177 - ModuleInfo is not exported on Windows" This reverts commit 2aabe864da7c95ea8eb8abbca7c4f0b1dcfe55ae. https://github.com/dlang/dmd/pull/14226
Comment #7 by dlang-bot — 2022-07-09T15:07:21Z
@ibuclaw created dlang/dmd pull request #14280 "merge stable" fixing this issue: - Fix Issue 23177 - ModuleInfo is not exported on Windows - Revert "Fix Issue 23177 - ModuleInfo is not exported on Windows" This reverts commit 2aabe864da7c95ea8eb8abbca7c4f0b1dcfe55ae. https://github.com/dlang/dmd/pull/14280
Comment #8 by dlang-bot — 2022-07-09T16:32:06Z
dlang/dmd pull request #14280 "merge stable" was merged into master: - 2aabe864da7c95ea8eb8abbca7c4f0b1dcfe55ae by richard andrew cattermole: Fix Issue 23177 - ModuleInfo is not exported on Windows - 4ee3ac43f5235d3798c0c0cd9f317f5e1aa07ce4 by Martin Kinkelin: Revert "Fix Issue 23177 - ModuleInfo is not exported on Windows" This reverts commit 2aabe864da7c95ea8eb8abbca7c4f0b1dcfe55ae. https://github.com/dlang/dmd/pull/14280
Comment #9 by dlang-bot — 2022-11-19T06:01:58Z
@rikkimax created dlang/dmd pull request #14647 "Fix issue 23177 - ModuleInfo is not exported on Windows" fixing this issue: - Fix issue 23177 - ModuleInfo is not exported on Windows https://github.com/dlang/dmd/pull/14647
Comment #10 by bugzilla — 2023-01-29T08:55:08Z
The ModuleInfo is necessary for static construction. For a DLL, the static construction is handled by DllMain. If the ModuleInfo is exported, the user of the dll will run the static constructors again.
Comment #11 by alphaglosined — 2023-01-29T10:44:39Z
(In reply to Walter Bright from comment #10) > The ModuleInfo is necessary for static construction. For a DLL, the static > construction is handled by DllMain. If the ModuleInfo is exported, the user > of the dll will run the static constructors again. This is already handled, we're good to go, it will only do what is in the binary. https://github.com/dlang/dmd/blob/master/druntime/src/rt/minfo.d#L264
Comment #12 by bugzilla — 2023-06-05T22:05:19Z
For another take on this, see: https://issues.dlang.org/show_bug.cgi?id=23974
Comment #13 by robert.schadek — 2024-12-13T19:23:26Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/20120 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB