]> git.ipfire.org Git - thirdparty/gcc.git/commit
libstdc++: Move stream initialization into compiled library [PR44952]
authorPatrick Palka <ppalka@redhat.com>
Sun, 6 Nov 2022 16:16:00 +0000 (11:16 -0500)
committerPatrick Palka <ppalka@redhat.com>
Sun, 6 Nov 2022 16:16:00 +0000 (11:16 -0500)
commit4e4e3ffd10f53ef71696bc728ab40258751a2df4
tree3a161134d60201a9391d4a0095c12ca8c4c6a6e7
parentd0a492faa6478c99d325fa4a7ed2e5633cef7529
libstdc++: Move stream initialization into compiled library [PR44952]

This patch moves the static object for constructing the standard streams
out from <iostream> and into the compiled library on systems that support
init priorities.  This'll mean <iostream> no longer introduces a separate
global constructor in each TU that includes it.

We can do this only if the init_priority attribute is supported because
we need a way to ensure the stream initialization runs first before any
user global initializer, particularly when linking with a static
libstdc++.a.

PR libstdc++/44952
PR libstdc++/39796
PR libstdc++/98108

libstdc++-v3/ChangeLog:

* include/std/iostream (__ioinit): No longer define here if
the init_priority attribute is usable.
* src/c++98/ios_init.cc (__ioinit): Define here instead if
init_priority is usable, via ...
* src/c++98/ios_base_init.h: ... this new file.
libstdc++-v3/include/std/iostream
libstdc++-v3/src/c++98/ios_base_init.h [new file with mode: 0644]
libstdc++-v3/src/c++98/ios_init.cc