There's other situations where it would be nice to express "this needs to happen in a single-threaded context before any multithreaded access", such as environment variable mutation[1].
Unfortunately, nothing stops C++ static constructors from calling pthread_create, and I have heard that there exist shared libraries that actually do that[2], so "before main" isn't even good enough.
We'd need a new "super early" process initialization phase, defined specifically by a guarantee that it would be executed single-threaded, after the dynamic linker was done processing relocations, but before the existing static initialization phase.
I am still interested in pursuing the POSIX-level API change proposal outlined in that thread, but not on a volunteer basis: someone would need to fund me to do it. Please get in touch if you're interested in seeing a concrete grant proposal. ↩︎
Nobody's ever come out and said which libraries these are in my hearing, though. ↩︎