On Thu, 9 Jun 2022 at 08:06, Boris Kolpackov via SG15 <sg15@lists.isocpp.org> wrote:
Nathan Sidwell <nathan@acm.org> writes:

> Do not take GCC's behaviour here as evidence that it is the minimum of what
> should be happening.

Currently, listing an object file when linking an executable will
result in its static initializers being called. I think we need
a really good reason to now say that for some object files this
may or may not happen. Modules will be confusing enough as it is.

It's already the case that object files in archives generally only get linked, and their initializers only get run, if some symbol from the object file is used. Implementations can hand-wave this away as being conforming by saying the TUs corresponding to the other object files in the archiveĀ aren't part of the program. I don't think we can hand-wave in quite the same way for implementation partitions, though, because symbols defined in an implementation partition that's never imported might still be used. (Eg, if they're redeclared and used in another unit of the same module.)