[Issue 22367] The __ModuleInfo member spuriously linked for modules compiler with -betterC

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Nov 30 07:42:03 UTC 2022


https://issues.dlang.org/show_bug.cgi?id=22367

--- Comment #7 from Walter Bright <bugzilla at digitalmars.com> ---
> $ dmd -betterC -lib mylib1.d mylib2.d

This compiles mylib1.d and mylib2.d, and creates a library file mylib.lib
containing the object code from both.

> $ dmd -I. mylib1 myexe.d -main

This compiles mylib1.d and myexe.d together to form an executable named
mylib1.exe. It fails to find anything from mylib2.d, because that wasn't given
on the command line. This is not a compiler bug.

I think what you really meant was:

    dmd -betterC mylib1.d mylib2.d

which creates mylib1.obj into which is placed the compiled versions of mylib1.d
and mylib2.d

    dmd -I. myexe.d mylib1.obj -main

which compiles myexe.d and links it to mylib1.obj, creating an executable named
myexe.exe. Or at least it tries to, as it gives:

    myexe.obj(myexe)
     Error 42: Symbol Undefined __D6mylib212__ModuleInfoZ

because -betterC suppresses generating a ModuleInfo, while myexe.d expects it
to be there. This is a compiler bug, or at least a compiler problem.

--


More information about the Digitalmars-d-bugs mailing list