Thread overview
[Issue 17707] unimported modules in libraries do not have their module constructors run
Aug 14, 2018
John Colvin
Dec 17, 2022
Iain Buclaw
Apr 21, 2023
Richard Cattermole
Apr 22, 2023
kinke
August 14, 2018
https://issues.dlang.org/show_bug.cgi?id=17707

--- Comment #1 from John Colvin <john.loughran.colvin@gmail.com> ---
The same behaviour is observed when the library is made with dmd, when the linking is done with dmd, etc...

Essentially dmd seems to be doing something different with the __modctor it gets from an object file or a library

--
December 17, 2022
https://issues.dlang.org/show_bug.cgi?id=17707

Iain Buclaw <ibuclaw@gdcproject.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P1                          |P2

--
April 21, 2023
https://issues.dlang.org/show_bug.cgi?id=17707

Richard Cattermole <alphaglosined@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |alphaglosined@gmail.com
         Resolution|---                         |WONTFIX

--- Comment #2 from Richard Cattermole <alphaglosined@gmail.com> ---
This is the expected behavior of static libraries.

The linker is eliding object files that are contained within a static library when it sees that the object file has no references to it.

This behavior also exists on Windows.

--
April 22, 2023
https://issues.dlang.org/show_bug.cgi?id=17707

kinke <kinke@gmx.net> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |kinke@gmx.net

--- Comment #3 from kinke <kinke@gmx.net> ---
Yep, this is expected default behavior. But linkers support force-pulling all object files from static libs:

* ld: --whole-archive libfoo.a --no-whole-archive
* Apple ld64: -force_load libfoo.a
* MS link.exe: /WHOLEARCHIVE:foo.lib

--