C++ Logo

sg15

Advanced search

Re: [isocpp-core] unimported implementation partitions

From: Ben Boeckel <ben.boeckel_at_[hidden]>
Date: Thu, 9 Jun 2022 09:42:50 -0400
On Thu, Jun 09, 2022 at 14:33:03 +0200, Mathias Stearn via SG15 wrote:
> That includes that dynamic init for all .o files passed to the
> linker will run. And that if you use the whole-archive flag when linking,
> every initializer in that static lib will also run.

I think this is not quite true on macOS (or at least wasn't true at some
point). IIUC, static initializers are not guaranteed to run until
something in its host object is used (no idea if any
`-ffunction-sections` equivalent would invalidate this in case it is
section-based rather than object-based). We have this whole setup which
injects static initializers on a Schwartz-counted action into any TU
which may care about that initializer because of this historical(?)
behavior on some platforms (maybe not macOS; could have been an
"esoteric" platform).

Of course, if anyone can confirm that this is some macOS 9 holdover that
is no longer relevant, I will gladly gladly this complexity from orbit
:) .

--Ben

Received on 2022-06-09 13:42:52